/* Medicine, A to Z and trust pages.
   Built to the SaaSpocalypse premium bar: hierarchy from type, weight and space; hairline
   rules instead of boxes; one accent element in view; no coloured bars on cards.
   Reading comes first: large body type, short lines, generous spacing, strong contrast. */

:root { --read: 17px; --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace; interpolate-size: allow-keywords; }
html.text-lg { --read: 20px; }

.skip-link { position: absolute; left: 16px; top: -64px; z-index: 10; background: var(--ink); color: var(--surface); padding: 12px 16px; border-radius: var(--control-radius); font-weight: 500; text-decoration: none; transition: top var(--sp-dur-1) var(--sp-ease-out); }
.skip-link:focus { top: 12px; color: var(--surface); }

.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.fig { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.doc main { padding: 0; max-width: none; }
.doc-wide .wrap { max-width: 1120px; }
.wrap.narrow { max-width: 760px; }

/* ---------- Page header ---------- */
.med, .az, .prose { padding-top: var(--sp-space-6); padding-bottom: 96px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--ink-muted); margin-bottom: var(--sp-space-8); }
.crumbs a { color: var(--ink-muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs span[aria-hidden] { color: var(--line-strong); }
.crumbs [aria-current] { color: var(--ink); }

.med-head { max-width: 820px; }
.med-head h1 { font-size: clamp(40px, 6.4vw, 68px); line-height: 1.02; letter-spacing: -0.045em; font-weight: 500; margin: 0 0 var(--sp-space-5); }
.med-head .lede { font-size: clamp(18px, 2vw, 21px); line-height: 1.55; color: var(--ink); max-width: 64ch; margin: 0 0 var(--sp-space-3); }
.ingredient { font-size: 14px; color: var(--ink-muted); margin: 0 0 var(--sp-space-6); }

.provenance { list-style: none; margin: 0; padding: var(--sp-space-4) 0; display: flex; flex-wrap: wrap; gap: 10px 28px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.5; color: var(--ink-muted); }
.provenance li { display: flex; align-items: flex-start; gap: 8px; }
.provenance .ico { margin-top: 1px; }
.provenance strong { color: var(--ink); font-weight: 500; }

.tools { display: flex; flex-wrap: wrap; gap: var(--sp-space-2); margin-top: var(--sp-space-5); }
.tools .btn, .actions .btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; font-weight: 500; font-size: 13px; text-decoration: none; }
.tools .btn[aria-pressed="true"] { background: var(--selected); border-color: var(--line-strong); }
.aa { font-weight: 600; font-size: 14px; }
a.btn.ghost:hover { color: var(--button-secondary-ink); }

/* ---------- Two columns: contents and reading ---------- */
.med-body { display: grid; grid-template-columns: 216px minmax(0, 720px); gap: 72px; align-items: start; margin-top: var(--sp-space-8); }
.med-nav { position: sticky; top: 92px; }
.med-nav p { font-size: 13px; font-weight: 500; color: var(--ink); margin: 0 0 var(--sp-space-3); }
.med-nav ol { list-style: none; margin: 0; padding: 0; }
.med-nav a { display: block; padding: 7px 10px; margin: 0 0 2px -10px; border-radius: 8px; color: var(--ink-muted); font-size: 14px; line-height: 1.35; text-decoration: none; transition: background-color var(--sp-dur-1) var(--sp-ease-out), color var(--sp-dur-1) var(--sp-ease-out); }
.med-nav a:hover { color: var(--ink); background: var(--hover); }
.med-nav a[aria-current="true"] { color: var(--ink); font-weight: 500; background: var(--selected); }

.med-main { font-size: var(--read); line-height: 1.65; min-width: 0; }
.doc-section { margin: 0; padding: var(--sp-space-8) 0; border-top: 1px solid var(--line); scroll-margin-top: 84px; }
.med-main > .doc-section:first-child { border-top: 0; padding-top: 0; }
.doc-section h2 { font-size: clamp(24px, 3vw, 30px); line-height: 1.2; letter-spacing: -0.03em; font-weight: 500; margin: 0 0 var(--sp-space-4); }
.doc-section p { margin: 0 0 var(--sp-space-4); max-width: 66ch; }
.doc-section .lead-in { color: var(--ink-muted); font-size: 0.94em; }
.doc-section .small { font-size: 13px; }
h3.sub { font-size: 1.12em; line-height: 1.3; font-weight: 500; letter-spacing: -0.01em; margin: 0 0 var(--sp-space-2); }

/* Key facts: numbered in the margin, separated by hairlines. */
.keyfacts { list-style: none; counter-reset: fact; margin: 0; padding: 0; }
.keyfacts li { counter-increment: fact; display: grid; grid-template-columns: 48px 1fr; padding: 18px 0; border-top: 1px solid var(--line); }
.keyfacts li:first-child { border-top: 0; padding-top: 4px; }
.keyfacts li::before { content: counter(fact, decimal-leading-zero); font: 400 13px/1 var(--mono); color: var(--ink-muted); padding-top: 0.5em; }

/* Plain rows for warnings and instructions. */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { padding: 13px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }

/* Short items in two columns, each with a quiet marker. */
.cols { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 40px; }
.cols li { break-inside: avoid; position: relative; padding: 5px 0 5px 16px; font-size: 0.94em; line-height: 1.5; }
.cols li::before { content: ""; position: absolute; left: 0; top: 0.92em; width: 4px; height: 4px; border-radius: 50%; background: var(--line-strong); }

/* Fold: the rest of a long list. */
.fold { margin-top: var(--sp-space-2); }
.fold > summary { cursor: pointer; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; color: var(--link); font-weight: 500; font-size: 14px; margin: 0; }
.fold[open] > summary .fold-open, .fold:not([open]) > summary .fold-close { display: none; }
.fold > .rows, .fold > .cols { margin-top: var(--sp-space-2); }
.fold > .rows li:first-child { border-top: 1px solid var(--line); }
.fold::details-content { block-size: 0; overflow: clip; transition: block-size 320ms var(--sp-ease-out), content-visibility 320ms allow-discrete; }
.fold[open]::details-content { block-size: auto; }

/* Urgent help: a status tint, an icon and plain words. */
.urgent { background: var(--status-danger-tint); border-radius: var(--card-radius); padding: var(--sp-space-6); margin: var(--sp-space-2) 0 var(--sp-space-8); }
.urgent h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 var(--sp-space-2); font-size: 1.05em; line-height: 1.3; font-weight: 500; color: var(--status-danger); }
.urgent h3 .ico { width: 22px; height: 22px; }
.urgent p { color: var(--ink); font-size: 0.94em; }
.urgent .rows li { border-color: color-mix(in oklab, var(--status-danger) 20%, transparent); }
.urgent .fold > summary { color: var(--status-danger); }

/* Side effects by frequency: the size of the risk is set large, the effects beside it. */
.ladder { margin: var(--sp-space-5) 0; border-top: 1px solid var(--line-strong); }
.rung { display: grid; grid-template-columns: 188px minmax(0, 1fr); gap: var(--sp-space-7); padding: 28px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 84px; }
.rung-key h3 { font-size: 15px; line-height: 1.3; font-weight: 500; margin: 0 0 6px; }
.rung-fig { margin: 0; font-size: 13px; line-height: 1.35; color: var(--ink-muted); }
.rung-fig strong { display: block; margin: 2px 0; font: 500 28px/1.1 var(--mono); letter-spacing: -0.04em; color: var(--ink); white-space: nowrap; }
.rung-none { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink-muted); }

/* Source panel. */
.facts-grid { margin: var(--sp-space-5) 0; border-top: 1px solid var(--line); }
.facts-grid div { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--sp-space-5); padding: 14px 0; border-bottom: 1px solid var(--line); }
.facts-grid dt { color: var(--ink-muted); font-size: 0.88em; }
.facts-grid dd { margin: 0; font-size: 0.94em; }
.source-note { color: var(--ink-muted); font-size: 0.94em; }
.actions { display: flex; flex-wrap: wrap; gap: var(--sp-space-2); }
.actions .ico { width: 16px; height: 16px; }

/* ---------- A to Z ---------- */
.az-find { margin-top: var(--sp-space-6); }
.az-find label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.az-field { position: relative; max-width: 460px; }
.az-field .ico { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); }
.az-field input { width: 100%; height: 51px; padding: 0 var(--sp-space-4) 0 46px; font: inherit; font-size: 16px; color: var(--ink); background: var(--input-bg); border: 1px solid var(--input-line); border-radius: var(--input-radius); }
.az-find .small { margin: 8px 0 0; min-height: 20px; }
.az-letters { display: flex; flex-wrap: wrap; gap: 4px; margin-top: var(--sp-space-4); }
.az-letters a { min-width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; font: 500 13px/1 var(--mono); color: var(--ink-muted); text-decoration: none; transition: background-color var(--sp-dur-1) var(--sp-ease-out), color var(--sp-dur-1) var(--sp-ease-out); }
.az-letters a:hover { background: var(--hover); color: var(--ink); }
.az main { margin-top: var(--sp-space-8); }
.az-group { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: var(--sp-space-7); padding: 28px 0; border-top: 1px solid var(--line); scroll-margin-top: 84px; }
.az-group h2 { margin: 0; font: 500 28px/1.2 var(--mono); color: var(--ink-muted); }
.az-list { list-style: none; margin: 0; padding: 0; columns: 3; column-gap: var(--sp-space-7); }
.az-list li { break-inside: avoid; }
.az-list a { display: block; padding: 7px 0; font-size: 16px; line-height: 1.4; color: var(--ink); text-decoration: none; transition: color var(--sp-dur-1) var(--sp-ease-out); }
.az-list a:hover { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.az-none { color: var(--ink-muted); padding: var(--sp-space-6) 0; }

/* ---------- Trust pages ---------- */
.prose { font-size: 17px; line-height: 1.65; }
.prose .doc-section { padding: var(--sp-space-7) 0; }
.prose .med-head { margin-bottom: var(--sp-space-6); }
.prose .bullets li { margin: 10px 0; }

.site-foot { border-top: 1px solid var(--line); padding: var(--sp-space-6) 0 var(--sp-space-8); color: var(--ink-muted); font-size: 13px; line-height: 1.7; }
.site-foot p { max-width: 80ch; margin: 0 0 var(--sp-space-2); }
.site-foot strong { color: var(--ink); font-weight: 500; }

/* ---------- Narrow screens ---------- */
@media (max-width: 940px) {
  .med-body { grid-template-columns: minmax(0, 1fr); gap: 0; margin-top: var(--sp-space-6); }
  /* The contents list becomes a strip that stays in reach while reading. */
  .med-nav { top: 64px; z-index: 1; margin: 0 calc(var(--sp-space-4) * -1) var(--sp-space-6); padding: 8px var(--sp-space-4); background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .med-nav p { display: none; }
  /* The strip scrolls sideways only, and never passes a sideways swipe on to the page. */
  .med-nav ol { display: flex; gap: 4px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none; position: relative; }
  .med-nav ol::-webkit-scrollbar { display: none; }
  .med-nav a { margin: 0; white-space: nowrap; padding: 9px 12px; }
  .rung { grid-template-columns: minmax(0, 1fr); gap: var(--sp-space-4); }
  .rung-fig strong { display: inline; font-size: 22px; }
  .az-list { columns: 2; }
  .az-group { grid-template-columns: 44px minmax(0, 1fr); gap: var(--sp-space-4); }
}
@media (max-width: 560px) {
  .cols { columns: 1; }
  .az-list { columns: 1; }
  .facts-grid div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .keyfacts li { grid-template-columns: 36px 1fr; }
  .med, .az, .prose { padding-bottom: 64px; }
  .tools .btn { height: 44px; }
}

/* ---------- People who ask for more contrast ---------- */
@media (prefers-contrast: more) {
  :root { --line: var(--line-strong); --ink-muted: var(--ink); }
  .urgent { outline: 2px solid var(--status-danger); }
}

/* ---------- Paper ---------- */
@media print {
  .site-head, .tools, .med-nav, .skip-link, .head-nav, .fold > summary, .actions, .az-find, .az-letters { display: none !important; }
  body { background: #fff; color: #000; }
  .med-body { display: block; margin-top: 16px; }
  .med-main { font-size: 11.5pt; }
  .doc-section { padding: 16px 0; break-inside: avoid-page; }
  .urgent { background: none; border: 1.5pt solid #000; }
  .urgent h3 { color: #000; }
  a { color: #000; }
  [data-reveal] { opacity: 1 !important; transform: none !important; }
}

/* ---------- Developer page ---------- */
.dev { padding-top: var(--sp-space-8); padding-bottom: 96px; font-size: 17px; line-height: 1.65; }
.dev .doc-section { max-width: 820px; }
.dev .med-head { margin-bottom: var(--sp-space-7); }
.code { margin: var(--sp-space-4) 0; padding: var(--sp-space-4) var(--sp-space-5); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--card-radius); overflow-x: auto; font: 400 13.5px/1.6 var(--mono); color: var(--ink); }
.table-scroll { overflow-x: auto; margin: var(--sp-space-4) 0; }
.plain { width: 100%; border-collapse: collapse; font-size: 15px; }
.plain th { text-align: left; font-size: 12px; font-weight: 500; color: var(--ink-muted); padding: 0 var(--sp-space-4) var(--sp-space-2) 0; border-bottom: 1px solid var(--line-strong); }
.plain td { padding: 12px var(--sp-space-4) 12px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.plain td:first-child { color: var(--ink-muted); }
.plain td:nth-child(2) { white-space: nowrap; }
.request { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-space-4); margin-top: var(--sp-space-5); }
.request .wide { grid-column: 1 / -1; }
.request .hp { position: absolute; left: -9999px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field input, .field textarea { width: 100%; padding: 10px var(--sp-space-3); font: inherit; font-size: 15px; color: var(--ink); background: var(--input-bg); border: 1px solid var(--input-line); border-radius: var(--input-radius); }
.field input { height: 44px; }
.form-note { margin-left: var(--sp-space-3); font-size: 14px; color: var(--ink-muted); }
.form-note[data-state="error"] { color: var(--status-danger); }
.form-note[data-state="ok"] { color: var(--status-success); }
@media (max-width: 560px) { .request { grid-template-columns: 1fr; } }
