/* Astra — single stylesheet. Tokens copied from the IBM Carbon design system
   (Apache 2.0, carbondesignsystem.com): g10 light theme, g100 dark theme, 8 px
   spacing grid, Carbon type scale. Font: IBM Plex Sans / Mono (SIL OFL 1.1,
   vendored in static/fonts/ with OFL.txt). No external font or resource. */

@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/IBMPlexSans-Regular-Latin1.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: italic; font-weight: 400; font-display: swap; src: url("fonts/IBMPlexSans-Italic-Latin1.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/IBMPlexSans-SemiBold-Latin1.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/IBMPlexMono-Regular-Latin1.woff2") format("woff2"); }

/* Carbon g10 (light). Names kept from the old sheet; values are Carbon tokens:
   bg = background, surface = layer-01, text = text-primary, muted =
   text-secondary, line = border-subtle, accent = link-primary, ok / warn / bad
   = support colours at text contrast (>= 4.5:1 on layer-01), *-soft = the
   matching 10 grade. seq-* = blue sequential data-vis ramp; cat-* = Carbon
   categorical palette (red kept for "late / negative" only). */
:root {
  --bg: #f4f4f4;
  --surface: #ffffff;
  --text: #161616;
  --muted: #525252;
  --line: #e0e0e0;
  --strong-line: #8d8d8d;
  --accent: #0f62fe;
  --accent-soft: #edf5ff;
  --ok: #198038;    --ok-soft: #defbe6;
  --warn: #8e6a00;  --warn-soft: #fcf4d6;
  --bad: #da1e28;   --bad-soft: #fff1f1;
  --mid: #8a3ffc;   --mid-soft: #f6f2ff;
  --banner-bg: #f1c21b; --banner-text: #161616;
  --seq-1: #d0e2ff; --seq-2: #78a9ff; --seq-3: #0043ce; --seq-3-text: #ffffff;
  --cat-1: #6929c4; --cat-2: #1192e8; --cat-3: #005d5d;
  --radius: 0;
  --max: 66rem;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}

/* Carbon g100 (dark). */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161616;
    --surface: #262626;
    --text: #f4f4f4;
    --muted: #c6c6c6;
    --line: #393939;
    --strong-line: #6f6f6f;
    --accent: #78a9ff;
    --accent-soft: #001d6c;
    --ok: #42be65;   --ok-soft: #022d0d;
    --warn: #f1c21b; --warn-soft: #302400;
    --bad: #ff8389;  --bad-soft: #520408;
    --mid: #be95ff;  --mid-soft: #31135e;
    --banner-bg: #f1c21b; --banner-text: #161616;
    --seq-1: #002d9c; --seq-2: #0f62fe; --seq-3: #a6c8ff; --seq-3-text: #161616;
    --cat-1: #be95ff; --cat-2: #33b1ff; --cat-3: #08bdba;
  }
}

* { box-sizing: border-box; }
html { font-size: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
code { font-family: var(--mono); font-size: .875em; }
h1, h2, h3 { font-weight: 400; }
h1 { font-size: 2rem; line-height: 2.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.5rem; line-height: 2rem; margin: 2.5rem 0 1rem; }
h3 { font-size: 1rem; line-height: 1.5rem; font-weight: 600; margin: 0; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem; z-index: 10; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.lead { font-size: 1.1rem; max-width: 46rem; }
.empty { color: var(--muted); font-style: italic; }
.en { color: var(--muted); font-style: italic; font-weight: normal; }

/* Header and navigation */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: .75rem max(1rem, calc((100% - var(--max)) / 2));
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 2rem;
}
.brand { font-weight: 700; font-size: 1.25rem; color: var(--text); text-decoration: none; }
.brand-sub { display: block; font-size: .75rem; font-weight: 400; color: var(--muted); }
.site-nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.site-nav a { color: var(--muted); text-decoration: none; padding: .2rem 0; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

main { max-width: var(--max); margin: 0 auto; padding: 2rem 1rem 3rem; }
.intro { margin-bottom: 1.5rem; }
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem max(1rem, calc((100% - var(--max)) / 2));
  font-size: .85rem; color: var(--muted);
}

/* Key figures */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .75rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stat-n { display: block; font-size: 1.8rem; font-weight: 700; }
.stat-l { color: var(--muted); font-size: .9rem; }

/* Badges */
.badge {
  display: inline-block; font-size: .78rem; font-weight: 600;
  padding: .1rem .55rem; border-radius: 1rem; white-space: nowrap;
  background: var(--accent-soft); color: var(--accent); vertical-align: middle;
}
.conf-established, .ok, .dir-pro { background: var(--ok-soft); color: var(--ok); }
.conf-debated, .dir-nuance { background: var(--warn-soft); color: var(--warn); }
.conf-speculative { background: var(--mid-soft); color: var(--mid); }
.warn { background: var(--warn-soft); color: var(--warn); }
.dir-con { background: var(--bad-soft); color: var(--bad); }
.status-done { background: var(--ok-soft); color: var(--ok); }
.status-open { background: var(--accent-soft); color: var(--accent); }
.level { background: transparent; border: 1px solid var(--line); color: var(--text); font-weight: 500; }
.level .dots { letter-spacing: 1px; color: var(--accent); }
.tag { display: inline-block; font-size: .78rem; padding: 0 .45rem; border: 1px solid var(--line); border-radius: 0; color: var(--muted); margin-right: .25rem; }
.count { font-size: .85rem; font-weight: 500; color: var(--muted); }
.legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; font-size: .9rem; color: var(--muted); }

/* Cards (map of aging) */
.family { margin-bottom: 2rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; display: flex; flex-direction: column;
}
.card header { display: grid; grid-template-columns: auto 1fr; column-gap: .6rem; }
.card-num {
  grid-row: span 2; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.card .en { margin: 0; font-size: .85rem; }
.card > p { flex: 1; margin: .75rem 0; }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; font-size: .85rem; }
.card-foot .more { margin-left: auto; }

/* Lists, tables, detail pages */
.list { list-style: none; padding: 0; margin: 0; }
.list > li { padding: .8rem 0; border-bottom: 1px solid var(--line); }
.list .meta { margin-top: .3rem; font-size: .85rem; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table th, .table td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.statement { font-size: 1.5rem; font-weight: 600; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 1rem; }
.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: .75rem; align-items: center; margin: .5rem 0; }
.vs { font-size: 1.4rem; color: var(--bad); }
.doi { font-family: var(--mono); font-size: .9em; word-break: break-all; }

/* Journal */
.timeline { list-style: none; padding: 0 0 0 1rem; margin: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: .35rem 0 .35rem .75rem; }
.timeline li::before {
  content: ""; position: absolute; left: -1.38rem; top: .85rem;
  width: .6rem; height: .6rem; border-radius: 50%; background: var(--accent);
}
.timeline .time { font-family: var(--mono); font-size: .85rem; color: var(--muted); margin-right: .4rem; }
.timeline.compact li::before { width: .45rem; height: .45rem; left: -1.3rem; }

/* Glossary */
.glossary .entry { padding: .7rem 0; border-bottom: 1px solid var(--line); scroll-margin-top: 1rem; }
.glossary .entry:target { background: var(--accent-soft); padding-left: .5rem; border-radius: 0; }
.glossary dt { font-weight: 700; }
.glossary dd { margin: .2rem 0 0; }

/* Literature notes (long text rendered from markdown) */
.prose { max-width: 44rem; font-size: 1.02rem; line-height: 1.7; overflow-wrap: break-word; }
.prose h1 { font-size: 1.9rem; margin: 0 0 1rem; }
.prose h2 { font-size: 1.35rem; margin: 2.5rem 0 .75rem; padding-bottom: .3rem; border-bottom: 1px solid var(--line); }
.prose h3 { font-size: 1.1rem; margin: 1.75rem 0 .5rem; }
.prose h4 { font-size: 1rem; margin: 1.5rem 0 .4rem; }
.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin: .25rem 0; }
.prose li > ul, .prose li > ol { margin: .25rem 0 0; }
.prose blockquote {
  margin: 1.25rem 0; padding: .75rem 1rem; border-left: 4px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code { background: var(--accent-soft); padding: .05rem .3rem; border-radius: 0; }
.prose pre { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
.prose img { max-width: 100%; height: auto; }
.prose sup, .prose sub { line-height: 0; }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; margin: 1.25rem 0; font-size: .92rem; max-width: 100%; }
.prose th, .prose td { border: 1px solid var(--line); padding: .45rem .65rem; text-align: left; vertical-align: top; }
.prose th { background: var(--surface); font-weight: 600; }
.prose tr:nth-child(even) td { background: var(--surface); }
.prose .footnote-definition { font-size: .88rem; color: var(--muted); margin: .4rem 0; }
.prose .footnote-definition p { display: inline; }
.prose .footnote-definition-label { font-weight: 600; margin-right: .3rem; }
.prose .footnote-reference a { text-decoration: none; }
.prose :target { background: var(--warn-soft); border-radius: 0; }
.doc-foot { max-width: 44rem; margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .9rem; }

/* Filter bar */
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; margin-bottom: 1rem; font-size: .9rem; }
.filter { display: flex; align-items: center; gap: .6rem; flex: 1 1 18rem; margin-bottom: 1rem; }
.toolbar .filter { margin-bottom: 0; }
input[type="search"], select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 0; padding: .45rem .65rem;
}
input[type="search"] { width: 100%; }
input[type="search"]:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.filter-count { font-size: .85rem; color: var(--muted); white-space: nowrap; }
[hidden] { display: none !important; }

/* Glossary tooltips */
abbr[data-term] { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.tooltip {
  position: absolute; z-index: 20; max-width: 22rem;
  background: var(--text); color: var(--bg);
  padding: .6rem .8rem; border-radius: 0; font-size: .85rem; line-height: 1.45;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.tooltip strong { display: block; margin-bottom: .15rem; }
.tooltip a { color: inherit; }

@media (max-width: 40rem) {
  h1 { font-size: 1.5rem; }
  .versus { grid-template-columns: 1fr; }
  .vs { text-align: center; }
  .table thead { display: none; }
  .table td { display: block; border: 0; padding: .25rem .75rem; }
  .table tr { display: block; border-bottom: 1px solid var(--line); padding: .5rem 0; }
}

@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --line: #bbb; }
  .site-nav, .toolbar, .filter, .skip, .tooltip, .card-foot .more { display: none !important; }
  [hidden] { display: revert !important; }
  body { font-size: 11pt; }
  main { padding: 0; max-width: none; }
  .card, .table, .stat, .prose table, .prose blockquote { break-inside: avoid; }
  .prose h2, .prose h3 { break-after: avoid; }
  .prose { max-width: none; }
  a { color: #000; text-decoration: none; }
  .doi::after { content: ""; }
  abbr[data-term] { text-decoration: none; }
}

/* D109: "research prototype, not medical advice" banner, on every page. */
.prototype-banner {
  margin: 0;
  padding: .4rem 1rem;
  background: var(--banner-bg);
  color: var(--banner-text);
  border-bottom: 1px solid var(--strong-line);
  text-align: center;
  font-weight: 600;
  font-size: .875rem;
  line-height: 1.25rem;
}

/* Roadmap: obstacle Gantt chart (SVG generated by astra-site). */
.gantt-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; margin-bottom: 1.5rem; }
.gantt { font: 12px var(--font); }
.gantt .grid { stroke: var(--line); }
.gantt .month, .gantt .year, .gantt .today-label { fill: var(--muted); }
.gantt .code { fill: currentColor; font-weight: 600; }
.gantt .bar.open { fill: var(--seq-2); } .gantt .exit.open, .gantt .milestone.open { fill: var(--seq-3); }
.gantt .bar.late, .gantt .exit.late, .gantt .milestone.late { fill: var(--bad); }
.gantt .exit.done, .gantt .milestone.done { fill: var(--ok); }
.gantt .today { stroke: var(--bad); stroke-dasharray: 3 3; }
.gantt a:hover .code { text-decoration: underline; }
tr.late td, .late { color: var(--bad); }
.tag.late { border-color: var(--bad); }
.doc-list li { margin: .3rem 0; }

/* Findings: ITP forest plot (SVG generated by astra-site) and axis coverage. */
.chart-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; margin-bottom: 1rem; }
.forest { font: 12px var(--font); }
.forest .grid, .forest .group { stroke: var(--line); }
.forest .zero { stroke: currentColor; stroke-width: 1.5; }
.forest .tick { fill: var(--muted); text-anchor: middle; }
.forest .compound { fill: currentColor; font-weight: 600; }
.forest .detail, .forest .value { fill: var(--muted); }
.forest .dot.extends { fill: var(--ok); stroke: var(--ok); }
.forest .dot.no-effect { fill: var(--muted); stroke: var(--muted); }
.forest .dot.unverified { fill: var(--surface); stroke-width: 1.5; }
.forest a:hover .detail { text-decoration: underline; }
/* Findings: R-Sim v0 challenge heatmap and cost curve. */
.heatmap, .cost { font: 12px var(--font); }
.heatmap text { fill: currentColor; }
.heatmap .panel { font-weight: 600; text-anchor: middle; }
.heatmap .age, .heatmap .dose { fill: var(--muted); }
.heatmap .dose, .heatmap .cell text { text-anchor: middle; }
.heatmap .cell rect { stroke: var(--surface); }
.heatmap .s0 rect, .legend .s0 { fill: var(--surface); background: var(--surface); }
.heatmap .s1 rect, .legend .s1 { fill: var(--seq-1); background: var(--seq-1); }
.heatmap .s2 rect, .legend .s2 { fill: var(--seq-2); background: var(--seq-2); }
.heatmap .split rect, .legend .split { fill: var(--seq-3); background: var(--seq-3); }
.heatmap .split text { fill: var(--seq-3-text); font-weight: 600; }
.heatmap .none rect { fill: var(--line); }
.legend { font-size: .85rem; color: var(--muted); }
.legend .sw { display: inline-block; width: 1rem; height: .8rem; border: 1px solid var(--line); vertical-align: middle; margin: 0 .2rem 0 .6rem; }
.cost .grid { stroke: var(--line); }
.cost .tick, .cost .axis { fill: var(--muted); text-anchor: middle; }
.cost .tick-y { fill: var(--muted); text-anchor: end; }
.cost .key { fill: currentColor; }
.cost path, .cost line.all, .cost line.repeat { fill: none; stroke: currentColor; stroke-width: 2; }
.cost .repeat { stroke-dasharray: 5 3; }
.cost .k0 { stroke: var(--cat-1); }
.cost .k1 { stroke: var(--cat-2); }
.cost .k2 { stroke: var(--cat-3); }
.missing { margin-bottom: 1.5rem; }
.coverage { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .4rem; }
.coverage li, .cov { border: 1px solid var(--line); border-left-width: 6px; border-radius: 0; padding: .3rem .5rem; }
.cov { display: inline-block; margin: 0 .3rem .3rem 0; }
.coverage .code { font-weight: 600; margin-right: .25rem; }
.coverage .muted { display: block; font-size: .8rem; }
.cov-readout { border-left-color: var(--ok); }
.cov-molecular { border-left-color: var(--warn); }
.cov-gap { border-left-color: var(--bad); background: var(--bad-soft); }
