/* ═══════════════════════════════════════════════════════════════════
   HERO — "the aperture"
   The film plays on scroll. As the character arrives and lifts his
   hand, the full-bleed frame contracts into a portrait window and
   the name recomposes around it.

   --ap-* are written every frame by js/hero.js. The WebGL mask and
   every DOM overlay read the same four numbers, so the viewfinder
   marks and the type can never drift from the shader.
   ═══════════════════════════════════════════════════════════════════ */

.hero {
  position: relative;
  height: 400vh;                /* scroll distance for the whole beat */
  background: var(--paper);
}

/* Sticky, not a JS pin. Native sticky cannot desync from the scrollbar,
   costs no pin-spacer, and leaves the composited layer alone. */
.hero__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  width: 100%;
  overflow: hidden;
  background: var(--paper);

  /* full-bleed defaults — the shape before JS speaks */
  --ap-l: 0px;
  --ap-t: 0px;
  --ap-w: 100vw;
  --ap-h: 100vh;
}

.hero__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* the source. decoded, never seen — the canvas is the picture. */
.hero__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  z-index: 0;
  pointer-events: none;
}

/* ── viewfinder ──────────────────────────────────────────────────── */
.hero__frame {
  position: absolute;
  left: var(--ap-l);
  top: var(--ap-t);
  width: var(--ap-w);
  height: var(--ap-h);
  z-index: 3;
  pointer-events: none;
  opacity: 0;
}
.hero__tick {
  position: absolute;
  width: 15px;
  height: 15px;
  border: 0 solid var(--ink);
  opacity: 0.42;
}
.hero__tick--tl { left: -9px;  top: -9px;    border-top-width: 1px; border-left-width: 1px; }
.hero__tick--tr { right: -9px; top: -9px;    border-top-width: 1px; border-right-width: 1px; }
.hero__tick--bl { left: -9px;  bottom: -9px; border-bottom-width: 1px; border-left-width: 1px; }
.hero__tick--br { right: -9px; bottom: -9px; border-bottom-width: 1px; border-right-width: 1px; }

/* ── the name and role, bracketing the window ────────────────────── */
.hero__split {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
}
/* Title case, not caps: the name should read as a name. Size is fitted
   at runtime to the space beside the window — see fitSplitType(). */
.hero__splitside {
  position: absolute;
  top: calc(var(--ap-t) + var(--ap-h) * 0.5);
  transform: translateY(-50%);
  margin: 0;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(2.5rem, 9vw, 11rem);
  line-height: 0.82;
  letter-spacing: -0.028em;
  /* h1 inherits uppercase from the global heading rule; a name should
     read as a name */
  text-transform: none;
  color: var(--ink);
  white-space: nowrap;
}
.hero__splitside > span { display: block; will-change: transform, opacity; }
.hero__w { display: block; }

/* Same face, same weight as the name — colour alone separates them. */
.hero__splitside--r {
  color: color-mix(in oklab, var(--ink) 58%, var(--paper));
}

/* each block tucks against its own edge of the window */
.hero__splitside--l {
  right: calc(100% - var(--ap-l) + clamp(0.75rem, 1.8vw, 2rem));
  text-align: right;
}
.hero__splitside--r {
  left: calc(var(--ap-l) + var(--ap-w) + clamp(0.75rem, 1.8vw, 2rem));
  text-align: left;
}

/* ── phase 3 · the greeting, arriving with the hand ──────────────── */
.hero__greet {
  position: absolute;
  left: 50%;
  top: calc(var(--ap-t) + var(--ap-h) + clamp(1.1rem, 2.6vh, 2rem));
  transform: translateX(-50%);
  z-index: 5;
  width: min(46ch, calc(100vw - var(--gutter) * 2));
  text-align: center;
  pointer-events: none;
}
/* The container owns the centring transform, so the animation has to run
   on the line inside it — GSAP would otherwise overwrite translateX(-50%). */
.hero__greet-line {
  opacity: 0;
  font-family: var(--f-body);
  font-size: clamp(0.9375rem, 0.85rem + 0.5vw, 1.3125rem);
  line-height: 1.5;
  color: var(--ink);
  text-wrap: balance;
}
.hero__greet-line em { color: var(--clay); font-weight: 420; }

/* ── instrument panel ────────────────────────────────────────────── */

.hero__cue {
  position: absolute;
  left: 50%;
  bottom: clamp(1.1rem, 2.4vh, 1.75rem);
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  pointer-events: none;
  color: #F2ECDE;
  mix-blend-mode: difference;
}
.hero__cue-rail {
  display: block;
  width: clamp(2.5rem, 6vw, 4.5rem);
  height: 1px;
  background: currentColor;
  opacity: 0.28;
  overflow: hidden;
}
.hero__cue-rail i {
  display: block;
  height: 100%;
  width: 100%;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
}

/* ── the window is portrait; on a phone so is the viewport ────────
   Bracketing left/right stops working, so the name stacks: one word
   shoulders the window from above, one carries it from below.       */
@media (max-width: 52rem) {
  .hero { height: 340vh; }

  /* one line each on a phone — two would eat the window's headroom */
  .hero__w { display: inline; }

  .hero__splitside {
    top: auto;
    left: var(--gutter);
    right: auto;
    transform: none;
    text-align: left;
    font-size: clamp(2.75rem, 15vw, 5.5rem);
  }
  .hero__splitside--l {
    bottom: calc(100% - var(--ap-t) + 0.18em);
  }
  .hero__splitside--r {
    top: calc(var(--ap-t) + var(--ap-h) + 0.14em);
  }
  .hero__greet {
    top: auto;
    bottom: clamp(3rem, 7vh, 4.5rem);
    text-align: left;
    left: var(--gutter);
    transform: none;
    width: min(38ch, calc(100vw - var(--gutter) * 2));
  }
  .hero__greet-line { text-wrap: pretty; }
  .hero__cue { left: auto; right: var(--gutter); transform: none; }
}

/* ── no motion: hand the whole beat over as one still composition ── */
.no-motion .hero { height: 100vh; }
.no-motion .hero__frame { opacity: 1; }
.no-motion .hero__split,
.no-motion .hero__greet-line { opacity: 1; }
.no-motion .hero__cue { display: none; }

/* ═══════════════════════════════════════════════════════════════════
   REEL — off the clock. Same aperture grammar as the hero, square
   window, driven by js/reel.js. --ap-* are written per frame exactly
   as they are above.
   ═══════════════════════════════════════════════════════════════════ */

.reel {
  position: relative;
  height: 660vh;   /* three beats: window close, then Catan and Bollywood */
  background: var(--paper);
}

.reel__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  width: 100%;
  overflow: hidden;
  background: var(--paper);

  --ap-l: 0px;
  --ap-t: 0px;
  --ap-w: 100vw;
  --ap-h: 100vh;
}

.reel__canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }

.reel__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  z-index: 0;
  pointer-events: none;
}

/* The second-beat film. Pinned to the very same aperture rect the shader
   draws the basketball into — the --ap-* vars — so it is exactly the same
   size and place. A 2px radius and a soft drop match the shader's matte
   and cast shadow, so the crossfade doesn't change the window's edge. */
.reel__swapv {
  position: absolute;
  left: var(--ap-l);
  top: var(--ap-t);
  width: var(--ap-w);
  height: var(--ap-h);
  z-index: 2;             /* catan, over the basketball canvas (z-1) */
  overflow: hidden;
  border-radius: 2px;
  opacity: 0;
  box-shadow: 0 24px 60px -34px rgb(12 14 8 / 0.5);
  pointer-events: none;
}
/* bollywood stacks over catan, so the second swap covers the first */
.reel__swapv--c { z-index: 3; }
.reel__swapv video {
  width: 100%;
  height: 100%;
  object-fit: cover;   /* 16:9 source into a square window, centred */
  object-position: 50% 42%;
}

.reel__frame {
  position: absolute;
  left: var(--ap-l);
  top: var(--ap-t);
  width: var(--ap-w);
  height: var(--ap-h);
  z-index: 4;
  pointer-events: none;
  opacity: 0;
}
.reel__tick {
  position: absolute;
  width: 15px; height: 15px;
  border: 0 solid var(--ink);
  opacity: 0.42;
}
.reel__tick--tl { left: -9px;  top: -9px;    border-top-width: 1px; border-left-width: 1px; }
.reel__tick--tr { right: -9px; top: -9px;    border-top-width: 1px; border-right-width: 1px; }
.reel__tick--bl { left: -9px;  bottom: -9px; border-bottom-width: 1px; border-left-width: 1px; }
.reel__tick--br { right: -9px; bottom: -9px; border-bottom-width: 1px; border-right-width: 1px; }

/* the title brackets the window's left edge, as the name does upstairs */
.reel__type { position: absolute; inset: 0; z-index: 5; pointer-events: none; opacity: 0; }
.reel__title {
  position: absolute;
  top: calc(var(--ap-t) + var(--ap-h) * 0.5);
  right: calc(100% - var(--ap-l) + clamp(0.75rem, 1.8vw, 2rem));
  transform: translateY(-50%);
  margin: 0;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(2.25rem, 8vw, 9rem);
  line-height: 0.82;
  letter-spacing: -0.028em;
  text-transform: none;
  text-align: right;
  color: var(--ink);
  white-space: nowrap;
}
.reel__title > span { display: block; will-change: transform, opacity; }
.reel__w { display: block; }

/* the quieter half of the pair — same face and weight, colour separates */
.reel__title--r {
  right: auto;
  left: calc(var(--ap-l) + var(--ap-w) + clamp(0.75rem, 1.8vw, 2rem));
  text-align: left;
  color: color-mix(in oklab, var(--ink) 58%, var(--paper));
}

/* Catan shares the left bracket with NBA. On the second scroll NBA rides
   up and out of its inner span while this one comes in from below — js
   drives the vertical offsets, so both keep the shared centring. */
.reel__title--alt { z-index: 1; }

.reel__note {
  position: absolute;
  left: 50%;
  top: calc(var(--ap-t) + var(--ap-h) + clamp(1.1rem, 2.6vh, 2rem));
  transform: translateX(-50%);
  z-index: 6;
  width: min(44ch, calc(100vw - var(--gutter) * 2));
  text-align: center;
  pointer-events: none;
}
.reel__note-line {
  opacity: 0;
  font-family: var(--f-body);
  font-size: clamp(0.9375rem, 0.85rem + 0.5vw, 1.3125rem);
  line-height: 1.5;
  color: var(--ink);
  text-wrap: balance;
}
.reel__note-line em { color: var(--clay); font-style: italic; }
/* the Catan caption overlays the NBA one and crossfades in the same spot */
.reel__note-line--alt { position: absolute; inset: 0; }

@media (max-width: 52rem) {
  .reel { height: 540vh; }
  .reel__w { display: inline; }
  .reel__title {
    top: auto;
    right: auto;
    left: var(--gutter);
    bottom: calc(100% - var(--ap-t) + 0.2em);
    transform: none;
    text-align: left;
    font-size: clamp(2.5rem, 13vw, 5rem);
  }
  /* stacks under the window on a phone, as the role line does upstairs */
  .reel__title--r {
    bottom: auto;
    left: var(--gutter);
    top: calc(var(--ap-t) + var(--ap-h) + 0.16em);
  }
  .reel__note {
    top: auto;
    bottom: clamp(3rem, 8vh, 5rem);
    left: var(--gutter);
    transform: none;
    text-align: left;
    width: min(36ch, calc(100vw - var(--gutter) * 2));
  }
  .reel__note-line { text-wrap: pretty; }
}

.no-motion .reel { height: 100vh; }
.no-motion .reel__frame,
.no-motion .reel__type,
.no-motion .reel__note-line { opacity: 1; }
/* the static composition is the NBA beat only — the Catan swap is a
   scroll gesture, so its layer stays out of the still */
.no-motion .reel__title--alt,
.no-motion .reel__note-line--alt,
.no-motion .reel__swapv { opacity: 0; }
