/* ============================================================
   Lävi Clinical Suite — lavi-clinical.com
   Design system: "the diagnostic display"
   Calibrated greyscale; colour appears only where it means
   something (amber = candidate/new–increasing + interaction;
   blue = resolving–decreasing + provenance). Abstention is
   drawn as a colourless hatch, never as an alarm colour.
   Tokens and rationale: docs/design-plan.md
   ============================================================ */

/* ---------- fonts (self-hosted, latin subsets) ---------- */
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url('/fonts/archivo-var.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('/fonts/source-serif-var.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/plex-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/plex-mono-500.woff2') format('woff2');
}

/* ---------- tokens ---------- */
:root {
  /* core palette — 6 named values (see design plan) */
  --bone: #F4F4F2;        /* page ground */
  --film: #D8D9D6;        /* rules, ticks, borders */
  --graphite: #3C4147;    /* body text */
  --ink: #14171B;         /* display type + figure panels */
  --amber: #A05400;       /* meaning: candidate change / action (on light) */
  --blue: #33637F;        /* meaning: resolving lane / provenance (on light) */
  /* derived tints — no new hues */
  --amber-bright: #E8963C; /* amber on dark panels */
  --blue-bright: #7FA8C0;  /* blue on dark panels */
  --muted: #5C6167;        /* captions, secondary text on light */
  --panel-text: #E9EAE7;   /* text on ink panels */
  --panel-muted: #9BA0A6;  /* secondary text on ink panels */
  --panel-line: #3A3F45;   /* structure lines on ink panels */
  --hatch: repeating-linear-gradient(
    -45deg,
    transparent 0 5px,
    rgba(120, 124, 128, 0.45) 5px 6px
  );

  --f-display: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --f-body: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --f-mono: 'IBM Plex Mono', 'Courier New', monospace;

  --measure: 66ch;
  --container: 1160px;
  --radius: 2px;

  color-scheme: light; /* deliberate single-theme identity */
}

/* ---------- reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
body {
  font-family: var(--f-body);
  font-size: 1.0625rem; /* 17px */
  line-height: 1.65;
  color: var(--graphite);
  background: var(--bone);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--amber); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: var(--radius); }
::selection { background: var(--ink); color: var(--bone); }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--bone);
  padding: 0.6rem 1rem; font-family: var(--f-mono); font-size: 0.85rem;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- type roles ---------- */
h1, h2, h3 {
  font-family: var(--f-display);
  font-variation-settings: 'wdth' 118;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.12;
  color: var(--ink);
  text-wrap: balance;
}
h1 { font-size: clamp(2.3rem, 5.4vw, 3.9rem); }
h2 { font-size: clamp(1.55rem, 3vw, 2.15rem); }
h3 { font-size: 1.125rem; font-variation-settings: 'wdth' 105; letter-spacing: -0.005em; }

.kicker {
  font-family: var(--f-mono);
  font-weight: 500;
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.kicker .kicker-no { color: var(--ink); }

.mono { font-family: var(--f-mono); }
.num { font-variant-numeric: tabular-nums; }

p, li { max-width: var(--measure); }
.standfirst {
  font-size: clamp(1.15rem, 2vw, 1.3rem);
  line-height: 1.55;
  max-width: 58ch;
}

/* ---------- layout primitives ---------- */
.container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 3rem);
}
.section {
  padding-block: clamp(3.5rem, 8vw, 6.5rem);
  border-top: 1px solid var(--film);
}
.section-head {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: clamp(1.8rem, 4vw, 2.8rem);
}
.section-head h2 { max-width: 24ch; }
.prose > * + * { margin-top: 1.1rem; }
.prose h3 { margin-top: 2rem; }

@media (min-width: 1024px) {
  .section-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 2.5rem;
    align-items: start;
  }
  .section-grid .section-head { position: sticky; top: 2rem; margin-bottom: 0; }
  .section-grid .section-head h2 { font-size: 1.45rem; }
}

/* ---------- header ---------- */
.site-header {
  border-bottom: 1px solid var(--film);
  background: var(--bone);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.25rem;
  flex-wrap: wrap;
  padding-block: 0.75rem;
}
.wordmark {
  font-family: var(--f-display);
  font-variation-settings: 'wdth' 122;
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
}
.wordmark:hover { text-decoration: none; }
.wordmark .wordmark-sub {
  font-family: var(--f-mono);
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.site-nav ul { display: flex; gap: clamp(1rem, 3vw, 2.2rem); list-style: none; }
.site-nav a {
  font-family: var(--f-mono);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  color: var(--graphite);
  text-decoration: none;
  padding-block: 0.4rem;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); box-shadow: 0 2px 0 0 var(--amber); }

/* ---------- hero ---------- */
.hero { padding-block: clamp(3rem, 7vw, 5.5rem) clamp(2.5rem, 5vw, 4rem); }
.hero-inner { display: flex; flex-direction: column; gap: 1.4rem; }
.hero h1 { max-width: 17ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-top: 0.6rem; }
.status-line {
  font-family: var(--f-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 1px solid var(--film);
  padding-top: 0.9rem;
  margin-top: 1.1rem;
  max-width: none;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  font-family: var(--f-mono);
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.btn-primary { background: var(--amber); color: #FFFFFF; }
.btn-primary:hover { background: #8A4800; }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--graphite); }
.btn-secondary:hover { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

/* ---------- figure panels ("the monitor in the page") ---------- */
.figure-panel {
  background: var(--ink);
  color: var(--panel-text);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 3vw, 2.2rem);
  position: relative;
}
.figure-panel .figcap {
  font-family: var(--f-mono);
  font-size: 0.78rem;
  color: var(--panel-muted);
  margin-top: 1rem;
  max-width: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.6rem;
}
.figure-panel .figcap strong { color: var(--panel-text); font-weight: 500; }
/* corner registration marks */
.figure-panel::before, .figure-panel::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border: 1px solid var(--panel-line);
  pointer-events: none;
}
.figure-panel::before { top: 8px; left: 8px; border-right: 0; border-bottom: 0; }
.figure-panel::after { bottom: 8px; right: 8px; border-left: 0; border-top: 0; }

.fig-desktop { display: block; }
.fig-mobile { display: none; }
@media (max-width: 719px) {
  .fig-desktop { display: none; }
  .fig-mobile { display: block; }
}

/* ---------- key-visual animation (one orchestrated moment) ---------- */
/* Fully rendered by default; JS adds .anim-armed (hides steps) then
   .anim-play (reveals in order). Without JS nothing is ever hidden. */
.anim-armed .anim-step { opacity: 0; }
.anim-armed .anim-slide { transform: translateX(-14px); opacity: 0; }
.anim-play .anim-step, .anim-play .anim-slide { opacity: 1; transform: none; }
.anim-play .anim-step, .anim-play .anim-slide {
  transition: opacity 0.5s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.anim-play .anim-d1 { transition-delay: 0.15s; }
.anim-play .anim-d2 { transition-delay: 0.55s; }
.anim-play .anim-d3 { transition-delay: 0.95s; }
.anim-play .anim-d4 { transition-delay: 1.35s; }
.anim-play .anim-d5 { transition-delay: 1.75s; }
@media (prefers-reduced-motion: reduce) {
  .anim-armed .anim-step, .anim-armed .anim-slide { opacity: 1; transform: none; }
  .anim-play .anim-step, .anim-play .anim-slide { transition: none; }
}

/* ---------- workflow ---------- */
.workflow { list-style: none; counter-reset: wf; display: flex; flex-direction: column; }
.workflow > li {
  counter-increment: wf;
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 1.1rem;
  padding-block: 1.35rem;
  position: relative;
}
.workflow > li + li { border-top: 1px solid var(--film); }
.workflow > li::before {
  content: "0" counter(wf);
  font-family: var(--f-mono);
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--ink);
  border: 1px solid var(--film);
  border-radius: var(--radius);
  width: 2.6rem; height: 2.6rem;
  display: flex; align-items: center; justify-content: center;
  background: #FFFFFF;
}
.workflow h3 { margin-bottom: 0.35rem; }
.workflow p { color: var(--graphite); }

/* ---------- domain cards ---------- */
.domains {
  list-style: none;
  display: grid;
  gap: 1px;
  background: var(--film);
  border: 1px solid var(--film);
  border-radius: var(--radius);
  overflow: hidden;
}
@media (min-width: 720px) { .domains { grid-template-columns: repeat(3, 1fr); } }
.domains > li { background: #FFFFFF; padding: 1.4rem 1.5rem 1.6rem; }
.domains h3 { margin-bottom: 0.4rem; }
.domains p { font-size: 0.97rem; }
.domains .kicker { display: block; margin-bottom: 0.9rem; }

/* ---------- fact list (plain strong statements) ---------- */
.facts { list-style: none; display: flex; flex-direction: column; }
.facts > li { padding-block: 1.2rem; }
.facts > li + li { border-top: 1px solid var(--film); }
.facts h3 { margin-bottom: 0.3rem; }

/* ---------- QC outcomes strip ---------- */
.qc-strip {
  display: grid;
  gap: 1px;
  background: var(--panel-line);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: var(--f-mono);
}
@media (min-width: 720px) { .qc-strip { grid-template-columns: repeat(3, 1fr); } }
.qc-strip > div { background: var(--ink); padding: 1.1rem 1.2rem 1.25rem; }
.qc-strip .qc-label {
  font-size: 0.8rem; font-weight: 500; letter-spacing: 0.1em;
  color: var(--panel-text); display: block; margin-bottom: 0.45rem;
}
.qc-strip p { font-family: var(--f-body); font-size: 0.92rem; color: var(--panel-muted); max-width: none; }
.qc-strip .qc-withheld { background-color: var(--ink); background-image: var(--hatch); }
.qc-strip .qc-withheld .qc-label { background: var(--ink); display: inline-block; padding: 0.1rem 0.35rem; margin-left: -0.35rem; }
.qc-strip .qc-withheld p { background: rgba(20, 23, 27, 0.85); padding: 0.2rem 0.35rem; margin-left: -0.35rem; }

/* ---------- status chip ---------- */
.chip {
  display: inline-block;
  font-family: var(--f-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.28rem 0.6rem;
  border: 1px solid var(--film);
  border-radius: var(--radius);
  color: var(--muted);
  background: #FFFFFF;
}
.chip-now { color: var(--ink); border-color: var(--graphite); }

/* ---------- evidence ladder (validation page) ---------- */
.ladder-group {
  border: 1px solid var(--film);
  border-radius: var(--radius);
  background: #FFFFFF;
}
.ladder-group-title {
  font-family: var(--f-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.8rem 1.4rem;
  border-bottom: 1px solid var(--film);
}
.ladder { list-style: none; }
.ladder > li {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  gap: 1rem;
  align-items: start;
  padding: 1.25rem 1.4rem;
}
.ladder > li + li { border-top: 1px solid var(--film); }
.ladder .rung-no { font-family: var(--f-mono); font-weight: 500; color: var(--ink); font-size: 0.95rem; padding-top: 0.15rem; }
.ladder h3 { margin-bottom: 0.3rem; }
.ladder p { font-size: 0.97rem; }
.ladder .chip { justify-self: end; }
@media (max-width: 719px) {
  .ladder > li { grid-template-columns: 2.2rem 1fr; }
  .ladder .chip { grid-column: 2; justify-self: start; margin-top: 0.5rem; }
}

.ladder-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-block: 1.6rem;
  font-family: var(--f-mono);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}
.ladder-divider::before, .ladder-divider::after {
  content: "";
  flex: 1;
  border-top: 2px solid var(--ink);
}

/* ---------- not-proven panel ---------- */
.not-proven {
  background: var(--ink);
  color: var(--panel-text);
  border-radius: var(--radius);
  padding: clamp(1.6rem, 4vw, 2.8rem);
  position: relative;
}
.not-proven::before {
  content: "";
  position: absolute;
  top: 10px; left: 10px;
  width: 14px; height: 14px;
  border: 1px solid var(--panel-line);
  border-right: 0; border-bottom: 0;
}
.not-proven h2, .not-proven h3 { color: #FFFFFF; }
.not-proven .kicker { color: var(--panel-muted); }
.not-proven ol { list-style: none; counter-reset: np; margin-top: 1.4rem; }
.not-proven ol > li {
  counter-increment: np;
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0.9rem;
  padding-block: 1rem;
}
.not-proven ol > li + li { border-top: 1px solid var(--panel-line); }
.not-proven ol > li::before {
  content: counter(np, decimal-leading-zero);
  font-family: var(--f-mono);
  font-size: 0.85rem;
  color: var(--panel-muted);
  padding-top: 0.2rem;
}
.not-proven p { color: var(--panel-text); }
.not-proven .status-line { border-top-color: var(--panel-line); color: var(--panel-muted); }

/* ---------- regulatory pathway ---------- */
.pathway { list-style: none; counter-reset: pw; }
.pathway > li {
  counter-increment: pw;
  display: grid;
  grid-template-columns: 2.6rem 1fr auto;
  gap: 1rem;
  align-items: baseline;
  padding-block: 0.95rem;
}
.pathway > li + li { border-top: 1px solid var(--film); }
.pathway > li::before {
  content: counter(pw);
  font-family: var(--f-mono);
  font-size: 0.9rem;
  color: var(--muted);
}
.pathway .stage-name { font-family: var(--f-display); font-variation-settings: 'wdth' 105; font-weight: 600; color: var(--ink); }
.pathway .stage-state {
  font-family: var(--f-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.pathway [data-stage-state="current"] .stage-state { color: var(--ink); }
.pathway [data-stage-state="current"]::before { color: var(--ink); font-weight: 500; }
.pathway [data-stage-state="current"] { box-shadow: inset 3px 0 0 0 var(--ink); padding-left: 0.9rem; }
@media (max-width: 719px) {
  .pathway > li { grid-template-columns: 2rem 1fr; }
  .pathway .stage-state { grid-column: 2; }
}

/* ---------- development status: built / not proven ---------- */
.split-status { display: grid; gap: 2.5rem; }
@media (min-width: 900px) { .split-status { grid-template-columns: 1fr 1fr; gap: 3.5rem; } }
.split-status h3 {
  font-family: var(--f-mono);
  font-variation-settings: normal;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.6rem;
  margin-bottom: 0.4rem;
}
.split-status ul { list-style: none; }
.split-status li { padding-block: 0.8rem; font-size: 0.99rem; }
.split-status li + li { border-top: 1px solid var(--film); }

/* ---------- contact ---------- */
.contact-block { display: flex; flex-direction: column; gap: 1.2rem; }
.contact-lines { font-family: var(--f-mono); font-size: 0.95rem; display: flex; flex-direction: column; gap: 0.4rem; }

/* ---------- footer ---------- */
.site-footer {
  background: var(--ink);
  color: var(--panel-text);
  margin-top: clamp(3rem, 7vw, 5rem);
  padding-block: clamp(2.5rem, 5vw, 3.5rem) 2rem;
}
.site-footer .regulatory {
  font-size: 1.02rem;
  line-height: 1.6;
  max-width: 72ch;
  color: #FFFFFF;
  border-left: 3px solid var(--panel-muted);
  padding-left: 1.2rem;
}
.footer-grid {
  display: grid;
  gap: 2rem;
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--panel-line);
}
@media (min-width: 720px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.site-footer h2 {
  font-family: var(--f-mono);
  font-variation-settings: normal;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--panel-muted);
  margin-bottom: 0.8rem;
}
.site-footer ul { list-style: none; display: flex; flex-direction: column; gap: 0.45rem; }
.site-footer a { color: var(--panel-text); }
.site-footer a:hover { color: #FFFFFF; }
.site-footer .fine {
  font-family: var(--f-mono);
  font-size: 0.75rem;
  color: var(--panel-muted);
  margin-top: 2.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.6rem;
  max-width: none;
}

/* ---------- page hero (subpages) ---------- */
.page-hero { padding-block: clamp(2.8rem, 6vw, 4.5rem) clamp(1.5rem, 3vw, 2.5rem); }
.page-hero h1 { max-width: 20ch; margin-block: 0.9rem 1.1rem; }

/* ---------- misc ---------- */
.hairline-note {
  font-size: 0.92rem;
  color: var(--muted);
  border-top: 1px solid var(--film);
  padding-top: 0.9rem;
  margin-top: 2rem;
}
.err-page { min-height: 55vh; display: flex; align-items: center; }
.figcap .glyph-new { color: var(--amber-bright); }
.figcap .glyph-res { color: var(--blue-bright); }
.wordmark .mark { align-self: center; height: 42px; width: auto; margin-right: 0.4rem; }

/* ---------- light figures ("Fig. n" journal style) ---------- */
.fig {
  border: 1px solid var(--film);
  background: #FFFFFF;
  border-radius: var(--radius);
  padding: clamp(1rem, 2.5vw, 1.6rem);
  margin-top: 1.8rem;
}
.fig svg { display: block; width: 100%; height: auto; }
.fig .fig-label {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.2rem;
  font-family: var(--f-mono);
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--film);
  padding-top: 0.7rem;
  margin-top: 1rem;
  max-width: none;
}
.fig .fig-label .fig-no { color: var(--ink); font-weight: 500; letter-spacing: 0.08em; }

/* fig-label variant used inside dark panels */
.figure-panel .fig-no { color: var(--panel-text); font-weight: 500; letter-spacing: 0.08em; }

/* ---------- step glyphs in workflow ---------- */
.workflow .step-glyph { display: block; margin-bottom: 0.5rem; }

/* ---------- domain glyphs ---------- */
.domains .domain-glyph { display: block; margin-bottom: 0.9rem; }

/* ---------- pull statement ---------- */
.pull {
  font-family: var(--f-display);
  font-variation-settings: 'wdth' 112;
  font-weight: 600;
  font-size: clamp(1.25rem, 2.4vw, 1.6rem);
  line-height: 1.32;
  color: var(--ink);
  border-left: 3px solid var(--ink);
  padding-left: 1.2rem;
  margin-block: 1.9rem;
  max-width: 34ch;
  text-wrap: balance;
}
@media (max-width: 719px) {
  .fig { overflow-x: auto; }
  .fig svg { min-width: 540px; }
}

/* ---------- product roadmap cards ---------- */
.products { display: grid; gap: 1.2rem; }
@media (min-width: 760px) { .products { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); } }
.product-card {
  border: 1px solid var(--graphite);
  border-radius: var(--radius);
  background: #FFFFFF;
  padding: 1.5rem 1.6rem 1.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  align-items: flex-start;
}
.product-card.planned { border-style: dashed; background: transparent; }
.product-card h3 { font-size: 1.35rem; }
.product-card p { font-size: 0.99rem; }
.product-card .card-link { margin-top: auto; padding-top: 0.5rem; }
