/* HeatCaller site motion. Loaded after site.css, on the landing page only.

   WHY (21 Nov 2026, Asher: "a more flashy website with animations on the landing page
   and when you scroll"): the page had one pulsing dot and nothing else moved.
   Plan: plans/website-motion-plan.md in the HeatCaller repo. This file is Phase 0
   (foundations) and Phase 1 (the hero goes on air).

   Rules this file keeps:
   1. Nothing is hidden waiting for motion.js. Every hidden starting state here is a CSS
      animation with a "backwards" fill, so it shows itself even if the script never loads.
      The only classes that hide things (.rv, .cw) are put there by motion.js itself.
   2. Only transform, opacity and filter move.
   3. Everything that moves sits inside (prefers-reduced-motion: no-preference).
   4. Cursor effects are for a mouse only. */

:root {
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
  --t-fast: .2s;
  --t-mid: .5s;
  --t-slow: .8s;
  --stagger: 70ms;
}

/* ---- film grain: stops the big dark gradients looking flat ----
   WHY a file and .grain (21 Nov 2026, Phase 5 checks): the grain used to be noise worked
   out by the browser (an SVG feTurbulence filter). Working it out took about half a second
   on the main thread and alone took Lighthouse's phone score from about 94 to 63. It is
   now a small ready-made picture (made by the script in the commit that added it), and
   motion.js adds .grain to <html> after the page has loaded so it never holds up the first
   picture. */
.grain body::after {
  content: ""; position: fixed; inset: 0; z-index: 90; pointer-events: none;
  background: url("/grain.png?v=1") 0 0 / 96px 96px;
  opacity: .07;
}
@media print { .grain body::after { display: none; } }

/* ---- hero: the start lights beside the Beta pill ---- */
.hero-top { display: flex; align-items: center; gap: 14px; margin: 0 0 26px; }
.hero-top .onair { margin: 0; flex: none; white-space: nowrap; }
.lights { display: inline-flex; gap: 7px; flex: none; }
.lights i {
  position: relative; width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255,255,255,.05); box-shadow: inset 0 0 0 1px var(--hair-2);
}
/* WHY a layer (21 Nov 2026, Phase 5 checks): the lights first changed their own colour and
   glow, which the browser has to repaint on its main thread. That one animation took
   Lighthouse's phone score from about 90 to 65. The lit look now sits in ::after and only
   its opacity changes. */
.lights i::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; opacity: 0;
  background: var(--magenta); box-shadow: 0 0 14px var(--magenta), inset 0 0 3px rgba(255,255,255,.7);
}
@media (max-width: 359px) { .lights { display: none; } }

h1 .hw { display: inline-block; }

/* ---- hero: the level meter beside "On air" ---- */
.meter { display: inline-flex; align-items: center; gap: 2px; height: 14px; margin-right: 4px; }
.meter i {
  width: 3px; height: 100%; border-radius: 1px; background: var(--magenta);
  transform: scaleY(.18); opacity: .55;
}

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

  /* ---- the hero goes on air: lights, headline, the rest, then the card ---- */
  .js .hero-top .onair { animation: hc-rise .6s var(--ease-out) 0s backwards; }

  /* Five lights come on one at a time, then all go out together at 0.95 s. Each light's
     animation simply IS "lit": it starts later and runs shorter the further right it is. */
  .js .lights i::after { animation: hc-lit linear; }
  .js .lights i:nth-child(1)::after { animation-delay: .15s; animation-duration: .80s; }
  .js .lights i:nth-child(2)::after { animation-delay: .27s; animation-duration: .68s; }
  .js .lights i:nth-child(3)::after { animation-delay: .39s; animation-duration: .56s; }
  .js .lights i:nth-child(4)::after { animation-delay: .51s; animation-duration: .44s; }
  .js .lights i:nth-child(5)::after { animation-delay: .63s; animation-duration: .32s; }
  @keyframes hc-lit { from, to { opacity: 1; } }

  .js h1 .hw { animation: hc-word .7s var(--ease-out) calc(.8s + var(--i, 0) * var(--stagger)) backwards; }
  @keyframes hc-word {
    from { opacity: .01; transform: translateY(.45em); filter: blur(8px); }
  }

  /* "produced like a broadcast." arrives out of a blur and flares bright as it lands.
     WHY (21 Nov 2026, Phase 5 checks): it used to have a band of light slide across the
     letters by moving a background, which is repainted every frame. Brightness is a filter,
     so the browser can do it without repainting. */
  .js h1 em { animation: hc-em 1.5s var(--ease-out) 1.1s backwards; }
  @keyframes hc-em {
    0%   { opacity: .01; filter: blur(12px) brightness(1) drop-shadow(0 0 28px rgba(255,46,136,0)); }
    45%  { opacity: 1;   filter: blur(0) brightness(1.7) drop-shadow(0 0 28px rgba(255,46,136,.6)); }
    100% { opacity: 1;   filter: blur(0) brightness(1) drop-shadow(0 0 28px rgba(255,46,136,.35)); }
  }

  .js .hero .lede { animation: hc-rise .7s var(--ease-out) 1.15s backwards; }
  .js .hero .lede + .lede { animation-delay: 1.25s; }
  .js .hero .actions { animation: hc-rise .7s var(--ease-out) 1.35s backwards; }
  .js .hero .chips { animation: hc-rise .7s var(--ease-out) 1.5s backwards; }
  /* WHY .01 and not 0 (21 Nov 2026, Phase 5 checks): a browser does not count text that
     starts fully invisible as painted, so the headline and the paragraphs under it were
     reported as arriving seconds late. At 1% they look the same and are counted when they
     are first drawn. The same goes for hc-word and hc-em above. */
  @keyframes hc-rise { from { opacity: .01; transform: translateY(16px); } }

  .js .rundown-card { animation: hc-card 1s var(--ease-out) .55s backwards; }
  @keyframes hc-card { from { opacity: 0; transform: translateY(30px) scale(.97); } }

  /* The On air lamp flickers on, like a tube warming up. */
  .js .rc-head .band { animation: hc-lamp .7s linear 1.3s backwards; }
  @keyframes hc-lamp {
    0% { opacity: .25; } 30% { opacity: 1; } 42% { opacity: .4; } 55% { opacity: 1; } 68% { opacity: .7; } 100% { opacity: 1; }
  }

  /* ---- the card reads itself out (motion.js adds .live, .cw and the rest) ---- */
  .rundown-card.live .cw { opacity: 0; }
  .rundown-card.live .cw.said { opacity: 1; transition: opacity .22s ease; }
  .rundown-card.live .rc-row .who { transition: opacity .3s ease; }
  .rundown-card.live .rc-row:not(.on):not(.said) .who { opacity: .45; }
  .rundown-card.live .rc-row .note { opacity: 0; transition: opacity .6s ease; }
  .rundown-card.live .rc-row.said .note { opacity: 1; }
  .rundown-card.live.wipe .cw.said,
  .rundown-card.live.wipe .rc-row.said .note { opacity: 0; transition: opacity .4s ease; }

  .rundown-card.speaking .meter i { opacity: 1; animation: hc-vu .5s ease-in-out infinite alternate; }
  .rundown-card.speaking .meter i:nth-child(1) { animation-duration: .43s; }
  .rundown-card.speaking .meter i:nth-child(2) { animation-duration: .31s; animation-delay: -.2s; }
  .rundown-card.speaking .meter i:nth-child(3) { animation-duration: .52s; animation-delay: -.1s; }
  .rundown-card.speaking .meter i:nth-child(4) { animation-duration: .37s; animation-delay: -.3s; }
  .rundown-card.speaking .meter i:nth-child(5) { animation-duration: .47s; animation-delay: -.15s; }
  @keyframes hc-vu { from { transform: scaleY(.2); } to { transform: scaleY(1); } }

  /* ---- the horizon grid drifts toward you ----
     The lines move to a ::before that slides by exactly one row (58 px) and repeats, so
     it is a transform on its own layer and nothing is repainted. */
  .horizon .floor { background-image: none; }
  .horizon .floor::before {
    content: ""; position: absolute; inset: -58px 0 0 0;
    background-image:
      repeating-linear-gradient(to right, rgba(255,46,136,.26) 0 1px, transparent 1px 90px),
      repeating-linear-gradient(to bottom, rgba(43,228,240,.16) 0 1px, transparent 1px 58px);
    animation: hc-drift 2.8s linear infinite;
  }
  @keyframes hc-drift { to { transform: translateY(58px); } }
  .stage.offstage .floor::before,
  .stage.offstage .dot,
  .stage.offstage .meter i { animation-play-state: paused; }

  /* ---- sections arrive as you reach them (motion.js adds .rv, then .in) ---- */
  .rv { opacity: 0; transform: translateY(22px); }
  h2.rv { filter: blur(6px); }
  .rv.in {
    opacity: 1; transform: none; filter: none;
    transition: opacity var(--t-slow) var(--ease-out) var(--d, 0ms), transform var(--t-slow) var(--ease-out) var(--d, 0ms), filter var(--t-slow) var(--ease-out) var(--d, 0ms);
  }
}

/* ---- mouse only: the glow leans toward the pointer and the card tilts a little ---- */
@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  .horizon .sun {
    transform: translate(calc(-50% + var(--mx, 0px)), var(--my, 0px));
    transition: transform .9s var(--ease-out);
  }
  .rundown-card {
    transform: perspective(1100px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    transition: transform .6s var(--ease-out);
  }
}

@media print { .rv { opacity: 1; transform: none; filter: none; } .rundown-card.live .cw, .rundown-card.live .rc-row .note { opacity: 1; } }

/* ---- one race, played by scrolling (Phase 2, 21 Nov 2026) ----
   WHY: the run of show was four still cards. On a wide screen the block now holds still
   while you scroll and a playhead runs the race: each call lights as it is reached and
   the panel underneath says who is on the mic and what the room hears. On phones, and
   any screen too short to hold the block, nothing is held: each card's calls light in
   turn as the card comes into view.
   motion.js puts .pinned or .lit on .race. Without it this is the four cards as before. */
.race { margin-top: 52px; }
.race .flow-title { margin-top: 0; }
.race-rail, .race-now { display: none; }

.race.pinned .race-pin { position: sticky; top: var(--pin-top, 84px); }
.race.pinned .race-rail { display: block; position: relative; height: 14px; margin: 0 0 14px; }
.race-rail::before, .race-rail .fill { content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 2px; border-radius: 2px; }
.race-rail::before { background: var(--hair-2); }
.race-rail .fill {
  transform-origin: left center; transform: scaleX(0);
  background: linear-gradient(90deg, var(--magenta), var(--cyan)); box-shadow: 0 0 12px rgba(255,46,136,.6);
}
.race-rail .head {
  position: absolute; left: -6px; top: 1px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 3px rgba(43,228,240,.3), 0 0 16px var(--cyan);
}

.race.pinned .step { overflow: hidden; opacity: .6; transition: opacity .4s ease; }
.race.pinned .step.reached { opacity: 1; }
.race.pinned .step.cur { box-shadow: 0 0 0 1px rgba(255,46,136,.55), 0 26px 60px -30px rgba(255,46,136,.65); }
.race.pinned .step.cur > span { color: var(--magenta); }
.race.pinned .step li, .race.lit .step li { opacity: .4; transition: opacity .35s ease; }
.race.pinned .step li.done, .race.lit .step li.done { opacity: .92; }
.race.pinned .step li.now { opacity: 1; color: var(--ink); }
.race.pinned .step li.now::before { background: var(--magenta); box-shadow: 0 0 10px var(--magenta); }

/* The checkered flag passes over "The flag" card as the race reaches it. */
.race.pinned .step.wave::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-conic-gradient(rgba(255,255,255,.17) 0 25%, transparent 0 50%) 0 0 / 18px 18px;
  -webkit-mask-image: linear-gradient(100deg, transparent 20%, #000 45%, #000 55%, transparent 80%);
  mask-image: linear-gradient(100deg, transparent 20%, #000 45%, #000 55%, transparent 80%);
  animation: hc-flag 1.1s var(--ease-soft) both;
}
@keyframes hc-flag { from { transform: translateX(-100%); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

.race.pinned .race-now {
  display: grid; grid-template-columns: 170px 1fr auto; gap: 8px 24px; align-items: start;
  height: 98px; margin-top: 14px; padding: 14px 22px; overflow: hidden;
  border-radius: var(--radius); box-shadow: 0 0 0 1px var(--hair);
  background: linear-gradient(90deg, rgba(255,46,136,.10), rgba(255,255,255,.02) 60%), var(--night-2);
}
.race-now .who { display: inline-flex; align-items: center; gap: 6px; padding-top: 3px; font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--cyan); }
.race-now .what { min-width: 0; }
.race-now .what b { display: block; font-weight: 600; font-size: 17px; color: var(--ink); }
.race-now .what p { margin: 2px 0 0; max-width: 92ch; color: var(--muted); font-size: 15px; line-height: 1.45; }
.race-now .count { padding-top: 4px; font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); white-space: nowrap; }
.race-now.in .what, .race-now.in .mic { animation: hc-rise .4s var(--ease-out) both; }
.race-now.talk .meter i { opacity: 1; animation: hc-vu .45s ease-in-out infinite alternate; }
.race-now.talk .meter i:nth-child(2) { animation-duration: .31s; animation-delay: -.2s; }
.race-now.talk .meter i:nth-child(3) { animation-duration: .52s; animation-delay: -.1s; }
.race-now.talk .meter i:nth-child(4) { animation-duration: .37s; animation-delay: -.3s; }


/* ---- Phase 3 (21 Nov 2026): the long middle of the page ---- */

/* The call ticker under the hero: calls the announcer makes, drifting past. motion.js
   moves it, faster and leaning a little when you scroll fast. Without the script it is
   one still line. */
.ticker {
  contain: layout paint style; overflow: hidden; padding: 13px 0; position: relative; z-index: 1;
  border-block: 1px solid var(--hair); background: rgba(255,255,255,.02);
}
.ticker-run { display: flex; width: max-content; white-space: nowrap; padding-left: 24px; }
.tk { display: inline-flex; align-items: baseline; font-family: var(--font-display); font-weight: 600; font-size: 21px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink); }
.tk i { font: 500 11px var(--font-mono); letter-spacing: .14em; color: var(--magenta); margin-right: 12px; }
.tk::after { content: ""; width: 6px; height: 6px; margin: 0 26px; align-self: center; transform: rotate(45deg); background: var(--cyan); opacity: .8; }

/* Scroll progress: a hairline under the header that fills as the page is read, and (from
   motion.js, wide screens only) which "lap" of the page you are on. */
.masthead::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; pointer-events: none;
  transform-origin: left center; transform: scaleX(var(--pp, 0));
  background: linear-gradient(90deg, var(--magenta), var(--cyan)); opacity: .9;
}
.lapcount {
  display: none; margin: 2px auto 0 4px; white-space: nowrap;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
  opacity: 0; transition: opacity .3s ease;
}
.lapcount b { color: var(--cyan); font-weight: 500; }
.lapcount.show { opacity: 1; }
@media (min-width: 1100px) { .lapcount { display: inline-block; } }

.tick { display: none; }
[data-count] { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: no-preference) {
  /* The browser fills the hairline itself where it can; motion.js sets --pp where it cannot. */
  @supports (animation-timeline: scroll()) {
    .masthead::after { animation: hc-lapbar linear both; animation-timeline: scroll(root block); }
  }
  @keyframes hc-lapbar { from { transform: scaleX(0); } to { transform: scaleX(1); } }

  /* "every two seconds": a small light that blinks once every two seconds, while on screen. */
  .tick {
    display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; vertical-align: middle;
    background: var(--live); opacity: .35;
  }
  .tick.live-on { animation: hc-tick 2s linear infinite; }
  @keyframes hc-tick {
    0% { opacity: 1; transform: scale(1.6); }
    18% { opacity: .35; transform: scale(1); }
    100% { opacity: .35; transform: scale(1); }
  }

  /* Headaches, before and after: the headache shows first, then it is struck through and
     the answer arrives. motion.js adds .hx to rows still below the screen, then .fx. */
  .fixes li.hx .ans { display: block; opacity: 0; transform: translateX(-14px); }
  .fixes li.hx .ouch { color: var(--ink); text-decoration: line-through; text-decoration-color: transparent; }
  .fixes li.hx.fx .ouch { color: var(--dim); text-decoration-color: rgba(255,46,136,.6); }
  .fixes-drivers li.hx.fx .ouch { text-decoration-color: rgba(43,228,240,.55); }
  .fixes li.hx.fx .ans {
    opacity: 1; transform: none;
    transition: opacity .5s var(--ease-out) calc(var(--d, 0ms) + 180ms), transform .5s var(--ease-out) calc(var(--d, 0ms) + 180ms);
  }
}

/* ---- Phase 4 (21 Nov 2026): the live phone, cursor polish, the flag finish ---- */

/* Live timing that is live. motion.js lays a small scripted race over the Live timing
   screenshot: the same eight drivers, drawn in HTML to the screenshot's own measurements
   (it is 601 px wide, so --u is one of its pixels at whatever size the phone is shown).
   The overlay starts as an exact copy of the picture underneath, so it appears and
   resets without a jump. */
.phone-frame.has-sim { position: relative; }
.sim {
  position: absolute; inset: 8px; border-radius: 27px; overflow: hidden; pointer-events: none;
  container-type: inline-size; --u: calc(100cqw / 601);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #F6F1FF;
  opacity: 0; transition: opacity .45s ease;
}
.sim.on { opacity: 1; }
.sim > div { position: absolute; background: #1a0f3a; }
.sim-lap {
  left: calc(330 * var(--u)); top: calc(334 * var(--u)); width: calc(232 * var(--u)); height: calc(64 * var(--u));
  padding-right: calc(11 * var(--u)); text-align: right; white-space: nowrap;
  font: 700 calc(47 * var(--u)) / calc(64 * var(--u)) "Arial Narrow", "Barlow Condensed", sans-serif; color: #A593D6;
}
.sim-lap b { color: #F6F1FF; font-weight: 700; }
.sim-pills { left: calc(45 * var(--u)); top: calc(408 * var(--u)); width: calc(462 * var(--u)); height: calc(44 * var(--u)); }
.sim-pills i {
  position: absolute; top: calc(10 * var(--u)); left: calc((6 + var(--n) * 37.7) * var(--u));
  width: calc(32 * var(--u)); height: calc(22 * var(--u)); border-radius: calc(6 * var(--u));
  background: #33215b;
}
.sim-pills i.on { background: #41d58a; }
.sim-pills i.last { box-shadow: 0 0 calc(14 * var(--u)) #41d58a; }
.sim-togo {
  left: calc(45 * var(--u)); top: calc(464 * var(--u)); width: calc(515 * var(--u)); height: calc(42 * var(--u));
  padding-left: calc(6 * var(--u)); white-space: nowrap;
  font-size: calc(21 * var(--u)); line-height: calc(42 * var(--u)); color: #A99BD0;
}
.sim-togo b { color: #F6F1FF; font-weight: 700; }
.sim > .sim-rows {
  left: calc(26 * var(--u)); top: calc(643 * var(--u)); width: calc(549 * var(--u)); height: calc(450 * var(--u));
  background: repeating-linear-gradient(to bottom, #150b2e 0 calc(56.25 * var(--u)), #1a0f3a calc(56.25 * var(--u)) calc(112.5 * var(--u)));
}
.sim-row {
  position: absolute; left: 0; right: 0; top: 0; height: calc(56.25 * var(--u));
  font-size: calc(20 * var(--u)); line-height: calc(56.25 * var(--u)); white-space: nowrap;
  transform: translateY(calc(var(--r) * 56.25 * var(--u))); transition: transform .7s cubic-bezier(.16, 1, .3, 1);
}
.sim-row span { position: absolute; top: 0; }
.sim-row .p { left: calc(19 * var(--u)); color: #A99BD0; }
.sim-row.lead .p { color: #FF2E88; font-weight: 700; }
.sim-row .n { left: calc(79 * var(--u)); }
.sim-row .l { right: calc(148 * var(--u)); }
.sim-row .g { right: calc(22 * var(--u)); }
.sim-row.fresh .l, .sim-row.fresh .g { color: #2BE4F0; }
.sim-row.gained .p { color: #41d58a; }

/* The finish: a checkered flag passes over the last "Join the beta" block as it arrives. */
@media (prefers-reduced-motion: no-preference) {
  .beta-band.flagged::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: repeating-conic-gradient(rgba(255,255,255,.13) 0 25%, transparent 0 50%) 0 0 / 28px 28px;
    -webkit-mask-image: linear-gradient(100deg, transparent 15%, #000 42%, #000 58%, transparent 85%);
    mask-image: linear-gradient(100deg, transparent 15%, #000 42%, #000 58%, transparent 85%);
    animation: hc-flag 1.5s var(--ease-soft) .15s both;
  }
}

/* Mouse only: cards pick up a soft glow where the pointer is. The four card kinds here all
   share one background in site.css (--surface over --night-2); this puts the glow on top. */
@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  .step, .lane, .switch li, .faq details {
    background-image: radial-gradient(360px circle at var(--gx, -600px) var(--gy, -600px), rgba(139,92,246,.17), transparent 68%), var(--surface);
    background-color: var(--night-2);
  }
  .hero .actions .btn { transition: transform .25s var(--ease-out), box-shadow .15s ease, background .15s ease, border-color .15s ease; }
}
