/* Motion: how the site moves (finishing plan, phase 2, 2026-11-20).
   Loads last on every page, after cinematic.css, so it overrides the older entrance and reveal
   timings in styles.css without touching that file. One feel everywhere: exponential ease-out,
   short, never a bounce. Everything here sits behind the .js gate (boot.js), so a page whose
   scripts fail shows all of its content, and reduced motion gets instant, still states. */

:root {
  --motion-enter: calc(var(--duration-slow) * 0.6);          /* 420 ms: one hero line building in */
  --motion-enter-gap: 60ms;                                  /* headline, then lead, then buttons */
  --motion-reveal: calc(var(--duration-slow) * 5 / 7);       /* 500 ms: a section rising in */
  --motion-reveal-gap: 60ms;                                 /* between items in a group */
  --motion-settle: 1600ms;                                   /* the hero photo easing back to size */
  --motion-page: var(--duration);                            /* the fade between pages */
}

/* ---------- Hero entrance: built in under 600 ms ----------
   Was 1.1 s per item with text still grey at 700 ms (audit). Now every item takes 420 ms with a
   60 ms step, so the last one (the buttons) is fully in by 600 ms. The data-enter number is the
   order: the headline is 1 (or 2 under a proof line on the homepage), the lead next, the buttons
   last. */
@media (prefers-reduced-motion: no-preference) {
  .js [data-enter] {
    animation: motion-enter var(--motion-enter) var(--ease-out) both;
    animation-delay: var(--enter-at, 0ms);
  }

  .js [data-enter="2"] {
    --enter-at: var(--motion-enter-gap);
  }

  .js [data-enter="3"] {
    --enter-at: calc(var(--motion-enter-gap) * 2);
  }

  .js [data-enter="4"],
  .js [data-enter="5"] {
    --enter-at: calc(var(--motion-enter-gap) * 3);
  }

  /* The hero photo settles very slowly from 1.04 to 1, under the copy. The frames clip it. */
  .js .hero-photo .cover,
  .js .hero--film .film .cover {
    animation: motion-settle var(--motion-settle) var(--ease-out) both;
  }
}

@keyframes motion-enter {
  from {
    opacity: 0;
    translate: 0 0.75rem;
  }

  to {
    opacity: 1;
    translate: 0 0;
  }
}

@keyframes motion-settle {
  from {
    scale: 1.04;
  }

  to {
    scale: 1;
  }
}

/* ---------- Scroll reveal: one rise for every section ----------
   app.js adds .is-revealed when a block enters the view. Same 16 px rise and 500 ms for single
   blocks and for groups, with a 60 ms step between the items of a group. */
@media (prefers-reduced-motion: no-preference) {
  .js [data-reveal],
  .js [data-reveal-group] > * {
    opacity: 0;
    translate: 0 1rem;
    transition:
      opacity var(--motion-reveal) var(--ease-out) var(--reveal-delay, 0ms),
      translate var(--motion-reveal) var(--ease-out) var(--reveal-delay, 0ms);
  }

  .js [data-reveal].is-revealed,
  .js [data-reveal-group].is-revealed > * {
    opacity: 1;
    translate: 0 0;
  }

  .js [data-reveal-group] > :nth-child(2) {
    --reveal-delay: var(--motion-reveal-gap);
  }

  .js [data-reveal-group] > :nth-child(3) {
    --reveal-delay: calc(var(--motion-reveal-gap) * 2);
  }

  .js [data-reveal-group] > :nth-child(4) {
    --reveal-delay: calc(var(--motion-reveal-gap) * 3);
  }

  .js [data-reveal-group] > :nth-child(5) {
    --reveal-delay: calc(var(--motion-reveal-gap) * 4);
  }

  .js [data-reveal-group] > :nth-child(6) {
    --reveal-delay: calc(var(--motion-reveal-gap) * 5);
  }

  .js [data-reveal-group] > :nth-child(7) {
    --reveal-delay: calc(var(--motion-reveal-gap) * 6);
  }

  .js [data-reveal-group] > :nth-child(n + 8) {
    --reveal-delay: calc(var(--motion-reveal-gap) * 7);
  }

  .js [data-reveal="late"] {
    --reveal-delay: calc(var(--motion-reveal-gap) * 2);
  }
}

/* ---------- Page to page: a soft cross-fade ----------
   Same-site links fade the old page into the new one (cross-document View Transitions). Browsers
   without support simply load the next page as before. */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--motion-page);
  animation-timing-function: var(--ease-out);
}

/* ---------- Reduced motion: still and instant ---------- */
@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  .js [data-enter],
  .js .hero-photo .cover,
  .js .hero--film .film .cover {
    animation: none;
  }

  .js [data-reveal],
  .js [data-reveal-group] > * {
    opacity: 1;
    translate: none;
    transition: none;
  }
}
