/* ==========================================================================================================
   W107 LANE A - N12 THE MENU MOTION PASS (docs/specs/W107-NARRATION-SEEDS.md 4.6, docs/notes/W107-A-ceremonies.md)

   J: "See how smooth when I click it ... everything's animated smoothly." One set of motion tokens for every
   menu, flipped by html[data-anim="full|some|none"] - the player's ANIMATIONS choice (index.html
   applyReducedMotion() writes the attribute next to body.cc-rm / body.cc-some / body.cc-nf; the OS "reduce
   motion" preference and MODE: BATTERY SAVER already feed it, W104 / D23).

     token            FULL                       SOME                NONE
     --mo-enter       160 ms (slide 14 px + fade) 90 ms, fade only    0
     --mo-stagger     40 ms x the first six rows  0                   0
     --mo-tab         120 ms cross-fade           80 ms               0
     --mo-pop         200 ms (.85 > 1.05 > 1)     120 ms (fade)       0
     --mo-close       130 ms                      90 ms               0
     --mo-press       .95 then a 1.02 spring      .97                 none
     --mo-count       80-100 ms a tick            4 ticks (JS)        the final value (JS)
     --mo-bob         +-4 px on a 1.5 s sine      off                 off
     --mo-shimmer     400 ms sweep every 4 s      off                 off (and off with FLASHES off)

   PRESENTATION ONLY: transform / translate / scale / opacity, nothing that lays out, nothing the sim reads.
   Any new screen from another lane uses these variables instead of private timings (spec 8.5, interface 4).
   Retune a number here and nowhere else.
   ========================================================================================================== */

:root,
html[data-anim="full"] {
  --mo-enter: 160ms;
  --mo-stagger: 40ms;
  --mo-tab: 120ms;
  --mo-pop: 200ms;
  --mo-close: 130ms;
  --mo-press-scale: .95;
  --mo-press-ms: 120ms;
  --mo-press-ease: cubic-bezier(.3, 1.8, .5, 1);
  --mo-count: 90ms;
  --mo-bob: 4px;
  --mo-bob-ms: 1500ms;
  --mo-shimmer-ms: 4000ms;
  --mo-slide: 14px;
  --mo-pop-from: .85;
  --mo-pop-over: 1.05;
}
html[data-anim="some"] {
  --mo-enter: 90ms;
  --mo-stagger: 0ms;
  --mo-tab: 80ms;
  --mo-pop: 120ms;
  --mo-close: 90ms;
  --mo-press-scale: .97;
  --mo-press-ms: 80ms;
  --mo-press-ease: ease-out;
  --mo-count: 0ms;
  --mo-bob: 0px;
  --mo-bob-ms: 0ms;
  --mo-shimmer-ms: 0ms;
  --mo-slide: 0px;
  --mo-pop-from: 1;
  --mo-pop-over: 1;
}
html[data-anim="none"] {
  --mo-enter: 0ms;
  --mo-stagger: 0ms;
  --mo-tab: 0ms;
  --mo-pop: 0ms;
  --mo-close: 0ms;
  --mo-press-scale: 1;
  --mo-press-ms: 0ms;
  --mo-press-ease: linear;
  --mo-count: 0ms;
  --mo-bob: 0px;
  --mo-bob-ms: 0ms;
  --mo-shimmer-ms: 0ms;
  --mo-slide: 0px;
  --mo-pop-from: 1;
  --mo-pop-over: 1;
}

/* ---------------------------------------------------------------- keyframes (transform / opacity only) */
@keyframes moRise { from { opacity: 0; translate: 0 var(--mo-slide); } to { opacity: 1; translate: 0 0; } }
@keyframes moFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes moPop {
  0% { opacity: 0; scale: var(--mo-pop-from); }
  60% { opacity: 1; scale: var(--mo-pop-over); }
  100% { opacity: 1; scale: 1; }
}
@keyframes moOut { from { opacity: 1; scale: 1; } to { opacity: 0; scale: .96; } }
@keyframes moBob { 0%, 100% { translate: 0 0; } 25% { translate: 0 calc(var(--mo-bob) * -1); } 75% { translate: 0 var(--mo-bob); } }
@keyframes moShimmer { 0% { translate: -130% 0; } 10% { translate: 130% 0; } 100% { translate: 130% 0; } }
@keyframes moTilePop { 0% { scale: 1; } 45% { scale: 1.15; } 100% { scale: 1; } }

/* ---------------------------------------------------------------- 1 SHEETS ENTER (160 ms: slide 14 px + fade) */
#detailOv:not(.hidden) #detailCard,
#swapOv:not(.hidden) .swapCard,
#tallyOv:not(.hidden) .tyCard {
  animation: moRise var(--mo-enter) cubic-bezier(.2, .8, .3, 1) backwards;
}

/* ---------------------------------------------------------------- 2 LISTS: the first six rows stagger 40 ms apart.
   motionEnter() (CapeMotion.enter) puts .moIn on a screen for ~700 ms when it is SHOWN, so an in-place repaint of a grid
   (a level bought on a card) never replays the rise. */
.moIn :is(.unitCard, .leaderCard, .chpRow, .ch-card, .alCover, .tuCard, .lbRow, .shopCard, .hqRow, .pfRow):nth-child(-n+6) {
  animation: moRise var(--mo-enter) cubic-bezier(.2, .8, .3, 1) backwards;
  animation-delay: calc(var(--mo-i, 0) * var(--mo-stagger));
}
.moIn :is(.unitCard, .leaderCard, .chpRow, .ch-card, .alCover, .tuCard, .lbRow, .shopCard, .hqRow, .pfRow):nth-child(1) { --mo-i: 0; }
.moIn :is(.unitCard, .leaderCard, .chpRow, .ch-card, .alCover, .tuCard, .lbRow, .shopCard, .hqRow, .pfRow):nth-child(2) { --mo-i: 1; }
.moIn :is(.unitCard, .leaderCard, .chpRow, .ch-card, .alCover, .tuCard, .lbRow, .shopCard, .hqRow, .pfRow):nth-child(3) { --mo-i: 2; }
.moIn :is(.unitCard, .leaderCard, .chpRow, .ch-card, .alCover, .tuCard, .lbRow, .shopCard, .hqRow, .pfRow):nth-child(4) { --mo-i: 3; }
.moIn :is(.unitCard, .leaderCard, .chpRow, .ch-card, .alCover, .tuCard, .lbRow, .shopCard, .hqRow, .pfRow):nth-child(5) { --mo-i: 4; }
.moIn :is(.unitCard, .leaderCard, .chpRow, .ch-card, .alCover, .tuCard, .lbRow, .shopCard, .hqRow, .pfRow):nth-child(6) { --mo-i: 5; }

#detailStats.moStatsIn { animation: moFade var(--mo-tab) ease-out backwards; }

/* ---------------------------------------------------------------- 3 TAB SWAPS cross-fade in 120 ms */
.ccTabPane.moShow { animation: moFade var(--mo-tab) ease-out both; }

/* ---------------------------------------------------------------- 4 MODALS / BANNERS pop .85 > 1.05 > 1 in 200 ms behind a 60% scrim; close 130 ms */
.moPop { animation: moPop var(--mo-pop) cubic-bezier(.2, .9, .3, 1.1) both; }
#tallyOv { background: rgba(8, 4, 20, .6); }
#tallyOv:not(.hidden) { animation: moFade var(--mo-enter) ease-out backwards; }
#tallyOv.hidden.moClosing { display: flex !important; pointer-events: none !important; animation: moOut var(--mo-close) ease-in both; }

/* ---------------------------------------------------------------- 5 PRESS: .95x then a 1.02x spring in 120 ms
   Extends polish.css's press squish. Same zero-specificity :where() selector as there, loaded after it, so the
   tokens win by order and any control's own press rule still wins over both. */
:where(button, [role=button], .ch-card, .alCover, .tuCard, .abub, .whHub):where(:not(:disabled)) {
  transition-property: scale, filter;
  transition-duration: var(--mo-press-ms);
  transition-timing-function: var(--mo-press-ease);
}
:where(button, [role=button], .ch-card, .alCover, .tuCard, .abub, .whHub):where(:not(:disabled)):where(:active) {
  scale: var(--mo-press-scale);
}
html[data-anim="none"] :where(button, [role=button], .ch-card, .alCover, .tuCard, .abub, .whHub):where(:active) { scale: none; }

/* ---------------------------------------------------------------- 6 FLOATING BADGES bob +-4 px on a 1.5 s sine */
html[data-anim="full"] .ch-railNew:not([hidden]),
html[data-anim="full"] .ch-railBadge.has-ready,
html[data-anim="full"] .ccClaimDot:not([hidden]),
html[data-anim="full"] .ccTabDot:not([hidden]),
.moBob {
  animation: moBob var(--mo-bob-ms) ease-in-out infinite;
}

/* ---------------------------------------------------------------- 7 RARE-AND-UP frames shimmer once every 4 s (a 400 ms sweep).
   Only the first eight cards of a grid, and only on FULL with FLASHES on: it is a sweep of light, so FLASHES off removes it. */
html[data-anim="full"]:not([data-flash="off"]) .unitCard:nth-child(-n+8):has(.ucChip.rar.r3),
html[data-anim="full"]:not([data-flash="off"]) .unitCard:nth-child(-n+8):has(.ucChip.rar.r4) {
  position: relative;
}
html[data-anim="full"]:not([data-flash="off"]) .unitCard:nth-child(-n+8):has(.ucChip.rar.r3)::after,
html[data-anim="full"]:not([data-flash="off"]) .unitCard:nth-child(-n+8):has(.ucChip.rar.r4)::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0; width: 46%;
  pointer-events: none;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .22) 50%, rgba(255, 255, 255, 0) 100%);
  translate: -130% 0;
  animation: moShimmer var(--mo-shimmer-ms) linear infinite;
}

/* ---------------------------------------------------------------- 8 changed STATS tiles pop 1.15x in 100 ms */
.ccTile.moPopTile { animation: moTilePop 100ms ease-out both; }

/* ---------------------------------------------------------------- NONE: nothing the tokens drive may keep running */
html[data-anim="none"] .moIn :is(.unitCard, .leaderCard, .chpRow, .ch-card, .alCover, .tuCard, .lbRow, .shopCard, .hqRow, .pfRow),
html[data-anim="none"] #detailCard, html[data-anim="none"] #swapOv .swapCard,
html[data-anim="none"] #tallyOv, html[data-anim="none"] #tallyOv .tyCard,
html[data-anim="none"] .ccTabPane.moShow, html[data-anim="none"] #detailStats.moStatsIn, html[data-anim="none"] .moPop, html[data-anim="none"] .moBob,
html[data-anim="none"] .ccTile.moPopTile, html[data-anim="none"] .ch-railNew, html[data-anim="none"] .ch-railBadge,
html[data-anim="none"] .ccClaimDot, html[data-anim="none"] .ccTabDot {
  animation: none !important;
}
html[data-anim="none"] .unitCard::after { animation: none !important; display: none !important; }
html[data-anim="some"] .unitCard::after { display: none; }
@media (prefers-reduced-motion: reduce) {
  :root { --mo-enter: 0ms; --mo-stagger: 0ms; --mo-tab: 0ms; --mo-pop: 0ms; --mo-close: 0ms; --mo-bob: 0px; --mo-slide: 0px; }
}

