/* ===========================================
   findusdoc.ch/help · the manual
   Rail on the left (260px, like --rail-w in the app), chapters on the right.
   =========================================== */

:root { --rail-w: 260px; --rail-row-h: 40px; --page-pad: 24px; }

.help { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); padding-top: var(--nav-h); min-height: 100vh; }

/* ---------- Rail ---------- */
.rail {
    position: sticky; top: var(--nav-h);
    height: calc(100vh - var(--nav-h));
    overflow-y: auto;
    border-right: 1px solid var(--rule);
    background: var(--bg-2);
}
.rail-search { padding: 14px; border-bottom: 1px solid var(--rule); background: var(--bg-2); position: sticky; top: 0; z-index: 1; }
.rail-search .label { display: block; margin-bottom: 6px; }
.rail-search input {
    width: 100%; height: 32px; padding: 0 10px;
    font-family: var(--font-mono); font-size: var(--text-sm);
    color: var(--ink); background: var(--bg);
    border: 1px solid var(--rule-strong);
}
.rail-search input:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.rail-result { margin-top: 6px; min-height: 14px; }

.toc-row {
    display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 6px;
    height: var(--rail-row-h); padding: 0 14px;
    border-bottom: 1px solid var(--rule);
    text-decoration: none; color: var(--ink-2);
    font-size: var(--text-md);
}
.toc-row .n { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); }
.toc-row .hits { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--accent-text); }
.toc-row:hover { background: var(--bg-3); color: var(--ink); }
.toc-row.active { background: var(--bg); color: var(--ink); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.toc-row.active .n { color: var(--accent-text); }
.toc-row.empty { opacity: 0.4; }

.toc-sub { list-style: none; border-bottom: 1px solid var(--rule); background: var(--bg); padding: 4px 0 8px; display: none; }
.toc-row.active + .toc-sub { display: block; }
.toc-sub a {
    display: block; padding: 4px 14px 4px 50px;
    font-size: var(--text-sm); color: var(--muted); text-decoration: none; line-height: 1.35;
}
.toc-sub a:hover, .toc-sub a.active { color: var(--ink); }
.toc-sub a.active { box-shadow: inset 2px 0 0 var(--rule-strong); }

/* ---------- Content ---------- */
.help-content { padding: 40px var(--page-pad) 96px 56px; max-width: 880px; }
.chapter { padding-bottom: 56px; margin-bottom: 56px; border-bottom: 1px solid var(--rule); }
.chapter:last-child { border-bottom: 0; }
.chapter[hidden] { display: none; }
.chapter-num { color: var(--accent-text); margin-bottom: 12px; display: block; }
.chapter h1 { font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1; margin-bottom: 14px; }
.chapter .lead { font-size: 1.08rem; color: var(--ink-2); line-height: 1.55; margin-bottom: 28px; max-width: 62ch; }

.chapter h2 {
    font-size: 1.2rem; font-weight: 800; letter-spacing: -0.01em;
    margin: 36px 0 10px; padding-top: 14px; border-top: 1px solid var(--rule);
}
.chapter p { margin: 0 0 12px; color: var(--ink-2); font-size: var(--text-lg); max-width: 68ch; }
.chapter strong { color: var(--ink); }
.chapter a { color: var(--accent-text); text-underline-offset: 3px; }
.chapter code {
    font-size: 0.84em; color: var(--ink);
    background: var(--bg-2); border: 1px solid var(--rule); padding: 0 4px;
    overflow-wrap: anywhere;
}
.chapter ul, .chapter ol { margin: 0 0 14px; padding-left: 0; list-style: none; max-width: 68ch; counter-reset: li; }
.chapter li { position: relative; padding: 6px 0 6px 28px; border-bottom: 1px solid var(--rule); color: var(--ink-2); }
.chapter li:first-child { border-top: 1px solid var(--rule); }
.chapter ul > li::before { content: ''; position: absolute; left: 6px; top: 15px; width: 6px; height: 6px; background: var(--accent); }
.chapter ol > li { counter-increment: li; }
.chapter ol > li::before { content: counter(li); position: absolute; left: 4px; top: 7px; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--accent-text); }

/* Tables and definition lists: the dense app idiom */
.t-wrap { overflow-x: auto; border: 1px solid var(--rule-strong); margin: 4px 0 16px; background: var(--bg); }
.chapter table { width: 100%; border-collapse: collapse; font-size: var(--text-md); }
.chapter th, .chapter td { text-align: left; vertical-align: top; padding: 6px 10px; border-bottom: 1px solid var(--rule); }
.chapter td + td, .chapter th + th { border-left: 1px solid var(--rule); }
.chapter tr:last-child td { border-bottom: 0; }
.chapter th {
    font-family: var(--font-mono); font-weight: 400; font-size: var(--text-2xs);
    text-transform: uppercase; letter-spacing: 0.12em;
    background: var(--bg-3); color: var(--ink); border-bottom-color: var(--rule-strong);
    white-space: nowrap;
}
.chapter tbody tr:nth-child(even) td { background: var(--bg-2); }
.chapter td:first-child { white-space: nowrap; }

.chapter dl { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; border-top: 1px solid var(--rule); margin: 4px 0 16px; }
.chapter dt, .chapter dd { padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: var(--text-md); }
.chapter dt { font-weight: 700; color: var(--ink); padding-right: 16px; }
.chapter dd { color: var(--ink-2); }

.chapter pre {
    font-family: var(--font-mono); font-size: var(--text-sm); line-height: 1.8;
    background: var(--bg-2); border: 1px solid var(--rule-strong);
    padding: 10px 12px; margin: 4px 0 16px; overflow-x: auto; color: var(--ink);
}

.chapter kbd {
    display: inline-block; font-size: var(--text-xs);
    padding: 1px 6px; border: 1px solid var(--rule-strong); background: var(--bg); color: var(--ink);
}

/* Note, warning */
.callout {
    margin: 8px 0 16px; padding: 10px 12px;
    border: 1px solid var(--rule-strong); border-left: 3px solid var(--accent);
    background: var(--bg); font-size: var(--text-md); color: var(--ink-2); max-width: 68ch;
}
.callout .label { display: block; margin-bottom: 2px; color: var(--accent-text); }
.callout--warn { border-left-color: var(--warn); background: var(--warn-soft); }
.callout--warn .label { color: var(--warn); }

/* The box about what happens underneath */
.tech { margin: 28px 0 8px; border: 1px solid var(--rule-strong); background: var(--bg); }
.tech > summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: baseline; gap: 12px;
    padding: 10px 12px; background: var(--bg-3);
}
.tech > summary::-webkit-details-marker { display: none; }
.tech > summary .label { color: var(--accent-text); flex: none; }
.tech > summary .tt { font-weight: 700; flex: 1; }
.tech > summary .plus { font-family: var(--font-mono); color: var(--muted); }
.tech[open] > summary { border-bottom: 1px solid var(--rule-strong); }
.tech[open] > summary .plus::before { content: '−'; }
.tech:not([open]) > summary .plus::before { content: '+'; }
.tech-body { padding: 12px 14px 4px; }
.tech-body h2 { margin-top: 18px; }

mark { background: var(--accent); color: var(--on-accent); padding: 0 1px; }

.no-hits { padding: 24px 0; color: var(--muted); }

/* Help footer sits under the content, not the rail */
.footer--help { padding: 20px 0; }

/* ---------- Mobile: the rail becomes a drawer ---------- */
.rail-toggle {
    display: none;
    font-family: var(--font-mono); font-size: var(--text-xs);
    text-transform: uppercase; letter-spacing: 0.12em;
    background: transparent; color: var(--ink); cursor: pointer;
    border: 1px solid var(--rule-strong); padding: 8px 10px;
}
.rail-backdrop { position: fixed; inset: var(--nav-h) 0 0 0; background: rgba(0, 0, 0, 0.45); z-index: 89; }

@media (max-width: 900px) {
    .help { grid-template-columns: 1fr; }
    .rail-toggle { display: block; }
    .rail {
        position: fixed; top: var(--nav-h); left: 0; bottom: 0; z-index: 90;
        width: min(320px, 86vw); height: auto;
        transform: translateX(-100%); transition: transform 0.2s ease;
        visibility: hidden;
    }
    .rail.open { transform: none; visibility: visible; }
    .help-content { padding: 28px 16px 72px; }
    .chapter dl { grid-template-columns: 1fr; }
    .chapter dt { border-bottom: 0; padding-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) { .rail { transition: none; } }
