/* ============================================================
   CSS Variables — always dark theme (GitHub Dark palette)
   ============================================================ */
:root {
    --bg-base: #0d1117;
    --bg-sidebar: #161b22;
    --bg-elevated: #21262d;
    --bg-code: #161b22;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-subtle: rgba(31, 111, 235, 0.15);
    --accent-hover: #79c0ff;
    --green: #3fb950;
    --purple: #d2a8ff;
    --orange: #ffa657;
    --border: #30363d;
    --border-subtle: #21262d;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --header-height: 52px;
    --sidebar-left-width: 256px;
    --sidebar-right-width: 216px;
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================================
   Base
   ============================================================ */
html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
}

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

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

/* ============================================================
   Top header bar (52px fixed)
   ============================================================ */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-shrink: 0;
    width: calc(var(--sidebar-left-width) - 1rem);
}

.site-logo {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
}

.site-logo:hover {
    color: var(--accent);
    text-decoration: none;
}

.version-badge {
    display: inline-block;
    background: var(--accent-subtle);
    color: var(--accent);
    border: 1px solid rgba(88, 166, 255, 0.3);
    border-radius: 2em;
    padding: 0.1em 0.6em;
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 480px;
}

.search-icon {
    position: absolute;
    left: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    fill: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem 0.375rem 2rem;
    outline: none;
    transition: border-color 0.15s;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    z-index: 200;
    max-height: 420px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.search-result-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover,
.search-result-item.search-result-selected {
    background: var(--accent-subtle);
    text-decoration: none;
}

.search-result-name {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    flex-shrink: 0;
    width: calc(var(--sidebar-right-width) - 1rem);
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.github-link {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

.github-link svg {
    fill: currentColor;
}

.github-link:hover {
    color: var(--text-primary);
    text-decoration: none;
}

/* ============================================================
   Three-column layout body
   ============================================================ */
.layout-body {
    display: flex;
    padding-top: var(--header-height);
    min-height: 100vh;
}

/* ============================================================
   Left sidebar (fixed, 256px)
   ============================================================ */
.sidebar-left {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-left-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1.25rem 0 2rem;
    flex-shrink: 0;
}

.nav-section {
    margin-bottom: 1.25rem;
    padding: 0 0.75rem;
}

.nav-section-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 0 0.5rem;
    margin-bottom: 0.375rem;
}

.nav-section a {
    display: block;
    padding: 0.3125rem 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.875rem;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-section a:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-section a.active {
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 500;
}

.nav-section a.hidden {
    display: none;
}

/* ============================================================
   Main content area
   ============================================================ */
.content {
    margin-left: var(--sidebar-left-width);
    margin-right: var(--sidebar-right-width);
    flex: 1;
    padding: 2.5rem 2.5rem 4rem;
    min-width: 0;
    max-width: 860px;
}

/* ============================================================
   Right TOC sidebar (fixed, 216px)
   ============================================================ */
.toc-sidebar {
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    width: var(--sidebar-right-width);
    overflow-y: auto;
    padding: 1.25rem 0.75rem 2rem;
    border-left: 1px solid var(--border);
    flex-shrink: 0;
}

.toc-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 0 0.5rem;
    margin-bottom: 0.375rem;
}

.toc-section-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 0.5rem 0.5rem 0.25rem;
}

.toc-section-label:first-child {
    padding-top: 0;
}

#toc-nav a {
    display: block;
    padding: 0.3125rem 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s, color 0.15s;
    border-left: 2px solid transparent;
}

#toc-nav a:hover {
    color: var(--text-primary);
    text-decoration: none;
    background: var(--bg-elevated);
}

#toc-nav a.toc-active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-subtle);
}

/* ============================================================
   Breadcrumb
   ============================================================ */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.breadcrumb a {
    color: var(--text-muted);
}

.breadcrumb a:hover {
    color: var(--accent);
}

.breadcrumb-sep {
    color: var(--text-muted);
    user-select: none;
}

.breadcrumb-current {
    color: var(--text-secondary);
}

/* ============================================================
   Page header
   ============================================================ */
.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.page-header h1 {
    font-size: 1.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
    font-family: var(--font-mono);
}

.page-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.1875rem 0.625rem;
    border-radius: 2em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}

/* ============================================================
   Module description
   ============================================================ */
.module-description {
    font-size: 0.9375rem;
    line-height: 1.75;
    color: var(--text-primary);
    margin-bottom: 2rem;
    padding: 1rem 1.25rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
}

.module-description p {
    margin: 0.625rem 0;
}

.module-description p:first-child {
    margin-top: 0;
}

.module-description p:last-child {
    margin-bottom: 0;
}

.module-description ul,
.module-description ol {
    margin: 0.625rem 0;
    padding-left: 1.5rem;
}

.module-description li {
    margin: 0.25rem 0;
}

.module-description code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--bg-code);
    padding: 0.1em 0.4em;
    border-radius: 3px;
}

/* ============================================================
   Section headings
   ============================================================ */
.section-heading {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* ============================================================
   Types list
   ============================================================ */
.type-list {
    list-style: none;
    margin: 0 0 1.5rem;
}

.type-list li {
    padding: 0.375rem 0;
}

.type-list a {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.9375rem;
}

.type-list a:hover {
    color: var(--accent-hover);
}

/* ============================================================
   Method and property cards
   ============================================================ */
.method,
.property {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    scroll-margin-top: calc(var(--header-height) + 1rem);
}

.method h3 {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--green);
    margin-bottom: 0.625rem;
    word-break: break-all;
}

.method h3 a {
    color: inherit;
    text-decoration: none;
}

.method h3 a:hover {
    color: var(--accent-hover);
    text-decoration: none;
}

.property h3 {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.625rem;
    word-break: break-all;
}

.property h3 a {
    color: inherit;
    text-decoration: none;
}

.property h3 a:hover {
    color: var(--accent-hover);
    text-decoration: none;
}

/* static badge */
.static-badge {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    background: rgba(210, 168, 255, 0.15);
    color: var(--purple);
    border: 1px solid rgba(210, 168, 255, 0.3);
    border-radius: 3px;
    padding: 0.1em 0.5em;
    margin-right: 0.5rem;
    vertical-align: middle;
    font-weight: 500;
}

/* description inside a card */
.description {
    font-size: 0.9375rem;
    color: var(--text-primary);
    line-height: 1.65;
    margin-bottom: 0.75rem;
}

/* ============================================================
   Section labels inside cards (Declaration / Parameters / Returns)
   ============================================================ */
.card-section-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 1.25rem 0 0.5rem;
}

.card-section-label:first-of-type {
    margin-top: 0.75rem;
}

/* ============================================================
   Code blocks
   ============================================================ */
.code-block {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin: 0.5rem 0 1rem;
}

.code-block-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    padding: 0.375rem 0.75rem;
}

.code-block-lang {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    padding: 0.1875rem 0.5rem;
    transition: border-color 0.15s, color 0.15s;
}

.copy-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.copy-btn.copied {
    border-color: var(--green);
    color: var(--green);
}

.code-block pre {
    background: var(--bg-code);
    border: none;
    border-radius: 0;
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
}

pre code.hljs {
    display: block;
    overflow-x: auto;
    padding: 0;
    background: transparent;
}

code.hljs {
    padding: 3px 5px;
}

pre {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    margin: 0.5rem 0 1rem;
}

pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: 0.875em;
    font-family: var(--font-mono);
    line-height: 1.55;
}

/* ============================================================
   Params table
   ============================================================ */
.params-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin: 0.5rem 0 0.75rem;
}

.params-table th {
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding: 0.375rem 0.75rem;
}

.params-table td {
    padding: 0.5rem 0.75rem;
    vertical-align: top;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.params-table tr:last-child td {
    border-bottom: none;
}

.param-name {
    font-family: var(--font-mono);
    color: var(--orange);
    white-space: nowrap;
}

.param-type {
    font-family: var(--font-mono);
    color: var(--accent);
    white-space: nowrap;
}

.param-desc {
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ============================================================
   Return value
   ============================================================ */
.return-type {
    font-family: var(--font-mono);
    color: var(--purple);
    font-size: 0.9375rem;
    margin-bottom: 0.375rem;
}

.return-desc {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ============================================================
   Source link (bottom of card)
   ============================================================ */
.source-link {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-subtle);
}

.source-link a {
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.source-link a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* ============================================================
   Type property inline type display
   ============================================================ */
.prop-type {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

/* ============================================================
   Index grid cards
   ============================================================ */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.875rem;
    margin: 1rem 0 2rem;
}

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.125rem 1.25rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    display: block;
}

.card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transform: translateY(-1px);
    text-decoration: none;
    color: var(--text-primary);
}

.card h3 {
    font-family: var(--font-mono);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.375rem;
}

.card p {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ============================================================
   Inline code
   ============================================================ */
code:not(.hljs):not(pre code) {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.875em;
    color: var(--text-primary);
}

/* ============================================================
   Highlight.js — GitHub Dark theme (verbatim)
   ============================================================ */
/*!
  Theme: GitHub Dark
  Description: Dark theme as seen on github.com
  Author: github.com
  Maintainer: @Hirse
  Updated: 2021-05-15

  Outdated base version: https://github.com/primer/github-syntax-dark
  Current colors taken from GitHub's CSS
*/
.hljs {
    color: #c9d1d9;
    background: #0d1117;
}

.hljs-doctag,
.hljs-keyword,
.hljs-meta .hljs-keyword,
.hljs-template-tag,
.hljs-template-variable,
.hljs-type,
.hljs-variable.language_ {
    /* prettylights-syntax-keyword */
    color: #ff7b72;
}

.hljs-title,
.hljs-title.class_,
.hljs-title.class_.inherited__,
.hljs-title.function_ {
    /* prettylights-syntax-entity */
    color: #d2a8ff;
}

.hljs-attr,
.hljs-attribute,
.hljs-literal,
.hljs-meta,
.hljs-number,
.hljs-operator,
.hljs-variable,
.hljs-selector-attr,
.hljs-selector-class,
.hljs-selector-id {
    /* prettylights-syntax-constant */
    color: #79c0ff;
}

.hljs-regexp,
.hljs-string,
.hljs-meta .hljs-string {
    /* prettylights-syntax-string */
    color: #a5d6ff;
}

.hljs-built_in,
.hljs-symbol {
    /* prettylights-syntax-variable */
    color: #ffa657;
}

.hljs-comment,
.hljs-code,
.hljs-formula {
    /* prettylights-syntax-comment */
    color: #8b949e;
}

.hljs-name,
.hljs-quote,
.hljs-selector-tag,
.hljs-selector-pseudo {
    /* prettylights-syntax-entity-tag */
    color: #7ee787;
}

.hljs-subst {
    /* prettylights-syntax-storage-modifier-import */
    color: #c9d1d9;
}

.hljs-section {
    /* prettylights-syntax-markup-heading */
    color: #1f6feb;
    font-weight: bold;
}

.hljs-bullet {
    /* prettylights-syntax-markup-list */
    color: #f2cc60;
}

.hljs-emphasis {
    /* prettylights-syntax-markup-italic */
    color: #c9d1d9;
    font-style: italic;
}

.hljs-strong {
    /* prettylights-syntax-markup-bold */
    color: #c9d1d9;
    font-weight: bold;
}

.hljs-addition {
    /* prettylights-syntax-markup-inserted */
    color: #aff5b4;
    background-color: #033a16;
}

.hljs-deletion {
    /* prettylights-syntax-markup-deleted */
    color: #ffdcd7;
    background-color: #67060c;
}

.hljs-char.escape_,
.hljs-link,
.hljs-params,
.hljs-property,
.hljs-punctuation,
.hljs-tag {
    /* purposely ignored */
}

/* Override hljs background to match our code block */
.hljs {
    background: var(--bg-code) !important;
}

/* ============================================================
   Responsive — below 960px collapse sidebars
   ============================================================ */
@media (max-width: 960px) {
    .toc-sidebar {
        display: none;
    }

    .content {
        margin-right: 0;
    }
}

@media (max-width: 680px) {
    .sidebar-left {
        display: none;
    }

    .content {
        margin-left: 0;
        padding: 1.5rem 1rem 3rem;
    }

    .header-left {
        width: auto;
    }

    .header-right {
        width: auto;
    }
}
