/* scrub-hero.css: layout and legibility for the scroll film hero.
   Base rules = the static hero (no JS, phones, portrait tablets, reduced motion).
   Rules under html.sfh-scrub = the scrubbed hero. The class is set by the inline head script
   and by scrub-hero.js from the one list of conditions, window.SFH_GATES. No media query in
   this file repeats those conditions, so CSS and JS cannot disagree.
   Set the tokens per project; the values here are neutral defaults, not a look. */

.sfh {
  --sfh-length: 520vh;            /* scrub length: 100vh of it is the pinned screen itself */
  --sfh-canvas: #0e0d12;          /* never pure black or white: tint toward the film's grade */
  --sfh-ink: #f3efe6;
  --sfh-scrim-rgb: 8 7 12;
  --sfh-scrim-a: .6;              /* per-band peak; override on the band, tune on its worst frame */
  --sfh-shadow: 0 1px 2px rgb(var(--sfh-scrim-rgb) / .9), 0 2px 14px rgb(var(--sfh-scrim-rgb) / .7),
                0 8px 40px rgb(var(--sfh-scrim-rgb) / .7);
  --sfh-gutter: clamp(1.25rem, 5vw, 5rem);
  position: relative;
  background: var(--sfh-canvas);
  color: var(--sfh-ink);
}

/* ---------- static hero (the default) ---------- */
.sfh-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: clamp(2rem, 6vh, 4rem);
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(5rem, 14vh, 9rem) var(--sfh-gutter) clamp(2.5rem, 8vh, 5rem);
  overflow: hidden;
}
.sfh-media { position: absolute; inset: 0; }
.sfh-media img,
.sfh-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sfh-video, .sfh-ending { opacity: 0; }
.sfh-scrim {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 120% 90% at 50% 40%, rgb(var(--sfh-scrim-rgb) / 0) 30%, rgb(var(--sfh-scrim-rgb) / .55) 100%),
    linear-gradient(to top, rgb(var(--sfh-scrim-rgb) / .7), rgb(var(--sfh-scrim-rgb) / 0) 70%);
}
.sfh-band { position: relative; text-shadow: var(--sfh-shadow); }
.sfh-band .sfh-btn, .sfh-band button { text-shadow: none; }

/* the text block of a band, with its own scrim riding the band's --k */
.sfh-copy { position: relative; isolation: isolate; max-width: min(42rem, 100%); }
.sfh-copy::before {
  content: ""; position: absolute; inset: -2.5rem -3.5rem; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%,
    rgb(var(--sfh-scrim-rgb) / var(--sfh-scrim-a)) 0%,
    rgb(var(--sfh-scrim-rgb) / calc(var(--sfh-scrim-a) * .66)) 46%,
    rgb(var(--sfh-scrim-rgb) / 0) 76%);
  opacity: calc(.3 + .7 * var(--k, 1));
}
/* small text over film: a chip, not the big scrim */
.sfh-chip {
  display: inline-block; padding: .35em .8em; border-radius: .6em;
  background: rgb(var(--sfh-scrim-rgb) / .58); border: 1px solid rgb(255 255 255 / .14);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  text-shadow: 0 1px 3px rgb(var(--sfh-scrim-rgb) / .85);
}

/* entrances: transform and opacity only, driven by --k (0..1). Unset --k = final state,
   so the static hero and the no-JS page show everything settled. */
.sfh-rise { opacity: var(--k, 1); transform: translateY(calc((1 - var(--k, 1)) * 1.25rem)); }
.sfh-rise-late {
  --kl: clamp(0, (var(--k, 1) - .45) * 2.2, 1);
  opacity: var(--kl); transform: translateY(calc((1 - var(--kl)) * 1rem));
}

.sfh-load {
  position: absolute; left: 0; right: 0; bottom: 0; height: 2px; pointer-events: none;
  background: currentColor; transform-origin: 0 50%; transform: scaleX(var(--load, 0));
  opacity: 0; transition: opacity .4s ease;
}
.sfh-skip { position: absolute; left: var(--sfh-gutter); top: -4rem; z-index: 3; }
.sfh-skip:focus-visible { top: 1rem; }

/* ---------- scrubbed hero ---------- */
html.sfh-scrub .sfh { height: var(--sfh-length); }
html.sfh-scrub .sfh-stage {
  position: sticky; top: 0; display: block; height: 100vh; min-height: 0; padding: 0;
}
html.sfh-scrub .sfh-scrim {
  background: radial-gradient(ellipse 120% 90% at 50% 45%, rgb(var(--sfh-scrim-rgb) / 0) 35%, rgb(var(--sfh-scrim-rgb) / .5) 100%);
}
html.sfh-scrub .sfh-band {
  position: absolute; inset: 0; display: grid;
  place-content: var(--sfh-place, end start);       /* where this band's text sits: set per band */
  padding: clamp(5rem, 14vh, 9rem) var(--sfh-gutter) clamp(3rem, 10vh, 6rem);
  pointer-events: none;
}
html.sfh-scrub .sfh-band + .sfh-band { opacity: 0; }  /* before the engine's first paint */
html.sfh-scrub .sfh-band.is-on > * { pointer-events: auto; }
html.sfh-scrub .sfh.has-film .sfh-video { opacity: 1; transition: opacity .5s ease; }
html.sfh-scrub .sfh.is-loading .sfh-load { opacity: .7; }

@media (max-height: 560px) { html.sfh-scrub .sfh-chip { display: none; } }  /* short window: no room for small overlays */
@media (prefers-reduced-motion: reduce) {
  .sfh-video, .sfh-load { transition: none !important; }
}
