/* ==========================================================================
   Scan body (src/sections/scan/body.html). The hero is styled only in scan-hero.css.
   1. section head  2. the instrument: body map + readout in one white card  3. the routes: seven light cards, each a
   warm-graded clinic photo over its copy, + a ruled red-flags line  4. the visit: a night panel (the page's one dark
   moment), a portrait consult photo as tall as the three ruled steps beside it, whose numerals light up in turn
   Breakpoints: <=640 phone, <=980 tablet (the instrument and the visit stack), >=981 desktop.
   ========================================================================== */

/* ---------- 1. Section heads: heading left, lede right (desktop). The lede's left edge is the readout's text edge ---------- */
:is(.pain-head, .routes-head) { display: grid; gap: var(--space-5) 0; }
:is(.pain-head, .routes-head) .lede { margin: 0; }
@media (min-width: 981px) {
  :is(.pain-head, .routes-head) { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: end; }
  :is(.pain-head, .routes-head) .lede { padding-left: var(--panel-pad); max-width: calc(40ch + var(--panel-pad)); padding-bottom: 0.35em; }
}

/* ---------- 2. The instrument ----------
   One white card on the butter field: the map flush in its left 7/12, the readout in its right 5/12.
   Every region's copy shares one grid cell, so the readout is always as tall as its longest region: the map (which
   stretches to the readout's height), the pins, the button and the note never move when the region changes. */
.pain-instrument {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  background: var(--card-bg, var(--surface));
  border-radius: var(--r-lg);
}

.body-map {
  position: relative;
  min-width: 0;
  min-height: 560px;
  overflow: hidden;
  isolation: isolate;
  background: var(--mist);
  border-radius: var(--r-lg) 0 0 var(--r-lg);
  /* the reticle frames the map 16px in (clear of the 24px corner curve); the edge markers sit as far inside the
     brackets as the brackets sit inside the frame */
  --reticle-inset: 16px;
  --reticle-len: 22px;
  --map-chip-inset: 32px;
}
/* the stage keeps the render's own 4:3 shape at the map's full height and sits centred, so a pin placed as a
   percentage of the stage lands on the same anatomy whatever the map's width or height */
.map-stage {
  position: absolute; top: 0; left: 50%;
  height: 100%;
  aspect-ratio: 1152 / 864;
  translate: -50% 0;
}
/* the render is graded to one teal: a part-grey base under a colour wash, so it reads as a monochrome scan on a light
   box (like the scan on the consult screen below), not a glossy stock illustration. The wash also turns the render's
   three small rainbow lens flares (chest wall, forearm, thigh) back into the body's own teal */
.map-stage img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center top;
  filter: grayscale(0.55) contrast(1.08) brightness(1.03);
}
.map-tone {
  position: absolute; inset: 0; pointer-events: none;
  mix-blend-mode: color;
  background: var(--teal-600);
  opacity: 0.35;
}
/* the light box: a fine graticule (a 48px grid with a stronger line every fourth) and film grain over the render,
   fading out over the body, so the frame reads as an instrument being read. Painted under the pins */
.map-grid {
  position: absolute; inset: 0; pointer-events: none;
  background:
    var(--grain),
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 48px 48px;
  mix-blend-mode: multiply;
  opacity: 0.9;
  -webkit-mask: radial-gradient(34% 58% at 52% 46%, transparent 0, transparent 40%, var(--ink) 100%);
  mask: radial-gradient(34% 58% at 52% 46%, transparent 0, transparent 40%, var(--ink) 100%);
}

/* pins: a 44px button, a 20px dot, a label that is part of the button, and a slow sonar ping on the chosen one */
.body-map .pin {
  position: absolute;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: transparent; border: 0;
  cursor: pointer;
  translate: -50% -50%;
  display: grid; place-items: center;
  isolation: isolate;                  /* the ping sits under the dot, inside the pin */
}
.body-map .pin::before {
  content: "";
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--teal-600);
  box-shadow: var(--shadow-sm);
  transition: scale var(--dur-2) var(--ease-spring), background-color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
.pin-pulse {
  position: absolute; left: 50%; top: 50%; z-index: -1;
  width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border-radius: 50%;
  background: var(--teal-400);
  opacity: 0;
  pointer-events: none;
}
@media (hover: hover) { .body-map .pin:hover::before { scale: 1.2; } }
.body-map .pin:focus-visible::before { scale: 1.2; }
.body-map .pin.hot::before { background: var(--teal-600); border-color: var(--surface); scale: 1.2; box-shadow: var(--halo), var(--shadow-sm); }
@media (prefers-reduced-motion: no-preference) {
  .body-map .pin.hot .pin-pulse { animation: pin-ping 2.6s var(--ease-out) infinite; }
}
@keyframes pin-ping {
  0% { opacity: 0.55; scale: 1; }
  70%, 100% { opacity: 0; scale: 3; }
}

/* one label face for every marker on the map (pin labels, the head and leg tabs): a white pill, ink text */
.body-map .pin::after,
.map-edge {
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sm);
  font-size: var(--fs-eyebrow); font-weight: var(--fw-ui); letter-spacing: 0.01em;
  border-radius: var(--r-pill); white-space: nowrap;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out), box-shadow var(--dur-3) var(--ease-out), translate var(--dur-3) var(--ease-out);
}
/* pin label: always shown, always on the pin's right, so no dot is anonymous and every label reads the same way */
.body-map .pin::after {
  content: attr(aria-label);
  position: absolute; left: calc(100% - 10px); top: 50%;
  translate: 0 -50%;
  padding: 0 12px; min-height: 30px; display: inline-flex; align-items: center;
  cursor: pointer;                     /* the label is part of the button: a tap on the word chooses the region */
}
@media (hover: hover) { .body-map .pin:not(.hot):hover::after { box-shadow: var(--shadow-md); } }
.body-map .pin.hot::after { background: var(--ink); color: var(--surface); }
.body-map .pin:focus-visible { outline-offset: -2px; }

/* pin positions, % of the 4:3 render: on the throat, the sternum, the small bowel and the outer hip */
.pin-neck { left: 55.5%; top: 8%; }
.pin-chest { left: 53%; top: 27%; }
.pin-abdomen { left: 54%; top: 58%; }
.pin-hip { left: 40.5%; top: 73%; }

/* head and leg: outside this view, so each is a tab on the frame that points the way (up to the head, down to the knee) */
.map-edge {
  position: absolute; left: var(--map-chip-inset); z-index: 4;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 16px 0 12px;
  border: 0;
  cursor: pointer;
}
.map-head { top: var(--map-chip-inset); }
.map-leg { bottom: var(--map-chip-inset); }
.map-edge svg { width: 16px; height: 16px; color: var(--teal-600); transition: translate var(--dur-3) var(--ease-out), color var(--dur-2) var(--ease-out); }
.map-edge.on { background: var(--ink); color: var(--surface); }
.map-edge.on svg { color: var(--teal-300); }

/* lower back: behind this view, so it gets its own rear-view inset with a pin on the lumbar spine */
.map-back {
  position: absolute; right: var(--map-chip-inset); bottom: var(--map-chip-inset); z-index: 4;
  display: grid; gap: 6px; justify-items: center;
  width: clamp(108px, 22%, 156px);
  padding: 6px 6px 8px;
  border-radius: var(--r-sm);
  background: var(--surface); border: 0;
  box-shadow: var(--shadow-sm);
  color: var(--ink); font-size: var(--fs-eyebrow); font-weight: var(--fw-ui); line-height: 1.2; text-align: center;
  cursor: pointer;
  transition: box-shadow var(--dur-3) var(--ease-out), translate var(--dur-3) var(--ease-out);
}
.map-back-photo { position: relative; display: block; width: 100%; aspect-ratio: 1; border-radius: calc(var(--r-sm) - 6px); overflow: hidden; background: var(--mist); }
.map-back-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; scale: 1.25; filter: grayscale(0.4) contrast(1.06); transition: scale var(--dur-4) var(--ease-out); }
.map-back-photo i {
  position: absolute; left: 50%; top: 52%; translate: -50% -50%;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--teal-600);
  box-shadow: var(--shadow-sm);
  transition: background-color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}
.map-back-label small { display: block; font-size: var(--fs-eyebrow); font-weight: 400; color: var(--ink-3); }
.map-back.on { box-shadow: inset 0 0 0 2px var(--teal-500), var(--shadow-md); }
.map-back.on .map-back-photo i { background: var(--teal-600); border-color: var(--surface); box-shadow: var(--halo); }
.map-edge:focus-visible, .map-back:focus-visible { outline-offset: 3px; }

/* the tabs and the rear-view inset answer the pointer like every other trigger on the map */
@media (hover: hover) {
  .map-edge:hover { box-shadow: var(--shadow-md); translate: 0 -2px; }
  .map-head:not(.on):hover svg { translate: 0 -2px; }
  .map-leg:not(.on):hover svg { translate: 0 2px; }
  .map-back:hover { translate: 0 -3px; }
  .map-back:not(.on):hover { box-shadow: var(--shadow-md); }
  .map-back:hover .map-back-photo img { scale: 1.34; }
}
.map-edge:active, .map-back:active { translate: 0 0; transition-duration: var(--dur-1); }

/* ---------- the readout ---------- */
.pain-panel { min-width: 0; display: flex; flex-direction: column; padding: var(--panel-pad); }
.pain-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
.pain-meta .eyebrow { margin: 0; }
.pain-count { font-size: var(--fs-small); color: var(--ink-3); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.pain-count span { color: var(--ink); font-weight: var(--fw-ui); }
/* four chips, a forced break, then three: no chip is ever left alone on a row */
.pain-panel .chips { padding-bottom: var(--space-7); border-bottom: 1px solid var(--line); }
.pain-panel .chip { padding: 0 16px; }
.chip-break { flex-basis: 100%; height: 0; margin-bottom: calc(-1 * var(--space-2)); }

/* every region (name, copy and its next step) sits in the same grid cell; only the chosen one is visible. The cell is
   as tall as the longest region, and a short region's spare room falls below its next step, never inside it */
.pain-readout { display: grid; padding-top: var(--space-7); }
.pain-readout > .pain-variant { grid-area: 1 / 1; min-width: 0; }
.pain-variant:not(.is-active) { visibility: hidden; opacity: 0; pointer-events: none; }
.pain-name {
  font-size: var(--fs-quote);
  font-weight: var(--fw-display);
  line-height: 1.02;
  letter-spacing: var(--tracking-display-2);
}
.pain-variant p { margin-top: var(--space-4); max-width: 44ch; color: var(--ink-2); font-size: var(--fs-body); line-height: 1.6; }
.pain-variant .pain-next { margin-top: var(--space-6); display: grid; gap: var(--space-1); line-height: 1.3; }
.pain-next span { font-size: var(--fs-small); color: var(--ink-3); }
.pain-spec { font-family: var(--font-display); font-weight: var(--fw-title); font-size: var(--fs-title); line-height: 1.25; letter-spacing: -0.01em; color: var(--teal-800); }
.pain-cta { align-self: flex-start; margin-top: var(--space-7); }
.pain-panel .disclaimer {
  margin-top: var(--space-6);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--r-sm);
  background: var(--card-badge, var(--tint));      /* the inset tone: tint on the white card */
  font-size: var(--fs-small); line-height: 1.5; color: var(--ink-2);
}
/* a newly chosen region settles in (opacity + a short rise) */
@media (prefers-reduced-motion: no-preference) {
  html.js .pain-variant.is-active { animation: pain-in var(--dur-3) var(--ease-out) both; }
}
@keyframes pain-in { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }

/* the map card is the #assess target: it lands with a solid teal ring that grows and lets go (a see-through teal
   halo over the butter field reads olive, so the ring is opaque and only its width animates; a mouse click on a
   route card must not leave the whole card ringed) */
.pain-instrument.is-target-flash { animation: instrument-flash 2.2s var(--ease-out) both; }
.pain-instrument:focus { outline: none; }
.pain-instrument:focus-visible { outline: 2px solid var(--ring-color); outline-offset: 3px; }
@keyframes instrument-flash {
  0%   { box-shadow: 0 0 0 0 var(--teal-500); }
  22%  { box-shadow: 0 0 0 3px var(--teal-500); }
  100% { box-shadow: 0 0 0 0 var(--teal-500); }
}
@media (prefers-reduced-motion: reduce) { .pain-instrument.is-target-flash { animation: none; box-shadow: none; } }

/* ---------- 3. The routes: seven light cards (Neko's calm photos, Function's numbered index) ----------
   Each card is a tint card on the canvas: one clinic photo across its top (all seven share one warm grade, so they read
   as one shoot; no scrim, the photos stay bright), then on the card face the region's number in the seven with a
   hairline and an arrow, its name, the first check and who reads it. The whole card is one link (it covers the card).
   The region open on the map wears white reticle corners on its photo, an "On your map" tag and a teal number.
   Head & face leads across two columns. >= 1101: four across (the lead + two, then four) · 641-1100: three across
   (the lead alone, then two rows of three) · <= 640: two across (the lead, then pairs). */
.routes {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  /* each card spans five rows (photo, number, name, first check, who) and shares them with its row as a subgrid, so
     every number, name and line in a row sits on one line whatever wraps */
  column-gap: var(--grid-gap); row-gap: 0;
}
.routes > .route {
  --card-pad: var(--space-6);
  display: grid; grid-template-rows: subgrid; grid-row: span 5; row-gap: 0;
  align-content: start;
  min-width: 0;
  margin-bottom: var(--grid-gap);
  padding: 0 0 var(--card-pad);
  transition: transform var(--dur-3) var(--ease-out), box-shadow var(--dur-3) var(--ease-out), background-color var(--dur-3) var(--ease-out);
}
.routes > .route-lead { grid-column: span 2; }
.routes > .route > :not(.route-media, .route-link) { grid-column: 1; min-width: 0; margin: 0; padding-inline: var(--card-pad); }

/* the photo: runs to the card's top and side edges, square on desktop (photo-led, like Neko's cards), 5:4 below;
   the lead's photo stretches to its row (set by the others' squares) */
.route-media {
  grid-row: 1; grid-column: 1;
  position: relative; overflow: hidden; isolation: isolate;
  aspect-ratio: 1;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--canvas-2);
  --reticle-inset: 14px; --reticle-len: 20px;
}
.route-lead > .route-media { aspect-ratio: auto; }
.route-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; max-width: none;
  object-fit: cover; object-position: var(--photo-pos, center);
  /* a crop that needs to come closer than cover: --photo-zoom around --photo-origin (the hover zoom is `scale`, so
     the two compose) */
  transform-origin: var(--photo-origin, 50% 50%);
  transform: scale(var(--photo-zoom, 1));
  /* the shared warm grade (components' .graded-img), so a cold clinic room and a warm portrait read as one shoot */
  filter: sepia(0.26) saturate(0.84) contrast(1.05) brightness(1.02);
  transition: scale 0.9s var(--ease-out);
}
/* a butter wash multiplied over every photo (the .graded recipe), the last step of the one grade */
.route-media::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: var(--butter); mix-blend-mode: multiply; opacity: 0.18;
}
/* aim each crop at its region */
[data-route-cell="head"] { --photo-pos: 50% 42%; }
[data-route-cell="neck"] { --photo-pos: 50% 40%; }                                                    /* the neck, collarbone and shoulder */
[data-route-cell="chest"] { --photo-pos: 50% 100%; --photo-origin: 50% 100%; --photo-zoom: 1.96; }   /* the stethoscope on his chest (only the tip of the beard, no half face) */
[data-route-cell="back"] { --photo-pos: 36% 50%; --photo-origin: 50% 100%; --photo-zoom: 2; }        /* her back, from the scan room (a different frame from the hero's) */
[data-route-cell="abdomen"] { --photo-pos: 22% 50%; }
[data-route-cell="hip"] { --photo-pos: 62% 45%; }
[data-route-cell="knee"] { --photo-pos: 46% 60%; }

/* the region open on the map: reticle corners lock onto its photo and the tag drops in */
.route-media::after {
  content: "";
  position: absolute; inset: var(--reticle-inset); z-index: 2; pointer-events: none;
  --rc: var(--reticle-light); --rl: var(--reticle-len); --rt: 2px;
  background:
    linear-gradient(var(--rc), var(--rc)) 0 0 / var(--rl) var(--rt),
    linear-gradient(var(--rc), var(--rc)) 0 0 / var(--rt) var(--rl),
    linear-gradient(var(--rc), var(--rc)) 100% 0 / var(--rl) var(--rt),
    linear-gradient(var(--rc), var(--rc)) 100% 0 / var(--rt) var(--rl),
    linear-gradient(var(--rc), var(--rc)) 0 100% / var(--rl) var(--rt),
    linear-gradient(var(--rc), var(--rc)) 0 100% / var(--rt) var(--rl),
    linear-gradient(var(--rc), var(--rc)) 100% 100% / var(--rl) var(--rt),
    linear-gradient(var(--rc), var(--rc)) 100% 100% / var(--rt) var(--rl);
  background-repeat: no-repeat;
  opacity: 0; scale: 1.08;
  transition: opacity var(--dur-3) var(--ease-out), scale var(--dur-4) var(--ease-out);
}
.route.is-on .route-media::after { opacity: 1; scale: 1; }
/* the tag sits inside the corners, a bracket's length clear of them */
.route-live {
  position: absolute; z-index: 3;
  left: calc(var(--reticle-inset) + var(--space-4)); top: calc(var(--reticle-inset) + var(--space-4));
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: 28px; padding: 0 12px 0 10px;
  border-radius: var(--r-pill);
  background: var(--glass-dark); border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  color: var(--on-photo); font-size: var(--fs-eyebrow); font-weight: var(--fw-ui); line-height: 1; white-space: nowrap;
  opacity: 0; translate: 0 -6px;
  transition: opacity var(--dur-3) var(--ease-out), translate var(--dur-3) var(--ease-out);
}
.route-live .dot-live { background: var(--teal-300); }
.route.is-on .route-live { opacity: 1; translate: 0 0; }

/* the card face: the number with a hairline running on to an arrow (an index row, like a report's), then the name,
   the first check and who reads it */
.routes .route-top { grid-row: 2; display: flex; align-items: center; gap: var(--space-4); padding-top: var(--space-6); padding-bottom: var(--space-4); }
.route-num {
  display: flex; align-items: center; gap: var(--space-4); flex: 1 1 auto; min-width: 0;
  font-family: var(--font-display); font-weight: var(--fw-display);
  font-size: var(--fs-stat-sm); line-height: 0.9; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--fg-3);
  transition: color var(--dur-3) var(--ease-out);
}
.route-num::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--rule-2); transition: background-color var(--dur-3) var(--ease-out); }
.route-go { flex: 0 0 auto; display: grid; place-items: center; color: var(--fg-link); transition: translate var(--dur-3) var(--ease-spring), color var(--dur-2) var(--ease-out); }
.route-go .icon-arrow { width: 18px; height: 18px; }
.routes .route-name {
  grid-row: 3;
  font-family: var(--font-display); font-weight: var(--fw-title);
  font-size: var(--fs-h3); line-height: 1.06; letter-spacing: var(--tracking-heading);
  color: var(--fg);
  text-wrap: balance;
}
.routes .route-first { grid-row: 4; padding-top: var(--space-3); max-width: 34ch; font-size: var(--fs-card); line-height: 1.45; color: var(--fg-2); }
.routes .route-who { grid-row: 5; padding-top: var(--space-4); font-size: var(--fs-small); font-weight: var(--fw-ui); line-height: 1.4; color: var(--fg-link); }
/* the middle dot gets real air either side (a 14px space alone glues it to both names) */
.route-sep { padding-inline: 0.18em; color: var(--fg-3); }
/* the lead's name keeps the card-title step above the others at every width */
.routes .route-lead .route-name { font-size: var(--fs-h3); }
.route.is-on .route-num { color: var(--accent-em); }
.route.is-on .route-num::after { background: var(--teal-500); }

/* the action: the link covers the whole card */
.route-link { position: absolute; inset: 0; z-index: 4; border-radius: inherit; }
.route-link:focus-visible { outline: 2px solid var(--ring-color); outline-offset: 3px; }
.routes > .route:has(.route-link:focus-visible) { transform: translateY(-4px); background-color: var(--card-bg-hover); box-shadow: var(--shadow-md); }
.routes > .route:has(.route-link:focus-visible) .route-go { translate: 4px 0; }
@media (hover: hover) {
  .routes > .route:hover { transform: translateY(-4px); background-color: var(--card-bg-hover); box-shadow: var(--shadow-md); }
  .routes > .route:hover .route-img { scale: 1.04; }
  .routes > .route:hover .route-go { translate: 4px 0; color: var(--accent); }
}
.routes > .route:active { transform: translateY(-1px); transition-duration: var(--dur-1); }

/* red flags: a ruled line on the canvas under the set (no black slab): the finding chip in the first column, the
   warning across the other three as a serif statement */
.routes-flag {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start;
  gap: var(--space-4) var(--grid-gap);
  margin-top: var(--space-6);
  padding-block: var(--space-8);
  border-top: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2);
}
/* the chip (30px) sits centred on the statement's first line: the title's em is the statement's size */
.routes-flag-title { margin: 0; padding-top: calc((1.12em - 30px) / 2); font-size: var(--fs-h2); line-height: 1; }
.routes-flag-copy {
  grid-column: 2 / -1;
  max-width: 40ch;
  font-family: var(--font-display); font-weight: var(--fw-title);
  font-size: var(--fs-h2); line-height: 1.12; letter-spacing: var(--tracking-heading);
  color: var(--fg); text-wrap: pretty;
}

/* ---------- 4. The visit: a night panel on the canvas ----------
   Head across the top; below it, on desktop, the consult photo is a portrait frame exactly as tall as the three steps
   beside it (it starts on the 01 rule and ends on the closing rule). motion.js (data-progress) marks the step at the
   reading line .is-current and writes data-current on the split; while it tracks, the numerals of the steps still to
   come rest dim, each lights as you reach it, and the photo's framing follows the step (the two women, then the scan
   on screen, then their faces). Outside the tracked span (and in captures, print and reduced motion) every numeral is
   lit and the photo rests on the two women. */
.visit-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "eye" "h2" "lede" "split" "act";
  border-radius: var(--r-lg);
  background: var(--wash-night);
  padding: clamp(var(--space-5), 4.6vw, var(--space-11));
}
.visit-eyebrow { grid-area: eye; margin-bottom: var(--space-6); }
.visit-h2 { grid-area: h2; }
.visit-lede { grid-area: lede; margin-top: var(--space-5); max-width: 40ch; }
.visit-split { grid-area: split; margin-top: var(--stack); }
.visit-actions { grid-area: act; }
@media (min-width: 981px) {
  .visit-panel {
    grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
    grid-template-areas: "eye eye" "h2 lede" "h2 act" "split split";
    grid-template-rows: auto auto 1fr auto;
    column-gap: clamp(var(--space-8), 5vw, var(--space-12));
  }
  /* the heading and the lede share one top line (their first lines start together) */
  .visit-h2 { align-self: start; }
  .visit-lede { margin: 0; align-self: start; padding-top: 0.3em; }
  .visit-actions { margin-top: var(--space-6); align-self: start; }
  .visit-split { margin-top: clamp(var(--space-9), 4.5vw, var(--space-12)); }
  .visit-steps > .visit-step { padding: var(--space-10) 0; }
}

.visit-split {
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
  column-gap: clamp(var(--space-8), 5vw, var(--space-12));
  align-items: stretch;
}
.visit-visual { position: relative; min-width: 0; }
/* desktop: the frame fills its column, so it is as tall as the steps (a portrait, about 4:5) */
.visit-photo {
  position: absolute; inset: 0;
  margin: 0;
  background: var(--night-2);
  --reticle-inset: 20px;
  --reticle-len: 26px;
}
.visit-cam {
  position: absolute; top: 0; left: 0;
  height: 100%; aspect-ratio: 16 / 9;
  transform-origin: 0 0;
  transform: translate(-15%, 0) scale(1);
  will-change: transform;
}
.visit-cam img { display: block; width: 100%; height: 100%; max-width: none; object-fit: cover; }
/* grain + a soft night vignette at the foot, so the warm photo sits in the panel and the file note always reads */
.visit-photo::before {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: var(--grain), linear-gradient(180deg, transparent 55%, var(--glass-dark) 100%);
  background-blend-mode: overlay, normal;
  opacity: 0.9;
}

/* the file the specialist opens: the region chosen on the map, as a note bottom left, well inside the reticle (clear
   of its corner and of the screen on the right). Dark glass keeps the white text >= 4.7:1 over any part of the photo */
.visit-file {
  position: absolute; left: var(--space-10); bottom: var(--space-10); z-index: 4;
  display: grid; gap: 2px;
  max-width: calc(100% - 2 * var(--space-10));
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-sm);
  background: var(--glass-dark);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  color: var(--on-photo);
}
.visit-file-label { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-eyebrow); color: var(--on-photo-2); }
.visit-file-label .dot-live { background: var(--teal-300); }
.visit-file-name { font-family: var(--font-display); font-weight: var(--fw-title); font-size: var(--fs-title); line-height: 1.2; margin-top: 2px; }
.visit-file-spec { font-size: var(--fs-small); color: var(--on-photo-2); }
@media (prefers-reduced-motion: no-preference) {
  .visit-file.is-new :is(.visit-file-name, .visit-file-spec) { animation: pain-in var(--dur-3) var(--ease-out) both; }
}

/* the steps: ruled rows, a big fine teal numeral in its own column, then the title, copy and one detail each
   (01 the seven regions as dots, 02 what gets done, 03 who reads the file) */
.visit-steps { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--rule-2); }
.visit-step {
  position: relative;
  display: grid; grid-template-columns: 1.3em minmax(0, 1fr); column-gap: var(--space-6);
  font-size: var(--fs-stat);              /* sizes the numeral column: em = the numeral's own size */
  padding: var(--space-8) 0 var(--space-9);
  border-top: 1px solid var(--rule-2);
}
/* the reading rule: draws in teal across the top of the current step */
.visit-step::before {
  content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 2px;
  background: var(--teal-300);
  transform-origin: left center; scale: 0 1;
  transition: scale var(--dur-5) var(--ease-out);
}
.visit-num {
  font-family: var(--font-display); font-weight: var(--fw-display);
  font-size: 1em; line-height: 0.82; letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--teal-300);
  transition: opacity var(--dur-4) var(--ease-out), text-shadow var(--dur-4) var(--ease-out);
}
.visit-text { min-width: 0; font-size: var(--fs-body); }
.visit-title {
  font-family: var(--font-display); font-weight: var(--fw-title);
  font-size: var(--fs-h3); line-height: 1.08; letter-spacing: var(--tracking-heading);
  color: var(--fg);
}
.visit-text > p { margin-top: var(--space-3); max-width: 40ch; color: var(--fg-2); font-size: var(--fs-card); line-height: 1.55; }
/* step 01: the seven regions as dots, the one chosen on the map lit, and its name */
.visit-text > .visit-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); margin-top: var(--space-5); font-size: var(--fs-small); color: var(--fg-3); }
.visit-meta b { font-weight: var(--fw-ui); color: var(--fg); }
.visit-dots { display: inline-flex; gap: 6px; }
.visit-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--rule-2); transition: background-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out); }
.visit-dots i.on { background: var(--teal-300); box-shadow: var(--halo); }
/* steps 02 and 03: quiet tags; in 03 the clinician seen first carries the live dot */
.visit-tags { list-style: none; margin: var(--space-5) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.visit-tags li {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: 32px; padding: 0 14px;
  border-radius: var(--r-pill); border: 1px solid var(--rule-2);
  font-size: var(--fs-small); font-weight: var(--fw-ui); color: var(--fg-2);
}
.visit-who li.is-first { padding-left: 12px; border-color: var(--teal-300); color: var(--fg); }
.visit-who .dot-live { background: var(--teal-300); }

/* the scroll-linked reading (motion only): steps still to come rest dim; the current one glows and draws its rule */
@media (prefers-reduced-motion: no-preference) {
  html.js .visit-split.is-tracking .visit-step.is-current ~ .visit-step .visit-num { opacity: 0.2; }
  html.js .visit-split.is-tracking .visit-step.is-current .visit-num { text-shadow: 0 0 28px var(--halo-mid); }
  html.js .visit-split.is-tracking .visit-step.is-current::before { scale: 1 1; }
}

/* the pair of actions: under the lede on desktop, closing the panel after the steps on tablet and phone */
.visit-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-8); }

/* ---------- Desktop: the photo's framing follows the steps ---------- */
@media (min-width: 981px) and (prefers-reduced-motion: no-preference) {
  html.js .visit-cam { transition: transform 1.6s var(--ease-in-out); }
  /* 02: across to the scan on screen · 03: in on the two faces (each keeps the photo over the whole frame) */
  html.js .visit-split.is-tracking[data-current="1"] .visit-cam { transform: translate(-55%, -5%) scale(1.12); }
  html.js .visit-split.is-tracking[data-current="2"] .visit-cam { transform: translate(-23%, -8%) scale(1.25); }
}

/* ---------- 641-1100: the routes go three across, the lead alone on its row with a wide photo ---------- */
@media (max-width: 1100px) {
  .routes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .route-media { aspect-ratio: 5 / 4; }
  .routes > .route-lead { grid-column: 1 / -1; }
  .routes > .route { --card-pad: var(--space-5); }
  .route-num { font-size: var(--fs-h3); }
  .routes .route-top { padding-top: var(--space-5); padding-bottom: var(--space-3); }
  .routes .route-name { font-size: var(--fs-title); }
  /* who reads it: one clinician per line, so no dot is left hanging at the end of a line */
  .route:not(.route-lead) .route-who > span:not(.route-sep) { display: block; }
  .route:not(.route-lead) .route-sep { display: none; }
  .routes-flag { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .routes-flag-copy { max-width: none; }
}
/* 641-1100: the lead lies across its row: the photo over the first two tracks, its copy in the third (on the same
   column lines as the cards below), the clinicians at the foot */
@media (min-width: 641px) and (max-width: 1100px) {
  .routes > .route-lead {
    grid-template-columns: subgrid; grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    padding: 0;
  }
  .routes > .route-lead > .route-media { grid-column: 1 / 3; grid-row: 1 / -1; aspect-ratio: 16 / 10; border-radius: var(--r-lg) 0 0 var(--r-lg); }
  .routes > .route-lead > :not(.route-media, .route-link) { grid-column: 3; padding-inline: 0 var(--card-pad); }
  .routes > .route-lead > .route-top { grid-row: 1; padding-top: var(--card-pad); }
  .routes > .route-lead > .route-name { grid-row: 2; }
  .routes > .route-lead > .route-first { grid-row: 3; }
  .routes > .route-lead > .route-who { grid-row: 5; padding-bottom: var(--card-pad); }
  .route-lead .route-num { font-size: var(--fs-stat-sm); }
}

/* ---------- Tablet and phone: the instrument and the visit stack ---------- */
@media (max-width: 980px) {
  .pain-instrument { grid-template-columns: minmax(0, 1fr); }
  .body-map { min-height: 0; aspect-ratio: 5 / 4; border-radius: var(--r-lg) var(--r-lg) 0 0; }

  /* the visit stacks: the photo (in flow, with its own shape) and the same gap under it as above it */
  .visit-split { grid-template-columns: minmax(0, 1fr); }
  .visit-photo { position: relative; inset: auto; width: 100%; aspect-ratio: 1; margin-bottom: var(--stack); }
  .visit-file { left: var(--space-8); bottom: var(--space-8); max-width: calc(100% - 2 * var(--space-8)); }
}
/* tablet: the readout uses the card's width: the region and its next step on the left, its copy on the right, then
   the button and the note side by side */
@media (min-width: 641px) and (max-width: 980px) {
  .pain-panel {
    display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: var(--space-8);
    grid-template-areas: "meta meta" "chips chips" "read read" "cta note";
    align-items: start;
  }
  .pain-meta { grid-area: meta; }
  .pain-panel .chips { grid-area: chips; }
  .chip-break { display: none; }
  .pain-readout { grid-area: read; }
  .pain-variant { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: var(--space-8); align-content: start; }
  .pain-variant > .pain-name { grid-area: 1 / 1; }
  .pain-variant > p:not(.pain-next) { grid-area: 1 / 2 / span 2; margin-top: 0; max-width: none; }
  .pain-variant > .pain-next { grid-area: 2 / 1; margin-top: var(--space-5); }
  .pain-cta { grid-area: cta; align-self: center; justify-self: start; margin-top: var(--space-7); }
  .pain-panel .disclaimer { grid-area: note; margin-top: var(--space-7); }

  /* the visit photo is a wide 16:10 here (the whole room), so it fills the frame normally */
  .visit-photo { aspect-ratio: 16 / 10; }
  .visit-cam { inset: 0; width: 100%; aspect-ratio: auto; transform: none; }
  .visit-cam img { object-position: 40% 50%; }
}
@media (max-width: 640px) {
  .body-map { aspect-ratio: 4 / 5; --map-chip-inset: 28px; --reticle-inset: 14px; --reticle-len: 18px; }
  .map-back { width: 92px; }
  .map-back-label small { display: none; }
  .pain-name { font-size: var(--fs-display-2); }

  /* routes: the lead across, then small cards in pairs: a square photo, the number, the name and who reads it (one
     per line; the first check is in the readout above). No arrow on the small cards: the whole card is the link */
  .routes { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-3); }
  .routes > .route { --card-pad: var(--space-4); margin-bottom: var(--space-3); }
  .routes > .route-lead { --card-pad: var(--space-5); }
  .route-media { --reticle-inset: 10px; --reticle-len: 16px; }
  .route:not(.route-lead) > .route-media { aspect-ratio: 1; }
  .route-lead > .route-media { aspect-ratio: 16 / 10; }
  .route:not(.route-lead) .route-first { display: none; }
  .route:not(.route-lead) .route-go { display: none; }
  .routes .route-top { padding-top: var(--space-4); padding-bottom: var(--space-2); }
  .route-lead .route-num { font-size: var(--fs-stat-sm); }
  .routes .route-who { padding-top: var(--space-3); }
  .route:not(.route-lead) .route-live { left: calc(var(--reticle-inset) + var(--space-3)); top: calc(var(--reticle-inset) + var(--space-3)); padding-right: 10px; }
  .route:not(.route-lead) .route-live-x { display: none; }
  .routes-flag { grid-template-columns: minmax(0, 1fr); margin-top: var(--space-4); padding-block: var(--space-6); }
  .routes-flag-title { padding-top: 0; font-size: var(--fs-h3); line-height: 1; }
  .routes-flag-copy { grid-column: 1; font-size: var(--fs-h3); line-height: 1.15; }

  .visit-photo { aspect-ratio: 4 / 5; }
  .visit-step { padding: var(--space-6) 0 var(--space-7); column-gap: var(--space-4); }
  .visit-file { left: var(--space-7); bottom: var(--space-7); max-width: calc(100% - 2 * var(--space-7)); }
  .visit-actions { flex-direction: column; align-items: stretch; margin-top: var(--space-7); }
}
