/*
 * Documentation section — sidebar + content + search.
 * Builds strictly on the hillcode brand tokens from style.css
 * (--text*, --surface*, --border*, --primary, --accent, --gradient, --radius, --glow).
 * No new colors. Monospace is a system stack (no webfont, keeps it CSP/offline-clean).
 */

:root {
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
    --docs-sidebar-w: 264px;
}

/* ---- shell: sidebar + content ---- */
.docs-shell {
    display: grid;
    grid-template-columns: var(--docs-sidebar-w) minmax(0, 1fr);
    gap: 2.8rem;
    align-items: start;
    margin: 1.5rem 0 4rem;
}
@media (max-width: 900px) {
    .docs-shell { grid-template-columns: 1fr; gap: 1.5rem; }
}

/* ---- sidebar ---- */
.docs-sidebar {
    position: sticky;
    top: 116px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding-right: 0.6rem;
}
@media (max-width: 900px) {
    .docs-sidebar {
        position: static;
        max-height: none;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 1.2rem 1.3rem;
        background: var(--surface);
    }
}
/* ---- language switcher (DE / EN) ---- */
.docs-lang {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    overflow: hidden;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 1.1rem;
}
.docs-lang a {
    padding: 0.3em 0.85em;
    color: var(--text-mute);
    letter-spacing: 0.04em;
    transition: background 0.2s, color 0.2s;
}
.docs-lang a:hover { color: var(--text); text-decoration: none; }
.docs-lang a[aria-current="true"] { background: var(--gradient); color: #fff; }
.docs-hub-lang { display: flex; justify-content: center; margin-bottom: 1.4rem; }

.docs-nav { margin-top: 1.4rem; }
.docs-nav-group { margin-bottom: 1.5rem; }
.docs-nav-group > h4 {
    font-size: 0.72rem !important;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-mute);
    margin: 0 0 0.6rem;
}
.docs-nav-group ul { list-style: none; padding: 0; margin: 0; }
.docs-nav-group li { margin: 0; }
.docs-nav-group a {
    display: block;
    padding: 0.34em 0.75em;
    margin: 0.1em 0;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    color: var(--text-soft);
    border-left: 2px solid transparent;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.docs-nav-group a:hover {
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
}
.docs-nav-group a[aria-current="page"] {
    background: rgba(231, 50, 131, 0.10);
    border-left-color: var(--accent);
    color: var(--text);
    font-weight: 600;
}

/* ---- content column ---- */
.docs-content { min-width: 0; max-width: 780px; }
.docs-content h1 { margin-bottom: 0.6rem; }
.docs-content .docs-lead {
    font-size: clamp(1.05rem, 1.6vw, 1.2rem);
    color: var(--text-soft);
    margin-bottom: 2rem;
}
.docs-content h2 {
    margin-top: 2.8rem;
    padding-top: 1.6rem;
    border-top: 1px solid var(--border);
    scroll-margin-top: 120px;
}
.docs-content h3 { margin-top: 1.9rem; scroll-margin-top: 120px; }
.docs-content p,
.docs-content li { color: var(--text-soft); }
.docs-content ul,
.docs-content ol { padding-left: 1.3rem; margin-bottom: 1.2rem; }
.docs-content li { margin-bottom: 0.45rem; }
.docs-content a { font-weight: 600; }
.docs-content a:hover { text-decoration: underline; }

/* ---- inline + block code ---- */
.docs-content :not(pre) > code {
    font-family: var(--mono);
    font-size: 0.86em;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.12em 0.42em;
    color: var(--text);
    overflow-wrap: break-word;
}
.docs-content pre {
    background: linear-gradient(160deg, #170b30, #0e0620);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 1.1rem 1.3rem;
    overflow-x: auto;
    margin: 1.2rem 0 1.6rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.docs-content pre code {
    font-family: var(--mono);
    font-size: 0.86rem;
    line-height: 1.65;
    color: var(--text-soft);
    white-space: pre;
    display: block;
}
/* faint token accents applied via spans in the markup */
.docs-content pre .c-com { color: var(--text-mute); font-style: italic; }
.docs-content pre .c-key { color: #d79be0; }
.docs-content pre .c-str { color: #7fd4a8; }
.docs-content pre .c-tag { color: #f0a0c0; }
.docs-content pre .c-attr { color: #c3b5e3; }

/* filename header on a code block */
.docs-code { margin: 1.2rem 0 1.6rem; }
.docs-code pre { margin: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.docs-code-name {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-mute);
    background: var(--surface-strong);
    border: 1px solid var(--border-strong);
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: 0.4em 0.9em;
}

/* ---- callouts ---- */
.callout {
    display: flex;
    gap: 0.85rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 1rem 1.2rem;
    margin: 1.4rem 0;
}
.callout .callout-ico { font-weight: 700; flex-shrink: 0; color: var(--primary); }
.callout p { margin: 0; font-size: 0.93rem; }
.callout p + p { margin-top: 0.5rem; }
.callout--tip { border-left-color: var(--accent); }
.callout--tip .callout-ico { color: var(--accent); }
.callout--warn { border-left-color: #e0a44d; }
.callout--warn .callout-ico { color: #e0a44d; }

/* ---- doc tables ---- */
.docs-content table {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    margin: 1.4rem 0;
    font-size: 0.92rem;
}
.docs-content th,
.docs-content td {
    text-align: left;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.docs-content thead th {
    color: var(--text-mute);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--surface);
}
.docs-content tbody tr:last-child td { border-bottom: none; }
.docs-content tbody tr:hover td { background: var(--surface); }
.docs-content td code { white-space: nowrap; }

/* ---- prev / next footer ---- */
.docs-pager {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 3rem;
    padding-top: 1.6rem;
    border-top: 1px solid var(--border);
}
.docs-pager a {
    flex: 1 1 200px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.9rem 1.1rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.25s, transform 0.25s;
}
.docs-pager a:hover { border-color: rgba(231, 50, 131, 0.5); transform: translateY(-2px); text-decoration: none; }
.docs-pager a.is-next { text-align: right; }
.docs-pager small { display: block; color: var(--text-mute); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
.docs-pager span { font-weight: 700; }

/* ---- on-page (right) table of contents — optional ---- */
.docs-onthispage { list-style: none; padding: 0; margin: 0; }
.docs-onthispage li { margin: 0.15rem 0; }
.docs-onthispage a { font-size: 0.85rem; color: var(--text-mute); }
.docs-onthispage a:hover { color: var(--accent); text-decoration: none; }

/* =========================================================================
   SEARCH — Pagefind UI, themed to the hillcode brand.
   Pagefind exposes CSS custom properties; we map them to our tokens so the
   drop-in widget matches the site. Works once `/docs/pagefind/` is built
   (npx pagefind --site <docroot>/docs). Until then the box shows a hint.
   ========================================================================= */
.docs-search { position: relative; }
#docs-search {
    --pagefind-ui-scale: 0.82;
    --pagefind-ui-primary: var(--accent);
    --pagefind-ui-text: var(--text);
    --pagefind-ui-background: #140b26;
    --pagefind-ui-border: var(--border-strong);
    --pagefind-ui-tag: var(--surface-strong);
    --pagefind-ui-border-width: 1px;
    --pagefind-ui-border-radius: var(--radius-sm);
    --pagefind-ui-font: 'Poppins', sans-serif;
}
/* input styling to match .form-control */
#docs-search .pagefind-ui__search-input {
    background: var(--surface);
    color: var(--text);
    font-weight: 400;
}
#docs-search .pagefind-ui__search-input::placeholder { color: var(--text-mute); }
#docs-search .pagefind-ui__result {
    border-top: 1px solid var(--border);
    padding-top: 0.9rem;
}
#docs-search .pagefind-ui__result-link { color: var(--text); font-weight: 600; }
#docs-search .pagefind-ui__result-excerpt { color: var(--text-mute); font-size: 0.85rem; }
#docs-search mark {
    background: rgba(231, 50, 131, 0.22);
    color: var(--text);
    border-radius: 3px;
    padding: 0 0.1em;
}

/* Fallback: shown only when Pagefind failed to load (index not built yet). */
.docs-search-fallback {
    display: none;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 0.8rem 1rem;
    font-size: 0.85rem;
    color: var(--text-mute);
}
.docs-search-fallback input {
    display: block;
    width: 100%;
    margin-bottom: 0.6rem;
    padding: 0.6rem 0.9rem;
    background: var(--background);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
}
.docs-search.no-index #docs-search { display: none; }
.docs-search.no-index .docs-search-fallback { display: block; }

/* ---- docs landing (hub) hero + product picker reuses .teaser-card ---- */
.docs-hub-search {
    max-width: 640px;
    margin: 0 auto 1rem;
}
.docs-hub-search #docs-search { --pagefind-ui-scale: 0.95; }
