/* ==========================================================================
   Home hero (.hero-home): the one screen that has to sell the visit.
   A light hero (data-nav-tone="light"): the scan room photo, unmirrored and graded to daylight, scanned in by the MDC
   scan line. Desktop: the copy stands on paper in the left column (over the cabinets, lamp and jars, which the paper
   covers) and the picture is laid out from the copy's right edge, so the patient and the whole scanner stand clear
   beside it; the picture's foot dissolves into the paper. Tablets and phones: the picture across the top, the copy
   under it. The ring lamp and the small globe are thrown out of focus, so the bore (locked on by the reticle) is the
   one object that reads. First screen: one headline, one line, two actions, one trust cue. The three numbers stand
   in a ruled band just below the first screen and count up there.
   The photo lives on a stage that keeps the picture's own 16:9 proportions, so everything on it (reticle, haze) is
   placed in picture coordinates and stays on its object at every crop.
   Every class here is namespaced .hh-* or scoped under .hero-home. Shared hero rules (load-in, split, stagger,
   the header contract) come from components.css (.hero-bleed).
   ========================================================================== */

.hero-home {
  /* desktop: the headline size, and the line where the copy column ends (its left edge + the headline's width + air).
     The picture is laid out from that line, so the patient's back starts just right of the copy at every width */
  --hh-fs: clamp(4.25rem, 2.5rem + 3.125vw, 7.5rem);    /* 80 @1280 · 100 @1920 */
  --hh-clear: calc(max(var(--gutter), (100cqw - var(--max)) / 2) + var(--hh-fs) * 5.82 + 20px);
  --hh-gap: 24px;          /* air between the bore's reticle and the right edge */
  /* the picture's width: as wide as it takes for the span from the patient's back (29% across the picture) to the
     scanner's outer edge (~92%) to fill the room right of the copy, but never shorter than 92% of the screen and never
     taller than the screen. (cq units resolve where these are used: on the stage and the veil, inside .hh-media) */
  --hh-w: min(max((100cqw - var(--hh-gap) - var(--hh-clear)) / 0.63, var(--hh-h) * 16 / 9 * 0.92), (var(--hh-h) + 16px) * 16 / 9);
  --hh-top: -16px;         /* a little spare picture above the screen's top edge, for the parallax drift */
  --hh-h: 100cqh;          /* how much of the first screen the photo may cover (phones and tablets: the top part) */
  --hh-veil-t: linear-gradient(180deg, color-mix(in srgb, var(--canvas) 34%, transparent) 0, transparent 140px);
  --hh-veil-b: linear-gradient(transparent, transparent);
  display: block;
  min-height: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--fg);
}

/* ---- the first screen ---- */
.hh-screen {
  position: relative;
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: var(--hero-h);
  padding: calc(var(--nav-h) + var(--space-10)) var(--gutter) clamp(2.5rem, 1.4rem + 3.6vw, 5.5rem);
}

/* ---- the photo stage: the picture in its own 16:9 box, so everything on it is placed in picture coordinates ---- */
.hero-home .hh-media { container-type: size; background: var(--canvas); }
/* an unclipped layer between the frame and the stage: it lets the stage drift on scroll (data-parallax) even though
   the picture is shorter than the screen (its foot dissolves into the paper, so no edge can show) */
.hh-drift { position: absolute; inset: 0; }
.hh-stage {
  position: absolute; z-index: 0; overflow: hidden;   /* the slow breathe stays inside the picture's own faded edges */
  width: var(--hh-w);
  height: calc(var(--hh-w) * 9 / 16);
  left: min(var(--hh-clear) - var(--hh-w) * 0.29, 100cqw - var(--hh-w) * 0.866 - var(--hh-gap));
  top: var(--hh-top);
}
.hh-stage > img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; max-width: none;
  object-fit: cover;
  filter: saturate(0.46) brightness(1.1) contrast(1.03);   /* the amber lamplight calmed to a clean daylight cream */
}
/* the ring lamp and the small globe beside her: thrown out of focus and bloomed into the room's light, so the scanner
   is the one object that reads (a box in picture coordinates around the lamps; it moves with the photo) */
.hh-haze {
  position: absolute; left: 47.5%; top: 2%; width: 20%; height: 48%; pointer-events: none;
  background:
    radial-gradient(ellipse 46% 36% at 46% 45%, color-mix(in srgb, var(--surface) 55%, transparent) 0, color-mix(in srgb, var(--surface) 42%, transparent) 60%, transparent 100%),
    radial-gradient(ellipse 21% 15.5% at 49.5% 83%, color-mix(in srgb, var(--surface) 45%, transparent) 0, transparent 100%);
  -webkit-backdrop-filter: blur(calc(var(--hh-w) * 0.009 + 4px)); backdrop-filter: blur(calc(var(--hh-w) * 0.009 + 4px));
  -webkit-mask: radial-gradient(ellipse 50% 50% at 54% 50%, var(--ink) 58%, transparent 100%);
  mask: radial-gradient(ellipse 50% 50% at 54% 50%, var(--ink) 58%, transparent 100%);
}
/* the picture's foot dissolves into the paper */
.hh-stage::after {
  content: ""; position: absolute; inset: -1px; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, transparent 65%, color-mix(in srgb, var(--canvas) 38%, transparent) 76%, color-mix(in srgb, var(--canvas) 80%, transparent) 87%, var(--canvas) 98%);
}
/* the paper column the copy stands on: it covers the picture's left part (cabinets, lamp, jars) and fades out right at
   the patient's back (--hh-clear), so she and the scanner stand clear. On a squarer screen, where the picture has to
   reach under the copy, it is what keeps the headline on paper */
.hh-veil {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, var(--canvas) 0, var(--canvas) calc(var(--hh-clear) - var(--hh-w) * 0.06), color-mix(in srgb, var(--canvas) 78%, transparent) calc(var(--hh-clear) - var(--hh-w) * 0.033), color-mix(in srgb, var(--canvas) 30%, transparent) calc(var(--hh-clear) - var(--hh-w) * 0.01), transparent calc(var(--hh-clear) + var(--hh-w) * 0.007));
}
/* the scanner, locked on: MDC reticle corners around the bore (picture coordinates, so it stays on the bore at every
   crop). They draw in as the scan line passes */
.hero-home .hh-lock {
  position: absolute; z-index: 2;
  left: 70.8%; top: 32.6%; width: 15.8%; height: 31.6%;
  --reticle-inset: 0px;
  --reticle-len: clamp(14px, 1.6cqw, 26px);
}
/* the reticle's caption: a small frosted label that names what is being read, hung from the bore's top-right corner */
.hh-tag {
  position: absolute; z-index: 3;
  right: 13.4%; bottom: calc(67.4% + var(--space-3));
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: 30px; padding: 0 var(--space-3) 0 10px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-xs);
  color: var(--ink-2);
  font-size: var(--fs-eyebrow); font-weight: var(--fw-ui); line-height: 1; white-space: nowrap;
}
.hh-tag .dot-live { width: 7px; height: 7px; }
@media (prefers-reduced-motion: no-preference) {
  html.js .hh-tag { transition: opacity var(--dur-4) var(--ease-out) 0.85s, translate var(--dur-4) var(--ease-out) 0.85s; }
  html.js .hh-stage:not(.is-in) .hh-tag { opacity: 0; translate: 0 8px; }
}
/* the scan line runs a little quicker on the first screen */
@media (prefers-reduced-motion: no-preference) {
  html.js .hero-home .hh-stage[data-reveal="scan"]:not(.is-done) { --reveal-dur: 900ms; }
  /* the haze settles with the photo (motion.css settles the img from 1.12 about its centre: 12.5% 100% in haze terms) */
  html.js .hh-stage:not(.is-done) > .hh-haze { transition: scale 1.6s var(--ease-out) var(--reveal-delay, 0ms); transform-origin: 12.5% 100%; }
  html.js .hh-stage:not(.is-in) > .hh-haze { scale: 1.12; }
}
/* once the scan has uncovered it, the photo breathes: a slow push-in and back (scale only, paused once the hero is
   gone, off for reduced motion), so the first screen is never a dead still */
@media (prefers-reduced-motion: no-preference) {
  html.js .hh-stage.is-done > :is(img, .hh-haze) { animation: hh-breathe 24s var(--ease-in-out) infinite alternate; transform-origin: 78.7% 48.4%; }   /* centred on the bore, so the reticle stays locked on it */
  html.js .hh-stage.is-done > .hh-haze { transform-origin: 156% 96.7%; }   /* the same point, in the haze box's own terms */
  html.past-hero .hh-stage > :is(img, .hh-haze) { animation-play-state: paused; }
}
@keyframes hh-breathe { from { scale: 1; } to { scale: 1.035; } }

/* the paper veils (replace the shared dark scrims): only a light lift under the header */
.hero-home .hh-media::after { background: var(--hh-veil-t), var(--hh-veil-b); }
.hero-home .hh-media::before { opacity: 0.1; }

/* ---- the copy ---- */
.hh-copy { position: relative; z-index: 1; }
.hero-home .display-1 { max-width: 13ch; line-height: 0.98; font-size: var(--hh-fs); }
.hero-home .display-1 em { white-space: nowrap; }
.hero-home .lede { max-width: 36ch; color: var(--fg-2); }

/* trust: the clinicians who read the results, as a small stack of faces */
.hh-trust {
  display: flex; align-items: center; gap: var(--space-3);
  margin-top: var(--space-7);
}
.hh-trust p { font-size: var(--fs-small); font-weight: var(--fw-ui); line-height: 1.35; color: var(--fg-2); }
.hh-faces { display: flex; flex: 0 0 auto; }
.hh-face {
  --face: 36px;
  position: relative; display: block; overflow: hidden;
  width: var(--face); height: var(--face);
  border-radius: 50%;
  background: var(--canvas-2);
  box-shadow: 0 0 0 2px var(--canvas);
}
.hh-face + .hh-face { margin-left: -10px; }
.hh-face > img {
  position: absolute; max-width: none; height: auto;
  width: calc(var(--face) * var(--iw) / var(--box));
  left: calc(var(--face) / 2 - var(--face) * var(--cx) / var(--box));
  top: calc(var(--face) / 2 - var(--face) * var(--cy) / var(--box));
}
.hh-face-1 { --iw: 1280; --box: 130; --cx: 390; --cy: 294; }
.hh-face-2 { --iw: 928; --box: 520; --cx: 492; --cy: 452; }
.hh-face-3 { --iw: 1280; --box: 150; --cx: 604; --cy: 166; }

/* ---- the numbers: a ruled band just below the first screen ---- */
.hh-band { padding: 0 var(--gutter); }
.hh-stats {
  --stat-cols: 3;
  gap: var(--space-6);
  padding: var(--space-8) 0 var(--space-9);
  border-top: 1px solid var(--rule);
}
.hh-stats .stat-label { max-width: 22ch; font-size: var(--fs-card); }

/* ---- tablets and phones: the photo across the top, the copy below it on the paper ---- */
@media (max-width: 980px) {
  .hero-home {
    /* sized off the first screen (not the section), so a short screen that grows the hero never grows the photo */
    --hh-h: calc(var(--hero-h) * 0.66); --hh-fx: 0.69;
    --hh-w: max(100cqw, var(--hh-h) * 16 / 9);
    --hh-veil-b: linear-gradient(180deg, transparent calc(var(--hero-h) * 0.48), color-mix(in srgb, var(--canvas) 55%, transparent) calc(var(--hero-h) * 0.55), var(--canvas) calc(var(--hero-h) * 0.61));
  }
  /* the photo across the top, aimed by --hh-fx, but pulled further left if that is what it takes to keep the whole bore
     (and its reticle, whose right edge is 86.6% across the picture) on screen */
  .hh-stage { left: max(100cqw - var(--hh-w), min((100cqw - var(--hh-w)) * var(--hh-fx), 100cqw - var(--hh-w) * 0.866 - var(--hh-gap))); }
  .hh-stage::after, .hh-veil { content: none; display: none; }
  /* the copy never starts above the photo's faded foot: on a short screen the hero grows instead */
  .hh-screen { padding-top: calc(var(--hero-h) * 0.58); }
}
/* tablets: the copy has the whole width under the photo, so the headline takes a bigger step (72px at 768) */
@media (min-width: 641px) and (max-width: 980px) {
  .hero-home { --hh-fs: calc(2.7rem + 3.77vw); }
  /* the copy is one centred poster block under the photo: no lopsided empty half */
  .hh-copy { display: flex; flex-direction: column; align-items: center; text-align: center; }
  .hero-home .hh-copy .lede { margin-inline: auto; }
  .hero-home .hero-actions, .hh-trust { justify-content: center; }
}
@media (max-width: 640px) {
  .hero-home { --hh-fs: var(--fs-display-1); }
}
@media (max-width: 640px) {
  /* phones: the photo is framed on the patient's profile and the whole bore, and starts just under the header capsule
     (paper behind the capsule), so nothing that matters sits under it */
  .hero-home {
    --hh-h: calc(var(--hero-h) * 0.5); --hh-top: calc(var(--hero-h) * 0.05 - 14px); --hh-fx: 0.77; --hh-gap: 16px;
    --hh-veil-t: linear-gradient(180deg, var(--canvas) calc(var(--hero-h) * 0.05), transparent calc(var(--hero-h) * 0.13));
    --hh-veil-b: linear-gradient(180deg, transparent calc(var(--hero-h) * 0.41), color-mix(in srgb, var(--canvas) 55%, transparent) calc(var(--hero-h) * 0.49), var(--canvas) calc(var(--hero-h) * 0.55));
  }
  .hh-screen { padding-top: calc(var(--hero-h) * 0.53); padding-bottom: var(--space-7); }
  .hero-home .hero-actions { margin-top: var(--space-7); gap: var(--space-2); }   /* side by side at 390; the second wraps under on narrower phones */
  .hero-home .hero-actions .btn { --btn-h: 52px; --btn-px: 20px; --btn-fs: 0.9375rem; }
  .hh-sm-hide { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: clip; clip-path: inset(50%); white-space: normal; }   /* as .sr-only: the name stays "Open the pain map" */
  .hh-cap { display: inline-block; }
  .hh-cap::first-letter { text-transform: uppercase; }
  .hh-trust { margin-top: var(--space-6); }
  .hh-face { --face: 32px; }
  .hh-stats { --stat-cols: 3; gap: var(--space-3); padding: var(--space-6) 0 var(--space-7); }
  .hh-stats > .stat + .stat { border-left: 1px solid var(--rule); border-top: 0; padding-top: 0; padding-left: var(--space-3); }
  .hh-stats .stat-value { font-size: var(--fs-h2); }
  .hh-stats .stat-label { font-size: var(--fs-eyebrow); }
}
