/* Home page motion (2.2). Everything is gated on html.motion, which motion.js sets
   only when reduced motion is off, so with no script or reduced motion the page is
   the static site. transform and opacity only, plus clip-path and filter on a few
   one-shot entrances. */
:root {
  --glow: color-mix(in oklab, var(--color-accent) 45%, transparent);
  --glow-soft: color-mix(in oklab, var(--color-accent) 18%, transparent);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Scroll progress: a thin yellow bar under the nav ── */
.motion .scroll-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: calc(var(--z-sticky-nav) + 1);
  background: var(--color-accent); transform-origin: 0 50%; transform: scaleX(var(--p, 0));
  box-shadow: 0 0 12px var(--glow);
}

/* ── Nav: tightens once you scroll ── */
.motion .site-nav { transition: background-color var(--dur-short) var(--ease-out); }
.motion .site-nav .nav-row { transition: min-height var(--dur-short) var(--ease-out); }
.motion.scrolled .site-nav { background: color-mix(in oklab, var(--color-paper-3) 92%, transparent); }
.motion .brand .cart-logo { transition: transform var(--dur-long) var(--ease-spring); }
.motion .brand:hover .cart-logo { transform: rotate(-12deg) scale(1.12); }

/* ── Hero: headline words rise in, then the TV powers on like a CRT ── */
.motion .hero h1 .w { display: inline-block; opacity: 0; transform: translateY(0.6em) rotate(2deg); filter: blur(6px); }
.motion.ready .hero h1 .w {
  opacity: 1; transform: none; filter: none;
  transition: opacity 600ms var(--ease-out), transform 800ms var(--ease-spring), filter 600ms var(--ease-out);
  transition-delay: calc(var(--i) * 70ms + 150ms);
}
.motion .hero .lead, .motion .hero-actions { opacity: 0; transform: translateY(16px); }
.motion.ready .hero .lead, .motion.ready .hero-actions {
  opacity: 1; transform: none; transition: opacity 700ms var(--ease-out), transform 700ms var(--ease-out);
}
.motion.ready .hero .lead { transition-delay: 650ms; }
.motion.ready .hero-actions { transition-delay: 800ms; }

/* CRT power-on: a bright line opens to the full picture */
.motion .hero-screen { transform: scaleY(0.006) scaleX(0.6); filter: brightness(3); opacity: 0.9; }
.motion.ready .hero-screen { animation: crt-on 900ms var(--ease-out) 350ms forwards; }
@keyframes crt-on {
  0%   { transform: scaleY(0.006) scaleX(0.6); filter: brightness(3); }
  35%  { transform: scaleY(0.006) scaleX(1);   filter: brightness(3); }
  60%  { transform: scaleY(1.04)  scaleX(1);   filter: brightness(1.6); }
  80%  { transform: scaleY(0.99)  scaleX(1);   filter: brightness(1.1); }
  100% { transform: none; filter: none; opacity: 1; }
}
/* The phone pad drops in after the TV is on, then floats */
.motion .hero-pad { opacity: 0; transform: translate3d(30px, 40px, 0) rotate(6deg); }
.motion.ready .hero-pad { animation: pad-in 900ms var(--ease-spring) 1150ms forwards, pad-float 6s ease-in-out 2100ms infinite; }
@keyframes pad-in { to { opacity: 1; transform: translate3d(0, 0, 0) rotate(-2deg); } }
@keyframes pad-float {
  0%, 100% { opacity: 1; transform: translate3d(0, 0, 0) rotate(-2deg); }
  50%      { opacity: 1; transform: translate3d(0, -10px, 0) rotate(-1deg); }
}
/* A soft scanline sweep rolls down the TV every few seconds */
.motion .hero-screen::after {
  content: ""; position: absolute; inset: -20% 0 auto; height: 22%; z-index: 2; pointer-events: none;
  background: linear-gradient(180deg, transparent, color-mix(in oklab, var(--color-ink) 9%, transparent), transparent);
  transform: translateY(-100%);
  animation: sweep 5.5s linear 2.2s infinite;
}
@keyframes sweep { 0% { transform: translateY(-100%); } 55%, 100% { transform: translateY(620%); } }
/* Glow behind the TV that breathes */
.motion .hero-media::before {
  content: ""; position: absolute; inset: 8% 6%; z-index: -1; border-radius: 40px;
  background: radial-gradient(closest-side, var(--glow-soft), transparent);
  filter: blur(30px); opacity: 0;
}
.motion.ready .hero-media::before { animation: breathe 7s ease-in-out 1.4s infinite; }
@keyframes breathe { 0%, 100% { opacity: 0.55; transform: scale(1); } 50% { opacity: 1; transform: scale(1.06); } }
/* Pointer tilt: the TV and the pad sit on different planes */
.motion .hero-media { transform-style: preserve-3d; perspective: 1200px; }
.motion .hero-tilt { transform: rotateX(var(--ry, 0deg)) rotateY(var(--rx, 0deg)); transition: transform 500ms var(--ease-out); transform-style: preserve-3d; }
.motion .hero-pad-wrap { position: absolute; inset: 0; pointer-events: none; transform: translate3d(var(--px, 0), var(--py, 0), 60px); transition: transform 500ms var(--ease-out); }
.motion .hero-pad-wrap .hero-pad { pointer-events: auto; }

/* ── Buttons: the App Store button shines, everything lifts ── */
.motion .app-store-badge { position: relative; overflow: hidden; transition: background-color var(--dur-micro) var(--ease-out), transform var(--dur-short) var(--ease-spring), box-shadow var(--dur-short) var(--ease-out); }
.motion .app-store-badge::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, color-mix(in oklab, var(--color-ink) 70%, transparent) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: shine 4.5s var(--ease-in-out) 2.4s infinite;
}
@keyframes shine { 0% { transform: translateX(-120%); } 30%, 100% { transform: translateX(120%); } }
.motion .app-store-badge:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 10px 30px var(--glow); }
.motion .btn-quiet:hover { transform: translateY(-2px); }
.motion .btn-quiet .play-glyph { transition: transform var(--dur-short) var(--ease-spring); }
.motion .btn-quiet:hover .play-glyph { transform: scale(1.35); }

/* ── Chapters: picture wipes open, slow push-in, copy follows ── */
.motion .chapter-pic { position: relative; transform: translate3d(0, var(--par, 0), 0); }
.motion .chapter-pic .pic-clip { overflow: hidden; border-radius: var(--radius-card); clip-path: inset(0 100% 0 0 round var(--radius-card)); transition: clip-path 1100ms var(--ease-in-out), box-shadow var(--dur-long) var(--ease-out), transform var(--dur-long) var(--ease-out); }
.motion .chapter.flip .chapter-pic .pic-clip { clip-path: inset(0 0 0 100% round var(--radius-card)); }
.motion .chapter.in .chapter-pic .pic-clip { clip-path: inset(0 0 0 0 round var(--radius-card)); }
.motion .chapter-pic img { transform: scale(1.18); transition: transform 1600ms var(--ease-out); }
.motion .chapter.in .chapter-pic img { transform: scale(1.04); animation: kenburns 18s ease-in-out 1.6s infinite alternate; }
@keyframes kenburns { from { transform: scale(1.04) translate(0, 0); } to { transform: scale(1.12) translate(-2%, -1.5%); } }
.motion .chapter-pic:hover .pic-clip { transform: translateY(-6px); box-shadow: 0 24px 60px -20px var(--glow); }
/* A light sweep crosses the picture as it lands */
.motion .chapter-pic .pic-clip::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, color-mix(in oklab, var(--color-ink) 22%, transparent) 50%, transparent 70%);
  transform: translateX(-130%);
}
.motion .chapter.in .chapter-pic .pic-clip::after { animation: glint 1400ms var(--ease-in-out) 700ms 1 forwards; }
@keyframes glint { to { transform: translateX(130%); } }

/* Copy: the numeral types in, the head rises, the line and links follow */
.motion .chapter .ch-numeral { opacity: 0; }
.motion .chapter.in .ch-numeral { opacity: 1; animation: blink-in 600ms steps(1) 200ms 1 both; }
@keyframes blink-in { 0% { opacity: 0; } 20% { opacity: 1; } 40% { opacity: 0; } 60%, 100% { opacity: 1; } }
.motion .chapter h2, .motion .chapter .chapter-body, .motion .chapter .chapter-link { opacity: 0; transform: translateY(28px); }
.motion .chapter.in h2, .motion .chapter.in .chapter-body, .motion .chapter.in .chapter-link {
  opacity: 1; transform: none; transition: opacity 700ms var(--ease-out), transform 900ms var(--ease-spring);
}
.motion .chapter.in h2 { transition-delay: 300ms; }
.motion .chapter.in .chapter-body { transition-delay: 450ms; }
.motion .chapter.in .chapter-link { transition-delay: calc(600ms + var(--i, 0) * 80ms); }
.motion .chapter-link { position: relative; transition: color var(--dur-micro) var(--ease-out); }
.motion .chapter-link:hover { transform: translateX(4px); }

/* Chapter 2: the phone layer floats over the TV layer and moves faster */
.motion .ch-phone {
  position: absolute; width: 40%; left: -6%; bottom: -8%; z-index: 3;
  border-radius: 8px; border: var(--rule-hair) solid var(--color-rule);
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.6);
  transform: translate3d(0, var(--par2, 0), 0) rotate(-4deg); opacity: 0;
  transition: opacity 600ms var(--ease-out) 900ms;
}
.motion .chapter.in .ch-phone { opacity: 1; }

/* Chapter 3: a "Player 2 joined" toast pops in over the picture */
.motion .ch-toast {
  position: absolute; right: 6%; top: 8%; z-index: 3;
  display: flex; align-items: center; gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md); border-radius: var(--radius-pill);
  background: var(--color-accent); color: var(--color-accent-ink);
  font-family: var(--font-outlier); font-size: var(--text-xs); line-height: 1;
  box-shadow: 0 10px 30px var(--glow);
  opacity: 0; transform: translateY(-12px) scale(0.8);
}
.motion .chapter.in .ch-toast { animation: toast 4s var(--ease-spring) 1300ms infinite; }
@keyframes toast {
  0%   { opacity: 0; transform: translateY(-12px) scale(0.8); }
  10%  { opacity: 1; transform: none; }
  80%  { opacity: 1; transform: none; }
  92%, 100% { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ── CRT section: the frame flickers on when it arrives ── */
.motion .crt-stage { opacity: 0; transform: translateY(30px) scale(0.98); }
.motion .crt-section.in .crt-stage { animation: flicker-on 900ms linear 150ms forwards; }
@keyframes flicker-on {
  0% { opacity: 0; transform: translateY(30px) scale(0.98); }
  10% { opacity: 0.8; } 14% { opacity: 0.1; } 22% { opacity: 0.9; } 26% { opacity: 0.3; }
  40% { opacity: 1; transform: translateY(6px) scale(0.995); }
  100% { opacity: 1; transform: none; }
}
.motion .crt-handle::after { animation: handle-pulse 2.4s ease-in-out infinite; }
@keyframes handle-pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--glow); } 50% { box-shadow: 0 0 0 12px transparent; } }

/* ── Generic reveal for section heads, features and showcases ── */
.motion .rv { opacity: 0; transform: translateY(32px); }
.motion .rv.in { opacity: 1; transform: none; transition: opacity 800ms var(--ease-out), transform 900ms var(--ease-spring); transition-delay: calc(var(--i, 0) * 90ms); }
.motion .feature { transition: border-color var(--dur-short) var(--ease-out); }
.motion .feature:hover { border-color: var(--color-accent); }
.motion .feature dt { transition: color var(--dur-short) var(--ease-out), transform var(--dur-short) var(--ease-spring); }
.motion .feature:hover dt { color: var(--color-accent); transform: translateX(4px); }
.motion .screenshot-frame { transition: transform var(--dur-long) var(--ease-out), box-shadow var(--dur-long) var(--ease-out); }
.motion .screenshot-frame:hover { transform: translateY(-6px); box-shadow: 0 24px 50px -20px var(--glow); }
.motion .car-shots .car-pane { transform: translateY(10px) scale(0.985); transition: opacity var(--dur-long) var(--ease-out), transform var(--dur-long) var(--ease-out); }
.motion .car-shots .car-pane.on { transform: none; }

/* ── Download: the cart floats, the coin glints ── */
.motion .cta-cart { animation: cart-float 5s ease-in-out infinite; filter: drop-shadow(0 18px 30px var(--glow-soft)); }
@keyframes cart-float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-14px) rotate(2deg); } }
.motion .requirements > div { transition: border-color var(--dur-short) var(--ease-out); }
.motion .requirements > div:hover { border-color: var(--color-accent); }


@media (prefers-reduced-motion: reduce) { .motion .scroll-bar { display: none; } }
.motion .hero-tilt { position: relative; }
.motion .chapter-pic .pic-clip { position: relative; }
.motion .chapter-pic .pic-clip video.ch-loop { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; transform: scale(1.18); transition: transform 1600ms var(--ease-out); }
.motion .chapter.in .chapter-pic video.ch-loop { transform: scale(1.02); }
@media (max-width: 60rem) { .motion .ch-phone { left: 2%; bottom: -10%; width: 46%; } }
