/* Motion & Matter — the hero.

   The wordmark is the film's control. "Motion" runs the film; "Matter" holds the frame.
   One rule, shared with the studio chapter further down: type that is only drawn (an
   outline) is something not yet made; solid type is something made. So whichever word is
   true right now is solid, and the other is an outline waiting.

   Holding the film sets the frame down as a print: a paper border closes round it and it
   keeps its time. The footage itself is never altered; only its window and the type move. */

.hero-film{
  --hold:0;                                   /* 0 running, 1 held (eased in hero.js) */
  --print:clamp(10px,1.5vw,22px);             /* paper border of a held print */
  --mark:247,245,240;
  --frame-now:max(calc(var(--settle) * var(--frame-inset)),calc(var(--hold) * var(--print)));
  clip-path:inset(
    var(--frame-now) var(--frame-now) calc(var(--hold) * var(--print)) var(--frame-now)
    round max(calc(var(--settle) * var(--frame-radius)),calc(var(--hold) * 8px))
  );
}
/* A held print has no further to go. */
.hero-film.is-held .hero-cue{opacity:0;pointer-events:none}
/* A held frame is still: the slow drift stops with it. */
.hero-film:not(.is-playing) .hero-stage video{animation-play-state:paused}
/* The centre play button is only for a film that could not start by itself. */
.hero-film.is-held .hero-overlay{display:none}
.hero-veil{
  background:
    linear-gradient(180deg,rgba(8,8,7,.45) 0%,rgba(8,8,7,.12) 28%,transparent 55%),
    linear-gradient(0deg,rgba(8,8,7,.56) 0%,rgba(8,8,7,.3) 24%,rgba(8,8,7,.08) 44%,transparent 58%);
}

.hero-copy{
  position:absolute;left:0;right:0;z-index:4;
  bottom:var(--hero-inset);
  /* Keeps its margins from the frame's edges as the frame closes in. */
  padding:0 calc(var(--hero-gutter) + var(--frame-now));
  color:rgb(var(--mark));
}

/* ---------- Credit row: what is playing, and its sound ---------- */
.hero-credit{
  display:flex;align-items:center;justify-content:space-between;gap:16px;
}
.hero-film-label{
  margin:0;
  font-size:var(--type-meta-size);
  color:rgba(var(--mark),.88);
  text-shadow:0 1px 10px rgba(0,0,0,.5);
}
.hero-sound{
  appearance:none;border:0;background:transparent;color:inherit;cursor:pointer;
  padding:6px;margin:-6px;
  display:grid;place-items:center;
  opacity:.88;
  filter:drop-shadow(0 1px 8px rgba(0,0,0,.45));
  transition:opacity var(--dur-quick) ease;
}
.hero-sound:hover{opacity:1}
.hero-sound:focus-visible,
.hero-word:focus-visible{outline:2px solid rgb(var(--mark));outline-offset:6px}
.hero-sound svg{width:20px;height:20px;display:block}
.hero-sound .icon-mute{display:none}
.hero-film.is-muted .hero-sound .icon-mute{display:block}
.hero-film.is-muted .hero-sound .icon-unmute{display:none}
.hero-sound.film-mute-pulse{animation:film-mute-pulse 1.6s ease infinite}

/* ---------- The wordmark ----------
   Set in the film's own title face (Inter Display Black, capitals), so the site's name and
   the film's words are one voice. While the film runs it is a signature in the corner and
   the picture has the whole frame. When the film is held or has ended, the frame dims and
   the name comes up full width: the site's title card, in the film's language. */
@font-face{
  font-family:"Inter Display Caps";
  src:url("assets/fonts/inter-display-black-caps.woff2?v=2") format("woff2");
  font-weight:900;font-style:normal;font-display:block;
}
.hero-copy{display:flex;flex-direction:column}
.hero-credit{
  order:1;margin:clamp(9px,1vw,14px) 0 0;
  /* Everything sits on the film's centre line: the name, what is playing, then its controls. */
  display:flex;flex-direction:column;align-items:center;gap:clamp(9px,.9vw,13px);
}
.hero-credit .hero-film-label{text-align:center}
.hero-controls{display:flex;align-items:center;justify-content:center;gap:22px}
.hero-toggle .icon-play{display:none}
.hero-film:not(.is-playing) .hero-toggle .icon-play{display:block}
.hero-film:not(.is-playing) .hero-toggle .icon-pause{display:none}
.hero-film{
  --mark-small:clamp(18px,1.7vw,28px);
  --mark-big:calc((100vw - 2 * var(--hero-gutter)) / 9.25);   /* hero.js measures and refines this */
}
.hero-mark{
  margin:0;
  display:flex;align-items:baseline;justify-content:center;gap:.26em;
  white-space:nowrap;
  font-family:"Inter Display Caps","Inter Display","Inter","Arial Black","Helvetica Neue",Arial,sans-serif;
  font-weight:900;
  font-size:var(--mark-big);
  line-height:.86;
  letter-spacing:-.022em;
  text-transform:uppercase;
  color:rgb(var(--mark));
  text-shadow:0 2px 22px rgba(0,0,0,.34);
}
/* Running: it starts as the signature and grows with the scroll, reaching full size as the
   frame finishes closing in (--settle, 0 to 1, from motion.js). */
.hero-film.is-playing .hero-mark,
.hero-film.is-playing .hero-emblem{font-size:calc(var(--mark-small) + (var(--mark-big) - var(--mark-small)) * var(--settle))}
/* The signature above the name shares its size (mark.css), so the two move as one. */
.hero-emblem{font-size:var(--mark-big)}
/* Only a change of state (run, hold, end) eases; the scroll drives the size directly. */
.hero-film.is-switching .hero-mark,
.hero-film.is-switching .hero-emblem{transition:font-size .7s var(--ease)}
/* Tall screens: two lines at every size, like THE / WILL. in the film. */
.hero-film.is-tall .hero-mark{flex-direction:column;align-items:center;gap:.06em}
.hero-word{
  appearance:none;border:0;background:none;padding:0;margin:0;
  font:inherit;color:inherit;text-align:center;line-height:inherit;letter-spacing:inherit;text-transform:inherit;
  cursor:pointer;
  display:block;
  -webkit-tap-highlight-color:transparent;
}
.hero-word-text{display:block}
.hero-amp{margin-right:.2em}
/* A held or finished film steps back behind the name. */
.hero-stage::after{
  content:"";position:absolute;inset:0;z-index:2;pointer-events:none;
  background:#000;opacity:0;
  transition:opacity .6s ease;
}
.hero-film:not(.is-playing) .hero-stage::after{opacity:.46}
@media (prefers-reduced-motion:reduce){
  .hero-film.is-switching .hero-mark,.hero-film.is-switching .hero-emblem,.hero-stage::after{transition:none}
}

/* ---------- What each word is doing, or would do ---------- */
.hero-state{
  display:flex;align-items:baseline;gap:.5em;
  font-family:var(--font-sans);
  font-size:12px;
  line-height:18px;
  letter-spacing:.01em;
  color:rgba(var(--mark),.9);
  text-shadow:0 1px 10px rgba(0,0,0,.55);
  cursor:pointer;
  /* Only shown once the switch works (hero.js). */
  visibility:hidden;
}
.hero-film.is-live .hero-state{visibility:visible}
.hero-state .tc{font-size:19px;line-height:18px;color:rgb(var(--mark))}
.hero-state.is-now{cursor:default}
.hero-state:not(.is-now){color:rgba(var(--mark),.72)}
.hero-state-hold{padding-right:5.5em} /* room for the scroll cue at the row's far end */

/* ---------- Scroll cue: the far end of the same row ---------- */
.hero-film .hero-cue{
  right:calc(var(--hero-gutter) + var(--frame-now));
  bottom:var(--hero-inset);
  translate:none;
  flex-direction:row;
  align-items:center;
  gap:9px;
  height:18px;
  font-size:var(--type-meta-size);
}
.hero-film .hero-cue-line{width:1px;height:16px}

/* ---------- Entrance: credit, the two words, then what they do ---------- */
@media (prefers-reduced-motion:no-preference){
  .hero-credit,
  .hero-word,
  .hero-state{
    animation:hero-rise .62s var(--ease) backwards;
    animation-delay:calc(var(--i,0) * 80ms);
  }
  .hero-word-motion{--i:1}
  .hero-word-matter{--i:2}
  .hero-state{--i:4}
}

@media(max-width:600px){
  .hero-film{
    --print:9px;
    /* Phones settle with a transform, not clip-path (cheaper per scroll frame); a held
       print is the same move, centred so the paper shows on every side. */
    clip-path:none;
    transform:translate3d(0,calc(var(--hold) * (1 - var(--settle)) * 2.25svh),0) scale(calc(1 - max(var(--settle) * .055,var(--hold) * .045)));
    border-radius:max(calc(var(--settle) * var(--frame-radius)),calc(var(--hold) * 8px));
  }
  .hero-copy{
    bottom:calc(var(--hero-inset) + env(safe-area-inset-bottom));
    padding:0 max(16px,env(safe-area-inset-right)) 0 max(16px,env(safe-area-inset-left));
  }
  .hero-film{--mark-small:16px}
  .hero-state{font-size:11px;gap:.4em}
  .hero-state .tc{font-size:17px}
  .hero-state-hold{padding-right:0}
  .hero-sound svg{width:18px;height:18px}
  .hero-film .hero-cue{
    right:max(16px,env(safe-area-inset-right));
    bottom:calc(var(--hero-inset) + env(safe-area-inset-bottom));
    gap:7px;
  }
  .hero-film .hero-cue-line{height:14px}
}
@media (prefers-reduced-motion:reduce){
  .hero-sound.film-mute-pulse{animation:none}
}

/* The film is shown whole, and never inside a box.

   Its words run edge to edge, so the frame always spans the full width and is never cropped
   at the sides. There are two cuts of it: the widescreen film, and a vertical cut reframed
   shot by shot for phones (hero.js picks one and sets .is-tall). Whatever shape is left
   over is handled above and below the frame only:
     screen wider than the cut    the frame fills the screen; a little sky falls outside.
     screen taller than the cut   the frame hangs from the top and its foot dissolves into
                                  its own light, under the wordmark.
   The light is the film itself, mirrored and blurred (hero.js paints it), so the edge of
   the picture and the start of the glow are the same colours: there is no line. */
.hero-state{display:none}
.hero-stage{overflow:hidden;background:#000}
.hero-ambient{display:none}
.hero-film .hero-stage video{
  position:relative;z-index:1;
  object-fit:contain;object-position:center center;
  background:transparent;transform:none;animation:none;
}
@supports (width:1cqw){
  .hero-stage{container-type:size}
  /* --gap is the room left over once the whole film is on screen: negative when the screen
     is the wider shape, and then the overflow comes mostly off the top, away from the
     wordmark. hero.js picks the widescreen film or the vertical cut and sets .is-tall. */
  .hero-film .hero-stage video,
  .hero-ambient{
    --film-h:56.25cqw;
    --gap:calc(100cqh - var(--film-h));
    --film-y:min(0px,calc(var(--gap) * .75));
  }
  .hero-film.is-tall .hero-stage video,
  .hero-film.is-tall .hero-ambient{
    --film-h:177.778cqw;
    --film-y:min(0px,calc(var(--gap) * .5));
  }
  .hero-film .hero-stage video{
    position:absolute;left:0;top:var(--film-y);
    width:100%;height:auto;aspect-ratio:16 / 9;
    object-fit:cover;
  }
  .hero-film.is-tall .hero-stage video{aspect-ratio:9 / 16}
  .hero-ambient{
    position:absolute;z-index:0;
    left:-7%;width:114%;
    top:calc(var(--film-y) - var(--film-h));
    height:calc(var(--film-h) * 3);
    filter:blur(min(calc(var(--film-h) * .075),64px)) saturate(1.2);
    opacity:.9;
    -webkit-mask-image:linear-gradient(to bottom,transparent 8%,rgba(0,0,0,.55) 26%,#000 34%,#000 66%,rgba(0,0,0,.55) 74%,transparent 92%);
    mask-image:linear-gradient(to bottom,transparent 8%,rgba(0,0,0,.55) 26%,#000 34%,#000 66%,rgba(0,0,0,.55) 74%,transparent 92%);
  }
  /* The screen is taller than the film: its foot dissolves, by as much as there is room. */
  @container (max-aspect-ratio:16/9){
    .hero-film:not(.is-tall) .hero-stage video{
      --feather:min(calc(var(--gap) * 2.2),calc(var(--film-h) * .34));
      -webkit-mask-image:linear-gradient(to top,transparent 0,rgba(0,0,0,.5) calc(var(--feather) * .42),#000 var(--feather));
      mask-image:linear-gradient(to top,transparent 0,rgba(0,0,0,.5) calc(var(--feather) * .42),#000 var(--feather));
    }
    .hero-film:not(.is-tall) .hero-ambient{display:block}
  }
  @container (max-aspect-ratio:9/16){
    .hero-film.is-tall .hero-stage video{
      --feather:min(calc(var(--gap) * 2.2),calc(var(--film-h) * .2));
      -webkit-mask-image:linear-gradient(to top,transparent 0,rgba(0,0,0,.5) calc(var(--feather) * .42),#000 var(--feather));
      mask-image:linear-gradient(to top,transparent 0,rgba(0,0,0,.5) calc(var(--feather) * .42),#000 var(--feather));
    }
    .hero-film.is-tall .hero-ambient{display:block}
  }
  /* Between the two shapes (a squarish window): the widescreen film floats, both edges dissolved. */
  @container (max-aspect-ratio:5/4){
    .hero-film:not(.is-tall) .hero-stage video,
    .hero-film:not(.is-tall) .hero-ambient{--film-y:max(76px,calc(41cqh - var(--film-h) / 2))}
    .hero-film:not(.is-tall) .hero-stage video{
      -webkit-mask-image:linear-gradient(to bottom,transparent 0,rgba(0,0,0,.6) 7%,#000 17%,#000 83%,rgba(0,0,0,.6) 93%,transparent 100%);
      mask-image:linear-gradient(to bottom,transparent 0,rgba(0,0,0,.6) 7%,#000 17%,#000 83%,rgba(0,0,0,.6) 93%,transparent 100%);
    }
  }
}
