/* ==========================================================================
   Products body (the hero is styled only in products-hero.css)
   1. The tools, on the butter field: three white cards, each showing its tool. Copy always sits on the white face;
      nothing sits on a photo behind a scrim. Every card's media is an inset stage (8px in, 16px corners):
        01 a dot map of Namibia and South Africa on the tint (code-built SVG; Windhoek pinned; the "2 countries"
           count in the map's empty north-east, which doubles as its key)
        02 a bright, warm photo (the shared .graded grade) with a forum thread floating on it, bottom left
        03 a live preview of the ICD-10 search on an aqua workspace (products.js types queries into it)
        >= 981   01 across: map 7/12 | copy 5/12. 02 (7/12) and 03 (5/12) under it on the same column line, sharing
                 one media line and one title line (subgrid)
        641-980  01 stacked (map on top, points beside the title); 02 | 03 side by side as above
        <= 640   the three stacked, media on top
   2. ICD-10 quick search, on a night band with rounded corners (butter above it, the footer's aqua below it).
      >= 981   the heading, lede and search (pill + chips) on the left; the live result card on the right (count as a
               display number beside its label, then the per-chapter bars), both columns sharing a top and bottom line
      <= 980   stacked: heading, search, result card (count | bars on tablets), report
      Then the codes as one ruled report on its own panel: two balanced columns from 981px (products.js sets --rows).
      From 981px the report keeps the full list's height while it filters (products.js sets --icd-h), so nothing
      below it jumps. Tap a code to copy it. Up to 980px the list opens on four common codes with "Show all 12".
      <= 640   no boxes: the result summary and the report sit straight on the band, ruled, as one report
   ========================================================================== */

/* ---------- 0. Split section head (the tools) ---------- */
.split-head { display: grid; gap: var(--space-5); }
.split-head .display-2 { max-width: 15ch; }
.split-head .lede { max-width: 40ch; margin-top: 0; }
@media (min-width: 981px) {
  .split-head { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: end; column-gap: var(--grid-gap); }
  .split-head .lede { padding-bottom: 0.35em; }
}

/* ---------- 1. The tools ---------- */
.pc-grid {
  --pc-media-h: 19rem;
  --pc-inset: var(--space-2);
  display: grid; gap: var(--grid-gap);
  grid-template-columns: minmax(0, 1fr);
}
/* the card: white on the butter field, no border, no shadow at rest */
.pc {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column; min-width: 0;
  border-radius: var(--r-lg);
  background: var(--card-bg);
  color: var(--fg);
  transition: transform var(--dur-3) var(--ease-out), box-shadow var(--dur-3) var(--ease-out);
}

/* every card's media: an inset stage with its own corners */
.pc-stage {
  position: relative; overflow: hidden; flex: 0 0 auto;
  margin: var(--pc-inset) var(--pc-inset) 0;
  height: var(--pc-media-h);
  border-radius: calc(var(--r-lg) - var(--pc-inset));
}

/* the copy, on the white face: "01 — Care" (+ the arrow), title, copy or points, links */
.pc-body { display: flex; flex-direction: column; min-width: 0; padding: var(--card-pad); }
.pc-meta {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 40px;
  color: var(--fg-3); font-size: var(--fs-small); line-height: 1.4;
}
.pc-num { display: inline-flex; align-items: center; gap: var(--space-3); color: var(--fg); font-weight: var(--fw-ui); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.pc-num::after { content: ""; width: 24px; height: 1px; background: currentColor; opacity: 0.5; }
.pc-cat { color: var(--fg-link); font-weight: var(--fw-ui); }
.pc-badge { margin-left: auto; --badge-bg: var(--tint); pointer-events: none; }
.pc-title {
  margin-top: var(--space-4);
  font-family: var(--font-display); font-weight: var(--fw-title);
  font-size: var(--fs-h3); line-height: 1.08; letter-spacing: var(--tracking-heading);
  text-wrap: balance;
}
.pc-title em { font-style: italic; color: var(--fg-em); }
.pc-copy { margin-top: var(--space-3); color: var(--fg-2); font-size: var(--fs-card); line-height: 1.55; max-width: 44ch; }
.pc-links { margin-top: var(--space-4); }
.pc .links a { white-space: nowrap; }

/* the lead's points: a short ruled report, a teal check on each line */
.pc-points { list-style: none; display: grid; margin-top: var(--space-5); border-top: 1px solid var(--rule); }
.pc-points > li {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 48px; padding: var(--space-2) 0;
  border-bottom: 1px solid var(--rule);
  color: var(--fg-2); font-size: var(--fs-card); line-height: 1.4;
}
.pc-points > li::before {
  content: ""; flex: 0 0 auto; width: 16px; height: 16px;
  background-color: var(--fg-mark);
  -webkit-mask: var(--icon-check) center / 16px no-repeat; mask: var(--icon-check) center / 16px no-repeat;
}

/* the lead: a display-size title */
.pc-lead .pc-title { font-weight: var(--fw-display); font-size: var(--fs-display-2); line-height: 1; letter-spacing: var(--tracking-display-2); }

/* the whole card is its first link; the other links sit above that hit area */
.pc-primary::before { content: ""; position: absolute; inset: 0; z-index: 5; border-radius: inherit; }
.pc .links a:not(.pc-primary) { position: relative; z-index: 6; }
.pc:has(.pc-primary:focus-visible) { outline: 2px solid var(--ring-color); outline-offset: 3px; }

@media (hover: hover) {
  .pc:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
  .pc:hover .fx-photo > img { scale: 1.04; }
  .pc:hover .pc-badge { transform: translateX(3px); background: var(--accent); color: var(--on-accent); }
}
.pc:has(.pc-primary:focus-visible) .pc-badge { transform: translateX(3px); background: var(--accent); color: var(--on-accent); }

/* ---- 01: the dot map. The SVG's viewBox is the map's own box (196 × 178), so the pin and the count are placed in
   its coordinates (%). Namibia in the accent, South Africa a lighter teal; Lesotho stays a hole ---- */
.pc-map {
  container-type: size;
  display: grid; place-items: center;
  padding: var(--space-6);
  background: var(--tint);
}
.map {
  container-type: inline-size;
  position: relative;
  width: min(100cqw, 100cqh * 1.101);
  aspect-ratio: 196 / 178;
}
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.map-svg path { fill: none; stroke-width: 2.5; stroke-linecap: round; }
.map-nam { stroke: var(--teal-600); }
.map-za { stroke: var(--teal-200); }

/* Windhoek: an ink dot in a white ring, a soft halo breathing out of it, its name in a pill to the left */
.map-pin {
  position: absolute; left: 27%; top: 31.8%;
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 3px var(--surface), var(--shadow-sm);
}
.map-pin::before {
  content: ""; position: absolute; inset: -12px; border-radius: 50%;
  background: var(--teal-400); opacity: 0.28;
}
.map-pin-label {
  position: absolute; right: calc(100% + 10px); top: 50%; translate: 0 -50%;
  display: inline-flex; align-items: center; min-height: 28px; padding: 0 12px;
  border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow-sm);
  color: var(--ink); font-size: var(--fs-eyebrow); font-weight: var(--fw-ui); line-height: 1; white-space: nowrap;
}
@keyframes map-breathe { 0% { scale: 0.4; opacity: 0.5; } 70%, 100% { scale: 1.5; opacity: 0; } }
@media (prefers-reduced-motion: no-preference) {
  .map-pin::before { animation: map-breathe 2.6s var(--ease-out) infinite; }
}

/* the count, in the empty north-east (Botswana's place): the numeral, then "countries" and the key */
.map-stat {
  position: absolute; left: 51%; right: 0; top: 13.5%;
  display: flex; align-items: flex-start; gap: max(var(--space-3), 3.4cqw);
}
.map-num {
  display: block;
  margin-top: -0.1em;
  font-family: var(--font-display); font-weight: var(--fw-display);
  font-size: 19cqw; line-height: 0.86; letter-spacing: -0.04em;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--ink);
}
.map-key { display: grid; gap: max(4px, 0.9cqw); padding-top: 0.5cqw; min-width: 0; }
.map-key-title {
  font-family: var(--font-display); font-weight: var(--fw-title);
  font-size: max(var(--fs-card), 4.4cqw); line-height: 1; letter-spacing: -0.01em; color: var(--ink);
  margin-bottom: max(2px, 0.8cqw);
}
.map-key-row {
  display: inline-flex; align-items: center; gap: var(--space-2);
  color: var(--ink-2); font-size: max(var(--fs-eyebrow), 2.9cqw); line-height: 1.25; white-space: nowrap;
}
.map-key-row::before { content: ""; flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: var(--teal-600); }
.map-key-row.is-za::before { background: var(--teal-200); box-shadow: inset 0 0 0 1px var(--teal-300); }
/* the key's text has a floor size, so on a small map it reaches the first South Africa rows: lift and tighten the key
   (only the key: it sits right of the Caprivi strip, the numeral does not) */
@container (max-width: 440px) {
  .map-key { gap: 2px; margin-top: -3.5cqw; }
}

/* ---- 02: the forum. The photo fills the stage (no scrim), mirrored. Up to 980px a taller portrait stage (25-26rem) crops
   to the two women (the screen stays out of frame), faces in the top half, the thread across the foot of the photo
   under them; from 981px a tight crop puts them on the
   left (the screen leaves the frame) and the thread floats on the right, over the curtains. Never over a face ---- */
/* the photo clips to the stage's own corners (a composited, mirrored img can otherwise paint past a parent's radius) */
.fx-photo { position: absolute; inset: 0; border-radius: inherit; }
/* up to 980px: a portrait crop of the two women (the screen stays out of frame), faces in the top half, the thread
   under them */
.fx-photo > img { transform: scaleX(-1); object-position: 20% 40%; transition: scale 0.9s var(--ease-out); }
.fx {
  position: absolute; left: var(--space-4); bottom: var(--space-4); z-index: 3;
  width: min(100% - 2 * var(--space-4), 21rem);
  display: grid; gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.fx-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding-bottom: var(--space-3); border-bottom: 1px solid var(--line);
  font-size: var(--fs-eyebrow); line-height: 1.2;
}
.fx-chan { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-weight: var(--fw-ui); }
.fx-chan::before { content: "#"; color: var(--teal-700); }
.fx-lock { color: var(--ink-3); }
.fx-msg { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--space-3); align-items: start; }
.fx-av {
  position: relative; overflow: hidden;
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--teal-50); color: var(--teal-800);
  font-size: var(--fs-eyebrow); font-weight: var(--fw-ui); letter-spacing: 0.02em;
}
/* a tight crop of a face from a wide photo */
.fx-av-photo > img {
  position: absolute; max-width: none; width: 300px; height: auto;
  left: -124px; top: -24px;
  filter: sepia(0.26) saturate(0.84) contrast(1.05) brightness(1.02);
}
.fx-say { display: grid; gap: 2px; min-width: 0; }
.fx-who { display: flex; align-items: baseline; gap: var(--space-2); font-size: var(--fs-eyebrow); line-height: 1.3; }
.fx-who b { color: var(--ink); font-weight: var(--fw-ui); }
.fx-who span { color: var(--ink-3); }
.fx-text { color: var(--ink-2); font-size: var(--fs-small); line-height: 1.4; text-wrap: pretty; }
.fx-file {
  justify-self: start; margin-top: var(--space-2);
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 12px 0 10px;
  border-radius: var(--r-pill); background: var(--tint); color: var(--ink);
  font-size: var(--fs-eyebrow); font-weight: var(--fw-ui); line-height: 1;
}
.fx-file::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  background: var(--teal-500); box-shadow: 0 0 0 3px var(--teal-100);
}

/* ---- 03: the live preview of the search, on an aqua workspace ---- */
.pc-icd .pc-stage {
  display: grid; place-items: center;
  padding: var(--space-5);
  background:
    radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 1.4px) 0 0 / 18px 18px,
    var(--mist);
}
.pv { width: 100%; max-width: 30rem; display: grid; gap: var(--space-3); }
.pv-search {
  display: flex; align-items: center; gap: var(--space-3);
  height: 52px; padding: 0 var(--space-4) 0 var(--space-5);
  border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sm);
  font-size: var(--fs-card);
}
.pv-ico {
  flex: 0 0 auto; width: 18px; height: 18px; background-color: var(--teal-700);
  -webkit-mask: var(--pv-icon-search) center / 18px no-repeat; mask: var(--pv-icon-search) center / 18px no-repeat;
}
.pv-q { display: inline-flex; align-items: center; min-width: 0; flex: 1 1 auto; white-space: nowrap; overflow: hidden; }
.pv-caret { width: 1.5px; height: 1.2em; margin-left: 2px; background: var(--teal-600); animation: pv-blink 1.1s steps(1) infinite; }
@keyframes pv-blink { 50% { opacity: 0; } }
.pv-count {
  flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 28px; padding: 0 var(--space-3);
  border-radius: var(--r-pill); background: var(--teal-50); color: var(--teal-800);
  font-size: var(--fs-eyebrow); font-weight: var(--fw-ui); font-variant-numeric: tabular-nums;
}
.pv-rows { list-style: none; display: grid; gap: var(--space-2); min-height: calc(3 * 48px + 2 * var(--space-2)); align-content: start; }
.pv-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-3);
  height: 48px; padding: 0 var(--space-3) 0 var(--space-2);
  border-radius: var(--r-sm); background: var(--surface);
  color: var(--ink); font-size: var(--fs-small);
}
.pv-code {
  display: inline-flex; align-items: center; gap: 6px;
  min-width: 4.75rem; height: 32px; padding: 0 var(--space-3);
  border-radius: var(--r-pill); background: var(--teal-50); color: var(--teal-700);
  font-weight: var(--fw-ui); font-variant-numeric: tabular-nums;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}
.pv-tick { display: none; width: 12px; height: 12px; background-color: currentColor; -webkit-mask: var(--icon-check) center / 12px no-repeat; mask: var(--icon-check) center / 12px no-repeat; }
.pv-row.is-copied .pv-code { background: var(--accent); color: var(--on-accent); }
.pv-row.is-copied .pv-tick { display: inline-block; }
.pv-name { min-width: 0; color: var(--ink); line-height: 1.25; text-wrap: pretty; }
.pv-name mark { background: var(--teal-200); color: inherit; border-radius: 3px; padding: 0 1px; }
.pv-chap {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--tint); color: var(--ink-2); font-size: var(--fs-eyebrow); font-weight: var(--fw-ui);
}
@keyframes pv-in { from { opacity: 0; translate: 0 6px; } }
.pv-row.is-entering { animation: pv-in var(--dur-3) var(--ease-out) both; animation-delay: calc(var(--k, 0) * 60ms); }
.pc-icd { --pv-icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Ccircle cx='8.75' cy='8.75' r='5.75' stroke='black' stroke-width='1.7'/%3E%3Cpath d='M13.1 13.1 17 17' stroke='black' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E"); }
@media (prefers-reduced-motion: reduce) { .pv-caret { animation: none; } .pv-row.is-entering { animation: none; } }

/* ---- layouts ---- */
/* tablets and up: 02 and 03 side by side, sharing one media line and one title line */
@media (min-width: 641px) {
  .pc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pc-lead { grid-column: 1 / -1; }
  .pc-side { grid-row: span 2; display: grid; grid-template-rows: subgrid; row-gap: 0; }
  .pc-side .pc-stage { height: auto; min-height: var(--pc-media-h); }
  .pc-side .pc-body { padding-bottom: calc(var(--card-pad) + var(--space-1)); }
  .pc-side .pc-links { margin-top: auto; padding-top: var(--space-4); }
}
@media (min-width: 641px) and (max-width: 980px) {
  .pc-grid { --pc-media-h: 26rem; }
  .pc-lead .pc-map { height: clamp(22rem, 54vw, 28rem); }
  /* the lead's copy: title and links on the left, the points on the right */
  .pc-lead .pc-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--space-7); align-items: start; }
  .pc-lead .pc-meta { grid-column: 1 / -1; }
  .pc-lead .pc-title { grid-column: 1; }
  .pc-lead .pc-points { grid-column: 2; grid-row: 2 / span 2; margin-top: var(--space-4); }
  .pc-lead .pc-links { grid-column: 1; }
  /* the preview in a half-width card: no chapter letters, a slimmer frame */
  .pc-icd .pc-stage { padding: var(--space-4); }
  .pv-chap { display: none; }
  .pv-row { grid-template-columns: auto minmax(0, 1fr); }
  .fx { left: var(--space-3); bottom: var(--space-3); width: calc(100% - 2 * var(--space-3)); }
}
/* up to 980px the thread lies across the foot of the photo, under the two faces: no head row */
@media (max-width: 980px) {
  .fx-head { display: none; }
}
@media (min-width: 981px) {
  .pc-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); --pc-media-h: clamp(20rem, 25vw, 28rem); }
  /* the lead: the map on the left (7/12), the copy on the white face to its right (5/12), on the column line of
     the two cards below */
  .pc-lead { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); column-gap: var(--grid-gap); min-height: clamp(32rem, 40vw, 40rem); }
  .pc-lead .pc-map { height: auto; margin: var(--pc-inset) 0 var(--pc-inset) var(--pc-inset); }
  .pc-lead .pc-body { padding: var(--panel-pad) var(--panel-pad) var(--panel-pad) var(--card-pad); }
  .pc-lead .pc-points { margin-top: auto; }
  .pc-lead .pc-title { max-width: 9ch; }
  /* a tight crop: the photo twice its stage's width, anchored right and mirrored, so the screen falls outside the
     frame and the two women fill its left half (faces at 10% and 44%; the thread starts past 55%) */
  .fx-photo > img { width: 200%; max-width: none; margin-left: -100%; object-position: 50% 36%; }
  .fx { left: auto; right: var(--space-5); bottom: var(--space-5); width: min(41%, 21rem); }
}

/* the widest screens: the previews grow with their stages */
@media (min-width: 1440px) {
  .pv { max-width: 34rem; gap: var(--space-4); }
  .pv-search { height: 60px; font-size: var(--fs-body); }
  .pv-rows { min-height: calc(3 * 56px + 2 * var(--space-2)); }
  .pv-row { height: 56px; font-size: var(--fs-card); padding-left: var(--space-3); }
  .pv-code { height: 36px; min-width: 5.5rem; }
  .fx { width: min(41%, 23rem); right: var(--space-6); bottom: var(--space-6); padding: var(--space-5); }
  .fx-text { font-size: var(--fs-card); }
}

/* phones: three stacked cards, media on top */
@media (max-width: 640px) {
  .pc-grid { gap: var(--space-4); --pc-media-h: 21rem; }
  .pc-lead .pc-map { height: auto; aspect-ratio: 1.08; padding: var(--space-4); }
  /* Windhoek's name hangs under its pin (to the left it would run off the stage) */
  .map-pin-label { right: auto; left: 50%; top: calc(100% + 10px); translate: -50% 0; }
  .pc-forum .pc-stage { height: 25rem; }
  .pc-icd .pc-stage { height: auto; padding: var(--space-4); }
  .fx { left: var(--space-3); bottom: var(--space-3); width: calc(100% - 2 * var(--space-3)); padding: var(--space-3) var(--space-4) var(--space-4); }
  .pv-row { padding-right: var(--space-2); }
  .pv-count { padding: 0 var(--space-2); }
}

/* ---------- 2. ICD-10 quick search ---------- */
/* the night band: drawn under the section with all four corners rounded. The butter shows round the top two and
   the footer's aqua sheet (which starts right under this section) round the bottom two, so the band reads as one
   night card set between the field above and the footer below, never a hard square edge */
.section-dark.icd-section {
  background: linear-gradient(180deg, var(--butter) 50%, var(--mist) 50%);
  isolation: isolate;
}
.icd-section::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: var(--r-lg);
  background: var(--wash-night);
}

.icd {
  --icd-cols: 6.75rem minmax(0, 1fr) 4.5rem;
  --icd-gap: calc(2 * var(--space-8));
  display: grid; gap: var(--stack);
  --icd-icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Ccircle cx='8.75' cy='8.75' r='5.75' stroke='black' stroke-width='1.7'/%3E%3Cpath d='M13.1 13.1 17 17' stroke='black' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E");
  --icd-icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Crect x='5.25' y='5.25' width='8.5' height='8.5' rx='2' stroke='black' stroke-width='1.5'/%3E%3Cpath d='M10.75 3.25A1.5 1.5 0 0 0 9.25 2.25h-5.5a1.5 1.5 0 0 0-1.5 1.5v5.5a1.5 1.5 0 0 0 1 1.41' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
}
.icd [hidden] { display: none !important; }

/* the intro: heading, lede and the search on the left; the live result card on the right (stacked below 981px) */
.icd-intro { display: grid; gap: var(--space-8); }
.icd-lead { display: flex; flex-direction: column; gap: var(--space-8); min-width: 0; }
.icd-head { display: grid; gap: var(--space-5); }
.icd-head .eyebrow { margin: 0; }
.icd-title {
  font-family: var(--font-display); font-weight: var(--fw-display);
  font-size: var(--fs-display-page); line-height: 1; letter-spacing: var(--tracking-display);
  color: var(--fg); text-wrap: balance; max-width: 12ch;
}
.icd-title em { font-style: italic; color: var(--fg-em); }
.icd-head .lede { max-width: 44ch; margin-top: 0; }
.icd-find { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }

/* the search pill: a magnifier at its start, the floating label beside it */
@media (min-width: 981px) { .icd-search { max-width: 40rem; } }
.icd-search .float { flex: 1 1 auto; min-width: 0; }
.icd-search .float::before {
  content: ""; position: absolute; left: 22px; top: 50%; z-index: 1;
  width: 18px; height: 18px; margin-top: -9px;
  background-color: var(--ink-3);
  -webkit-mask: var(--icd-icon-search) center / 18px no-repeat; mask: var(--icd-icon-search) center / 18px no-repeat;
  pointer-events: none;
  transition: background-color var(--dur-2) var(--ease-out);
}
.icd-search .float:focus-within::before { background-color: var(--teal-700); }
.icd-search input { height: 64px; padding-left: 52px; font-size: var(--fs-body); }
.icd-search .float > label { left: 53px; }

.icd-try { align-items: center; }
.icd-try-label { color: var(--fg-3); font-size: var(--fs-small); margin-right: var(--space-1); }

/* the result card: a head row, the live count as one display number, then the codes per chapter as bars */
.icd-card {
  --card-bd: var(--rule);
  display: flex; flex-direction: column; gap: var(--space-6);
  min-width: 0; padding: var(--panel-pad);
}
.icd-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding-bottom: var(--space-4); border-bottom: 1px solid var(--rule);
  color: var(--fg-3); font-size: var(--fs-eyebrow); font-weight: var(--fw-ui); line-height: 1.3;
  letter-spacing: var(--tracking-eyebrow); text-transform: uppercase;
}
.icd-live { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--fg-2); letter-spacing: 0.02em; text-transform: none; font-size: var(--fs-small); font-weight: var(--fw-ui); }
.icd-live .dot-live { background: var(--teal-300); }

/* the live count: one display number, its label and a hint on two fixed lines (so nothing shifts as it changes).
   The number's box is trimmed to its ink (Newsreader: figures 0.728em tall on a 0.736em ascent) */
.icd-stat { display: flex; align-items: flex-end; gap: var(--space-5); min-width: 0; }
.icd-count-num {
  display: block;
  margin: -0.01em 0 -0.25em -0.05em;
  font-family: var(--font-display); font-weight: var(--fw-display);
  font-size: calc(var(--fs-display-1) * 1.5); line-height: 1; letter-spacing: -0.045em;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--fg);
}
@keyframes icd-tick { from { opacity: 0.25; translate: 0 0.1em; } }
.icd-count-num.is-ticking { animation: icd-tick var(--dur-3) var(--ease-out) both; }
.icd-count-text { display: grid; gap: 2px; min-width: 0; padding-bottom: 0.15em; }
.icd-count-label { color: var(--fg); font-size: var(--fs-body); font-weight: var(--fw-ui); line-height: 1.35; overflow-wrap: anywhere; }
.icd-hint { color: var(--fg-3); font-size: var(--fs-small); line-height: 1.4; }

/* per-chapter bars: they shrink with the search */
.icd-chart { display: grid; align-content: end; gap: var(--space-4); min-width: 0; margin-top: auto; }
.icd-chart-head { color: var(--fg-3); font-size: var(--fs-small); line-height: 1.3; }
.icd-bar {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center;
  column-gap: var(--space-3); row-gap: 6px;
  --v: 0.5;
  transition: opacity var(--dur-3) var(--ease-out);
}
.icd-bar[data-icd-bar="M"] { --v: 1; }
.icd-bar.is-zero :is(.icd-bar-name, .icd-bar-n) { color: var(--fg-3); }
.icd-bar.is-zero .icd-chap { opacity: 0.5; }
.icd-bar > .icd-chap { grid-row: 1 / span 2; }
.icd-bar-name { color: var(--fg-2); font-size: var(--fs-small); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icd-bar-n { color: var(--fg); font-size: var(--fs-small); font-weight: var(--fw-ui); font-variant-numeric: tabular-nums; text-align: right; }
.icd-bar-track { grid-column: 2 / -1; display: block; height: 6px; border-radius: var(--r-pill); background: var(--viz-track); overflow: hidden; }
.icd-bar-track > i {
  display: block; height: 100%; border-radius: inherit;
  background: var(--fg-mark);
  transform-origin: 0 50%; transform: scaleX(var(--v, 1));
  transition: transform var(--dur-4) var(--ease-out);
}
/* the bars grow in with the card (one after another), then follow the search */
@media (prefers-reduced-motion: no-preference) {
  html.js .icd-card:not(.is-in) .icd-bar-track > i { transform: scaleX(0); }
  .icd-card:not(.is-done) .icd-bar[data-icd-bar="G"] .icd-bar-track > i { transition-delay: 300ms; }
  .icd-card:not(.is-done) .icd-bar[data-icd-bar="M"] .icd-bar-track > i { transition-delay: 420ms; }
  .icd-card:not(.is-done) .icd-bar[data-icd-bar="R"] .icd-bar-track > i { transition-delay: 540ms; }
}
.icd-chap {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--face); color: var(--fg);
  font-size: var(--fs-eyebrow); font-weight: var(--fw-ui); line-height: 1;
}

/* wide: the heading and the search on the left, the result card standing beside them (top and bottom lines shared) */
@media (min-width: 981px) {
  .icd-intro { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); column-gap: var(--grid-gap); align-items: stretch; }
  .icd-lead { justify-content: space-between; padding-right: var(--space-8); }
}
/* tablets: the card lies across, the count beside the bars */
@media (min-width: 641px) and (max-width: 980px) {
  .icd-card { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: 0; row-gap: var(--space-6); }
  .icd-card-head { grid-column: 1 / -1; }
  .icd-stat { flex-direction: column; align-items: stretch; justify-content: space-between; gap: var(--space-4); padding-right: var(--space-7); }
  .icd-count-text { padding-bottom: 0; }
  .icd-chart { padding-left: var(--space-7); border-left: 1px solid var(--rule); margin-top: 0; }
}

/* the codes: one ruled report on its own panel. Columns: code · condition · chapter. Two balanced columns from 981px
   (filled top to bottom, so the codes read in order), one rule down the middle of the gap */
.icd-panel { --card-bd: var(--rule); display: flex; flex-direction: column; padding-top: var(--space-3); }
.icd-results { position: relative; }
/* wide: the report panel keeps the full list's height while it filters (products.js measures it), so the foot note
   and everything below stay put */
@media (min-width: 981px) { .icd-panel { min-height: var(--icd-h, 0px); } }
.icd-heads { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: var(--icd-gap); }
.icd-thead {
  display: grid; grid-template-columns: var(--icd-cols); gap: var(--space-4); align-items: end;
  padding: var(--space-5) 0 var(--space-3);
  border-bottom: 1px solid var(--rule-2);
  color: var(--fg-3); font-size: var(--fs-eyebrow); font-weight: var(--fw-ui); line-height: 1.2;
  letter-spacing: var(--tracking-eyebrow); text-transform: uppercase;
}
.icd-thead > :last-child { text-align: right; }
.icd-thead + .icd-thead { display: none; }
.icd-list { list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); column-gap: var(--icd-gap); }
.icd-row {
  display: grid; grid-template-columns: var(--icd-cols); align-items: center; gap: var(--space-4);
  min-height: 72px; padding: var(--space-3) 0;
  border-bottom: 1px solid var(--rule);
}
.icd-code {
  justify-self: start;
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-3) 0 var(--space-4);
  border-radius: var(--r-pill);
  background: var(--face); color: var(--fg-link);
  font-family: var(--font-sans); font-size: var(--fs-card); font-weight: var(--fw-ui);
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em; white-space: nowrap;
}
button.icd-code {
  cursor: copy;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
.icd-copy-ico {
  width: 14px; height: 14px; flex: 0 0 auto;
  background-color: currentColor; opacity: 0.55;
  -webkit-mask: var(--icd-icon-copy) center / 14px no-repeat; mask: var(--icd-icon-copy) center / 14px no-repeat;
  transition: opacity var(--dur-2) var(--ease-out);
}
@media (hover: hover) {
  button.icd-code:hover { background: var(--face-hover); }
  button.icd-code:hover .icd-copy-ico { opacity: 1; }
}
button.icd-code:active { transform: scale(0.97); }
button.icd-code.is-copied { background: var(--accent); color: var(--on-accent); }
button.icd-code.is-copied .icd-copy-ico { opacity: 1; -webkit-mask-image: var(--icon-check); mask-image: var(--icon-check); }
.icd-name { color: var(--fg); font-size: var(--fs-body); line-height: 1.4; text-wrap: pretty; }
.icd-ch { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); min-width: 0; color: var(--fg-3); font-size: var(--fs-small); line-height: 1.3; }
.icd-ch .icd-chap { width: 26px; height: 26px; }
/* the chapter's name is read out everywhere; it shows beside its letter on tablets and the widest screens */
.icd-ch-name { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: clip; clip-path: inset(50%); }
.icd-results mark { background: var(--viz-band); color: inherit; border-radius: var(--r-xs); padding: 0 1px; }
.icd-results .is-copied mark { background: transparent; }

/* rows that come back into the list as the search widens */
@keyframes icd-in { from { opacity: 0; translate: 0 8px; } }
.icd-row.is-entering { animation: icd-in var(--dur-3) var(--ease-out) both; animation-delay: calc(var(--k, 0) * var(--stagger) / 3); }

/* nothing found: the empty state takes the report's place */
.icd.is-empty :is(.icd-heads, .icd-list) { display: none; }
.icd-empty { padding: var(--space-6) 0 var(--space-2); }
.icd-empty-title { font-family: var(--font-display); font-weight: var(--fw-title); font-size: var(--fs-h3); line-height: 1.15; letter-spacing: -0.012em; overflow-wrap: anywhere; }
.icd-empty-copy { margin-top: var(--space-3); color: var(--fg-2); font-size: var(--fs-card); max-width: 52ch; }
.icd-empty .links { align-items: center; gap: var(--space-3) var(--space-5); margin-top: var(--space-5); }

/* up to 980px the list opens on four common codes; the button shows the rest (only without a search) */
.icd-more { display: none; }
@media (max-width: 980px) {
  .icd.is-js:not(.has-query) .icd-more { display: flex; width: 100%; margin-top: var(--space-6); --btn-bd: var(--rule-2); }
  .icd.is-js.is-collapsed:not(.has-query) .icd-row:not([data-top]) { display: none; }
}

.icd-foot {
  margin-top: auto; padding-top: var(--space-7);
  color: var(--fg-3); font-size: var(--fs-small); line-height: 1.6;
}
/* the WHO link keeps a 44px target (on a phone it drops to its own line under the note) */
.icd-foot .link { display: inline-block; padding-block: 11px; margin-block: -11px; }
/* with nothing found, the empty state carries the WHO link: the foot note would repeat it */
.icd.is-empty .icd-foot { display: none; }

/* wide: two balanced columns of rows (rows line up across them, so the rules run straight through) */
@media (min-width: 981px) {
  .icd-heads { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .icd-thead + .icd-thead { display: grid; }
  .icd-list { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: column; grid-template-rows: repeat(var(--rows, 6), auto); }
  .icd-results::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--rule); }
  .icd-results[data-cols="1"] :is(.icd-heads, .icd-list) { grid-template-columns: minmax(0, 1fr); }
  .icd-results[data-cols="1"] .icd-thead + .icd-thead { display: none; }
  .icd-results[data-cols="1"]::before, .icd.is-empty .icd-results::before { content: none; }
}
/* the widest screens spell the chapter out beside its letter */
@media (min-width: 1440px) {
  .icd { --icd-cols: 6.75rem minmax(0, 1fr) 10.5rem; }
  .icd-ch-name { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none; }
}
/* tablets: one column, the chapter spelled out */
@media (min-width: 641px) and (max-width: 980px) {
  .icd { --icd-cols: 6.5rem minmax(0, 1fr) 10.5rem; }
  .icd-ch-name { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none; }
  .icd-row { min-height: 64px; }
}
@media (max-width: 640px) {
  .icd { --icd-cols: 5.75rem minmax(0, 1fr); }
  .icd-intro { gap: var(--space-8); }
  .icd-lead { gap: var(--space-7); }
  /* no boxes on a phone: the summary and the report sit on the band itself, ruled, as one report */
  .icd-card, .icd-panel { --card-bg: transparent; --card-bd: none; box-shadow: none; padding: 0; border-radius: 0; }
  .icd-card { gap: var(--space-5); }
  .icd-live { display: none; }
  .icd-panel { margin-top: calc(-1 * var(--space-3)); }
  .icd-search input { height: 56px; }
  .icd-stat { gap: var(--space-4); }
  .icd-count-num { font-size: calc(var(--fs-display-1) * 1.4); }
  .icd-thead > :last-child { display: none; }
  .icd-row { grid-template-columns: var(--icd-cols); grid-template-rows: auto auto; row-gap: 2px; column-gap: var(--space-4); min-height: 64px; }
  .icd-row > .icd-code { grid-row: 1 / span 2; align-self: center; }
  .icd-ch { grid-column: 2; justify-content: flex-start; }
  .icd-ch .icd-chap { display: none; }
  .icd-ch-name { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none; }
  .icd-code { min-width: 5.75rem; padding: 0 var(--space-3) 0 var(--space-4); font-size: var(--fs-small); }
  .icd-name { font-size: var(--fs-card); }
}
