/* scrub-hero.css
 * Default rules give the STATIC layout (no JS, reduced motion, Save-Data, errors):
 * the hold frame with every caption stacked and readable. The scrubbing layout
 * (tall section + sticky stage + captions fading in place) is switched on only
 * when JS runs and motion is allowed.
 */
:root {
  --bg: #07080d;
  --fg: #f5f5f7;
  --muted: #c3c6d4;
  --accent: #ffb86b;
  --gutter: clamp(16px, 5vw, 72px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 1rem/1.5 var(--font);
}

/* ---------- header (sits over the footage, so it gets its own scrim) */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(14px, env(safe-area-inset-top)) var(--gutter) 28px;
  background: linear-gradient(rgb(0 0 0 / 0.62), rgb(0 0 0 / 0));
  pointer-events: none;
}
.site-header a { pointer-events: auto; color: var(--fg); text-decoration: none; }
.brand { font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.95rem; }
.nav { display: flex; gap: 1.25rem; font-size: 0.95rem; }
.nav a { padding: 0.5rem 0; }

/* ---------- static layout (default) */
.scrub { position: relative; background: var(--bg); }
.scrub__stage { position: relative; min-height: 100vh; min-height: 100svh; overflow: hidden; }
.scrub__poster,
.scrub__poster img,
.scrub__canvas,
.scrub__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.scrub__poster img, .scrub__video { object-fit: cover; }
.scrub__canvas, .scrub__video { display: none; }

.scrub__scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to top, rgb(0 0 0 / 0.80) 0%, rgb(0 0 0 / 0.58) 30%, rgb(0 0 0 / 0) 62%);
}

.scrub__captions {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 1.25rem;
  padding: 96px var(--gutter) calc(10vh + env(safe-area-inset-bottom, 0px));
}

.cap {
  margin: 0;
  max-width: min(24ch, 100%);
  overflow-wrap: break-word;
  color: var(--fg);
  font-size: clamp(1.25rem, 0.95rem + 1.5vw, 2rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.55), 0 2px 18px rgb(0 0 0 / 0.40);
}
.cap--lead {
  max-width: min(14ch, 100%);
  font-size: clamp(2.25rem, 1.3rem + 4.4vw, 5rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.025em;
}
.btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.8rem 1.25rem;
  border-radius: 999px;
  background: var(--fg);
  color: #0b0c12;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  text-decoration: none;
  text-shadow: none;
}
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

@media (min-width: 768px) and (orientation: landscape) {
  /* Desktop band: lower left, away from the subject in the centre. The static
     layout stacks every caption, so the column reaches higher into the bright
     sky and needs a deeper scrim than the one-at-a-time scrubbing layout. */
  .scrub__scrim {
    background:
      linear-gradient(to right, rgb(0 0 0 / 0.80) 0%, rgb(0 0 0 / 0.66) 38%, rgb(0 0 0 / 0) 70%),
      linear-gradient(to top, rgb(0 0 0 / 0.50) 0%, rgb(0 0 0 / 0) 45%);
  }
  .scrub__captions { padding-bottom: 14vh; }
  .cap { max-width: min(22ch, 42vw); }
  .cap--lead { max-width: min(12ch, 46vw); }
}

/* ---------- scrubbing layout (JS running, motion allowed) */
@media (prefers-reduced-motion: no-preference) {
  .js .scrub:not(.scrub--static) { height: var(--scrub-length, 400vh); }
  .js .scrub:not(.scrub--static) .scrub__stage {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100lvh;   /* large viewport: stays put while mobile toolbars slide */
    min-height: 0;
  }
  .js .scrub:not(.scrub--static) .scrub__canvas,
  .js .scrub:not(.scrub--static) .scrub__video { display: block; opacity: 0; }
  /* Same selector chain plus .scrub--live, so it always wins over the line above. */
  .js .scrub.scrub--live:not(.scrub--static) .scrub__canvas,
  .js .scrub.scrub--live:not(.scrub--static) .scrub__video { opacity: 1; }

  .js .scrub:not(.scrub--static) .scrub__scrim,
  .js .scrub:not(.scrub--static) .scrub__captions {
    position: absolute;
    inset: 0 0 auto 0;
    height: 100vh;
    height: 100svh;   /* small viewport: captions never slide under a toolbar */
    min-height: 0;
  }
  .js .scrub:not(.scrub--static) .scrub__captions {
    display: grid;
    grid-template: 1fr / 1fr;  /* one cell; every caption stacks in it */
    justify-content: stretch;  /* undo the static flex alignment */
    padding: 0;
    pointer-events: none;
  }
  .js .scrub:not(.scrub--static) .cap {
    grid-area: 1 / 1;
    align-self: end;
    justify-self: start;
    margin: 0 var(--gutter) calc(10vh + env(safe-area-inset-bottom, 0px));
    opacity: 0;
    will-change: opacity, transform;
    /* Short ease: smooths the snap to 0/1 when scrolling stops inside a fade (restCaptions). */
    transition: opacity 0.18s ease-out, transform 0.18s ease-out;
  }
  /* The first line is visible before the script runs: it is often the LCP text. */
  .js .scrub:not(.scrub--static) .cap[data-in="0"] { opacity: 1; }
  .js .scrub:not(.scrub--static) .cap.is-on a { pointer-events: auto; }
  /* Keyboard focus on a hidden caption's link reveals the caption. */
  .js .scrub:not(.scrub--static) .cap:focus-within { opacity: 1 !important; transform: none !important; }
}
@media (prefers-reduced-motion: no-preference) and (min-width: 768px) and (orientation: landscape) {
  .js .scrub:not(.scrub--static) .cap { margin-bottom: 14vh; }
  .js .scrub:not(.scrub--static) .scrub__scrim {
    background:
      linear-gradient(to right, rgb(0 0 0 / 0.74) 0%, rgb(0 0 0 / 0.50) 30%, rgb(0 0 0 / 0) 58%),
      linear-gradient(to top, rgb(0 0 0 / 0.45) 0%, rgb(0 0 0 / 0) 40%);
  }
}

/* ---------- content after the hero */
.after {
  position: relative;
  z-index: 1;
  padding: 18vh var(--gutter) 12vh;
  max-width: 72rem;
}
.after h2 { margin: 0 0 1.5rem; font-size: clamp(1.75rem, 1.2rem + 2.4vw, 3rem); line-height: 1.1; letter-spacing: -0.02em; }
.after ol { margin: 0; padding-left: 1.25rem; color: var(--muted); font-size: 1.125rem; }
.after li + li { margin-top: 0.75rem; }
.after code { color: var(--fg); font-size: 0.95em; overflow-wrap: anywhere; }
.site-footer { padding: 2rem var(--gutter) 3rem; color: var(--muted); font-size: 0.875rem; }
