/* Flux motion layer: a staging overlay on the unchanged baseline styles.
   Short, calm motion with one soft ease. The baseline's prefers-reduced-motion
   rule (animation/transition: none !important) also switches all of this off. */
:root{--motion-soft:cubic-bezier(.32,.72,0,1);--motion-press:.1s;--motion-quick:.18s;--motion-reveal:.42s}

@keyframes flux-fade{from{opacity:0}to{opacity:1}}
@keyframes flux-rise{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
@keyframes flux-pop{from{opacity:0;transform:translateY(16px) scale(.97)}to{opacity:1;transform:none}}
@keyframes flux-grow-x{from{transform:scaleX(0)}to{transform:scaleX(1)}}

/* Screens and tab panels: motion.js adds .motion-enter for ~0.9s when one opens,
   so later re-renders (sync, filtering, typing) never replay the animation. */
.motion-enter{animation:flux-fade .22s ease-out both}
.motion-enter :is(.home-hero,.stat,.project-attention-card,.activity-row,.project-directory-card,
  .full-activity-row,.insights-summary,.insights-equipment-section,.insights-panel,.security-card,
  .preference-row,.unit-workspace-panel,.project-workspace-panel>*,.filetable){
  animation:flux-rise var(--motion-reveal) var(--motion-soft) both;
  animation-delay:calc(var(--motion-base,0s) + var(--motion-i,0) * 40ms)}
/* Siblings follow one another (capped at eight); home reads hero, tiles, then lists. */
.motion-enter :first-child{--motion-i:0}.motion-enter :nth-child(2){--motion-i:1}
.motion-enter :nth-child(3){--motion-i:2}
.motion-enter :nth-child(4){--motion-i:3}.motion-enter :nth-child(5){--motion-i:4}
.motion-enter :nth-child(6){--motion-i:5}.motion-enter :nth-child(7){--motion-i:6}
.motion-enter :nth-child(n+8){--motion-i:7}
.motion-enter .stat{--motion-base:.06s}
.motion-enter :is(.project-attention-card,.activity-row){--motion-base:.14s}

/* Sign-in card. */
#gateBox{animation:flux-pop .5s var(--motion-soft) both}

/* Navigation: the active underline grows in; tabs ease between states. */
.appnav-item{transition:color var(--motion-quick) ease,background-color var(--motion-quick) ease,border-color var(--motion-quick) ease,transform var(--motion-press) ease}
.appnav-item.active::after{transform-origin:left center;animation:flux-grow-x .4s var(--motion-soft) both}
/* With motion.js, one underline glides from the previous tab to the new one. */
.motion-glide-anchor{position:relative}
.motion-glide .appnav-item.active::after{opacity:0;animation:none}
.motion-glider{position:absolute;left:0;top:0;height:2px;border-radius:2px;background:var(--grad);pointer-events:none;opacity:0;
  transition:transform .45s var(--motion-soft),width .45s var(--motion-soft),opacity .2s ease}
.motion-glider.motion-glide-instant{transition:none}

/* Press feedback on buttons. Wide list rows only dip slightly. */
:is(.savebtn,.secondary,.actbtn,.danger,.backbtn,.modalclose,.textbtn,.appnav-item,.settings-tab,
  .project-workspace-tab,.file-scope-tab,.compact-filter-btn){
  transition:transform var(--motion-press) ease,background-color var(--motion-quick) ease,border-color var(--motion-quick) ease,
    color var(--motion-quick) ease,box-shadow var(--motion-quick) ease,opacity var(--motion-quick) ease,filter var(--motion-quick) ease}
:is(.savebtn,.secondary,.actbtn,.danger,.backbtn,.modalclose,.appnav-item,.settings-tab,.project-workspace-tab,
  .file-scope-tab,.compact-filter-btn):active:not(:disabled):not([aria-disabled="true"]){transform:scale(.97)}
:is(.project-directory-card,.project-attention-card,.activity-row):active{transform:scale(.99)}
.savebtn:hover:not(:disabled){filter:brightness(1.06) saturate(1.05);box-shadow:0 6px 18px rgba(74,26,139,.22)}

/* Cards lift a little on hover, with a softer landing. */
:is(.project-directory-card,.project-attention-card,.stat){
  transition:transform .28s var(--motion-soft),box-shadow .28s var(--motion-soft),border-color var(--motion-quick) ease,background-color var(--motion-quick) ease}
@media (hover:hover){
  .project-directory-card:hover,.project-attention-card:hover{transform:translateY(-3px);box-shadow:0 14px 30px rgba(20,25,35,.1)}
  .stat:hover{transform:translateY(-2px)}
}

/* Inputs ease into their focus state. */
:is(input,select,textarea){transition:border-color var(--motion-quick) ease,box-shadow var(--motion-quick) ease,background-color var(--motion-quick) ease}

/* Dialogs: the backdrop fades and softly blurs, the panel rises in. */
.modal{-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}
.modal.open{animation:flux-fade .2s ease-out both}
.modal.open>.modalbox{animation:flux-pop .38s var(--motion-soft) both}
/* Where display can transition, dialogs use transitions both ways, so closing
   fades the backdrop and drops the panel. Other browsers close instantly. */
@supports (transition-behavior:allow-discrete){
  .modal{opacity:0;transition:opacity .2s ease,display .2s allow-discrete}
  .modal.open{opacity:1;animation:none}
  .modal:not(.open){pointer-events:none}
  .modal>.modalbox{opacity:0;transform:translateY(12px) scale(.98);transition:opacity .2s ease,transform .2s ease}
  .modal.open>.modalbox{opacity:1;transform:none;animation:none;transition:opacity .3s ease-out,transform .38s var(--motion-soft)}
  @starting-style{
    .modal.open{opacity:0}
    .modal.open>.modalbox{opacity:0;transform:translateY(16px) scale(.97)}
  }
}

/* Toasts glide up and settle. */
.toast{transition:opacity .22s ease,transform .45s var(--motion-soft)}

/* Status bars on the home tiles fill from the left when the screen opens. */
.motion-enter .stat .bar progress{transform-origin:left center;animation:flux-grow-x .7s var(--motion-soft) .2s both}

/* Insights bars grow in one after another when the screen opens. */
.motion-enter .insights-bar-row{--motion-row:var(--motion-i,0)}
.motion-enter .insights-bar-row progress{transform-origin:left center;animation:flux-grow-x .7s var(--motion-soft) both;
  animation-delay:calc(.12s + var(--motion-row,0) * 50ms)}

/* After a sync (classes set by motion.js): changed tiles pulse, new activity
   rows slide in with a brief tint, and project groups whose counts changed flash. */
@keyframes flux-bump{30%{transform:scale(1.03)}100%{transform:none}}
@keyframes flux-slide-in{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:none}}
@keyframes flux-highlight{from{background-color:color-mix(in srgb,var(--b3) 14%,transparent)}to{background-color:transparent}}
.motion-bump{animation:flux-bump .6s var(--motion-soft)}
.motion-new{animation:flux-slide-in .45s var(--motion-soft) both,flux-highlight 1.4s ease-out .15s backwards}
.motion-changed>td{animation:flux-highlight 1.4s ease-out backwards}

/* Sign-in: the card gives a short shake when the app reports an error. The
   entrance animation stays first in the list, so removing the shake afterwards
   does not restart it (the card would otherwise pop in a second time). */
@keyframes flux-shake{15%{transform:translateX(-7px)}35%{transform:translateX(6px)}55%{transform:translateX(-4px)}75%{transform:translateX(2px)}100%{transform:none}}
#gateBox.motion-shake{animation:flux-pop .5s var(--motion-soft) both,flux-shake .42s cubic-bezier(.36,.07,.19,.97) both}

/* Sync: after a successful manual sync the icon briefly becomes a checkmark. */
@keyframes flux-check{from{opacity:0;transform:scale(.4) rotate(-12deg)}to{opacity:1;transform:none}}
.header-sync-btn.motion-synced svg{display:none}
.header-sync-btn.motion-synced::before{content:"✓";display:inline-block;width:16px;font-size:15px;font-weight:800;line-height:16px;
  text-align:center;color:var(--ok-fg,var(--ok));animation:flux-check .45s var(--motion-soft) both}

/* Opening a project: its card grows into the workspace header (View Transitions;
   other browsers switch instantly). */
::view-transition-group(flux-project){animation-duration:.48s;animation-timing-function:var(--motion-soft)}
::view-transition-old(flux-project),::view-transition-new(flux-project){height:100%;object-fit:none;object-position:left top}
::view-transition-old(root),::view-transition-new(root){animation-duration:.26s}
