/* PharmaOps AI — "lab paper and film coat".
 * One meaning per colour, everywhere: measured = film coat, estimate = steel blue,
 * statistical flag = amber. Type: Atkinson Hyperlegible (label legibility). */

@font-face { font-family: "Atkinson"; src: url("/assets/fonts/atkinson-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("/assets/fonts/atkinson-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("/assets/fonts/atkinson-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --paper: #f5f8f7;
  --sheet: #ffffff;
  --ink: #13272c;
  --ink-soft: #4b6066;
  --rule: #d3dedb;
  --grid: #e4ecea;
  --measured: #d98f7e;      /* film coat: observed / measured */
  --measured-ink: #9c4f3d;
  --estimate: #2f6fa3;      /* model estimate */
  --estimate-soft: #cfe0ee;
  --flag: #b7791f;          /* statistical flag (cohort comparison) */
  --flag-soft: #f5e6c8;
  --focus: #2f6fa3;
  --pocket-empty: #e9efed;
  --shadow: 0 1px 0 rgba(19, 39, 44, 0.06);
  --measure: 72ch;
  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.4rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1d21;
    --sheet: #152a2f;
    --ink: #e7efed;
    --ink-soft: #a7bab6;
    --rule: #2c4449;
    --grid: #213a3f;
    --measured: #e4a593;
    --measured-ink: #f0bfb1;
    --estimate: #7fb3dd;
    --estimate-soft: #1f3c52;
    --flag: #e0a948;
    --flag-soft: #3d3220;
    --focus: #9cc8ec;
    --pocket-empty: #1d353a;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Atkinson", system-ui, sans-serif;
  font-size: var(--step-0);
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}
a { color: var(--estimate); text-underline-offset: 0.18em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--sheet); padding: 0.5rem 1rem; }
.skip:focus { left: 1rem; z-index: 10; }

/* ---------------------------------------------------------------- masthead */
.masthead {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 2rem;
  padding: 1rem clamp(1rem, 4vw, 3rem) 0.75rem;
  border-bottom: 1px solid var(--rule);
  background: var(--sheet);
}
.brand { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--ink); text-decoration: none; font-weight: 700; font-size: var(--step-1); }
.brand-mark { width: 1.6rem; height: 1.6rem; }
.brand-mark ellipse { fill: var(--measured); stroke: var(--ink); stroke-width: 2; }
.brand-mark line { stroke: var(--ink); stroke-width: 2; }
nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.1rem; }
nav a { color: var(--ink-soft); text-decoration: none; padding: 0.2rem 0; border-bottom: 2px solid transparent; }
nav a:hover { color: var(--ink); }
nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--measured); }
.research-strip {
  margin: 0; padding: 0.45rem clamp(1rem, 4vw, 3rem);
  font-size: var(--step--1); color: var(--ink-soft);
  background: repeating-linear-gradient(135deg, transparent 0 10px, var(--grid) 10px 11px);
  border-bottom: 1px solid var(--rule);
  max-width: none;
}

/* ---------------------------------------------------------------- layout */
main { padding: clamp(1.25rem, 4vw, 3rem); max-width: 1180px; margin: 0 auto; outline: none; }
main:focus, main:focus-visible { outline: none; }
.view > * + * { margin-top: 2.25rem; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: clamp(1.9rem, 4.6vw, var(--step-3)); font-weight: 700; max-width: 22ch; letter-spacing: -0.01em; }
h2 { font-size: var(--step-2); font-weight: 700; }
h3 { font-size: var(--step-1); font-weight: 700; }
p { margin: 0; max-width: var(--measure); }
.lede { font-size: var(--step-1); color: var(--ink-soft); max-width: 60ch; margin-top: 1rem; }
.section-head { display: grid; gap: 0.4rem; }
.section-head p { color: var(--ink-soft); }
.loading, .notice { color: var(--ink-soft); }
.notice { border-left: 3px solid var(--flag); padding: 0.6rem 0.9rem; background: var(--flag-soft); max-width: var(--measure); }
.error { border-left: 3px solid var(--measured-ink); padding: 0.6rem 0.9rem; background: var(--sheet); }

/* batch-record header: label | value rows */
.record {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); margin: 0;
}
.record div { padding: 0.65rem 0.9rem 0.75rem 0; border-bottom: 1px solid var(--grid); }
.record dt { font-size: var(--step--1); color: var(--ink-soft); }
.record dd { margin: 0.1rem 0 0; font-size: var(--step-1); font-weight: 700; }
.record dd small { font-weight: 400; font-size: var(--step--1); color: var(--ink-soft); }

/* ---------------------------------------------------------------- blister pack */
.blister-wrap { background: var(--sheet); border: 1px solid var(--rule); padding: 1rem; overflow-x: auto; }
.blister { display: block; width: 100%; height: auto; }
.blister .card { fill: var(--grid); stroke: var(--rule); }
.blister .month { fill: var(--ink-soft); font-size: 11px; }
.blister .pocket { stroke: var(--rule); stroke-width: 1; cursor: pointer; }
.blister a:focus-visible .pocket, .blister a:hover .pocket { stroke: var(--focus); stroke-width: 2.5; }
.blister .ring { fill: none; stroke: var(--flag); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; font-size: var(--step--1); color: var(--ink-soft); margin-top: 0.75rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.swatch { width: 0.9rem; height: 0.9rem; border-radius: 50%; display: inline-block; border: 1px solid var(--rule); }
.swatch.ring { border: 2px solid var(--flag); background: transparent; }
.ramp { width: 5rem; height: 0.7rem; border-radius: 0.35rem; display: inline-block; }

/* ---------------------------------------------------------------- charts & tables */
figure { margin: 0; }
figcaption { font-size: var(--step--1); color: var(--ink-soft); margin-top: 0.5rem; max-width: var(--measure); }
.chart { width: 100%; height: auto; display: block; background: var(--sheet); border: 1px solid var(--rule); }
.chart text { fill: var(--ink-soft); font-size: 11px; font-family: "Atkinson", system-ui, sans-serif; }
.chart .axis { stroke: var(--rule); }
.chart .gridline { stroke: var(--grid); }
.chart .measured { fill: var(--measured); stroke: var(--measured); }
.chart .estimate { fill: var(--estimate); stroke: var(--estimate); }
.chart .estimate-line { fill: none; stroke: var(--estimate); stroke-width: 2; }
.chart .measured-line { fill: none; stroke: var(--measured-ink); stroke-width: 2; }
.chart .ink-line { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.chart .band { fill: var(--estimate-soft); }
.chart .flag { fill: var(--flag); }
.chart .diag { stroke: var(--ink-soft); stroke-dasharray: 4 4; }
.chart .bar { fill: var(--estimate); }
.chart .bar.muted { fill: var(--rule); }
.chart .bar.flagged { fill: var(--flag); }
.chart .bar.lower { fill: var(--ink-soft); }
.chart .split { stroke: var(--ink); stroke-dasharray: 3 3; }
.chart .split-label { fill: var(--ink); font-weight: 700; }
.chart .whisker { stroke: var(--ink); stroke-width: 1.5; }
.grid-2 { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); align-items: start; }
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); background: var(--sheet); }
table { border-collapse: collapse; width: 100%; font-size: var(--step--1); }
th, td { text-align: left; padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { color: var(--ink-soft); font-weight: 700; background: var(--paper); position: sticky; top: 0; }
td.num, th.num { text-align: right; }
tr.is-flag td:first-child { box-shadow: inset 3px 0 var(--flag); }
tbody tr:hover { background: var(--paper); }

/* origin chips: what kind of number this is */
.kind { display: inline-block; font-size: 0.75rem; padding: 0.05rem 0.45rem; border-radius: 1rem; border: 1px solid currentColor; white-space: nowrap; }
.kind.measured { color: var(--measured-ink); }
.kind.estimate { color: var(--estimate); }
.kind.flag { color: var(--flag); }
.kind.model { color: var(--ink-soft); }

/* ---------------------------------------------------------------- controls */
.controls { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: end; }
label { display: grid; gap: 0.25rem; font-size: var(--step--1); color: var(--ink-soft); }
select, input {
  font: inherit; color: var(--ink); background: var(--sheet);
  border: 1px solid var(--rule); border-radius: 4px; padding: 0.45rem 0.6rem; min-width: 10rem;
}
button {
  font: inherit; font-weight: 700; cursor: pointer;
  color: var(--sheet); background: var(--ink); border: 1px solid var(--ink);
  border-radius: 4px; padding: 0.5rem 1rem;
}
button.secondary { background: transparent; color: var(--ink); }
button:disabled { opacity: 0.55; cursor: progress; }
.segmented { display: inline-flex; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; background: transparent; color: var(--ink-soft); font-weight: 400; }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--sheet); font-weight: 700; }

/* ---------------------------------------------------------------- investigation */
.verdict { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.reading { border-top: 2px solid currentColor; padding-top: 0.5rem; }
.reading.measured { color: var(--measured-ink); }
.reading.estimate { color: var(--estimate); }
.reading .value { font-size: var(--step-3); font-weight: 700; line-height: 1.1; }
.reading p { color: var(--ink-soft); font-size: var(--step--1); }
.draft-panel { background: var(--sheet); border: 1px solid var(--rule); padding: 1.25rem; display: grid; gap: 1rem; }
.draft-text { white-space: pre-wrap; background: var(--paper); padding: 1rem; border-left: 3px solid var(--estimate); max-width: none; }
.draft-status { font-size: var(--step--1); color: var(--ink-soft); }
.report { white-space: pre-wrap; font-size: var(--step--1); background: var(--sheet); border: 1px solid var(--rule); padding: 1rem; max-height: 28rem; overflow: auto; max-width: none; }
details summary { cursor: pointer; font-weight: 700; }
details[open] summary { margin-bottom: 0.75rem; }

/* ---------------------------------------------------------------- method */
ol.pipeline { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: 0; border-top: 2px solid var(--ink); }
ol.pipeline li { counter-increment: step; display: grid; grid-template-columns: 3rem 1fr; gap: 0.75rem; padding: 0.85rem 0; border-bottom: 1px solid var(--grid); }
ol.pipeline li::before { content: counter(step); font-weight: 700; font-size: var(--step-2); color: var(--measured-ink); line-height: 1; }
ol.pipeline p { color: var(--ink-soft); }
code, .hash { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.85em; overflow-wrap: anywhere; }

.colophon { padding: 1.5rem clamp(1rem, 4vw, 3rem) 2.5rem; border-top: 1px solid var(--rule); color: var(--ink-soft); font-size: var(--step--1); display: grid; gap: 0.35rem; }

@media (max-width: 640px) {
  .masthead { gap: 0.5rem; }
  nav { gap: 0.15rem 0.85rem; font-size: var(--step--1); }
  .reading .value { font-size: var(--step-2); }
}
@media (prefers-reduced-motion: no-preference) {
  .blister .pocket { transition: stroke-width 120ms ease; }
  .view { animation: settle 260ms ease-out; }
  @keyframes settle { from { opacity: 0.4; } to { opacity: 1; } }
}
