/* ==========================================================================
   Scan hero (src/sections/scan/hero.html). Everything here is scoped under .scan-hero.

   A light photo hero (data-nav-tone="light"): a woman seen from behind, head and both shoulders in warm bokeh
   (hero-tight). Where the wellness hero uses the same sitting dark and tight on her head, here she is bright and whole,
   set right of the copy, and she opens onto the paper on the copy's side and at her waist (a clean paper wash, no blur),
   so the copy reads as paper (ink, the teal italic) and the header is ink at rest.
   The scanner signature, in one short load-in: a luminous line reads her top to bottom, the pain shows as a teal contour
   field on the top of her shoulder, a reticle locks onto it, then a live pin draws a leader to its readout (up into the
   bokeh beside her head on desktops, down onto the paper on phones and portrait tablets). The readout is a real link:
   it opens Neck & shoulders on the pain map (scan.js, data-route).

   Geometry: .scan-hero-media is a size container. Each .scan-hero-frame is the photo's own 16:9 box, --sh-h tall, placed
   so her spine (51% across the photo) stands at --sh-x on screen (never leaving the hero's right edge uncovered). The
   photo frame sits under the paper wash (.hero-media::after), the overlay frame (field + lock + pin) above it; both
   carry the same data-parallax, so they move as one, and everything placed in PHOTO coordinates (--sh-px / --sh-py)
   stays on her shoulder at every width.
   ========================================================================== */
.scan-hero {
  --sh-h: max(106cqh, 56.25cqw);   /* the photo's height: the hero's height + parallax room, and always full width */
  --sh-x: 66cqw;                   /* where her spine stands on screen */
  --sh-top: calc((100cqh - var(--sh-h)) / 2);
  --sh-px: 58.6%;                  /* the pain point on the photo: the top of her left shoulder, beside the neck */
  --sh-py: 58.5%;
  --sh-lock: clamp(112px, 5.5rem + 5vw, 208px);
  --sh-lead: calc(var(--sh-lock) / 2 + var(--space-3));
  --sh-heat: calc(var(--sh-lock) * 3.1);            /* the pain field: an ellipse along the shoulder line */
  --sh-tilt: 21deg;                                 /* the slope of her shoulder */
  --sh-ring: 12px;                                  /* the field's contour spacing */
  --sh-chip-x: calc(50% - 26px);                    /* the readout's left edge sits just left of the pin */
  --sh-wash: var(--canvas);
  min-height: var(--hero-h);
  background: var(--canvas);
  color: var(--fg);
}

/* ---- the photo and its two frames ---- */
.scan-hero .scan-hero-media { container-type: size; }
.scan-hero .scan-hero-frame {
  position: absolute;
  height: var(--sh-h);
  width: calc(var(--sh-h) * 16 / 9);
  left: max(calc(100cqw - var(--sh-h) * 16 / 9), calc(var(--sh-x) - var(--sh-h) * 16 / 9 * 0.51));
  top: var(--sh-top);
}
.scan-hero .scan-hero-frame > img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  max-width: none;
  object-fit: cover;
  filter: brightness(1.06) saturate(0.94) contrast(0.98);
  /* the photo's own left edge dissolves (it lies under the paper on desktops; off screen on phones), so no seam shows */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%);
  mask-image: linear-gradient(90deg, transparent, #000 14%);
}
.scan-hero .scan-hero-over { z-index: 3; pointer-events: none; }

/* the paper wash: the canvas behind the copy and under her waist, opening onto the full photo round her head and
   shoulders (no blur: the photo stays in focus wherever it shows) */
.scan-hero .scan-hero-media::after {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--sh-wash) 0%, transparent) 64%,
      color-mix(in srgb, var(--sh-wash) 58%, transparent) 81%,
      color-mix(in srgb, var(--sh-wash) 90%, transparent) 93%,
      var(--sh-wash) 100%),
    linear-gradient(90deg,
      var(--sh-wash) 0%,
      color-mix(in srgb, var(--sh-wash) 96%, transparent) 30%,
      color-mix(in srgb, var(--sh-wash) 90%, transparent) 42%,
      color-mix(in srgb, var(--sh-wash) 62%, transparent) 50%,
      color-mix(in srgb, var(--sh-wash) 20%, transparent) 58%,
      color-mix(in srgb, var(--sh-wash) 0%, transparent) 65%);
}
.scan-hero .scan-hero-media::before { opacity: 0.12; }

/* ---- the reading: one luminous line passes down the photo as the page opens (load-in only, then gone) ---- */
/* (the frame stays put and carries the fade-out mask; its ::before is the moving line) */
.scan-hero .scan-hero-sweep {
  position: absolute; inset: 0; z-index: 3;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 34%, #000 58%);
  mask-image: linear-gradient(90deg, transparent 34%, #000 58%);
}
.scan-hero .scan-hero-sweep::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--halo-faint) calc(100% - 96px), color-mix(in srgb, var(--teal-400) 11%, transparent) calc(100% - 3px), var(--teal-400) calc(100% - 2px), var(--teal-400) 100%);
  translate: 0 -100%;
  opacity: 0;
}

/* ---- the pain field: contour lines radiating from the point that hurts (an ellipse along the shoulder line), a soft
       teal glow under them and, once the page is in, a slow ping that travels out through them ---- */
.scan-hero .scan-hero-heat {
  position: absolute;
  left: var(--sh-px); top: var(--sh-py);
  width: var(--sh-heat); height: calc(var(--sh-heat) * 0.6);
  margin: calc(var(--sh-heat) * -0.3) 0 0 calc(var(--sh-heat) * -0.5);
  rotate: var(--sh-tilt);
  pointer-events: none;
}
.scan-hero .scan-hero-heat > i { position: absolute; inset: 0; border-radius: 50%; }
.scan-hero .scan-hero-heat > i:nth-child(1) {
  background: radial-gradient(closest-side, color-mix(in srgb, var(--teal-400) 34%, transparent), color-mix(in srgb, var(--teal-400) 12%, transparent) 55%, transparent);
}
.scan-hero .scan-hero-heat > i:nth-child(2) {
  background: repeating-radial-gradient(closest-side, transparent 0 calc(var(--sh-ring) - 1.25px), color-mix(in srgb, var(--teal-300) 90%, transparent) calc(var(--sh-ring) - 1.25px) var(--sh-ring));
  -webkit-mask-image: radial-gradient(closest-side, #000 18%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 18%, transparent 100%);
}
.scan-hero .scan-hero-heat > i:nth-child(3) {
  border: 1.5px solid var(--teal-300);
  opacity: 0;
}

/* ---- the lock: reticle corners round the pain point (they lock in as it fades up) ---- */
.scan-hero .scan-hero-lock {
  position: absolute;
  left: var(--sh-px); top: var(--sh-py);
  width: var(--sh-lock); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  --reticle-color: var(--reticle-light);
  --reticle-inset: 0px;
  --reticle-len: clamp(16px, 0.8rem + 0.6vw, 26px);
}

/* ---- the pin: a dot on the shoulder, a leader, the readout chip (one link). Desktops: the leader rises from the dot
       and the readout floats in the bokeh beside her head ---- */
.scan-hero .scan-hero-pin {
  position: absolute;
  left: var(--sh-px); top: var(--sh-py);
  display: flex; flex-direction: column-reverse; align-items: center;
  transform: translate(-50%, calc(-100% + 9px));
  pointer-events: auto;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--r-pill);
}
.scan-hero .scan-hero-dot {
  position: relative;
  width: 18px; height: 18px; flex: 0 0 auto;
  border-radius: 50%;
  background: var(--teal-400);
  box-shadow: 0 0 0 3px var(--surface), var(--shadow-sm);
}
.scan-hero .scan-hero-dot::after {
  content: ""; position: absolute; inset: -3px;
  border-radius: 50%;
  border: 1.5px solid var(--surface);
  opacity: 0;
}
.scan-hero .scan-hero-lead {
  width: 1.5px; height: var(--sh-lead); flex: 0 0 auto;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transform-origin: center bottom;
}
.scan-hero .scan-hero-chip {
  display: flex; align-items: stretch;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-md);
  translate: var(--sh-chip-x) 0;
}
.scan-hero .scan-hero-read {
  display: grid; gap: 2px; align-content: center;
  padding: 10px 16px 10px 22px;
  border-radius: var(--r-pill) 0 0 var(--r-pill);
  background: var(--glass-light);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  white-space: nowrap;
}
.scan-hero .scan-hero-read-k { font-size: var(--fs-small); font-weight: var(--fw-ui); line-height: 1.25; color: var(--ink); }
.scan-hero .scan-hero-read-v { font-size: var(--fs-eyebrow); line-height: 1.3; color: var(--ink-2); }
.scan-hero .scan-hero-go {
  display: grid; place-items: center;
  width: 52px; min-height: 52px;
  border-radius: 0 var(--r-pill) var(--r-pill) 0;
  background: var(--accent); color: var(--on-accent);
  transition: background-color var(--dur-2) var(--ease-out);
}
.scan-hero .scan-hero-go .icon-arrow { width: 16px; height: 16px; transition: translate var(--dur-2) var(--ease-out); }
.scan-hero .scan-hero-pin:focus-visible { outline: 2px solid var(--ring-color); outline-offset: 4px; }
@media (hover: hover) {
  .scan-hero .scan-hero-pin:hover .scan-hero-go { background: var(--accent-hover); }
  .scan-hero .scan-hero-pin:hover .scan-hero-go .icon-arrow { translate: 3px 0; }
}

/* ---- the copy ---- */
.scan-hero .scan-hero-copy { display: grid; justify-items: start; }
.scan-hero .scan-hero-copy h1 { max-width: none; font-size: var(--fs-display-1); line-height: 0.98; }
.scan-hero .scan-hero-line { display: block; }
.scan-hero .eyebrow { margin-bottom: var(--space-6); }
.scan-hero .lede { margin-top: var(--space-6); max-width: 36ch; }

/* the CTA and the old lede's two facts share one row (Function's action + stat row, set quietly) */
.scan-hero .scan-hero-foot {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--space-6) var(--space-9);
  margin-top: var(--space-8);
}
.scan-hero .scan-hero-facts {
  display: grid; grid-template-columns: repeat(2, minmax(0, max-content));
  list-style: none; margin: 0; padding: 0;
}
.scan-hero .scan-hero-facts li {
  display: grid; gap: 2px; align-content: start;
  padding: 0 var(--space-7);
  border-left: 1px solid var(--rule-2);
}
.scan-hero .scan-hero-facts li:first-child { padding-left: 0; border-left: 0; }
.scan-hero .scan-hero-facts b { font-size: var(--fs-body); font-weight: var(--fw-ui); color: var(--fg); line-height: 1.35; }
.scan-hero .scan-hero-facts span { font-size: var(--fs-small); color: var(--fg-2); line-height: 1.45; max-width: 25ch; }

/* ---- load-in: the line reads her, the field blooms, the lock is read, the dot lands, the leader draws and the
       readout slides in. All of it is over by ~2.2s; reduced motion / no JS: everything simply shows ---- */
@media (prefers-reduced-motion: no-preference) {
  html.js .scan-hero .scan-hero-sweep.is-in::before { animation: scan-hero-sweep 1.5s var(--ease-in-out) both; }
  html.js .scan-hero .scan-hero-heat:not(.is-done) { --reveal-dur: 1200ms; }
  html.js .scan-hero .scan-hero-heat:not(.is-in) { scale: 0.5; }
  html.js .scan-hero .scan-hero-heat > i:nth-child(3) { animation: scan-hero-wave 3.6s var(--ease-out) 2.3s infinite; }
  html.js .scan-hero .scan-hero-pin:not(.is-in) .scan-hero-dot { scale: 0; }
  html.js .scan-hero .scan-hero-pin:not(.is-in) .scan-hero-lead { scale: 1 0; }
  html.js .scan-hero .scan-hero-pin:not(.is-in) .scan-hero-chip { opacity: 0; translate: var(--sh-chip-x) 8px; }
  html.js .scan-hero .scan-hero-pin:not(.is-done) .scan-hero-dot { transition: scale 0.5s var(--ease-spring) 1.1s; }
  html.js .scan-hero .scan-hero-pin:not(.is-done) .scan-hero-lead { transition: scale 0.5s var(--ease-out) 1.3s; }
  html.js .scan-hero .scan-hero-pin:not(.is-done) .scan-hero-chip { transition: opacity 0.45s var(--ease-out) 1.5s, translate 0.55s var(--ease-out) 1.5s; }
  .scan-hero .scan-hero-dot::after { animation: scan-hero-ping 3.6s var(--ease-out) 2.3s infinite; }
}
@keyframes scan-hero-sweep {
  0% { translate: 0 -100%; opacity: 1; }
  82% { opacity: 1; }
  100% { translate: 0 0; opacity: 0; }
}
@keyframes scan-hero-wave {
  0% { opacity: 0.9; scale: 0.08; }
  75%, 100% { opacity: 0; scale: 1; }
}
@keyframes scan-hero-ping {
  0% { opacity: 0.9; scale: 1; }
  70%, 100% { opacity: 0; scale: 2.6; }
}

/* wide screens: the readout grows with the type */
@media (min-width: 1700px) {
  .scan-hero { --sh-ring: 14px; --sh-x: 71.5cqw; }
  .scan-hero .scan-hero-read { padding: 12px 18px 12px 26px; }
  .scan-hero .scan-hero-read-k { font-size: var(--fs-body); }
  .scan-hero .scan-hero-read-v { font-size: var(--fs-small); }
  .scan-hero .scan-hero-go { width: 60px; min-height: 60px; }
}

/* ---- portrait screens below the desktop header (phones, tablets, an iPad Pro upright) and every phone: she stands in a band of photo across the top, centred, the header capsule on the
       paper above her head, and fades into the paper the copy sits on. The band is capped by the screen's height, and
       the copy always starts at the band's foot (padding-top), so the pin and the copy can never meet. The readout
       hangs below the lock, centred on the screen ---- */
@media (max-width: 640px), (max-width: 1279px) and (orientation: portrait) {
  .scan-hero {
    --sh-band: min(140cqw, max(100svh - 310px, 380px), 600px);
    --sh-h: var(--sh-band);
    --sh-x: 50cqw;
    --sh-top: 36px;
    --sh-lock: 112px;
    --sh-lead: calc(var(--sh-lock) / 2 + var(--space-2));
    --sh-chip-x: calc(var(--sh-band) * 16 / 9 * -0.076);
    padding-top: calc(36px + min(140vw, max(100svh - 310px, 380px), 600px) - var(--space-8));
  }
  .scan-hero .scan-hero-frame { left: calc(var(--sh-x) - var(--sh-h) * 16 / 9 * 0.51); }
  .scan-hero .scan-hero-media::after {
    background: linear-gradient(180deg,
      var(--sh-wash) 0,
      var(--sh-wash) calc(var(--sh-top) - 1px),
      color-mix(in srgb, var(--sh-wash) 0%, transparent) calc(var(--sh-top) + 28px),
      color-mix(in srgb, var(--sh-wash) 0%, transparent) calc(var(--sh-top) + var(--sh-band) - 200px),
      color-mix(in srgb, var(--sh-wash) 72%, transparent) calc(var(--sh-top) + var(--sh-band) - 80px),
      var(--sh-wash) calc(var(--sh-top) + var(--sh-band)));
  }
  .scan-hero .scan-hero-sweep {          /* the line reads the photo, not the paper below it */
    top: var(--sh-top); bottom: auto; height: calc(var(--sh-band) - 60px);
    -webkit-mask-image: linear-gradient(180deg, #000 72%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 72%, transparent 100%);
  }
  .scan-hero .scan-hero-pin { flex-direction: column; transform: translate(-50%, -9px); }
  .scan-hero .scan-hero-lead { transform-origin: center top; }
  .scan-hero .scan-hero-foot { row-gap: var(--space-8); }
  @media (prefers-reduced-motion: no-preference) {
    html.js .scan-hero .scan-hero-pin:not(.is-in) .scan-hero-chip { translate: var(--sh-chip-x) -8px; }
  }
}
@media (max-width: 1279px) and (min-width: 641px) and (orientation: portrait) {
  .scan-hero { --sh-top: 48px; --sh-band: min(80cqw, max(100svh - 484px, 420px), 680px); padding-top: calc(48px + min(80vw, max(100svh - 484px, 420px), 680px) - var(--space-9)); }
  .scan-hero .scan-hero-foot { row-gap: var(--space-9); }
  .scan-hero .scan-hero-facts { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* portrait tablets and phones: the two facts close the hero as a ruled row across the copy's full width */
@media (max-width: 640px), (max-width: 1279px) and (orientation: portrait) {
  .scan-hero .scan-hero-foot { justify-self: stretch; }
  .scan-hero .scan-hero-facts { border-top: 1px solid var(--rule-2); padding-top: var(--space-5); }
}
/* phones: a tighter lock and readout; the hero runs a little past the first screen, so the first screen holds the photo,
   the headline, the lede and the action; the two facts follow just below it */
@media (max-width: 640px) {
  .scan-hero {
    --sh-lock: 96px;
    --sh-ring: 10px;
    min-height: calc(var(--hero-h) + 128px);
  }
  .scan-hero .scan-hero-go { width: 48px; min-height: 48px; }
  .scan-hero .scan-hero-copy h1 { font-size: var(--fs-display-page); line-height: 1; }
  .scan-hero .eyebrow { margin-bottom: var(--space-4); }
  .scan-hero .lede { margin-top: var(--space-4); }
  .scan-hero .scan-hero-foot { margin-top: var(--space-7); gap: var(--space-11); }   /* the facts start just below the first screen */
  .scan-hero .scan-hero-facts { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scan-hero .scan-hero-facts li { padding: 0 var(--space-4); }
  .scan-hero .scan-hero-facts li:first-child { padding-left: 0; }
  .scan-hero .scan-hero-facts b { font-size: var(--fs-small); }
}
/* short landscape screens (a phone on its side): the hero keeps enough height for the copy to sit below the lock */
@media (orientation: landscape) and (max-height: 540px) and (min-width: 641px) and (max-width: 1279px) {
  .scan-hero { min-height: 760px; }
}
