/* Motion: one system for the app (tokens live in app.css :root).
   Short, physical, never in the way: entrances --dur-base, exits --dur-fast, transform and opacity only.
   Exits are a .leaving class added by leave() in ui.js; the element takes no input while it fades.
   Reduced motion: app.css turns every animation and transition off, so leave() removes at once. */

@keyframes mFade    { from{opacity:0} }
@keyframes mFadeOut { to{opacity:0} }
@keyframes mPop     { from{opacity:0;transform:scale(.97)} }
@keyframes mPopOut  { to{opacity:0;transform:scale(.98)} }
@keyframes mDrop    { from{opacity:0;transform:translateY(-4px) scale(.98)} }   /* out of a trigger above it */
@keyframes mRise    { from{opacity:0;transform:translateY(4px) scale(.98)} }    /* out of a trigger below it */
@keyframes mSheet   { from{opacity:0;transform:translateY(8px)} }
@keyframes mToastIn { from{opacity:0;transform:translateY(-8px) scale(.98)} }
@keyframes mToastOut{ to{opacity:0;transform:translateY(-4px) scale(.98)} }
@keyframes mDotIn   { from{opacity:0;transform:scale(.3)} }

/* ---- menus, dropdowns, date pickers: grow out of the trigger ---- */
/* fill "backwards", not "both": a transform still applied after the animation makes the menu the containing block of
   the fixed-position company flyout inside it, which then shows scrollbars and is clipped away */
.uiPop{ transform-origin:top left; animation:mDrop var(--dur-base) var(--ease-out) backwards; }
.uiPop[data-side="top"]{ transform-origin:bottom left; animation-name:mRise; }
.uiPop.uiSub{ animation-name:mFade; }
.uiPop.leaving{ animation:mPopOut var(--dur-fast) var(--ease-out) forwards; }

/* ---- modals and alerts: scrim fades, the dialog settles from 97% ---- */
.overlay, .uiDlgWrap{ animation:mFade var(--dur-base) var(--ease-out) both; }
.modal, .uiDlg{ animation:mPop var(--dur-base) var(--ease-out) backwards; }
.overlay.leaving, .uiDlgWrap.leaving{ animation:mFadeOut var(--dur-fast) var(--ease-out) forwards; }
.overlay.leaving > .modal, .uiDlgWrap.leaving > .uiDlg{ animation:mPopOut var(--dur-fast) var(--ease-out) forwards; }
/* full-page sheets: the page fades in over the content and the form settles 8px up; leaving is a plain fade */
.overlay.pageSheet > .modal.pageForm{ animation:mSheet var(--dur-base) var(--ease-out) backwards; }
.overlay.pageSheet.leaving > .modal.pageForm{ animation:none; }
/* the till opens its dialogs hundreds of times a day, from the keyboard: no motion there */
#app[data-page="pos"] ~ .overlay, #app[data-page="pos"] ~ .overlay > .modal{ animation:none; }

/* ---- toasts: drop in from the top, leave the same way, faster ---- */
.toastMsg{ position:relative; animation:mToastIn var(--dur-base) var(--ease-out) backwards; }
.toastMsg.leaving{ animation:mToastOut var(--dur-fast) var(--ease-out) forwards; }
/* the icon snaps in just after the toast lands */
.toastMsg .tIcon{ animation:mDotIn var(--dur-slow) var(--ease-snap) 60ms both; }

/* ---- press: every button gives under the finger ---- */
/* press: the button gives at once on touch-down and eases back on release (Apple's touch-down / touch-up feel) */
.btn, .iconBtn{ transition:background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease,
  box-shadow var(--dur-fast) ease, transform 240ms var(--ease-out); }
.btn:active:not(:disabled), .iconBtn:active:not(:disabled){ transform:scale(.96); transition-duration:var(--dur-fast), var(--dur-fast), var(--dur-fast), var(--dur-fast), 70ms; }

/* ---- table rows: hover tint eases instead of blinking ---- */
tbody tr{ transition:background-color var(--dur-fast) ease; }

/* ---- sidebar: same behaviour as before, on the shared tokens (opening --dur-base, closing --dur-fast) ---- */
.navBtn,.navHead{ transition:background-color var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out), padding .2s var(--ease-out); }
.navHead .chev{ transition:transform var(--dur-base) var(--ease-out), opacity .16s ease; }
.navItems{ transition:grid-template-rows var(--dur-fast) var(--ease-out); }
.navGroup.open>.navItems{ transition-duration:var(--dur-base); }
.navItems>div{ transition:opacity var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out); }
.navGroup.open>.navItems>div{ transition:opacity var(--dur-base) ease 30ms, transform var(--dur-base) var(--ease-out); }

/* ---- screens, lists, tabs, sidebar, theme (the rest of the system) ---- */
/* a new screen settles in (a redraw of the same screen keeps its host, so it does not replay) */
@keyframes mScreen { from{opacity:0;transform:translateY(4px)} }
#screen > .screen{ animation:mScreen var(--dur-base) var(--ease-out) backwards; }
/* rows replace the skeleton with a short crossfade, opacity only */
/* a dashboard widget's figures fade in as they replace its loading skeleton */
.dbBody > *{ animation:mFade var(--dur-fast) ease-out backwards; }
/* only the first rows fade in: a long list must not start hundreds of animations at once */
.plBody tr.docRow:nth-child(-n+24), .listRows > li:not(.skLine):nth-child(-n+24){ animation:mFade var(--dur-fast) ease-out backwards; }
/* tabs: the underline and colour ease to the chosen tab */
.hubTabs button{ transition:color var(--dur-fast) ease, border-color var(--dur-base) var(--ease-out), background-color var(--dur-fast) ease; }
/* filter chips and setup choices ease between states rather than snapping */
.plQuickBtn, .plChip, .obOpt, .obChip span{ transition:background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out); }
/* sidebar collapse on the shared curve */
/* the menu and the page beside it move on Apple's sheet curve: quick off the mark, a long soft landing, no bounce */
:root{ --ease-glide:cubic-bezier(.45,0,.25,1); --dur-glide:340ms; }   /* calm ease-in-out: a fast-start curve made the pill jump 40 px in its first frame */
#sidebar{ transition:width var(--dur-glide) var(--ease-glide); }
#sbToggle{ transition:left var(--dur-glide) var(--ease-glide), opacity var(--dur-fast) ease, color var(--dur-fast) ease, transform 240ms var(--ease-out); }
#sbToggle:active{ transform:scale(.9); }
#sidebar .navBtn,#sidebar .navHead{ transition:background-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out), transform 240ms var(--ease-out), padding var(--dur-glide) var(--ease-glide); }
#sidebar .navBtn:active,#sidebar .navHead:active{ transform:scale(.96); transition-duration:var(--dur-fast),var(--dur-fast),70ms,var(--dur-glide); }
#sidebar .navItems, #sidebar .navGroup.open>.navItems{ transition:grid-template-rows var(--dur-glide) var(--ease-glide); }
#sidebar .navGroup.open>.navItems>div{ transition:opacity var(--dur-base) ease 40ms, transform var(--dur-glide) var(--ease-glide); }
/* light/dark: colours cross-fade for the switch only */
html.themeSwitch, html.themeSwitch *, html.themeSwitch *::before, html.themeSwitch *::after{
  transition:background-color 300ms ease, color 300ms ease, border-color 300ms ease, fill 300ms ease, stroke 300ms ease !important; }
@media (prefers-reduced-motion: reduce){
  #screen > .screen, .plBody tr.docRow, .listRows > li{ animation:none; }
  #sidebar,#sbToggle{ transition:none; }
}
