/* =====================================================================
   El Tablero · motion.css · Motion system v2 (TAB-0117, on top of v1 TAB-0041)
   Spec: docs/design/motion-v2.md (v1: docs/design/motion-system.md)
   Loaded after winpot-ds.css and refine.css. Rules:
   - transform and opacity (plus a one-off blur on entrances) only;
   - every animation sits behind (prefers-reduced-motion: no-preference);
     under "reduce" lujo.css also kills every animation/transition;
   - content is final in the HTML: no count-up on the answer figure, no
     pulsing sign-up CTA, nothing celebrates a win, bonus or jackpot amount.
   ===================================================================== */

:root {
  --ease-expo: cubic-bezier(.16, 1, .3, 1);          /* entrances, page, sheen */
  --ease-spring-v2: cubic-bezier(.34, 1.56, .64, 1); /* settles: press release, deal, pop */
  --mo-rise: 24px;          /* reveal travel (v1: 12px) */
  --mo-stagger: 70ms;       /* per item in a group, capped at 6 steps in motion.js */
  --mo-in: 620ms;           /* reveal duration */
  --mo-page: 200ms;         /* page transition (product: 200ms or less) */
}

/* --- M8 · winners ticker pause control (WCAG 2.2.2) ------------------ */
.ticker__pause {
  position: absolute; right: 8px; top: 50%; z-index: 3;
  width: 32px; height: 32px; margin-top: -16px;
  display: none; place-items: center;
  background: var(--ground-2); border: 1px solid var(--line); border-radius: 6px;
  color: var(--text-2); cursor: pointer;
}
.ticker__pause:hover { color: var(--text); border-color: var(--text-3); }
.ticker__pause:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.ticker__pause svg { width: 12px; height: 12px; fill: currentColor; }
.ticker__pause::after { content: ""; position: absolute; inset: -7px; }
.ticker.is-paused .ticker__track { animation-play-state: paused; }

/* --- V2 · hero light: a soft light field on navy behind the ask (static under reduced motion).
   It reuses the .ask__light layer (z-index -1 inside the isolated .ask). Moves only by transform. */
.ask__light {
  display: block; inset: -18% -12%;
  background:
    radial-gradient(34% 46% at 72% 34%, rgba(116,160,236,.14), transparent 70%),
    radial-gradient(30% 40% at 18% 8%, rgba(116,160,236,.07), transparent 70%);
  transform: translate3d(var(--px, 0px), var(--py, 0px), 0);
}

/* --- V13 · countdown tiles: the same look with and without motion (design review D5). Present from the
   first paint, so nothing shifts; only the flip (.mo-flip pseudo-elements) lives in the motion block. */
[data-countdown] b {
  display: inline-block; position: relative; min-width: 1.4em; padding: .06em .12em; text-align: center;
  font-variant-numeric: tabular-nums; border: 1px solid var(--line-strong); border-radius: var(--radius-sm, 4px);
  background: var(--surface-2);
}

@media (prefers-reduced-motion: no-preference) {

  /* =================================================== V16 · page transitions
     Old page slides left and fades, new page rises. The header stays. Shared elements:
     a guide title / related card → the article H1 (tablero-title) and a deck card → the
     category / game card (tablero-art). motion.js names the clicked one on pageswap. */
  /* The @view-transition opt-in itself is inline in src/layouts/Base.astro <head> (same media gate). */
  .header { view-transition-name: tablero-header; }
  .article-top h1, .cat-hero h1, #ficha-h1 { view-transition-name: tablero-title; }
  .cat-hero .card, .ficha__card .card { view-transition-name: tablero-art; }
  ::view-transition-old(root) { animation: mo-page-out 160ms var(--ease-out) both; }
  ::view-transition-new(root) { animation: mo-page-in calc(var(--mo-page) + 60ms) var(--ease-expo) both; }
  ::view-transition-group(tablero-header) { animation-duration: 0s; }
  html:active-view-transition-type(back)::view-transition-old(root) { animation-name: mo-page-out-back; }
  ::view-transition-group(tablero-title), ::view-transition-group(tablero-art) { animation-duration: 280ms; animation-timing-function: var(--ease-expo); }
  ::view-transition-old(tablero-title), ::view-transition-new(tablero-title) { height: 100%; object-fit: fill; }
  ::view-transition-new(tablero-title):only-child, ::view-transition-new(tablero-art):only-child { animation: mo-page-in 280ms var(--ease-expo) both; }

  /* =================================================== V1 · hero entrance (home)
     Pure CSS from the first paint: kicker → H1 words (blur to sharp) → ask box → hint → chips.
     The H1 never goes below 25% opacity, so it paints at first paint (LCP is not delayed). */
  .ask__kicker { animation: mo-fade-up 600ms var(--ease-expo) both; }
  @media (max-width: 600px) { .ask h1 { --mo-wblur: 4px; } }   /* lighter paint on phones */
  .ask h1 .mo-w { display: inline-block; animation: mo-word 900ms var(--ease-expo) both; animation-delay: calc(100ms + var(--w, 0) * 55ms); }
  .ask .askbox__field { animation: mo-fade-up 760ms var(--ease-expo) 360ms both; }
  .ask #ask-hint { animation: mo-fade 600ms var(--ease-out) 520ms both; }
  .ask .askchips li { animation: mo-chip 560ms var(--ease-spring-v2) both; animation-delay: 600ms; }
  .ask .askchips li:nth-child(2) { animation-delay: 650ms; }
  .ask .askchips li:nth-child(3) { animation-delay: 700ms; }
  .ask .askchips li:nth-child(4) { animation-delay: 750ms; }
  .ask .askchips li:nth-child(n+5) { animation-delay: 800ms; }
  /* V2 · the light fades in, follows the pointer (motion.js sets --px/--py with an eased lag) and drifts with scroll */
  .ask__light { animation: mo-light-in 1600ms var(--ease-expo) both; will-change: transform; }
  @supports (animation-timeline: scroll()) {
    .ask__light { animation: mo-light-in 1600ms var(--ease-expo) both, mo-light-drift linear both; animation-timeline: auto, scroll(root); animation-range: normal, 0 700px; }
  }
  /* V3 · the typewriter caret breathes instead of a hard step blink */
  .askbox__ghost::after { animation: mo-caret 1100ms ease-in-out infinite; }
  .askbox__field:focus-within .askbox__ghost::after { animation: none; opacity: 0; }

  /* =================================================== V4 / V5 / V6 · live board
     motion.js: .mo-board-wait until the board is in view, then .mo-board-in (tiles deal in). */
  .board .cell { position: relative; }
  .mo-board-wait .cell:not(.cell--ph) { opacity: 0; }
  .mo-board-in .cell:not(.cell--ph) { animation: mo-deal-tile 760ms var(--ease-expo) both; }
  .mo-board-in .cell:nth-child(2) { animation-delay: 80ms; }
  .mo-board-in .cell:nth-child(3) { animation-delay: 160ms; }
  .mo-board-in .cell:nth-child(4) { animation-delay: 240ms; }
  .mo-board-in .cell:nth-child(n+5) { animation-delay: 320ms; }
  /* reels: expo roll, no overshoot (design review D1/D2), each digit 40ms after the previous. The window is clipped
     so exactly one row shows at every frame. Money figures (jackpot, "ganado hoy") never roll from 0: motion.js
     paints their first value instantly; a live change rolls only the digits that changed, with the standard ease. */
  .reel, .reel__d:not(.reel__s) { overflow: hidden; clip-path: inset(0); }
  .reel__d > span { transition: transform 900ms var(--ease-expo); }
  .cell[data-id="jackpot"] .reel__d > span, [data-live="wonToday"] .reel__d > span { transition: transform 600ms var(--ease-out); transition-delay: 0s !important; }
  .mo-reel-now .reel__d > span { transition: none !important; }
  .reel__d:nth-child(2) > span { transition-delay: 40ms; }
  .reel__d:nth-child(3) > span { transition-delay: 80ms; }
  .reel__d:nth-child(4) > span { transition-delay: 120ms; }
  .reel__d:nth-child(5) > span { transition-delay: 160ms; }
  .reel__d:nth-child(6) > span { transition-delay: 200ms; }
  .reel__d:nth-child(7) > span { transition-delay: 240ms; }
  .reel__d:nth-child(8) > span { transition-delay: 280ms; }
  .reel__d:nth-child(n+9) > span { transition-delay: 320ms; }
  /* V5 · sheen: one light band crosses the tile when it deals in and each time its value changes */
  .board .cell::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
    background: linear-gradient(105deg, transparent 34%, rgba(255,255,255,.06) 50%, transparent 66%);
    transform: translateX(-110%);
  }
  .board .cell.is-changed::after { animation: mo-sheen-b 1100ms var(--ease-expo) both; }
  /* V6 · live dot: compositor ring (was a box-shadow pulse, infinite). 3 pings at load, 2 on each change, then still. */
  .dot, .cell__stamp .dot, .odds .dot, .tile--next .dot, .ficha__now .dot, .dot--gold { position: relative; animation: none; box-shadow: none; }
  .dot::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; pointer-events: none;
    animation: mo-ping 1400ms var(--ease-out) 3 both;
  }
  .cell.is-changed .dot::after { animation: mo-ping-b 1200ms var(--ease-out) 2 both; }

  /* =================================================== V7 · deck deal + 3D art bob */
  .mo-deal-wait .card { opacity: 0; }
  .mo-deal .card { animation: mo-deal-m 700ms var(--ease-expo) backwards; }
  @media (min-width: 900px) {
    .mo-deal .card { animation: mo-deal-d 900ms var(--ease-spring-v2) backwards; }
  }
  .mo-deal .card:nth-child(2) { animation-delay: 70ms; }
  .mo-deal .card:nth-child(3) { animation-delay: 140ms; }
  .mo-deal .card:nth-child(4) { animation-delay: 210ms; }
  .mo-deal .card:nth-child(5) { animation-delay: 280ms; }
  .mo-deal .card__art .ill3d, .cat-hero .card__art .ill3d, .ficha__card .card__art .ill3d { animation: mo-bob 1600ms ease-in-out 3 both; animation-delay: 900ms; }
  .mo-deal .card:nth-child(2) .card__art .ill3d { animation-delay: 1020ms; }
  .mo-deal .card:nth-child(3) .card__art .ill3d { animation-delay: 1140ms; }
  .mo-deal .card:nth-child(4) .card__art .ill3d { animation-delay: 1260ms; }
  .mo-deal .card:nth-child(5) .card__art .ill3d { animation-delay: 1380ms; }
  .cat-hero .card__art .ill3d, .ficha__card .card__art .ill3d { animation-delay: 500ms; }

  /* =================================================== V8 · pointer tilt on art cards (motion.js, fine pointers, max 4°)
     The tilted box is already in its final place: only a rotate around its centre. */
  .mo-tilt {
    transform: perspective(800px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    transition: transform 520ms var(--ease-spring-v2), background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  }
  .mo-tilt.mo-tilting { transition-duration: 120ms, var(--t-fast), var(--t-fast), var(--t-fast); transition-timing-function: var(--ease-out); }
  .ficha__card .card.mo-tilt { transition: transform 620ms var(--ease-spring-v2); }
  /* V9 · guide rows: the art zooms inside its clipped thumbnail (design review D8: no tilt, no sweep) */
  .guide__thumb { overflow: hidden; }
  .guide__thumb img { transition: transform 600ms var(--ease-expo); }
  @media (hover: hover) and (pointer: fine) { .guide:hover .guide__thumb img { transform: scale(1.06); } }

  /* =================================================== V10 · staggered reveal v2 (rise + scale + blur to sharp) */
  .mo-hide { opacity: 0; transform: translateY(var(--mo-rise)) scale(.98); filter: blur(6px); }
  .join.mo-hide, .compare-wrap.mo-hide, .fomo__tile.mo-hide { filter: none; }
  .mo-in {
    opacity: 1; transform: none; filter: none;
    transition: opacity var(--mo-in) var(--ease-expo), transform var(--mo-in) var(--ease-expo), filter var(--mo-in) var(--ease-expo);
    transition-delay: calc(var(--mo-i, 0) * var(--mo-stagger));
  }

  /* =================================================== V11 · scroll-driven heads and dividers
     User-driven (scroll), so no timer. Browsers without view() timelines get the V10 reveal (motion.js). */
  @supports (animation-timeline: view()) {
    .section__head > :first-child { animation: mo-head linear both; animation-timeline: view(); animation-range: entry 0% entry 90%; }
    .picado > i { animation: mo-picado-a linear both; animation-timeline: view(); animation-range: cover 0% cover 100%; }
    .picado > i + i { animation-name: mo-picado-b; }
  }

  /* =================================================== M3 · answer figure accent (v1, unchanged: no count-up) */
  .ans__fig small { position: relative; }
  .ans__fig small::before {
    content: ""; position: absolute; left: 0; right: 0; top: -6px; height: 2px; border-radius: 2px;
    background: var(--green); transform-origin: left center; transform: scaleX(0); opacity: 0;
    animation: mo-sweep 1100ms var(--ease-out) 250ms 1 both;
  }

  /* =================================================== V15 · press spring, CTA hover, focus ring */
  .btn, .guide, .qrow, .related a, .rel a, .odds__pick, .intent, .chip, .askchips button, .pager a, .helpful button, .bigq a, .askbox__go {
    transition-property: background, border-color, color, transform, filter;
    transition-duration: var(--t-fast), var(--t-fast), var(--t-fast), 420ms, var(--t-fast);
    transition-timing-function: var(--ease-out), var(--ease-out), var(--ease-out), var(--ease-spring-v2), var(--ease-out);
  }
  .btn:active, .guide:active, .qrow:active, .related a:active, .rel a:active, .odds__pick:active,
  .intent:active, .chip:active, .askchips button:active, .pager a:active, .helpful button:active, .bigq a:active, .askbox__go:active,
  html body a.btn--primary:active, html body .btn--gold:active { transform: scale(.96); transition-duration: var(--t-fast), var(--t-fast), var(--t-fast), 90ms, var(--t-fast); }
  /* rows and cards press less than buttons: same feel at every size (design review D12) */
  .guide:active, .qrow:active, .related a:active, .rel a:active, .bigq a:active { transform: scale(.985); }
  /* no hover lift on green CTAs: the DS has no elevation on hover (design review, V15 not approved) */
  @media (hover: hover) and (pointer: fine) { .askbox__go:hover { transform: translateX(2px); } }
  :focus-visible { animation: mo-focus 280ms var(--ease-expo); }

  /* =================================================== V14 · odds price tick (M5 made obvious) */
  .odds__pick { position: relative; overflow: hidden; }
  .odds__pick::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; }
  .odds__pick b { display: inline-block; }
  .odds__pick.mo-up::before { background: var(--status); animation: mo-flash 900ms var(--ease-out) 1; }
  .odds__pick.mo-down::before { background: var(--red); animation: mo-flash 900ms var(--ease-out) 1; }
  .odds__pick.mo-up b { animation: mo-price-up 560ms var(--ease-expo) 1; }
  .odds__pick.mo-down b { animation: mo-price-down 560ms var(--ease-expo) 1; }

  /* =================================================== V13 · countdown flip cards (≤ 1 change per second)
     Tile look from the first paint (no shift). On a change motion.js sets data-prev/data-next and .mo-flip:
     the old top half folds down, then the new bottom half folds into place. */
  [data-countdown] b { perspective: 300px; }
  [data-countdown] b::before, [data-countdown] b::after {
    position: absolute; inset: 0; padding: inherit; border-radius: inherit; text-align: center;
    background: var(--surface-2); color: inherit; backface-visibility: hidden; pointer-events: none; opacity: 0;
  }
  [data-countdown] b::before { content: attr(data-prev); clip-path: inset(0 0 50% 0); transform-origin: 50% 50%; }
  [data-countdown] b::after { content: attr(data-next); clip-path: inset(50% 0 0 0); transform-origin: 50% 50%; }
  [data-countdown] b.mo-flip::before { animation: mo-flip-top 440ms linear 1 both; }
  [data-countdown] b.mo-flip::after { animation: mo-flip-bottom 440ms linear 1 both; }

  /* =================================================== V12 · ticker fill: items slide in (no highlight on a win: design review D13) */
  .ticker.mo-filled .ticker__item { animation: mo-tick-in 620ms var(--ease-expo) both; }
  .ticker.mo-filled .ticker__item:nth-child(2) { animation-delay: 60ms; }
  .ticker.mo-filled .ticker__item:nth-child(3) { animation-delay: 120ms; }
  .ticker.mo-filled .ticker__item:nth-child(4) { animation-delay: 180ms; }
  .ticker.mo-filled .ticker__item:nth-child(n+5) { animation-delay: 240ms; }

  /* =================================================== V18 · FAQ smooth height, TOC slider, drawer stagger (M9) */
  .faq details[open] > p { animation: mo-rise-in 420ms var(--ease-expo) both; }
  @supports (interpolate-size: allow-keywords) and selector(::details-content) {
    .faq, .toc--inline { interpolate-size: allow-keywords; }
    .faq details::details-content, .toc--inline::details-content {
      height: 0; overflow: clip;
      transition: height 420ms var(--ease-expo), content-visibility 420ms allow-discrete;
    }
    .faq details[open]::details-content, .toc--inline[open]::details-content { height: auto; }
  }
  .faq summary::after, .toc summary::after { display: inline-block; transition: transform 360ms var(--ease-spring-v2); }
  .faq details[open] summary::after { transform: rotate(180deg); }
  .toc, html body .aside .toc { position: relative; }
  .mo-toc-bar {
    position: absolute; left: -1px; top: 0; width: 2px; height: 1px; border-radius: 2px; background: var(--accent); pointer-events: none;
    transform-origin: 0 0; transform: translateY(var(--ty, 0px)) scaleY(var(--th, 0));
    transition: transform 420ms var(--ease-expo), opacity 200ms; opacity: 0;
  }
  .mo-toc-bar.is-on { opacity: 1; }
  .toc a { transition: color var(--t-base) var(--ease-out); }
  .drawer[aria-hidden="false"] .drawer__body > *,
  .drawer[aria-hidden="false"] .drawer__body nav > .intent { animation: mo-rise-in 420ms var(--ease-expo) both; }
  .drawer[aria-hidden="false"] .drawer__body > :nth-child(2) { animation-delay: 50ms; }
  .drawer[aria-hidden="false"] .drawer__body > :nth-child(3) { animation-delay: 100ms; }
  .drawer[aria-hidden="false"] .drawer__body > :nth-child(n+4) { animation-delay: 150ms; }
  .drawer[aria-hidden="false"] .drawer__body nav > .intent:nth-child(2) { animation-delay: 70ms; }
  .drawer[aria-hidden="false"] .drawer__body nav > .intent:nth-child(3) { animation-delay: 110ms; }
  .drawer[aria-hidden="false"] .drawer__body nav > .intent:nth-child(4) { animation-delay: 150ms; }
  .drawer[aria-hidden="false"] .drawer__body nav > .intent:nth-child(n+5) { animation-delay: 190ms; }

  /* --- M8 · ticker: pause control visible, pause on keyboard focus too */
  .ticker__pause { display: grid; }
  .ticker:focus-within .ticker__track { animation-play-state: paused; }

  /* --- M10 · skeleton */
  .ticker__track:empty::before {
    content: ""; display: block; width: min(60vw, 520px); height: 1.6em; border-radius: 4px;
    background: var(--surface-2); animation: mo-skel 1.2s ease-in-out infinite alternate;
  }
  .mo-skel { background: var(--surface-2); border-radius: 4px; animation: mo-skel 1.2s ease-in-out infinite alternate; }
}

@keyframes mo-page-out { to { opacity: 0; transform: translateX(-16px); } }
@keyframes mo-page-out-back { to { opacity: 0; transform: translateX(16px); } }
@keyframes mo-page-in { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes mo-fade { from { opacity: 0; } }
@keyframes mo-fade-out { to { opacity: 0; } }
@keyframes mo-fade-up { from { opacity: 0; transform: translateY(18px); } }
@keyframes mo-rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes mo-word { from { opacity: .25; transform: translateY(.45em); filter: blur(var(--mo-wblur, 10px)); } to { opacity: 1; transform: none; filter: none; } }
@keyframes mo-chip { from { opacity: 0; transform: translateY(12px) scale(.9); } }
@keyframes mo-light-in { from { opacity: 0; scale: .85; } to { opacity: 1; scale: 1; } }
@keyframes mo-light-drift { to { translate: 0 140px; } }
@keyframes mo-caret { 0%, 100% { opacity: 1; } 50% { opacity: .1; } }
@keyframes mo-deal-tile { from { opacity: 0; transform: translateY(24px) scale(.96); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes mo-sheen { from { transform: translateX(-110%); } to { transform: translateX(110%); } }
@keyframes mo-sheen-b { from { transform: translateX(-110%); } to { transform: translateX(110%); } }
@keyframes mo-ping { from { transform: scale(1); opacity: .7; } to { transform: scale(3.4); opacity: 0; } }
@keyframes mo-ping-b { from { transform: scale(1); opacity: .8; } to { transform: scale(3.8); opacity: 0; } }
@keyframes mo-deal-d { from { opacity: 0; transform: translateX(0) translateY(120px) rotate(0deg) scale(.9); } }
@keyframes mo-deal-m { from { opacity: 0; transform: translateY(32px) scale(.95); } }
@keyframes mo-bob { 0%, 100% { transform: translateY(0) rotate(0deg); } 40% { transform: translateY(-7px) rotate(-2deg); } 70% { transform: translateY(-3px) rotate(1.5deg); } }
@keyframes mo-head { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
@keyframes mo-picado-a { from { translate: 0 -3px; } to { translate: 0 3px; } }
@keyframes mo-picado-b { from { translate: 0 3px; } to { translate: 0 -3px; } }
@keyframes mo-sweep { 0% { transform: scaleX(0); opacity: 1; } 55% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
@keyframes mo-focus { from { outline-offset: 8px; outline-color: transparent; } }
@keyframes mo-flash { 0% { opacity: .16; } 100% { opacity: 0; } }
@keyframes mo-price-up { from { opacity: 0; transform: translateY(80%); } to { opacity: 1; transform: none; } }
@keyframes mo-price-down { from { opacity: 0; transform: translateY(-80%); } to { opacity: 1; transform: none; } }
@keyframes mo-flip-top { 0% { opacity: 1; transform: rotateX(0deg); } 50% { opacity: 1; transform: rotateX(-90deg); } 51%, 100% { opacity: 0; transform: rotateX(-90deg); } }
@keyframes mo-flip-bottom { 0%, 49% { opacity: 0; transform: rotateX(90deg); } 50% { opacity: 1; transform: rotateX(90deg); } 99% { opacity: 1; transform: rotateX(0deg); } 100% { opacity: 0; transform: rotateX(0deg); } }
@keyframes mo-tick-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes mo-skel { from { opacity: .45; } to { opacity: .9; } }

/* print and reduced motion: never leave anything hidden */
@media print {
  .mo-hide { opacity: 1 !important; transform: none !important; filter: none !important; }
  .mo-board-wait .cell, .mo-deal-wait .card { opacity: 1 !important; }
  .ticker__pause, .mo-toc-bar { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .mo-hide { opacity: 1 !important; transform: none !important; filter: none !important; }
  .mo-board-wait .cell, .mo-deal-wait .card { opacity: 1 !important; }
}
