/* ==========================================================================
   BuckBallot motion: derived tokens (Asset Pack v4 + v6: all 28 motions of brand/reference/brand/motion/MOTION_SPEC.md (v1-v4)).
   css/motion.css is a verbatim copy of the pack's motion.css (the base tokens). Every timing in the spec that is not a single
   base token is built here from base tokens with calc(), so screens and js/motion.js only ever use NAMED tokens.
   JS reads them with PKMotion.dur('--m-…'); no literal milliseconds anywhere else (checked by scripts/motion-audit.mjs).

   Reduced motion: the pack's @media block shrinks the base tokens (settle/celebrate/stagger → 0, enter/route/stamp → 150ms).
   --m-press does NOT shrink, so every token derived from it is overridden below to match the spec's "Reduced motion" column.
   html.still (the ?still address flag) gets the same values.
   ========================================================================== */
:root{
  /* 1. App open (~1.2s): ring draws 600, hat springs in 550, wordmark rises 350 */
  --m-ring: calc(var(--m-press) * 4);                       /* 600ms, --e-standard */
  --m-hat: calc(var(--m-enter) + var(--m-route-out));        /* 550ms, spring keyframes */
  --m-hat-delay: calc(var(--m-press) * 2);                   /* 300ms: hat starts while the ring is half drawn */
  --m-wordmark: var(--m-enter);                              /* 350ms, --e-enter */
  --m-wordmark-delay: calc(var(--m-press) * 4);              /* 600ms: rises as the ring closes */
  --m-open-total: calc(var(--m-press) * 8);                  /* 1200ms: whole launch, overlay fades out after */
  --m-open-hold: 0ms;                                        /* reduced: static logo hold (below) */
  --m-open-fade: var(--m-route-out);                         /* 200ms overlay fade-out (reduced: 150ms crossfade) */
  /* 2. Tab switch: out 200 / in 300, 100 overlap; indicator 250 */
  --m-tab-out: var(--m-route-out);                           /* 200ms, --e-exit */
  --m-tab-in: calc(var(--m-press) * 2);                      /* 300ms, --e-enter */
  --m-tab-overlap: calc(var(--m-route-out) / 2);             /* 100ms: in starts 100ms before out ends */
  --m-tab-in-delay: calc(var(--m-tab-out) - var(--m-tab-overlap));   /* 100ms */
  --m-indicator: var(--m-settle);                            /* 250ms, --e-standard */
  /* 3. Feed entrance (first Feed view each day) */
  --m-card-in: var(--m-enter);                               /* 350ms per card, --stagger 60ms */
  --m-art-reveal: calc(var(--m-press) * 3);                  /* 450ms clip-path, --e-standard */
  --m-bubble: calc(var(--m-press) * 2);                      /* 300ms spring */
  --m-feed-fade: 0ms;                                        /* reduced: 150ms fade, all at once */
  /* 4. Swipe vote */
  --m-stamp-land: var(--m-stamp);                            /* 180ms spring */
  --m-nudge: calc(var(--m-press) * 0.8);                     /* 120ms */
  --m-flyout: var(--m-route-out);                            /* 200ms, --e-exit */
  --m-next-card: calc(var(--m-press) * 2);                   /* 300ms, --e-enter */
  --m-stamp-down: calc(var(--m-press) * 0.8);                /* 120ms: PASSED/FAILED/VERIFIED/AUDITED stamp-down, scale 1.3 → 1 */
  /* 5. Split 100 bucks */
  --m-bars: var(--m-settle);                                 /* 250ms with a small overshoot */
  --m-roll: var(--m-settle);                                 /* 250ms number roll */
  --m-pulse: calc(var(--m-press) * 2);                       /* 300ms total pulse at 100 */
  /* 6. Books count-up (first Books view per session) */
  --m-count: calc(var(--m-press) * 6);                       /* 900ms, --e-enter */
  --m-bars-fill: calc(var(--m-press) * 4);                   /* 600ms */
  --m-bars-delay: var(--m-press);                            /* after 150ms */
  /* 7. My two bucks sheet */
  --m-sheet-press: var(--m-press);                           /* 150ms + button press */
  --m-sheet-up: var(--m-route-in);                           /* 400ms, --e-enter */
  --m-scrim: var(--m-settle);                                /* 250ms */
  --m-sheet-close: var(--m-route-out);                       /* 200ms, --e-exit */
  /* 8. Badge unlock (once per badge) */
  --m-flip: calc(var(--m-route-out) * 2.5);                  /* 500ms spring */
  --m-glint: var(--m-celebrate);                             /* 700ms */
  --m-dots: calc(var(--m-press) * 4);                        /* 600ms, 10 gold dots, --e-exit */
  --m-badge-fade: 0ms;                                       /* reduced: 150ms fade only */
  /* ---- v2 of the spec (pack v6): eight more motions ---- */
  /* 9. Your receipt print-out (~1.6s): paper feeds 900, lines 120 apart, button last */
  --m-receipt-feed: calc(var(--m-press) * 6);                /* 900ms, --e-standard */
  --m-receipt-line: var(--m-settle);                         /* 250ms per line fade/rise, --e-enter */
  --m-receipt-gap: calc(var(--m-press) * 0.8);               /* 120ms between lines (use as a stagger: n * gap) */
  --m-receipt-button: calc(var(--m-press) * 8 / 3);          /* 400ms */
  --m-receipt-button-delay: calc(var(--m-press) * 8);        /* 1200ms: button lands last, total 1.6s */
  --m-receipt-fade: 0ms;                                     /* reduced: whole receipt fades in 150ms */
  /* 10. Card to bill detail (shared element) */
  --m-detail-grow: var(--m-route-in);                        /* 400ms, --e-enter */
  --m-detail-content: var(--m-route-out);                    /* 200ms content fade, --e-enter */
  --m-detail-content-delay: calc(var(--m-route-in) - var(--m-route-out));   /* 200ms: content lands with the container */
  --m-detail-back: calc(var(--m-press) * 2);                 /* 300ms, --e-exit */
  --m-theme: var(--m-celebrate);                             /* 700ms: Night edition palette crossfade (spec v10 TM10); reduced: instant */
  --m-detail-back-half: calc(var(--m-detail-back) / 2);     /* 150ms: on the way back the detail's content leaves, then the card's arrives */
  /* 11. Docket complete */
  --m-done-ring: calc(var(--m-press) * 4);                   /* 600ms, --e-standard */
  --m-done-check: var(--m-settle);                           /* 250ms spring */
  --m-done-text: var(--m-enter);                             /* 350ms, --e-enter */
  --m-done-fade: 0ms;                                        /* reduced: final state with a 150ms fade */
  /* 12. Pull to refresh (follows the finger; threshold 72px is a distance, not a token) */
  --m-refresh-sweep: calc(var(--m-press) * 6);               /* 900ms magnifier sweep, loops ONLY while loading */
  --m-refresh-snap: var(--m-settle);                         /* 250ms snap back, --e-standard */
  /* 13. Loading to content */
  --m-shimmer: calc(var(--m-press) * 8);                     /* 1200ms shimmer, linear, loops ONLY while waiting */
  --m-skeleton-wait: calc(var(--m-press) * 2);               /* 300ms: a load shorter than this shows no skeleton (a wait, not a motion) */
  --m-skeleton-swap: var(--m-route-out);                     /* 200ms crossfade to content, --e-standard */
  /* 14. Vote saved toast (with Undo) */
  --m-toast-in: var(--m-settle);                             /* 250ms, --e-enter */
  --m-toast-stay: calc(var(--m-press) * 80 / 3);             /* 4000ms on screen (a reading time, not a motion; pauses on hover/focus) */
  --m-toast-stay-long: calc(var(--m-toast-stay) * 2);        /* 8000ms: an informational toast with a longer message (not votes) */
  --m-toast-out: var(--m-route-out);                         /* 200ms, --e-exit */
  /* 15. Call It result */
  --m-callit-flip: calc(var(--m-press) * 3);                 /* 450ms, --e-standard */
  --m-callit-count: var(--m-route-in);                       /* 400ms points count-up, --e-enter */
  /* 16. Form error */
  --m-shake: calc(var(--m-press) * 2);                       /* 300ms, 3 small cycles, linear */
  --m-error-msg: var(--m-route-out);                         /* 200ms message in, --e-enter */

  /* ---- v3 of the spec (pack v7/v8): six more motions ---- */
  /* 17. Same split / Different take reaction */
  --m-react-press: var(--m-press);                           /* 150ms press, --e-standard */
  --m-react-fill: var(--m-settle);                           /* 250ms fill, --e-standard */
  --m-react-float: calc(var(--m-press) * 8 / 3);             /* 400ms "+1" floats up and fades, --e-exit */
  --m-react-line: var(--m-settle);                           /* 250ms agreement line update, --e-enter */
  /* 18. Follow button */
  --m-follow-morph: var(--m-settle);                         /* 250ms Follow → Following, --e-standard */
  --m-follow-check: var(--m-route-out);                      /* 200ms check draws (clip-path), --e-enter */
  /* 19. Onboarding steps (direction follows Continue / Back) */
  --m-onboard-out: var(--m-route-out);                       /* 200ms, --e-exit */
  --m-onboard-in: calc(var(--m-press) * 2);                  /* 300ms, --e-enter */
  --m-onboard-pill: var(--m-settle);                         /* 250ms progress pill, --e-standard */
  /* 20. Search open */
  --m-search-expand: calc(var(--m-press) * 2);               /* 300ms field expands, --e-enter */
  --m-search-chip: var(--m-route-out);                       /* 200ms per filter chip, --e-enter */
  --m-search-stagger: calc(var(--stagger) * 2 / 3);          /* 40ms between chips */
  /* 21. Official verified (once, to the official) */
  --m-verify-seal: calc(var(--m-press) * 8 / 3);             /* 400ms seal lands, spring */
  --m-verify-check: var(--m-settle);                         /* 250ms check, --e-enter */
  --m-verify-label: calc(var(--m-press) * 2);                /* 300ms label, --e-enter */
  /* 22. Settings toggle */
  --m-toggle: var(--m-route-out);                            /* 200ms knob (slight overshoot keyframe) and track fill opacity, --e-standard */
  /* ---- v4 of the spec (pack v9/v10): six more motions ---- */
  /* 23. Compare reveal */
  --m-reveal-flip: calc(var(--m-press) * 2);                 /* 300ms per friend bar, --e-standard */
  --m-reveal-stagger: var(--stagger);                        /* 60ms */
  --m-reveal-head: var(--m-enter);                           /* 350ms headline, --e-enter */
  /* 24. Send to a friend */
  --m-send-shrink: var(--m-enter);                           /* 350ms card shrinks, --e-exit */
  --m-send-bubble: var(--m-settle);                          /* 250ms message bubble lands, --e-enter; then the system share sheet */
  /* 25. Group results */
  --m-group-avatar: var(--m-settle);                         /* 250ms avatars spring in */
  --m-group-stagger: calc(var(--stagger) * 4 / 3);           /* 80ms */
  --m-group-bars: calc(var(--m-press) * 2);                  /* 300ms */
  --m-group-head: var(--m-enter);                            /* 350ms headline, --e-enter */
  /* 26. Swipe sheet down (follows the finger) */
  --m-dismiss-close: var(--m-route-out);                     /* 200ms close, --e-exit */
  --m-dismiss-snap: var(--m-settle);                         /* 250ms snap back if released early, --e-standard */
  --m-dismiss-flick: var(--m-route-out);                     /* 200ms: a downward flick inside this window closes (a time window, not a motion) */
  --m-press-tint: calc(var(--m-press) * 2 / 3);              /* 100ms: the pressed tint on rows and tabs comes and goes (kept in reduced motion) */
  /* 27. Long-press preview */
  --m-peek-hold: calc(var(--m-press) * 8 / 3);               /* 400ms hold before the preview (a press time, not a motion; never shrinks) */
  --m-peek-lift: var(--m-route-out);                         /* 200ms card lifts, --e-standard */
  --m-peek-blur: var(--m-route-out);                         /* 200ms background blur (an overlay's opacity), --e-standard */
  --m-peek-menu: var(--m-route-out);                         /* 200ms quick-action menu, --e-enter */
  /* 28. Live night reactions */
  --m-live-pop: var(--m-press);                              /* 150ms tap pop, spring keyframes */
  --m-live-batch: calc(var(--m-press) * 40 / 3);             /* 2000ms between count batches (a polling interval, not a motion) */
  --m-live-roll: var(--m-settle);                            /* 250ms count roll, --e-standard */
  /* Town map (MOTION_SPEC "Town map motions" TM1-TM5; behind the townMap flag, js/townmap.js; ported from feature/town-map for item 6 of the November 16 prompt). Reduced motion: js/townmap.js
     swaps every one of these for the 150ms crossfade (--m-fade); no lift, ripple, zoom or drop. */
  --m-tm-switch: var(--m-settle);                            /* 250ms Tiles · Map knob slide, --e-standard */
  --m-tm-tiles-out: var(--m-route-out);                      /* TM1: 200ms tiles fade back to .98, --e-exit */
  --m-tm-map-in: var(--m-enter);                             /* TM1: 350ms map plate .96 → 1 and fade in, --e-enter */
  --m-tm-map-fade: var(--m-settle);                          /* TM1: 250ms map view fade, --e-standard */
  --m-tm-label: var(--m-settle);                             /* TM1/TM5: 250ms each label drops 8px, pin pops, line fades, --e-enter */
  --m-tm-label-gap: var(--stagger);                          /* TM1: 60ms between labels */
  --m-tm-label-gap-back: calc(var(--stagger) / 2);           /* TM5: 30ms between labels */
  --m-tm-labels-out: var(--m-press);                         /* TM2/TM4: 150ms labels, pins and lines fade, --e-exit */
  --m-tm-map-out: var(--m-route-out);                        /* TM2: 200ms map fades out, --e-exit */
  --m-tm-tiles-in: var(--m-settle);                          /* TM2: 250ms tiles rise 10px, --e-enter */
  --m-tm-tiles-gap: calc(var(--stagger) * 2 / 3);            /* TM2: 40ms between tiles */
  --m-tm-press: var(--m-press);                              /* TM3: 150ms label lifts 2px, pin dips to .8 */
  --m-tm-ripple: calc(var(--m-press) * 7 / 3);               /* TM3: 350ms cream ripple, scale 1 → 5 */
  --m-tm-zoom: var(--m-route-in);                            /* TM4: 400ms camera zooms 2.4x toward the building, --e-enter */
  --m-tm-door: var(--m-route-in);                            /* TM4: 400ms place opens out of the building (clip-path circle), --e-enter */
  --m-tm-door-delay: calc(var(--m-press) * 22 / 15);         /* TM4: the door starts 220ms into the zoom */
  --m-tm-hit-delay: calc(var(--m-press) * 4 / 5);            /* TM4: the tapped label fades 120ms after the others */
  --m-tm-door-close: calc(var(--m-press) * 2);               /* TM5: 300ms place closes into the building, --e-exit */
  --m-tm-zoom-out: var(--m-route-in);                        /* TM5: 400ms camera pulls back to 1x, --e-standard */
  /* shared */
  --m-flash: calc(var(--m-press) * 8 / 3);                   /* 400ms: the "you just changed this row" tint fades (reduced: none); not over 400 so no skip needed */
  --m-flash-hold: calc(var(--m-press) * 34 / 3);             /* 1700ms: how long a changed row keeps its highlight class (the reduced-motion outline stays this long); a hold, not a motion */
  --m-fade: var(--m-press);                                  /* the 150ms reduced-motion fade */
  --m-title-swap: var(--m-route-out);                        /* 200ms: v29 native nav, the large title gives way to the small centred one, --e-standard (reduced: instant) */
  --m-skip-threshold: calc(var(--m-press) * 8 / 3);          /* 400ms: motions longer than this are tap-skippable (built on --m-press so it does not shrink) */

  /* older names (js/shell.js, css/shell.css and screen CSS still use them), re-pointed to the pack scale */
  --m-fast: var(--m-press); --m-base: var(--m-settle); --m-slow: var(--m-route-in); --m-grow: var(--m-bars-fill); --m-stagger: var(--stagger);
  --ease-out: var(--e-standard); --ease-in: var(--e-exit); --ease-spring: var(--e-standard);
}
@media (prefers-reduced-motion: reduce){
  :root{
    --m-ring: 0ms; --m-hat: 0ms; --m-hat-delay: 0ms; --m-wordmark: 0ms; --m-wordmark-delay: 0ms;
    --m-open-hold: calc(var(--m-press) * 8 / 3);             /* static logo 400ms */
    --m-open-total: calc(var(--m-press) * 8 / 3);
    --m-open-fade: var(--m-press);                           /* then a 150ms crossfade */
    --m-tab-in: var(--m-press); --m-tab-overlap: var(--m-press); --m-tab-in-delay: 0ms;   /* one 150ms crossfade; indicator jumps (--m-settle = 0) */
    --m-art-reveal: 0ms; --m-bubble: 0ms; --m-feed-fade: var(--m-press);
    --m-nudge: 0ms; --m-next-card: var(--m-press); --m-stamp-down: 0ms;
    --m-pulse: 0ms;
    --m-count: 0ms; --m-bars-fill: 0ms; --m-bars-delay: 0ms;
    --m-sheet-press: 0ms; --m-scrim: var(--m-press);
    --m-flip: 0ms; --m-dots: 0ms; --m-badge-fade: var(--m-press);
    /* v6 motions */
    --m-receipt-feed: 0ms; --m-receipt-line: 0ms; --m-receipt-gap: 0ms; --m-receipt-button: 0ms; --m-receipt-button-delay: 0ms; --m-receipt-fade: var(--m-press);
    --m-detail-grow: 0ms; --m-detail-content: var(--m-press); --m-detail-content-delay: 0ms; --m-detail-back: var(--m-press);
    --m-done-ring: 0ms; --m-done-check: 0ms; --m-done-text: 0ms; --m-done-fade: var(--m-press);
    --m-refresh-sweep: 0ms; --m-refresh-snap: 0ms;
    --m-shimmer: 0ms; --m-skeleton-swap: 0ms;
    --m-toast-in: var(--m-press); --m-toast-out: var(--m-press);
    --m-callit-flip: 0ms; --m-callit-count: 0ms;
    --m-shake: 0ms; --m-error-msg: var(--m-press);
    --m-flash: 0ms;
    /* v7-v10 motions */
    --m-react-press: 0ms; --m-react-fill: 0ms; --m-react-float: 0ms; --m-react-line: 0ms;
    --m-follow-morph: 0ms; --m-follow-check: 0ms;
    --m-onboard-out: var(--m-press); --m-onboard-in: var(--m-press); --m-onboard-pill: 0ms;
    --m-search-expand: var(--m-press); --m-search-chip: var(--m-press); --m-search-stagger: 0ms;
    --m-verify-seal: 0ms; --m-verify-check: 0ms; --m-verify-label: var(--m-press);
    --m-toggle: 0ms;
    --m-reveal-flip: 0ms; --m-reveal-stagger: 0ms; --m-reveal-head: var(--m-press);
    --m-send-shrink: 0ms; --m-send-bubble: 0ms;
    --m-group-avatar: 0ms; --m-group-stagger: 0ms; --m-group-bars: 0ms; --m-group-head: var(--m-press);
    --m-dismiss-close: var(--m-press); --m-dismiss-snap: 0ms;
    --m-peek-lift: 0ms; --m-peek-blur: 0ms; --m-peek-menu: var(--m-press);
    --m-live-pop: 0ms; --m-live-roll: 0ms;
    --m-title-swap: 0ms;
  }
}
html.still{
  --m-settle: 0ms; --m-enter: var(--m-press); --m-route-in: var(--m-press); --m-route-out: var(--m-press); --m-stamp: var(--m-press); --m-celebrate: 0ms; --stagger: 0ms;
  --m-ring: 0ms; --m-hat: 0ms; --m-hat-delay: 0ms; --m-wordmark: 0ms; --m-wordmark-delay: 0ms;
  --m-open-hold: calc(var(--m-press) * 8 / 3); --m-open-total: calc(var(--m-press) * 8 / 3); --m-open-fade: var(--m-press);
  --m-tab-in: var(--m-press); --m-tab-overlap: var(--m-press); --m-tab-in-delay: 0ms;
  --m-art-reveal: 0ms; --m-bubble: 0ms; --m-feed-fade: var(--m-press);
  --m-nudge: 0ms; --m-next-card: var(--m-press); --m-stamp-down: 0ms; --m-pulse: 0ms;
  --m-count: 0ms; --m-bars-fill: 0ms; --m-bars-delay: 0ms;
  --m-sheet-press: 0ms; --m-scrim: var(--m-press);
  --m-flip: 0ms; --m-dots: 0ms; --m-badge-fade: var(--m-press);
  /* v6 motions */
  --m-receipt-feed: 0ms; --m-receipt-line: 0ms; --m-receipt-gap: 0ms; --m-receipt-button: 0ms; --m-receipt-button-delay: 0ms; --m-receipt-fade: var(--m-press);
  --m-detail-grow: 0ms; --m-detail-content: var(--m-press); --m-detail-content-delay: 0ms; --m-detail-back: var(--m-press);
  --m-done-ring: 0ms; --m-done-check: 0ms; --m-done-text: 0ms; --m-done-fade: var(--m-press);
  --m-refresh-sweep: 0ms; --m-refresh-snap: 0ms;
  --m-shimmer: 0ms; --m-skeleton-swap: 0ms;
  --m-toast-in: var(--m-press); --m-toast-out: var(--m-press);
  --m-callit-flip: 0ms; --m-callit-count: 0ms;
  --m-shake: 0ms; --m-error-msg: var(--m-press);
  --m-flash: 0ms;
  /* v7-v10 motions */
  --m-react-press: 0ms; --m-react-fill: 0ms; --m-react-float: 0ms; --m-react-line: 0ms;
  --m-follow-morph: 0ms; --m-follow-check: 0ms;
  --m-onboard-out: var(--m-press); --m-onboard-in: var(--m-press); --m-onboard-pill: 0ms;
  --m-search-expand: var(--m-press); --m-search-chip: var(--m-press); --m-search-stagger: 0ms;
  --m-verify-seal: 0ms; --m-verify-check: 0ms; --m-verify-label: var(--m-press);
  --m-toggle: 0ms;
  --m-reveal-flip: 0ms; --m-reveal-stagger: 0ms; --m-reveal-head: var(--m-press);
  --m-send-shrink: 0ms; --m-send-bubble: 0ms;
  --m-group-avatar: 0ms; --m-group-stagger: 0ms; --m-group-bars: 0ms; --m-group-head: var(--m-press);
  --m-dismiss-close: var(--m-press); --m-dismiss-snap: 0ms;
  --m-peek-lift: 0ms; --m-peek-blur: 0ms; --m-peek-menu: var(--m-press);
  --m-live-pop: 0ms; --m-live-roll: 0ms;
  --m-title-swap: 0ms;
}

/* The spring (spec): scale 0.6 → 1.06 at 55% → 0.98 at 80% → 1.0; one visible overshoot. Use with a token duration and linear. */
@keyframes pk-spring{ 0%{transform:scale(.6);opacity:0} 55%{transform:scale(1.06);opacity:1} 80%{transform:scale(.98)} 100%{transform:scale(1);opacity:1} }
@keyframes pk-fade-in{ from{opacity:0} to{opacity:1} }
@keyframes pk-fade-out{ from{opacity:1} to{opacity:0} }
@keyframes pk-flash-out{ from{opacity:1} to{opacity:0} }
/* the results stamp-down (PASSED / FAILED / VERIFIED / AUDITED): scale 1.3 → 1 */
@keyframes pk-stamp-down{ from{transform:scale(1.3);opacity:0} to{transform:scale(1);opacity:1} }
.pk-stamp-down{ animation:pk-stamp-down var(--m-stamp-down) var(--e-standard) both }
@media (prefers-reduced-motion: reduce){ .pk-stamp-down{ animation:pk-fade-in var(--m-fade) linear both } }
html.still .pk-stamp-down{ animation:pk-fade-in var(--m-fade) linear both }
