/* Help site shell (ADR-0014). Standalone: no MudBlazor, no framework. Theme follows the app's
   persisted DarkMode (same origin → same localStorage) via help.js, else the OS preference. */

:root {
    --bg: #ffffff;
    --bg-muted: #f5f6f8;
    --bg-code: #f0f1f4;
    --fg: #1f2328;
    --fg-muted: #5b6470;
    --border: #d9dde3;
    --accent: #1e5eff;
    --accent-soft: #e8efff;
    --warn-bg: #fff6d6;
    --warn-fg: #5a4600;
    --warn-border: #e8c95a;
    --sidebar-w: 17rem;
    --toc-w: 13rem;
    --topbar-h: 3.25rem;
    --radius: 8px;
    --font: Roboto, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
    --bg: #181a1f;
    --bg-muted: #20232a;
    --bg-code: #262a33;
    --fg: #e6e8eb;
    --fg-muted: #a4abb5;
    --border: #333944;
    --accent: #7ea6ff;
    --accent-soft: #24314f;
    --warn-bg: #3d3412;
    --warn-fg: #f3dd8a;
    --warn-border: #7a6a2a;
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme]) {
        --bg: #181a1f;
        --bg-muted: #20232a;
        --bg-code: #262a33;
        --fg: #e6e8eb;
        --fg-muted: #a4abb5;
        --border: #333944;
        --accent: #7ea6ff;
        --accent-soft: #24314f;
        --warn-bg: #3d3412;
        --warn-fg: #f3dd8a;
        --warn-border: #7a6a2a;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
    position: absolute;
    left: -999px;
    top: 0.5rem;
    background: var(--accent);
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    z-index: 100;
}
.skip-link:focus { left: 0.5rem; }

/* Top bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: var(--topbar-h);
    padding: 0 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.topbar__menu {
    display: none;
    border: 1px solid var(--border);
    background: var(--bg-muted);
    color: var(--fg);
    border-radius: var(--radius);
    font-size: 1.1rem;
    padding: 0.2rem 0.55rem;
    cursor: pointer;
}
.topbar__brand {
    font-weight: 600;
    color: var(--fg);
    font-size: 1.05rem;
}
.topbar__brand:hover { text-decoration: none; }
.topbar__brand-sub { font-weight: 400; color: var(--fg-muted); margin-left: 0.35rem; }
/* Search (ADR-0084): the box sits in the top bar of every page; results drop under it. */
.search {
    position: relative;
    flex: 0 1 22rem;
    min-width: 7rem;
    margin-left: 0.5rem;
}
.search__input {
    width: 100%;
    height: 2rem;
    padding: 0 0.7rem;
    border: 1px solid var(--fg-muted);
    border-radius: 999px;
    background: var(--bg);
    color: var(--fg);
    font: inherit;
    font-size: 0.9rem;
}
.search__input::placeholder { color: var(--fg-muted); opacity: 1; }
.search__input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.search__panel {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    width: min(36rem, 92vw);
    max-height: min(70vh, 34rem);
    overflow-y: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    z-index: 20;
}
.search__status { margin: 0; padding: 0.5rem 0.9rem; font-size: 0.8rem; color: var(--fg-muted); }
.search__status:empty { display: none; }
.search__results { list-style: none; margin: 0; padding: 0; }
.search__results a {
    display: block;
    padding: 0.55rem 0.9rem;
    border-top: 1px solid var(--border);
    color: var(--fg);
}
.search__results a:hover, .search__results a:focus-visible { background: var(--accent-soft); text-decoration: none; outline: none; }
.search__title { font-weight: 600; font-size: 0.93rem; }
.search__heading { color: var(--fg-muted); font-size: 0.85rem; }
.search__heading::before { content: "›"; margin: 0 0.4rem; }
.search__excerpt { display: block; font-size: 0.85rem; color: var(--fg-muted); line-height: 1.45; }
.search__excerpt mark { background: var(--accent-soft); color: var(--fg); font-weight: 600; border-radius: 3px; padding: 0 0.1em; }

.topbar__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}
.topbar__theme {
    border: 1px solid var(--border);
    background: var(--bg-muted);
    color: var(--fg);
    border-radius: 999px;
    width: 2rem;
    height: 2rem;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}
.topbar__app {
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.25rem 0.7rem;
}
.lang-switch { display: inline-flex; gap: 0.25rem; }
.lang-switch a, .lang-switch span {
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
}
.lang-switch span[aria-current] { background: var(--accent-soft); color: var(--fg); }

/* Three-column layout */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
    min-height: calc(100vh - var(--topbar-h));
}
.sidebar {
    border-right: 1px solid var(--border);
    padding: 1.25rem 0.75rem 2rem;
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    background: var(--bg-muted);
}
/* The index entry above the sections (ADR-0089 rule 5): one link, set apart from the first section. */
.sidebar__index {
    margin: 0 0 0.9rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}
.sidebar__index a { font-weight: 600; }
.sidebar__section { margin: 0 0 1.1rem; }
.sidebar__section-title {
    margin: 0 0 0.3rem;
    padding: 0 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-muted);
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a {
    display: block;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius);
    color: var(--fg);
    font-size: 0.92rem;
}
.sidebar li a:hover { background: var(--accent-soft); text-decoration: none; }
.sidebar li a[aria-current="page"] {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.content {
    padding: 1.5rem 2.5rem 4rem;
    max-width: 52rem;
    width: 100%;
}

.breadcrumb { font-size: 0.85rem; color: var(--fg-muted); margin-bottom: 0.75rem; }
.breadcrumb a { color: var(--fg-muted); }
.breadcrumb span + span::before { content: "›"; margin: 0 0.45rem; }

.notice {
    border: 1px solid var(--warn-border);
    background: var(--warn-bg);
    color: var(--warn-fg);
    border-radius: var(--radius);
    padding: 0.6rem 0.9rem;
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
}

.topic h1 { font-size: 1.9rem; line-height: 1.25; margin: 0 0 1rem; }
.topic h2 { font-size: 1.35rem; margin: 2rem 0 0.6rem; padding-top: 0.25rem; border-top: 1px solid var(--border); }
.topic h3 { font-size: 1.1rem; margin: 1.4rem 0 0.4rem; }
.topic p, .topic ul, .topic ol { margin: 0 0 0.9rem; }
.topic li { margin: 0.2rem 0; }
.topic code {
    font-family: var(--mono);
    font-size: 0.875em;
    background: var(--bg-code);
    padding: 0.1em 0.35em;
    border-radius: 4px;
}
.topic pre {
    background: var(--bg-code);
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
}
.topic pre code { background: none; padding: 0; }
.topic table { border-collapse: collapse; width: 100%; margin: 0 0 1rem; font-size: 0.95rem; }
.topic th, .topic td { border: 1px solid var(--border); padding: 0.45rem 0.6rem; text-align: left; vertical-align: top; }
.topic th { background: var(--bg-muted); }
.topic blockquote {
    margin: 0 0 1rem;
    padding: 0.5rem 1rem;
    border-left: 4px solid var(--accent);
    background: var(--accent-soft);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.topic blockquote p:last-child { margin: 0; }
.topic img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.topic kbd {
    font-family: var(--mono);
    font-size: 0.8em;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 0 0.35em;
    background: var(--bg-muted);
}

.topic-footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
}

/* Index page cards */
.index-intro { margin-bottom: 1.5rem; }
.index-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.index-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    background: var(--bg-muted);
}
.index-section h2 { font-size: 1rem; margin: 0 0 0.5rem; border: 0; padding: 0; }
.index-section ul { list-style: none; margin: 0; padding: 0; }
.index-section li { margin: 0.2rem 0; font-size: 0.93rem; }

/* On-this-page */
.toc {
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    padding: 1.5rem 1rem 2rem 0;
    font-size: 0.85rem;
}
.toc__title {
    margin: 0 0 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-muted);
}
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.toc li a { display: block; padding: 0.2rem 0 0.2rem 0.75rem; color: var(--fg-muted); }
.toc li a:hover { color: var(--accent); text-decoration: none; }

/* Not-found page */
.notfound { text-align: center; padding: 4rem 1rem; }
.notfound h1 { font-size: 2rem; }
.notfound p { color: var(--fg-muted); }
.notfound .links { display: flex; justify-content: center; gap: 1rem; margin-top: 1.5rem; }

@media (max-width: 1100px) {
    .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
    .toc { display: none; }
}

@media (max-width: 780px) {
    .topbar__menu { display: inline-block; }
    .topbar__app { display: none; }
    .topbar__brand-sub { display: none; }
    .search { flex: 1 1 auto; margin-left: 0; }
    .search__panel { position: fixed; top: var(--topbar-h); left: 0.5rem; right: 0.5rem; width: auto; }
    .layout { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: fixed;
        left: 0;
        top: var(--topbar-h);
        width: min(var(--sidebar-w), 85vw);
        transform: translateX(-100%);
        transition: transform 0.15s ease;
        z-index: 9;
        box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0);
    }
    html[data-nav-open] .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35); }
    .content { padding: 1.25rem 1.25rem 3rem; }
}

@media print {
    .topbar, .sidebar, .toc, .topic-footer, .skip-link, .search { display: none !important; }
    .layout { display: block; }
    .content { max-width: none; padding: 0; }
}
