/* =============================================================================
   RDDSquare — Help and About pages (help.html, about.html)
   The same design tokens as c.css; the app passes ?theme=dark when it is in
   dark mode, and the page also follows the system setting.
   ============================================================================= */

:root {
    --rdd-navy: #0d2240;
    --rdd-blue: #0d5ea6;
    --rdd-blue-light: #4da6ff;
    --rdd-accent: #f0a500;
    --rdd-bg: #f4f6f9;
    --rdd-surface: #ffffff;
    --rdd-border: #dde3ee;
    --rdd-text: #111827;
    --rdd-text-muted: #5a6a80;
    --rdd-code-bg: #eef3fa;
    --rdd-ok: #1e7b4f;
    --rdd-warn: #9a5b00;
    --rdd-radius: 12px;
    --rdd-radius-sm: 6px;
    --rdd-nav-h: 52px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --rdd-bg: #070f1c; --rdd-surface: #0f1e30; --rdd-border: #1e3050;
        --rdd-text: #e2eaf4; --rdd-text-muted: #7a94b0; --rdd-code-bg: #142740;
        --rdd-ok: #5fd39a; --rdd-warn: #f0b44c;
    }
}
:root[data-theme="dark"] {
    --rdd-bg: #070f1c; --rdd-surface: #0f1e30; --rdd-border: #1e3050;
    --rdd-text: #e2eaf4; --rdd-text-muted: #7a94b0; --rdd-code-bg: #142740;
    --rdd-ok: #5fd39a; --rdd-warn: #f0b44c;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--rdd-bg);
    color: var(--rdd-text);
    line-height: 1.55;
}

/* ── Top nav (same as the app) ──────────────────────────────────────────── */
.top-nav {
    position: sticky; top: 0; z-index: 10;
    height: var(--rdd-nav-h);
    background: var(--rdd-navy);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.top-nav-logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.top-nav-title { font-size: 1rem; font-weight: 600; color: #fff; line-height: 1.2; }
.top-nav-sub { font-size: .75rem; color: #9fb6d4; }
.top-nav-links { display: flex; gap: 6px; }
.top-nav-links a {
    color: #c9d8ec; text-decoration: none; font-size: .85rem;
    padding: 6px 10px; border-radius: var(--rdd-radius-sm);
}
.top-nav-links a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.top-nav-links a[aria-current="page"] { background: rgba(77,166,255,0.18); color: #fff; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.doc {
    max-width: 1080px; margin: 0 auto;
    padding: 28px 20px 64px;
    display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px;
}
@media (max-width: 820px) {
    .doc { grid-template-columns: minmax(0, 1fr); padding: 20px 16px 48px; }
    .toc { position: static !important; }
    /* the contents become a compact row of chips */
    .toc ol { display: flex; flex-wrap: wrap; gap: 6px; }
    .toc a { background: var(--rdd-surface); border: 1px solid var(--rdd-border); padding: 3px 10px; border-radius: 999px; font-size: .8rem; }
    .top-nav { padding: 0 12px; }
    .top-nav-sub { display: none; }
    .top-nav-title { white-space: nowrap; }
}

.toc {
    position: sticky; top: calc(var(--rdd-nav-h) + 20px); align-self: start;
    font-size: .88rem;
}
.toc h2 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--rdd-text-muted); margin: 0 0 8px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; padding: 4px 8px; border-radius: var(--rdd-radius-sm); color: var(--rdd-text-muted); text-decoration: none; }
.toc a:hover { background: var(--rdd-surface); color: var(--rdd-text); }

main h1 { font-size: 1.7rem; margin: 0 0 6px; color: var(--rdd-text); }
.lede { color: var(--rdd-text-muted); margin: 0 0 24px; font-size: 1.02rem; }
main h2 { font-size: 1.25rem; margin: 40px 0 12px; scroll-margin-top: calc(var(--rdd-nav-h) + 16px); }
main h3 { font-size: 1.02rem; margin: 22px 0 8px; }
main p, main li { max-width: 72ch; }
main a { color: var(--rdd-blue-light); }
code, kbd {
    font-family: Consolas, "Cascadia Code", monospace; font-size: .88em;
    background: var(--rdd-code-bg); padding: 1px 6px; border-radius: 4px;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card {
    background: var(--rdd-surface); border: 1px solid var(--rdd-border);
    border-radius: var(--rdd-radius); padding: 16px 18px;
}
.card h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.card p { margin: 0 0 10px; color: var(--rdd-text-muted); font-size: .93rem; }
.card .tag {
    display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .03em;
    padding: 2px 8px; border-radius: 999px; background: var(--rdd-code-bg); color: var(--rdd-text-muted);
    margin-right: 4px;
}

/* ── Route sections ─────────────────────────────────────────────────────── */
.route {
    background: var(--rdd-surface); border: 1px solid var(--rdd-border);
    border-radius: var(--rdd-radius); padding: 18px 20px; margin: 14px 0;
}
.route h3 { margin-top: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.route .route-id { font-size: .72rem; font-weight: 600; color: var(--rdd-text-muted); background: var(--rdd-code-bg); padding: 2px 8px; border-radius: 999px; }
.route dl { display: grid; grid-template-columns: 130px minmax(0,1fr); gap: 6px 14px; margin: 10px 0 0; font-size: .93rem; }
.route dt { color: var(--rdd-text-muted); font-weight: 600; }
.route dd { margin: 0; }
@media (max-width: 560px) { .route dl { grid-template-columns: minmax(0,1fr); } .route dt { margin-top: 6px; } }

/* ── Example questions (click to copy) ──────────────────────────────────── */
.examples { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.examples li { max-width: none; }
.ask {
    width: 100%; text-align: left; cursor: pointer;
    background: var(--rdd-bg); color: var(--rdd-text);
    border: 1px solid var(--rdd-border); border-radius: var(--rdd-radius-sm);
    padding: 7px 10px; font: inherit; font-size: .92rem;
    display: flex; justify-content: space-between; gap: 10px; align-items: center;
}
.ask:hover { border-color: var(--rdd-blue-light); }
.ask .copy-hint { font-size: .75rem; color: var(--rdd-text-muted); white-space: nowrap; }
.ask.copied .copy-hint { color: var(--rdd-ok); }

/* ── Notes / callouts ───────────────────────────────────────────────────── */
.note {
    border-left: 3px solid var(--rdd-blue-light); background: var(--rdd-surface);
    padding: 10px 14px; border-radius: 0 var(--rdd-radius-sm) var(--rdd-radius-sm) 0; margin: 14px 0;
}
.note.warn { border-left-color: var(--rdd-accent); }
.note strong { color: var(--rdd-text); }

table.plain { border-collapse: collapse; width: 100%; font-size: .92rem; background: var(--rdd-surface); border-radius: var(--rdd-radius-sm); overflow: hidden; }
table.plain th, table.plain td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rdd-border); vertical-align: top; }
table.plain th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--rdd-text-muted); }
.table-wrap { overflow-x: auto; }

/* ── Flow diagram (About) ───────────────────────────────────────────────── */
.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin: 14px 0; }
.flow .step {
    flex: 1 1 150px; background: var(--rdd-surface); border: 1px solid var(--rdd-border);
    border-radius: var(--rdd-radius-sm); padding: 10px 12px; font-size: .88rem;
}
.flow .step b { display: block; margin-bottom: 2px; }
.flow .step.ai { border-color: var(--rdd-blue-light); }
.flow .step.code { border-color: var(--rdd-ok); }
.flow .arrow { align-self: center; color: var(--rdd-text-muted); }
.legend { font-size: .82rem; color: var(--rdd-text-muted); }
.legend span { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: middle; border: 2px solid; }

/* ── Data dictionary / reference blocks (Help) ──────────────────────────── */
main h4 { font-size: .9rem; margin: 18px 0 6px; color: var(--rdd-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--rdd-text-muted); }
details.dict-block {
    background: var(--rdd-surface); border: 1px solid var(--rdd-border);
    border-radius: var(--rdd-radius); padding: 0 18px; margin: 10px 0;
}
details.dict-block[open] { padding-bottom: 16px; }
details.dict-block > summary {
    cursor: pointer; list-style: none; padding: 14px 0; font-weight: 600;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
details.dict-block > summary::-webkit-details-marker { display: none; }
details.dict-block > summary::before { content: "▸"; color: var(--rdd-text-muted); transition: transform .15s; }
details.dict-block[open] > summary::before { transform: rotate(90deg); }
details.dict-block > summary .muted { font-weight: 400; font-size: .85rem; margin-left: auto; }
.route-id { font-size: .72rem; font-weight: 600; color: var(--rdd-text-muted); background: var(--rdd-code-bg); padding: 2px 8px; border-radius: 999px; }
.caps { font-size: .85rem; color: var(--rdd-text-muted); }
table.dict td { font-size: .86rem; }
table.dict td:first-child { white-space: nowrap; }
table.dict code { font-size: .78rem; }
@media (max-width: 560px) {
    /* stack each field as a card on phones */
    table.dict thead { display: none; }
    table.dict, table.dict tbody, table.dict tr, table.dict td { display: block; width: 100%; }
    table.dict tr { border-bottom: 1px solid var(--rdd-border); padding: 8px 0; }
    table.dict td { border: none; padding: 2px 10px; white-space: normal !important; }
    table.dict td:nth-child(2), table.dict td:nth-child(4) { display: inline-block; width: auto; color: var(--rdd-text-muted); font-size: .78rem; }
    details.dict-block { padding: 0 12px; }
}
.vals { margin-top: 4px; font-size: .8rem; color: var(--rdd-text-muted); }
.vals span { font-weight: 600; }
ul.measures { columns: 2 220px; padding-left: 18px; font-size: .9rem; }
ul.measures li { break-inside: avoid; }
.route dl dd ul { margin: 0; padding-left: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; padding: 0; list-style: none; }
.chips li { background: var(--rdd-code-bg); border-radius: 999px; padding: 2px 10px; font-size: .82rem; max-width: none; }

footer.doc-foot { grid-column: 1 / -1; border-top: 1px solid var(--rdd-border); padding-top: 14px; color: var(--rdd-text-muted); font-size: .82rem; }

table.plain tr.grp th { background: var(--rdd-code-bg); color: var(--rdd-text); text-transform: none; letter-spacing: 0; font-size: .85rem; }
table.docs td:nth-child(2), table.docs td:nth-child(3) { white-space: nowrap; color: var(--rdd-text-muted); }
