/* Sibaq motion. Needs tokens.css and components.css.
   Entrance classes (add once, or let motion.js enter() do it). Stagger with style="--i: 3" or the sq-stagger parent.
     sq-in-rise   up and in          sq-in-pop    scale in with a small overshoot
     sq-in-fade   fade only          sq-in-drop   down from above (stage headers, toasts)
     sq-in-sweep  wipe in from the start edge (question text)
   Everything here is switched to a plain short fade when the reader asks for reduced motion. */

@keyframes sq-spin { to { rotate: 1turn; } }
@keyframes sq-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes sq-beat { 0% { scale: 1.22; } 40%, 100% { scale: 1; } }
@keyframes sq-hop { 0%, 60%, 100% { translate: 0 0; opacity: 0.55; } 30% { translate: 0 -0.45em; opacity: 1; } }
@keyframes sq-shimmer { to { background-position: -300% 0; } }

@keyframes sq-rise { from { opacity: 0; translate: 0 calc(18 * var(--g)); } }
@keyframes sq-pop { 0% { opacity: 0; scale: 0.6; } 60% { opacity: 1; } 100% { scale: 1; } }
@keyframes sq-fade { from { opacity: 0; } }
@keyframes sq-drop { from { opacity: 0; translate: 0 calc(-16 * var(--g)); } }
@keyframes sq-sweep { from { opacity: 0; clip-path: inset(0 100% 0 0); filter: blur(calc(6 * var(--g))); } to { clip-path: inset(-20% -5% -20% -5%); filter: blur(0); } }
@keyframes sq-sweep-rtl { from { opacity: 0; clip-path: inset(0 0 0 100%); filter: blur(calc(6 * var(--g))); } to { clip-path: inset(-20% -5% -20% -5%); filter: blur(0); } }
@keyframes sq-out { to { opacity: 0; translate: 0 calc(8 * var(--g)); } }

.sq-in-rise { animation: sq-rise var(--t-slow) var(--ease-out) both; }
.sq-in-pop { animation: sq-pop var(--t-slow) var(--ease-back) both; }
.sq-in-fade { animation: sq-fade var(--t-slow) var(--ease-out) both; }
.sq-in-drop { animation: sq-drop var(--t-slow) var(--ease-out) both; }
.sq-in-sweep { animation: sq-sweep var(--t-slower) var(--ease-out) both; }
[dir="rtl"].sq-in-sweep, [dir="rtl"] .sq-in-sweep { animation-name: sq-sweep-rtl; }
.sq-out { animation: sq-out var(--t-base) var(--ease-in) both; }
.sq-in-rise, .sq-in-pop, .sq-in-fade, .sq-in-drop, .sq-in-sweep { animation-delay: calc(var(--i, 0) * var(--stagger)); }
.sq-stagger > :nth-child(1) { --i: 0; } .sq-stagger > :nth-child(2) { --i: 1; } .sq-stagger > :nth-child(3) { --i: 2; } .sq-stagger > :nth-child(4) { --i: 3; }
.sq-stagger > :nth-child(5) { --i: 4; } .sq-stagger > :nth-child(6) { --i: 5; } .sq-stagger > :nth-child(7) { --i: 6; } .sq-stagger > :nth-child(8) { --i: 7; }
.sq-stagger > :nth-child(n + 9) { --i: 8; }

/* Chips arriving in the lobby, toasts */
.sq-chip.sq-in-pop { animation-duration: 520ms; }
.sq-toast { animation: sq-rise var(--t-slow) var(--ease-out) both; }
[data-context="stage"] .sq-toast, .sq-toasts--top .sq-toast, .sq-conn { animation: sq-drop var(--t-slow) var(--ease-out) both; }
.sq-toast.sq-out { animation: sq-out var(--t-base) var(--ease-in) both; }
.sq-modal[open] { animation: sq-pop var(--t-slow) var(--ease-out) both; }
.sq-modal[open]::backdrop { animation: sq-fade var(--t-slow) var(--ease-out) both; }

/* Countdown 3-2-1: motion.js countdown() builds this inside the element you pass. */
.sq-countdown { position: absolute; z-index: 70; inset: 0; display: grid; place-items: center; background: radial-gradient(60% 60% at 50% 50%, rgb(14 59 107 / 0.98), rgb(6 20 42 / 0.99)); color: var(--cream-100); overflow: hidden; }
.sq-countdown--fixed { position: fixed; }
.sq-countdown__num { grid-area: 1 / 1; font: 700 var(--fs-mega)/1 var(--font-display); font-variant-numeric: lining-nums; font-variation-settings: 'opsz' 144; letter-spacing: -0.04em; animation: sq-count var(--count-step, 900ms) var(--ease-out) both; }
.sq-countdown__num[data-go] { color: var(--gold-300); }
.sq-countdown__ring { grid-area: 1 / 1; inline-size: calc(var(--fs-mega) * 1.7); aspect-ratio: 1; border-radius: 50%; border: var(--ring) solid var(--gold-500); animation: sq-count-ring var(--count-step, 900ms) var(--ease-out) both; }
@keyframes sq-count { 0% { opacity: 0; scale: 1.7; filter: blur(calc(10 * var(--g))); } 28% { opacity: 1; scale: 1; filter: blur(0); } 78% { opacity: 1; scale: 0.96; } 100% { opacity: 0; scale: 0.82; } }
@keyframes sq-count-ring { 0% { opacity: 0.9; scale: 0.5; } 100% { opacity: 0; scale: 1.25; } }

/* Tile lock-in: a quick squash, then the badge pops (badge pop is in components.css). */
.sq-tile.is-selected { animation: sq-lock 460ms var(--ease-out); }
@keyframes sq-lock { 0% { scale: 1; } 28% { scale: 0.94; } 62% { scale: 1.035; } 100% { scale: 1; } }

/* Reveal of the right answer: lift, and one sweep of light across the tile. */
.sq-tile.is-correct { animation: sq-reveal 900ms var(--ease-out) both; overflow: visible; }
@keyframes sq-reveal { 0% { scale: 1; } 30% { scale: 1.06; } 100% { scale: 1.02; } }
.sq-tile.is-correct .sq-tile__text, .sq-tile.is-correct .sq-tile__mark { animation: sq-glint 900ms var(--ease-out) 120ms both; }
@keyframes sq-glint { 0% { opacity: 0.5; } 100% { opacity: 1; } }
.sq-tile__count { animation: sq-pop var(--t-slow) var(--ease-back) both; animation-delay: calc(var(--i, 0) * var(--stagger) + 200ms); }

/* Score and points */
.sq-score-pop { animation: sq-score 620ms var(--ease-back) both; }
@keyframes sq-score { 0% { scale: 0.5; opacity: 0; } 55% { scale: 1.14; opacity: 1; } 100% { scale: 1; } }
.sq-result.is-right .sq-result__badge { animation: sq-pop 620ms var(--ease-back) both; }
.sq-result.is-right .sq-result__badge::after { animation: sq-draw 520ms var(--ease-out) 260ms both; }
@keyframes sq-draw { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 -10% 0 0); } }
.sq-result.is-wrong .sq-result__badge, .sq-result:not(.is-right):not(.is-wrong) .sq-result__badge { animation: sq-fade var(--t-slow) var(--ease-out) both; }

/* Leaderboard: rows that moved get a brief lift while FLIP runs (motion.js flipReorder adds is-moving). */
.sq-row.is-moving { z-index: 2; box-shadow: var(--shadow-3); }
.sq-row.is-moving-up { z-index: 3; }

/* Podium: blocks grow from the floor, third then second then first; names follow. motion.js podiumRise() adds is-risen. */
.sq-podium.is-waiting .sq-podium__block { transform: scaleY(0); }
.sq-podium.is-waiting .sq-podium__name, .sq-podium.is-waiting .sq-podium__score { opacity: 0; }
.sq-podium.is-risen .sq-podium__block { animation: sq-grow 900ms var(--ease-out) both; animation-delay: var(--d); }
.sq-podium.is-risen .sq-podium__name, .sq-podium.is-risen .sq-podium__score { animation: sq-rise 520ms var(--ease-out) both; animation-delay: calc(var(--d) + 620ms); }
.sq-podium__place[data-place="3"] { --d: 0ms; }
.sq-podium__place[data-place="2"] { --d: 900ms; }
.sq-podium__place[data-place="1"] { --d: 1900ms; }
@keyframes sq-grow { 0% { transform: scaleY(0); } 70% { transform: scaleY(1.03); } 100% { transform: scaleY(1); } }

/* Celebration canvas made by motion.js celebrate() */
.sq-celebrate { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; z-index: 60; pointer-events: none; transition: opacity 600ms var(--ease-out); }
.sq-celebrate--fixed { position: fixed; }

/* Reduced motion: no travel, no scale, no loops. State changes still show, as short fades. */
@media (prefers-reduced-motion: reduce) {
    [class*="sq-"], [class*="sq-"]::before, [class*="sq-"]::after { animation-duration: 1ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
    .sq-timer[data-urgent] .sq-timer__num, .sq-loader i, .sq-skel, .sq-pill[data-tone="live"]::before { animation: none !important; }
    .sq-loader i { opacity: 0.8; }
    .sq-countdown__num { animation: sq-fade 200ms linear both !important; }
    .sq-countdown__ring { display: none; }
    .sq-btn.is-loading::after { animation: sq-spin 1.4s linear infinite !important; }
    .sq-podium.is-risen .sq-podium__block { animation: none !important; transform: none; }
    .sq-celebrate { transition-duration: 300ms !important; }
}
