/* ==========================================================================
   Speculum — shared stylesheet for faberlang.dev
   ==========================================================================
   This is the ONE stylesheet. The generator cannot write CSS.
   Design tokens are extracted from the homepage :root block (formerly
   forked across 18 HTML files). See CONTENT-PLAN.md Decision 14.
   ========================================================================== */

:root {
    --paper: #faf9f6;
    --paper-alt: #f3f1eb;
    --paper-deep: #eae7df;
    --ink: #1a1a18;
    --ink-dim: #5a5954;
    --ink-faint: #8a8880;
    --rule: #d8d5cb;
    --rule-strong: #c4c0b4;
    --glyph: #2a4a9e;
    --glyph-soft: #e6ebf8;
    --glyph-hover: #1e3a82;
    --fallback: #a8a49a;
    --support: #2f6b4c;
    --limited: #9a7420;
    --reject: #a33f30;
    --defer: #6b6a64;
    --serif: 'Noto Serif', Georgia, 'Times New Roman', serif;
    --sans: 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'Noto Sans Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    --radius: 4px;
    --shadow-soft: 0 1px 2px rgba(26, 26, 24, 0.04);
    --shadow-lift: 0 4px 14px rgba(26, 26, 24, 0.06);
}

/* Dark scheme: same paper-and-ink identity, lamplight instead of daylight. */
@media (prefers-color-scheme: dark) {
    :root {
        --paper: #1c1b19;
        --paper-alt: #242320;
        --paper-deep: #2c2b27;
        --ink: #e8e6df;
        --ink-dim: #aeaba1;
        --ink-faint: #817e75;
        --rule: #3a3833;
        --rule-strong: #4c4a43;
        --glyph: #93a9e8;
        --glyph-soft: #262c40;
        --glyph-hover: #b0c1f2;
        --fallback: #6f6c63;
        --support: #7fbe9b;
        --limited: #d3a94f;
        --reject: #d47f70;
        --defer: #8e8d83;
        --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.35);
        --shadow-lift: 0 4px 14px rgba(0, 0, 0, 0.45);
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; color-scheme: light dark; }
::selection { background: var(--glyph); color: var(--paper); }
body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--serif);
    font-size: 16.5px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

/* ---------- links ---------- */
a {
    color: var(--glyph);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
a:hover {
    color: var(--glyph-hover);
    border-bottom-color: var(--glyph);
}
a:focus-visible {
    outline: 2px solid var(--glyph);
    outline-offset: 2px;
}
.content a {
    border-bottom: 1px solid color-mix(in srgb, var(--glyph) 35%, transparent);
}
.content a:hover {
    border-bottom-color: var(--glyph);
    background: var(--glyph-soft);
}
a.section-link { border: none; font-weight: 700; color: var(--ink); }
a.section-link:hover { border-bottom: 1px solid var(--glyph); color: var(--glyph); }
code { font-family: var(--mono); font-size: 0.88em; }

/* Inline code chips in prose (fenced blocks reset below) */
.content code {
    background: var(--paper-alt);
    border: 1px solid var(--rule);
    border-radius: 3px;
    padding: 0.08em 0.35em;
}
.content a code {
    background: var(--glyph-soft);
    border-color: color-mix(in srgb, var(--glyph) 25%, var(--rule));
    color: inherit;
}
.content pre code {
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    font-size: 100%;
}

/* ---------- inline span classes ---------- */
code.kw { color: var(--glyph); font-weight: 700; }
code.typ { color: var(--support); }

/* ---------- rendering bar ---------- */
.renderbar {
    border-top: 3px solid var(--glyph);
    border-bottom: 1px solid var(--rule);
    background: linear-gradient(180deg, var(--paper-alt) 0%, var(--paper) 100%);
}
.renderbar .in {
    max-width: 1240px; margin: 0 auto; padding: 10px 28px;
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    font-family: var(--sans); font-size: 12px;
}
.renderbar .lbl {
    color: var(--ink-faint); letter-spacing: 0.12em;
    text-transform: uppercase; font-size: 10.5px; font-weight: 600;
}
.locbtns { display: flex; gap: 4px; flex-wrap: wrap; }
.locbtn {
    font-family: var(--sans); font-size: 12.5px; border: 1px solid transparent;
    background: none; color: var(--ink-dim); padding: 5px 12px;
    cursor: pointer; border-radius: var(--radius);
    transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.locbtn:hover { border-color: var(--rule-strong); color: var(--ink); background: var(--paper); }
.locbtn[aria-pressed="true"] {
    background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.locbtn .th { font-family: 'Noto Sans Thai', var(--sans); }
.locbtn .ar { font-family: 'Noto Sans Arabic', var(--sans); }
.locbtn .hi { font-family: 'Noto Sans Devanagari', var(--sans); }
.locbtn .zh { font-family: 'Noto Sans SC', var(--sans); }
.renderbar .canon { margin-left: auto; color: var(--ink-faint); font-size: 11.5px; }
.renderbar .machine-links {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    align-items: center;
}
.renderbar .machine-links a {
    border: none;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--ink-faint);
    padding: 2px 0;
}
.renderbar .machine-links a:hover {
    color: var(--glyph);
    border: none;
    background: none;
}

/* ---------- layout ---------- */
.page {
    max-width: 1280px; margin: 0 auto; padding: 0 28px;
    display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 36px;
}
aside {
    padding: 22px 0 56px;
    border-right: 1px solid var(--rule);
    padding-right: 18px;
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100vh;
    overflow-y: auto;
}
main {
    padding: 28px 0 72px;
    min-width: 0;
    max-width: 52rem;
}

/* ---------- brand / sidebar ---------- */
aside .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    border: none;
    margin: 0 0 18px;
    padding: 4px 0 14px;
    border-bottom: 1px solid var(--rule);
}
aside .brand:hover { border-bottom-color: var(--glyph); background: none; }
aside .brand-mark {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    background: var(--glyph);
    color: #faf9f6;
    font-family: var(--serif);
    font-style: italic;
    font-size: 26px;
    line-height: 1;
    padding-bottom: 3px;
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}
aside .brand:hover .brand-mark { background: var(--glyph-hover); }
aside .brand-text { display: block; min-width: 0; }
aside .brand-name {
    display: block;
    font-family: var(--serif);
    font-size: 26px;
    line-height: 1.15;
    color: var(--ink);
    font-weight: 400;
    letter-spacing: -0.01em;
}
aside .brand-tag {
    display: block;
    margin-top: 4px;
    font-family: var(--sans);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
aside .side-h {
    font-family: var(--sans); font-size: 10px; letter-spacing: 0.14em;
    text-transform: uppercase; color: var(--ink-faint); font-weight: 600;
    border-bottom: 1px solid var(--rule); padding-bottom: 6px; margin: 2px 0 8px;
}
aside ul.nav { list-style: none; margin-bottom: 18px; }
aside ul.nav li { font-size: 13.5px; line-height: 1.3; }
aside ul.nav li a {
    border: none;
    display: block;
    padding: 5px 8px;
    margin: 0 -8px;
    border-radius: var(--radius);
    color: var(--ink-dim);
    font-family: var(--sans);
}
aside ul.nav li a:hover {
    border: none;
    color: var(--ink);
    background: var(--paper-alt);
}
aside ul.nav li a.active {
    font-weight: 700;
    color: var(--ink);
    background: var(--glyph-soft);
}
aside ul.nav-compact li { font-size: 12.5px; }
aside ul.nav-compact li a {
    padding: 4px 8px;
    font-family: var(--mono);
    font-size: 11.5px;
}
aside .side-meta {
    margin-top: 4px;
    padding: 10px 0 0;
    border-top: 1px solid var(--rule);
    font-family: var(--sans);
    font-size: 11.5px;
}
aside .side-meta-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 3px 0;
    color: var(--ink-dim);
}
aside .side-meta-row .k { color: var(--ink-faint); }
aside .side-meta-row .v { color: var(--ink); text-align: right; }
aside .sidelist { list-style: none; margin-bottom: 30px; }
aside .sidelist li {
    font-size: 14px; line-height: 25px;
    display: flex; justify-content: space-between; gap: 8px;
}
aside .sidelist .v { font-family: var(--sans); font-size: 10.5px; }

/* ---------- agent notice (homepage) ---------- */
.agent-notice {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin: 16px 0 22px;
    padding: 14px 16px;
    border: 1px solid var(--rule);
    background: linear-gradient(180deg, var(--glyph-soft) 0%, var(--paper-alt) 100%);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}
.agent-notice-label {
    flex: 0 0 auto;
    font-family: var(--sans);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--glyph);
    padding-top: 3px;
}
.agent-notice-body {
    font-family: var(--sans);
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ink-dim);
}
.agent-notice-body p { margin: 0; max-width: none; }
.agent-notice-body code {
    font-size: 0.92em;
    color: var(--glyph);
}
.agent-notice-body a { border-bottom-color: color-mix(in srgb, var(--glyph) 40%, transparent); }

/* ---------- article typography ---------- */
h1 {
    font-family: var(--serif); font-size: 2.15rem; line-height: 1.2; font-weight: 400;
    border-bottom: 1px solid var(--rule); padding-bottom: 12px; letter-spacing: -0.015em;
}
/* Homepage hero: larger masthead, lead opening paragraph. */
body.home h1 { font-size: 2.9rem; padding-bottom: 16px; }
body.home .content > p:first-of-type {
    font-size: 1.16rem;
    line-height: 1.72;
}
.sub { font-family: var(--sans); font-size: 13px; color: var(--ink-faint); margin: 8px 0 24px; }
h2 {
    font-family: var(--serif); font-size: 1.45rem; font-weight: 400; margin: 2.1rem 0 0.55rem;
    border-bottom: 1px solid var(--rule); padding-bottom: 8px; scroll-margin-top: 24px;
    letter-spacing: -0.01em;
}
h3 { font-family: var(--serif); font-size: 1.12rem; font-weight: 700; margin: 1.5rem 0 0.5rem; }
p { margin-bottom: 0.95rem; max-width: 70ch; }
.lead { font-size: 1.1rem; line-height: 1.7; color: var(--ink-dim); }
.dim { color: var(--ink-dim); }
.content ul, .content ol {
    margin: 0 0 1rem 1.25rem;
    max-width: 70ch;
}
.content li { margin-bottom: 0.35rem; padding-left: 0.15rem; }
.content li::marker { color: var(--ink-faint); }

/* ---------- tables (full content width) ---------- */
.content table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 1.35rem;
    font-family: var(--sans);
    font-size: 0.9rem;
    line-height: 1.45;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}
.content thead { background: var(--paper-alt); }
.content th {
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-dim);
    padding: 0.7rem 0.9rem;
    border-bottom: 2px solid color-mix(in srgb, var(--glyph) 30%, var(--rule-strong));
    vertical-align: bottom;
}
.content tbody tr:nth-child(even) {
    background: color-mix(in srgb, var(--paper-alt) 55%, transparent);
}
.content td {
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid var(--rule);
    vertical-align: top;
    color: var(--ink);
}
.content tbody tr:last-child td { border-bottom: none; }
.content tbody tr {
    transition: background 0.1s ease;
}
.content tbody tr:hover { background: var(--paper-alt); }
.content th:first-child,
.content td:first-child { width: 28%; min-width: 8rem; }
/* Key-value tables (empty header row) still stretch */
.content thead:empty,
.content thead tr:has(th:empty):not(:has(th:not(:empty))) {
    display: none;
}
.content table code { font-size: 0.85em; }

/* ---------- infobox ---------- */
.infobox {
    float: right; width: 300px; margin: 4px 0 20px 28px;
    border: 1px solid var(--rule); background: var(--paper-alt);
    font-family: var(--sans); font-size: 12.5px; line-height: 20px;
    border-radius: var(--radius); box-shadow: var(--shadow-soft);
}
.infobox .ib-h {
    background: var(--ink); color: var(--paper); padding: 8px 12px;
    font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; text-align: center;
}
.infobox .ib-g { padding: 5px 12px; border-top: 1px solid var(--rule); display: grid; grid-template-columns: 96px 1fr; gap: 10px; }
.infobox .k { color: var(--ink-faint); }
.infobox .glyphs { color: var(--glyph); font-family: var(--mono); letter-spacing: 0.16em; }

/* ---------- section cards ---------- */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin: 20px 0 12px; }
.topic-card {
    border: 1px solid var(--rule); background: var(--paper-alt);
    padding: 18px 20px; border-radius: var(--radius);
    transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.topic-card:hover {
    border-color: var(--rule-strong);
    box-shadow: var(--shadow-lift);
    transform: translateY(-1px);
}
.topic-card h3 { margin: 0 0 6px; }
.topic-card h3 a { border: none; color: var(--ink); }
.topic-card h3 a:hover { border-bottom: 1px solid var(--glyph); color: var(--glyph); background: none; }
.topic-card p { font-size: 14px; line-height: 1.5; margin: 0; color: var(--ink-dim); max-width: none; }
.topic-card .tag-row { margin-top: 10px; font-family: var(--sans); font-size: 11px; color: var(--ink-faint); }

.platform-row { display: flex; gap: 24px; flex-wrap: wrap; margin: 16px 0 10px; }
.platform-row .plat { font-family: var(--sans); font-size: 12.5px; color: var(--ink-dim); }
.platform-row .plat b { color: var(--ink); }

/* ---------- code blocks ---------- */
pre.faber-code {
    font-family: var(--mono); font-size: 13px; line-height: 1.55;
    background: var(--paper-alt); border: 1px solid var(--rule);
    padding: 14px 16px; margin: 12px 0 1.1rem; overflow-x: auto; white-space: pre;
    border-radius: var(--radius); box-shadow: var(--shadow-soft);
}

/* ---------- footer ---------- */
footer {
    border-top: 1px solid var(--rule); margin-top: 48px; padding: 22px 0 56px;
    font-family: var(--sans); font-size: 12px; color: var(--ink-faint);
    display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
    max-width: 52rem;
}
footer a { border-bottom: 1px solid var(--rule); color: var(--ink-dim); }
footer a:hover { color: var(--glyph); border-bottom-color: var(--glyph); }

/* Download section emphasis on homepage */
.content h2#download {
    color: var(--ink);
    border-bottom-color: var(--glyph);
}
.content h2#download + p {
    padding: 10px 14px;
    background: var(--paper-alt);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    max-width: none;
}
.content h2#download + p + table,
.content h2#download + table {
    border-color: color-mix(in srgb, var(--glyph) 35%, var(--rule));
    box-shadow: 0 2px 10px rgba(42, 74, 158, 0.06);
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
    .page { grid-template-columns: 1fr; gap: 0; padding: 0 18px; }
    aside {
        border-right: none; border-bottom: 1px solid var(--rule);
        padding-right: 0; position: static; max-height: none; overflow: visible;
        padding-bottom: 18px;
    }
    aside ul.nav {
        display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px;
    }
    aside ul.nav li a { padding: 6px 10px; margin: 0; }
    aside .side-meta { display: none; }
    .renderbar .machine-links { margin-left: 0; width: 100%; }
    .agent-notice { flex-direction: column; gap: 8px; }
    .infobox { float: none; width: 100%; margin: 16px 0; }
    main { max-width: none; padding-top: 18px; }
    h1 { font-size: 1.75rem; }
    body.home h1 { font-size: 2.2rem; }
    .content th:first-child,
    .content td:first-child { width: auto; min-width: 0; }
}
