/* Loaded only with prefers-reduced-motion: no-preference (see the <link media>).
   Scroll-linked motion runs on the scroll position, not on a clock: it moves only while the page moves,
   so a page at rest costs nothing. Only transform and opacity are animated, which the compositor
   handles off the main thread. Browsers without scroll timelines keep the still page from site.css. */

@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .32s; }
.grid { view-transition-name: pellar-grid; }

/* The hero lines rise out of a slot once, on load, and stop. */
@keyframes rise { from { transform: translateY(105%); } }
.hero h1 span { overflow: clip; padding-bottom: .06em; margin-bottom: -.06em; }
.hero h1 span > i { display: block; font-style: normal; animation: rise .9s linear(0, .45 9%, .74 18%, .9 30%, .97 45%, 1) both; }
.hero h1 .l2 > i { animation-delay: .12s; }
/* The intro plays once per visit; switching language or coming back lands on the finished hero. */
.seen .hero h1 span > i, .seen .hero .kicker, .seen .hero-foot { animation: none; }
@keyframes fade-up { from { opacity: 0; transform: translateY(18px); } }
.hero .kicker, .hero-foot { animation: fade-up .8s .5s cubic-bezier(.16, 1, .3, 1) both; }

@supports (animation-timeline: view()) {
  @property --t { syntax: "<integer>"; inherits: true; initial-value: 0; }

  /* Reading progress along the top edge. */
  .progress { display: block; position: fixed; inset: 0 0 auto; z-index: 30; height: 3px; background: var(--ver); transform-origin: 0 50%; animation: grow linear both; animation-timeline: scroll(root); }
  @keyframes grow { from { transform: scaleX(0); } }

  /* The film pushes in as it arrives. */
  .film-frame { animation: push-in linear both; animation-timeline: view(); animation-range: entry 0% cover 42%; }
  @keyframes push-in { from { transform: scale(.86); } }

  /* Section titles slide up as they enter. */
  .mega { animation: title-in linear both; animation-timeline: view(); animation-range: entry 10% cover 30%; }
  @keyframes title-in { from { opacity: 0; transform: translateY(14%); } }

  /* Each request lands as you reach it; the answer follows a beat later. */
  .lines li { animation: line-in linear both; animation-timeline: view(); animation-range: entry 0% cover 28%; }
  .lines li p { animation: line-in linear both; animation-timeline: view(); animation-range: entry 30% cover 34%; }
  @keyframes line-in { from { opacity: 0; transform: translateY(40px); } }

  /* The three outcomes slide in from alternate sides, like poster strips. */
  .band { animation: band-l linear both; animation-timeline: view(); animation-range: entry 0% cover 38%; }
  .band:nth-child(2) { animation-name: band-r; }
  @keyframes band-l { from { transform: translateX(-34%); } }
  @keyframes band-r { from { transform: translateX(34%); } }

  /* Apple's endpoints scroll past behind the numbers. */
  .paths pre { animation: drift-up linear both; animation-timeline: view(); animation-range: cover; }
  .paths pre:nth-child(even) { animation-name: drift-down; }
  @keyframes drift-up { from { transform: translateY(6%); } to { transform: translateY(-26%); } }
  @keyframes drift-down { from { transform: translateY(-26%); } to { transform: translateY(6%); } }

  /* The numbers count up as they arrive: a registered integer drives a CSS counter. */
  .stat b[style*="--to"] { color: transparent; position: relative; }
  .stat b[style*="--to"]::after { position: absolute; inset: 0; color: var(--c, var(--off)); counter-reset: n var(--t); content: counter(n); animation: count linear both; animation-timeline: view(); animation-range: entry 20% cover 46%; }
  /* Four-digit numbers count their last three digits behind a fixed "1,": no math functions a browser might reject. */
  .stat b.k[style*="--to"]::after { content: "1," counter(n, pad3) var(--plus, ""); }
  .stat:nth-child(2) b { --c: var(--ver); }
  .stat:nth-child(3) b { --c: var(--yel); }
  @keyframes count { from { --t: 0; } to { --t: var(--to); } }
  @counter-style pad3 { system: extends decimal; pad: 3 "0"; }

  /* The reel: vertical scroll drives a horizontal run of hard-cut posters. */
  .reel { view-timeline: --reel block; height: 320vh; }
  .reel-stage { position: sticky; top: 0; height: 100svh; overflow: clip; }
  .reel-track { display: flex; height: 100%; width: max-content; animation: reel linear both; animation-timeline: --reel; animation-range: contain; }
  .reel-track li { min-width: 72vw; min-height: 0; height: 100%; padding: 0 var(--gut) 12svh; font-size: clamp(64px, 13vw, 240px); white-space: nowrap; }
  @keyframes reel { to { transform: translateX(calc(-100% + 100vw)); } }
  @media (max-width: 700px) {
    .reel-track li { min-width: 0; width: 88vw; font-size: 11vw; white-space: normal; word-break: keep-all; }
  }

  /* The name pushes in to fill the frame, as at the end of the film. */
  .finale .word { transform-origin: 0 100%; animation: name-in linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
  @keyframes name-in { from { transform: scale(.62); opacity: .2; } }
}

@supports not (animation-timeline: view()) {
  .reel-track li { min-height: 260px; }
}
