/* ---------------------------------------------------------------------------
   Wikipedia-style theme for the /Wiki area (FR-W33, scheme A selected
   2026-07-05). Self-hosted, CSP-clean (no CDN, no inline styles required
   by markup). It should *feel* like Wikipedia — sidebar, infobox rail,
   TOC, footnotes, category bar — without claiming to be it.

   Design system of record: docs/DESIGN_SYSTEM_SPEC.md v1.0 (2026-07-28,
   ten-system research synthesis). Georgia serif for everything read,
   system sans for everything used, warm near-black ink on faint warm
   paper (#fff reserved for exhibits), aubergine #5B2C6F on links and
   the active-tab underline only. Semantic badge/chart colors and the
   wiki figure SVGs keep their meaning (figure recolor = separate pass
   with a prose sweep).

   Exhibit framing: bounded exhibits — charts, the right-rail infobox,
   data tables, scope/pull-out boxes — get a 1px light-gray hairline
   (#c8c8c8, square/<=2px corners; never black at frame weight, never
   red), with an optional light-gray caption strip (#f7f7f7) inside the
   bottom edge for figure captions and data-vintage stamps. Body prose
   stays unframed.

   The custom properties below are the scheme-A values of record, shared
   by both areas since P2.4 (wiki is master, directive 2026-07-05):
   _Layout.cshtml links this file site-wide (after site.css), site.css
   consumes the tokens for the report chrome, and divergence between the
   two areas is a defect. Rules in this file stay .wiki-*-scoped; the
   masthead and page base live in site.css.
--------------------------------------------------------------------------- */

/* TOKENS OF RECORD — docs/DESIGN_SYSTEM_SPEC.md v1.0 (2026-07-28) defines
   every value below and the complete element assignments. Do not add
   font-size/font-family literals outside this block (exceptions: .archmap
   SVG internals, chart config, Cambria Math). */
:root {
    /* §2 ONE family (edict 1, v1.1) — the sans carries everything; the
       serif token remains only for document exports (Word memos). */
    --wk-sans: "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
    --wk-serif: Georgia, "Times New Roman", serif;
    --wk-mono: Consolas, "Courier New", monospace;
    /* §3 type roles — v1.1 mockup-approved values */
    --fs-h1: 28px;      /* every page title, 400, lh 1.2 */
    --fs-h2: 20px;      /* section heads, 400, lh 1.25 */
    --fs-brand: 19px;   /* masthead brand, 700 — the one bold-at-size */
    --fs-h3: 18px;      /* card titles / minor heads, 700 */
    --fs-body: 15px;    /* prose, 400, lh 1.6, measure <=46em */
    --fs-ui: 14px;      /* ALL chrome: nav, user, tables, forms, labels */
    --fs-meta: 13px;    /* secondary metadata: muted, bylines, captions */
    --fs-small: 12.5px; /* fine print floor — nothing renders smaller */
    /* §4 color */
    --wk-ink: #1A1A1A;        /* warm near-black — never #000 */
    --wk-ink-2: #57534B;      /* the ONE secondary gray (warm) */
    --wk-paper: #FAF9F6;      /* page canvas incl. masthead */
    --wk-exhibit: #fff;       /* exhibit surfaces: tables, cards, login box */
    --wk-muted: var(--wk-ink-2);
    --wk-link: #5B2C6F;       /* aubergine: links, active tab, focus — nothing else */
    --wk-link-hover: #4A235A; /* darker, never brighter */
    --wk-rule: #1A1A1A;       /* top-rank rules: masthead bottom, table head */
    --wk-hairline: #D8D3C9;   /* exhibit frames + structural rules (warm) */
    --wk-cellline: #E9E5DD;   /* interior table cell rules (warm) */
    --wk-caption-bg: #F4F2ED; /* caption strip / pull-out box tint */
}

/* Page base and masthead moved to site.css at P2.4 (scheme A everywhere;
   the active-tab red underline is .topbar .navlink.active, set per current
   page by _Layout.cshtml). */

.wiki-shell {
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    gap: 0;
    font-family: var(--wk-sans);
    color: var(--wk-ink);
    background: var(--wk-paper);
    border: 1px solid var(--wk-hairline);
    border-radius: 2px;
    min-height: 70vh;
}

/* --- links: red is for links (and the active-tab underline) only --- */
.wiki-shell a { color: var(--wk-link); }
.wiki-shell a:visited { color: var(--wk-link); }
.wiki-shell a:hover { color: var(--wk-link-hover); }
/* Wanted/missing-article "red links" (FR-W1): with ordinary links now red,
   the broken-link signal moves to the dashed underline; the darker pure
   red is kept for continuity. */
.wiki-shell a.wiki-red, .wiki-shell a.wiki-red:visited {
    color: #ba0000;
    text-decoration: underline dashed;
}

/* --- neutral controls: no colored chrome inside the wiki --- */
.wiki-shell button {
    background: var(--wk-paper);
    color: var(--wk-ink);
    border: 1px solid var(--wk-hairline);
    border-radius: 2px;
}
.wiki-shell button:hover { background: var(--wk-caption-bg); filter: none; }
.wiki-shell input, .wiki-shell select, .wiki-shell textarea {
    border: 1px solid var(--wk-hairline);
    border-radius: 2px;
}

/* --- sidebar --- */
.wiki-sidebar {
    padding: 0.9rem 0.8rem;
    font-size: var(--fs-ui);
    border-right: 1px solid var(--wk-hairline);
}
.wiki-logo { margin-bottom: 0.8rem; }
.wiki-logo a {
    font-size: var(--fs-body);
    line-height: 1.25;
    color: var(--wk-ink);
    text-decoration: none;
    display: inline-block;
}
.wiki-side-search { display: flex; gap: 0.25rem; margin-bottom: 0.9rem; }
.wiki-side-search input { width: 100%; min-width: 0; font-size: var(--fs-ui); }
.wiki-side-search button { font-size: var(--fs-ui); padding: 0.25rem 0.5rem; }
.wiki-sidebar h3 {
    font-size: var(--fs-ui);
    color: var(--wk-muted);
    border-bottom: 1px solid var(--wk-hairline);
    margin: 0.9rem 0 0.3rem;
    padding-bottom: 0.15rem;
    font-weight: 700;
    text-transform: none;
}
.wiki-sidebar ul { list-style: none; margin: 0; padding: 0; }
.wiki-sidebar li { margin: 0.15rem 0; }
.wiki-sidebar a { text-decoration: none; }
.wiki-sidebar a:hover { text-decoration: underline; }

/* --- content pane --- */
.wiki-main {
    background: var(--wk-paper);
    padding: 1.4rem 2rem 2.4rem;
    min-width: 0;
}

.wiki-title, .wiki-main h1 {
    color: var(--wk-ink);
    font-size: var(--fs-h1);
    font-weight: normal;
    line-height: 1.2;
    border-bottom: 1px solid var(--wk-hairline);
    padding-bottom: 0.15rem;
    margin: 0.2rem 0 0.5rem;
}
.wiki-body h1 {
    color: var(--wk-ink);
    font-weight: normal;
    font-size: var(--fs-h1);
    line-height: 1.2;
    border-bottom: 1px solid var(--wk-hairline);
    padding-bottom: 0.15rem;
    margin-top: 1.5rem;
}
.wiki-body h2 {
    color: var(--wk-ink);
    font-weight: normal;
    font-size: var(--fs-h2);
    line-height: 1.25;
    border-bottom: 1px solid var(--wk-hairline);
    padding-bottom: 0.15rem;
    margin-top: 1.5rem;
}
.wiki-body h3 { font-size: var(--fs-h3); font-weight: 700; margin-top: 1.2rem; }
.wiki-body { line-height: 1.6; font-size: var(--fs-body); max-width: 46em; }
/* Spec §2: wiki apparatus (sidebar, infobox, crumbs, footnotes) is chrome */
.wiki-sidebar, .wiki-infobox, .wiki-topn-crumbs, .wiki-body .footnotes {
    font-family: var(--wk-sans);
}
/* Even paragraph rhythm (Wikipedia-feel audit 2026-07-11): the same gap
   between every block, no double-spaced or cramped stretches. */
.wiki-body p { margin: 0.6em 0; }
.wiki-body ul, .wiki-body ol { margin: 0.6em 0; }
.wiki-body li { margin: 0.25em 0; }

/* --- article figures (methodology teaching graphics, 2026-07-10) ---
   Markdown images get the exhibit treatment: hairline frame, white
   ground, caption strip. Class hooks come from Markdig generic
   attributes: ![alt](src){.wiki-fig} and *caption*{.wiki-figcap}. */
.wiki-body img {
    max-width: 100%;
    height: auto;
}
.wiki-body img.wiki-fig {
    display: block;
    border: 1px solid var(--wk-hairline);
    border-radius: 2px;
    background: var(--wk-paper);
    padding: 0.6rem;
    margin: 1rem 0 0;
}
.wiki-body img.wiki-fig + br { display: none; }

/* --- math blocks (```math fences): serif math typography, not code ---
   Markdig emits <pre><code class="language-math">. Cambria Math carries
   proper Greek, radicals, and operators on this Windows-served LAN. */
.wiki-body pre:has(> code.language-math) {
    background: transparent;
    border: none;
    padding: 0.3rem 0 0.3rem 2.2rem;
    overflow-x: auto;
}
.wiki-body code.language-math {
    font-family: "Cambria Math", Cambria, "Times New Roman", serif;
    font-size: var(--fs-h2);
    line-height: 1.9;
    color: var(--wk-ink);
    background: transparent;
}
/* symbol legend under a formula: definition list, tight and indented */
.wiki-body dl { margin: 0.2rem 0 1rem 2.2rem; }
.wiki-body dt {
    float: left;
    clear: left;
    min-width: 3.4rem;
    font-family: "Cambria Math", Cambria, "Times New Roman", serif;
    font-size: var(--fs-body);
    font-weight: 600;
}
.wiki-body dd { margin: 0 0 0.35rem 4.2rem; }
.wiki-body em.wiki-figcap {
    display: block;
    font-style: italic;
    font-size: var(--fs-ui);
    color: var(--wk-muted);
    background: var(--wk-caption-bg);
    border: 1px solid var(--wk-hairline);
    border-top: none;
    border-radius: 0 0 2px 2px;
    padding: 0.35rem 0.6rem;
    margin: 0 0 1rem;
}

/* --- Main Page (P2.1, portal form 2026-07-10): wikipedia.org-style
   portal — centered wordmark, categories flanking a central emblem,
   search, then Featured/Start-here and a grid of destination rows.
   Monochrome: hairline frames, red kept for links only. --- */
.wiki-portal { max-width: 62rem; margin: 0 auto; }
.wiki-portal-mast { text-align: center; margin: 0.8rem 0 0.4rem; }
.wiki-portal-title {
    border-bottom: none;
    font-size: var(--fs-h1);
    letter-spacing: 0.04em;
    margin: 0;
}
.wiki-portal-sub { color: var(--wk-muted); margin: 0.15rem 0 0; font-size: var(--fs-body); }
/* W-2.3 module strip: one quiet row, ui-size, hairline-separated. */
.wiki-portal-modules {
    display: flex; justify-content: center; flex-wrap: wrap;
    gap: 0.4rem 1.6rem; margin-top: 0.6rem; font-size: var(--fs-ui);
}
.wiki-portal-module { display: inline-flex; gap: 0.55rem; align-items: baseline; }
.wiki-portal-module .muted { font-size: var(--fs-meta); }
.wiki-portal-center {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1.6rem;
    align-items: center;
    justify-items: center;
    margin: 1.2rem 0 1rem;
}
.wiki-portal-emblem { display: block; }
.wiki-portal-cats {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-self: stretch;
    padding: 0.4rem 0;
}
.wiki-portal-cats-left { align-items: flex-end; text-align: right; }
.wiki-portal-cats-right { align-items: flex-start; text-align: left; }
.wiki-portal-cat a { text-decoration: none; font-size: var(--fs-body); }
.wiki-portal-cat a:hover { text-decoration: underline; }
.wiki-portal-cat .muted { display: block; font-size: var(--fs-ui); }
.wiki-portal-search { display: flex; justify-content: center; gap: 0.4rem; margin: 0.6rem 0; }
.wiki-portal-search input { width: min(30rem, 70%); padding: 0.4rem 0.7rem; font-size: var(--fs-body); }
.wiki-portal-edit { text-align: center; margin: 0.4rem 0 0; }
.wiki-portal-rule {
    border: none;
    border-top: 1px solid var(--wk-hairline);
    margin: 1.4rem 0;
}
.wiki-portal-rows {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.9rem 1.4rem;
    margin: 1.4rem 0 0.6rem;
}
@media (max-width: 60rem) { .wiki-portal-rows { grid-template-columns: 1fr; } }
.wiki-portal-row {
    display: flex;
    gap: 0.7rem;
    align-items: center;
    text-decoration: none;
    color: var(--wk-ink);
}
.wiki-portal-row strong { color: var(--wk-link); }
.wiki-portal-row:hover strong { text-decoration: underline; }
.wiki-portal-row .muted { font-size: var(--fs-ui); }
.wiki-portal-glyph {
    flex: 0 0 auto;
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid var(--wk-hairline);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-h2);
    background: var(--wk-caption-bg);
}
.wiki-mp-grid {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 1rem;
    align-items: start;
}
@media (max-width: 60rem) { .wiki-mp-grid { grid-template-columns: 1fr; } }
.wiki-mp-col { display: flex; flex-direction: column; gap: 1rem; }
.wiki-mp-box {
    border: 1px solid var(--wk-hairline);
    border-radius: 2px;
    background: var(--wk-paper);
}
.wiki-mp-h {
    margin: 0;
    padding: 0.35rem 0.8rem;
    background: var(--wk-caption-bg);
    border-bottom: 1px solid var(--wk-hairline);
    font-size: var(--fs-body);
    font-weight: 600;
}
.wiki-mp-body { padding: 0.6rem 0.9rem 0.8rem; }
.wiki-mp-body > :first-child { margin-top: 0.2rem; }
.wiki-mp-body > :last-child { margin-bottom: 0; }
.wiki-mp-featured-title { font-size: var(--fs-h2); margin: 0.2rem 0 0.4rem; }
.wiki-mp-path { margin: 0.4rem 0 0.6rem; padding-left: 1.4rem; }
.wiki-mp-path li { margin: 0.25rem 0; }
/* --- collapsible context columns (2026-07-11, wired in site.js) ---
   Cells marked .col-ctx (z raw, percentile, paid-dollar context) are
   hidden by default so the big scoring tables lead with the ~11 triage
   columns; the Show-All-Columns toggle reveals them, and the choice is
   remembered per browser. Nothing is removed — CSV exports always carry
   every column. */
.col-ctx { display: none; }
table.show-ctx .col-ctx { display: table-cell; }
.table-ctx-toggle {
    display: inline-block;
    font-size: var(--fs-ui);
    margin: 0.2rem 0.9rem 0.8rem 0;
    text-decoration: none;
}
.table-ctx-toggle:hover { text-decoration: underline; }

/* --- sortable tables + CSV links (2026-07-10, wired in site.js) --- */
th.th-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.th-sortable:hover { background: #efefef; }
th.th-sortable::after { content: " ↕"; color: var(--wk-hairline); font-size: 0.8em; }
th.th-sortable[data-sort="asc"]::after { content: " ▲"; color: var(--wk-ink); }
th.th-sortable[data-sort="desc"]::after { content: " ▼"; color: var(--wk-ink); }
.table-csv-link {
    display: inline-block;
    font-size: var(--fs-ui);
    margin: 0.2rem 0 0.8rem;
    text-decoration: none;
}
.table-csv-link:hover { text-decoration: underline; }
/* header tooltips: dotted underline marks a th that explains itself */
th[title] { text-decoration: underline dotted var(--wk-muted); text-underline-offset: 3px; cursor: help; }
th[title] a { cursor: pointer; }

/* --- data tables are exhibits: hairline frame, light interior rules --- */
.wiki-body table, .wiki-main table {
    width: auto;
    border: 1px solid var(--wk-hairline);
    border-radius: 2px;
}
.wiki-body th, .wiki-main th { background: var(--wk-caption-bg); }
.wiki-body th, .wiki-body td,
.wiki-main th, .wiki-main td {
    border: 1px solid var(--wk-cellline);
}
/* Table density (design review 2026-07-12): Wikipedia-compact. Prose keeps
   1rem/1.6, but data cells drop to 0.95rem with tight padding and top
   alignment, so a one-line row is ~1.8rem tall instead of ~2.3rem — the
   Recent-Changes and top-N tables read as lists, not layouts. (The infobox
   defines its own, later in this sheet.) */
.wiki-body table, .wiki-main table {
    border-collapse: collapse;
    font-size: var(--fs-ui);
}
.wiki-body th, .wiki-body td,
.wiki-main th, .wiki-main td {
    padding: 0.18rem 0.5rem;
    line-height: 1.35;
    vertical-align: top;
}
/* timestamp columns keep one line (Changes / History) */
.wiki-main td.nowrap, .wiki-main th.nowrap { white-space: nowrap; }
/* footnote back-references (↩): breathing room so they don't read as
   junk glued to a reference URL */
.wiki-body .footnotes a[href^="#fnref"] {
    margin-left: 0.35rem;
    font-size: 0.85em;
}

/* --- article tabs (Read / Edit / History): red underline = active --- */
.wiki-main .wiki-tabs { border-bottom: 1px solid var(--wk-hairline); }
.wiki-tabs a { text-decoration: none; padding-bottom: 0.3rem; }
.wiki-tabs a.active {
    color: var(--wk-ink);
    border-bottom: 3px solid var(--wk-link);
    margin-bottom: -1px;
}

/* --- table of contents (auto for >= 3 headings): pull-out box --- */
.wiki-toc {
    display: inline-block;
    background: var(--wk-caption-bg);
    border: 1px solid var(--wk-hairline);
    border-radius: 2px;
    padding: 0.5rem 1.1rem 0.5rem 0.8rem;
    font-size: var(--fs-ui);
    margin: 0.4rem 0 1rem;
}
.wiki-toc ol { margin: 0.3rem 0 0; padding-left: 1.4rem; }
.wiki-toc li.toc-l3 { margin-left: 1.1rem; list-style-type: lower-alpha; }
.wiki-toc li.toc-l4, .wiki-toc li.toc-l5, .wiki-toc li.toc-l6 { margin-left: 2rem; }
.wiki-toc a { text-decoration: none; }

/* --- right-rail infobox (FR-W33); live-data infoboxes reuse this shell.
       Exhibit: hairline frame; the vintage note is the caption strip. --- */
.wiki-infobox {
    float: right;
    clear: right;
    width: 17rem;
    margin: 0 0 0.8rem 1.2rem;
    background: var(--wk-paper);
    border: 1px solid var(--wk-hairline);
    border-radius: 2px;
    font-size: var(--fs-ui);
    padding: 0.35rem;
}
.wiki-infobox-title {
    text-align: center;
    font-weight: 600;
    padding: 0.25rem 0.2rem 0.35rem;
    font-size: var(--fs-body);
}
.wiki-infobox table { width: 100%; background: transparent; font-size: var(--fs-ui); border: none; }
.wiki-infobox th, .wiki-infobox td {
    border: none;
    border-bottom: 1px solid var(--wk-cellline);
    padding: 0.22rem 0.3rem;
    vertical-align: top;
    background: transparent;
    position: static;
}
.wiki-infobox th { text-align: left; width: 38%; color: var(--wk-muted); font-weight: 600; }
.wiki-infobox-note {
    text-align: center;
    color: var(--wk-muted);
    background: var(--wk-caption-bg);
    margin: 0.35rem -0.35rem -0.35rem;
    padding: 0.35rem 0.55rem;
    border-top: 1px solid var(--wk-hairline);
    font-size: var(--fs-ui);
}

/* --- charts are exhibits too (caption strip via .wiki-exhibit-caption) --- */
.wiki-main .chart {
    border: 1px solid var(--wk-hairline);
    border-radius: 2px;
    background: var(--wk-paper);
}
.wiki-exhibit-caption {
    background: var(--wk-caption-bg);
    border: 1px solid var(--wk-hairline);
    border-top: none;
    margin-top: -1.75rem;      /* sit flush under .chart's bottom margin */
    margin-bottom: 1.75rem;
    padding: 0.3rem 0.6rem;
    color: var(--wk-muted);
    font-size: var(--fs-ui);
}

/* --- footnotes (Markdig renders div.footnotes) --- */
.wiki-body .footnotes { font-size: var(--fs-ui); color: var(--wk-ink); margin-top: 1.5rem; }
.wiki-body .footnotes hr { border: none; border-top: 1px solid var(--wk-hairline); }
.wiki-body sup a { text-decoration: none; }

/* --- category bar / byline inherit site.css; tighten inside theme --- */
.wiki-main .wiki-catbar {
    background: var(--wk-caption-bg);
    border-color: var(--wk-hairline);
    border-radius: 2px;
}
.wiki-main .wiki-byline { border-color: var(--wk-hairline); color: var(--wk-muted); }

@media (max-width: 900px) {
    .wiki-shell { grid-template-columns: 1fr; }
    .wiki-sidebar { border-right: none; border-bottom: 1px solid var(--wk-hairline); }
    .wiki-infobox { float: none; width: auto; margin: 0.8rem 0; }
}

/* --- scope banner (FR-W2) and wiki guardrail footer (A7/FR-W34):
       pull-out boxes — hairline frame, quiet tint, no colored chrome --- */
.wiki-scope-banner {
    background: var(--wk-caption-bg);
    border: 1px solid var(--wk-hairline);
    padding: 0.35rem 0.7rem;
    font-size: var(--fs-ui);
    color: var(--wk-ink);
    margin-bottom: 0.9rem;
    border-radius: 2px;
}
.wiki-guardrail {
    margin-top: 2rem;
    border-top: 1px solid var(--wk-hairline);
    padding-top: 0.5rem;
    font-size: var(--fs-ui);
    color: var(--wk-muted);
}

/* --- top-N list pages (FR-W16) and article live-data links --- */
.wiki-livedata {
    background: var(--wk-caption-bg);
    border: 1px solid var(--wk-hairline);
    padding: 0.35rem 0.7rem;
    font-size: var(--fs-ui);
    margin: 0 0 0.9rem 0;
    border-radius: 2px;
}
/* auto-layout starves the one prose column while numeric columns hoard
   width — give provider names room so they wrap once, not four times */
.wiki-main table.code-table td:nth-child(3),
.wiki-main table.code-table th:nth-child(3) { min-width: 14rem; }
.wiki-topn-crumbs { font-size: var(--fs-ui); color: var(--wk-muted); }
.wiki-topn-crumbs a { margin: 0 0.1rem; }
.wiki-topn-drill {
    columns: 4 12rem;
    list-style: none;
    padding: 0;
    font-size: var(--fs-ui);
}
.wiki-topn-drill li { margin-bottom: 0.25rem; break-inside: avoid; }
