/* Dominion Labs — research paper stylesheet (theme-aware, self-contained).
   Used by the hosted research papers under /research/. Charts are inline SVG
   styled through these tokens so they read in both light and dark. */

:root {
    --bg: #fbfbf9;
    --fg: #1b1b1a;
    --muted: #5c5b57;
    --faint: #8a8984;
    --rule: #e3e2dd;
    --box: rgba(0, 0, 0, .045);
    --accent: #8c1d1d;
    --accent-soft: #b34a4a;
    --grid: rgba(0, 0, 0, .09);
    --axis: rgba(0, 0, 0, .45);
    /* categorical series palette (OpenAI-ish) */
    --s1: #3b6fd4;
    --s2: #d46a9f;
    --s3: #4f9d69;
    --s4: #8a6fd0;
    --s5: #d98b3f;
    --s6: #7a3b3b;
    --maxw: 45rem;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #16161a;
        --fg: #e6e5e1;
        --muted: #a7a69f;
        --faint: #77766f;
        --rule: #2c2c31;
        --box: rgba(255, 255, 255, .06);
        --accent: #e07a7a;
        --accent-soft: #c96a6a;
        --grid: rgba(255, 255, 255, .10);
        --axis: rgba(255, 255, 255, .45);
        --s1: #6f9bef;
        --s2: #e58bbb;
        --s3: #6fc088;
        --s4: #a892e6;
        --s5: #e8a862;
        --s6: #c98a8a;
    }
}

:root[data-theme="dark"] {
    --bg: #16161a;
    --fg: #e6e5e1;
    --muted: #a7a69f;
    --faint: #77766f;
    --rule: #2c2c31;
    --box: rgba(255, 255, 255, .06);
    --accent: #e07a7a;
    --accent-soft: #c96a6a;
    --grid: rgba(255, 255, 255, .10);
    --axis: rgba(255, 255, 255, .45);
    --s1: #6f9bef;
    --s2: #e58bbb;
    --s3: #6fc088;
    --s4: #a892e6;
    --s5: #e8a862;
    --s6: #c98a8a;
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--fg);
    margin: 0;
    font-family: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, "Times New Roman", serif;
    font-size: 18px;
    line-height: 1.62;
    -webkit-text-size-adjust: 100%;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 3.2rem 1.25rem 5rem; }

/* Top strip back to the site */
.paper-nav {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 1.4rem 1.25rem 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.9rem;
}
.paper-nav a { color: var(--muted); text-decoration: none; }
.paper-nav a:hover { color: var(--fg); }

/* Header */
header.paper {
    text-align: center;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 1.8rem;
    margin-bottom: 2.2rem;
}
header.paper .eyebrow {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    color: var(--accent);
    margin-bottom: 1rem;
}
header.paper h1 {
    font-size: 1.9rem;
    line-height: 1.22;
    margin: 0 0 .5rem;
    font-weight: 700;
    letter-spacing: -.01em;
    text-wrap: balance;
}
header.paper .subtitle {
    font-size: 1.06rem;
    color: var(--muted);
    font-style: italic;
    line-height: 1.4;
    margin: 0 auto .95rem;
    max-width: 34rem;
    text-wrap: balance;
}
header.paper .byline { font-size: 1rem; margin: .2rem 0; }
header.paper .affil { font-size: .93rem; color: var(--muted); }
header.paper .affil a { color: var(--accent); text-decoration: none; }
header.paper .date { font-size: .88rem; color: var(--faint); margin-top: .5rem; }

/* Abstract */
.abstract { margin: 0 auto 2.2rem; padding: 0 1.1rem; max-width: 40rem; }
.abstract .lbl {
    font-variant: small-caps;
    letter-spacing: .06em;
    font-weight: 700;
    font-size: .92rem;
    text-align: center;
    display: block;
    margin-bottom: .5rem;
}
.abstract p { font-size: .96rem; line-height: 1.55; margin: 0; text-align: justify; hyphens: auto; }

/* Sections */
section { margin-top: 2.1rem; }
h2 { font-size: 1.28rem; font-weight: 700; margin: 2.2rem 0 .7rem; letter-spacing: -.01em; scroll-margin-top: 1rem; }
h2 .num { color: var(--accent); margin-right: .55rem; font-variant-numeric: tabular-nums; }
h3 { font-size: 1.05rem; font-weight: 700; margin: 1.5rem 0 .4rem; }
p { margin: .85rem 0; text-align: justify; hyphens: auto; }
.runin { font-weight: 700; }
a { color: var(--accent); }
a.xref { text-decoration: none; }
a.xref:hover { text-decoration: underline; }
ul, ol { padding-left: 1.4rem; }
li { margin: .35rem 0; text-align: justify; hyphens: auto; }

/* Key-point callout */
blockquote.key {
    margin: 1.3rem 0;
    padding: .6rem 1.2rem;
    border-left: 3px solid var(--accent-soft);
    font-style: italic;
    background: var(--box);
    border-radius: 0 4px 4px 0;
}

/* Figures + charts */
figure { margin: 1.9rem 0; text-align: center; }
figure .canvas { overflow-x: auto; }
figure svg { max-width: 100%; height: auto; }
figcaption {
    font-size: .86rem;
    color: var(--muted);
    line-height: 1.45;
    margin-top: .8rem;
    text-align: left;
    max-width: 40rem;
    margin-left: auto;
    margin-right: auto;
}
figcaption .fnum { font-weight: 700; color: var(--fg); }

.chart-title {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 700;
    font-size: 1.02rem;
    color: var(--fg);
    text-align: left;
    max-width: 40rem;
    margin: 0 auto .4rem;
}

/* SVG chart primitives (applied to inline chart markup) */
.chart text {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    fill: var(--muted);
}
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .tick { font-size: 11px; fill: var(--faint); }
.chart .axis-label { font-size: 11px; fill: var(--muted); }
.chart .series-line { fill: none; stroke-width: 2.2; }
.chart .dot { stroke: var(--bg); stroke-width: 1.5; }
.chart .bar { rx: 2; }
.chart .val { font-size: 11px; font-variant-numeric: tabular-nums; fill: var(--fg); }
.s1 { color: var(--s1); } .fill-s1 { fill: var(--s1); } .stroke-s1 { stroke: var(--s1); }
.s2 { color: var(--s2); } .fill-s2 { fill: var(--s2); } .stroke-s2 { stroke: var(--s2); }
.s3 { color: var(--s3); } .fill-s3 { fill: var(--s3); } .stroke-s3 { stroke: var(--s3); }
.s4 { color: var(--s4); } .fill-s4 { fill: var(--s4); } .stroke-s4 { stroke: var(--s4); }
.s5 { color: var(--s5); } .fill-s5 { fill: var(--s5); } .stroke-s5 { stroke: var(--s5); }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem 1.1rem;
    justify-content: center;
    margin-top: .7rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: .8rem;
    color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: .4rem; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* Tables */
.tbl { margin: 1.6rem auto; max-width: 100%; overflow-x: auto; }
table { border-collapse: collapse; margin: 0 auto; font-size: .92rem; line-height: 1.4; }
table caption { caption-side: bottom; font-size: .86rem; color: var(--muted); text-align: left; margin-top: .6rem; }
table caption .fnum { font-weight: 700; color: var(--fg); }
th, td { padding: .4rem .85rem; text-align: left; }
thead th { border-bottom: 1.5px solid var(--fg); font-weight: 700; }
tbody tr:last-child td { border-bottom: 1.5px solid var(--fg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* References */
hr.sep { border: 0; border-top: 1px solid var(--rule); margin: 2.6rem 0 1.4rem; }
ol.refs { padding-left: 0; list-style: none; counter-reset: ref; font-size: .9rem; line-height: 1.5; }
ol.refs li { counter-increment: ref; position: relative; padding-left: 2.4rem; margin: .5rem 0; text-align: left; }
ol.refs li::before { content: "[" counter(ref) "]"; position: absolute; left: 0; color: var(--accent); font-variant-numeric: tabular-nums; }
ol.refs li:target { background: var(--box); border-radius: 4px; }
a.cite { color: var(--accent); text-decoration: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
a.cite:hover { text-decoration: underline; }

.foot { font-size: .82rem; color: var(--faint); text-align: center; margin-top: 2.5rem; }

@media (max-width: 640px) {
    body { font-size: 17px; }
    .wrap { padding: 2.2rem 1.1rem 4rem; }
    header.paper h1 { font-size: 1.55rem; }
}
