/* Vaytax shell: motion (week 49, bet 1). Marketing's seven patterns (drafts/2026-11-25-motion-tokens.md) on the
   October set's guardrails (motion-set/motion-set.css). Needs /shell/tokens.css for the --mo-* values.

   Rules this file keeps by construction (tests/test_shell_tokens_motion.py checks them):
   1. Only transform and opacity move. Colour, background colour and border colour may fade on hover and focus
      (paint only, no layout; Marketing 25.11). Every element keeps its final box: CLS 0.
   2. Nothing is hidden by CSS alone. An element only starts hidden when /shell/motion.js has given it the
      class mo-wait, which it does after the load event, only below the visible screen, and never when the
      visitor asks for reduced motion. No JS, a failed script or reduced motion = the static end state.
   3. Each element moves once per page view, no loops. No single motion is longer than --mo-dur-l.
   4. Never on /register or the pay step. Nothing runs by itself on or next to the main call-to-action; the
      press scale (.mo-press, the visitor's own tap, once) is allowed on it (Marketing 25.11).

   Patterns (attribute on the container; the helper adds mo-wait, then mo-in when it scrolls into view):
     1 scroll reveal        data-mo="enter"    direct children rise in, --mo-stagger apart (6 at most)
     2 hover and press      .mo-card, .mo-press (CSS only)
     3 count-up             data-mo="count"    the HTML holds the real figure; the helper counts up to it
     4 step sequencer       data-mo="steps"    items light one after another; a .mo-pill inside each pops
     5 tab / section swap   data-mo="swap"     a child that loses [hidden] (or a <details> that opens) fades in
     6 product card beat   data-mo="beat"     its [data-mo-beat] pill gives one pop --mo-beat after it is seen
     7 animated diagram     data-mo="diagram"  its [data-mo-part] parts appear in order, about 3 s in all */

/* 1. Scroll reveal */
[data-mo="enter"].mo-wait > * { opacity: 0; transform: translateY(var(--mo-rise)); }
[data-mo="enter"].mo-in > * {
  animation: moRise var(--mo-dur-m) var(--mo-ease) both;
  animation-delay: calc(var(--mo-i, 0) * var(--mo-stagger));
}

/* 2. Hover and press. The lift is a transform; the deeper shadow sits on a pseudo-element whose opacity
      changes, so the shadow itself is never animated. Colour, background and border colour fade over --mo-dur-s. */
.mo-card { position: relative; transition: transform var(--mo-dur-s) var(--mo-ease), color var(--mo-dur-s) var(--mo-ease),
  background-color var(--mo-dur-s) var(--mo-ease), border-color var(--mo-dur-s) var(--mo-ease); }
.mo-card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: var(--ds-shadow-m); opacity: 0; transition: opacity var(--mo-dur-s) var(--mo-ease);
}
.mo-card:hover, .mo-card:focus-within { transform: translateY(var(--mo-lift)); }
.mo-card:hover::after, .mo-card:focus-within::after { opacity: 1; }
.mo-press { transition: transform var(--mo-dur-xs) var(--mo-ease), color var(--mo-dur-s) var(--mo-ease),
  background-color var(--mo-dur-s) var(--mo-ease), border-color var(--mo-dur-s) var(--mo-ease); }
.mo-press:active { transform: scale(var(--mo-press)); }
.mo-card:focus-visible, .mo-press:focus-visible { outline: 2px solid var(--ds-focus); outline-offset: 2px; }

/* 3. Count-up. inline-block from the first paint, so the helper can hold the box at its final width. */
[data-mo="count"] { display: inline-block; font-variant-numeric: tabular-nums; }

/* 4. Step sequencer. Items stay readable (not hidden) before they light. */
[data-mo="steps"].mo-wait > * { opacity: .45; }
[data-mo="steps"].mo-in > * {
  animation: moLight var(--mo-dur-m) var(--mo-ease) both;
  animation-delay: calc(var(--mo-i, 0) * var(--mo-step));
}
[data-mo="steps"].mo-wait .mo-pill { opacity: 0; transform: scale(.85); }
[data-mo="steps"].mo-in .mo-pill {
  animation: moPop var(--mo-dur-m) var(--mo-ease-pop) both;
  animation-delay: calc(var(--mo-i, 0) * var(--mo-step));
}

/* 5. Tab and section swap. The helper adds mo-sw when a child is shown, and only after the load event, so
      the panel that is open on arrival never moves. */
[data-mo="swap"] .mo-sw:not(details), [data-mo="swap"] details.mo-sw > :not(summary) {
  animation: moSwap var(--mo-dur-m) var(--mo-ease) both;
}

/* 6. Product card beat: the pill is always visible; it pops once, it never appears from nothing. */
[data-mo="beat"].mo-in [data-mo-beat] { animation: moBeat var(--mo-dur-l) var(--mo-ease-pop) var(--mo-beat) both; }

/* 7. Animated diagram */
[data-mo="diagram"].mo-wait [data-mo-part] { opacity: 0; transform: translateY(var(--mo-slide)); }
[data-mo="diagram"].mo-in [data-mo-part] {
  animation: moSwap var(--mo-dur-m) var(--mo-ease) both;
  animation-delay: calc(var(--mo-i, 0) * var(--mo-part));
}

@keyframes moRise  { from { opacity: 0; transform: translateY(var(--mo-rise)); } to { opacity: 1; transform: none; } }
@keyframes moLight { from { opacity: .45; } to { opacity: 1; } }
@keyframes moPop   { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes moSwap  { from { opacity: 0; transform: translateY(var(--mo-slide)); } to { opacity: 1; transform: none; } }
@keyframes moBeat  { 0%, 100% { transform: none; } 45% { transform: scale(1.12); } }

/* Reduced motion: the end state, whatever state the helper left (the setting can change mid-visit). */
@media (prefers-reduced-motion: reduce) {
  [data-mo] *, [data-mo], .mo-card, .mo-card::after, .mo-press { animation: none !important; transition: none !important; }
  [data-mo].mo-wait > *, [data-mo].mo-wait .mo-pill, [data-mo].mo-wait [data-mo-part] { opacity: 1 !important; transform: none !important; }
  .mo-card:hover, .mo-card:focus-within, .mo-press:active { transform: none; }
}
