/* ===========================================
   Anzaran - Documentation Styles
   =========================================== */

/* Documentation Layout */
.docs-layout {
    display: flex;
    min-height: 100vh;
    padding-top: 4.5rem;
    /* Account for fixed nav */
}

/* ===========================================
   Sidebar Navigation
   =========================================== */
.docs-sidebar {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid var(--color-border);
    background: var(--color-bg);
    position: fixed;
    top: 4.5rem;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    padding: 2rem 0;
}

.sidebar-section {
    padding: 0 1.5rem;
    margin-bottom: 1.5rem;
}

.sidebar-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    margin-bottom: 0.75rem;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 0.25rem;
}

.sidebar-nav a {
    min-height: 44px;
    display: block;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.sidebar-nav a:hover {
    color: var(--color-text);
    background: var(--color-surface);
}

.sidebar-nav a.active {
    color: var(--color-accent);
    background: rgba(0, 102, 255, 0.08);
    font-weight: 500;
}

/* Version switcher (sidebar "Version" block) */
.version-select {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
}

.version-select:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
}

/* Version marker above each page title */
.docs-version-badge {
    display: inline-block;
    margin-bottom: 1rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--color-accent);
    background: rgba(0, 102, 255, 0.08);
    border-radius: 999px;
}

/* ===========================================
   Main Content Area
   =========================================== */
.docs-content {
    flex: 1;
    /* Without this a single long token (a JSON payload, a KEY=value string)
       sets the flex item's minimum size and drags the whole page wider than
       the screen. */
    min-width: 0;
    margin-left: 280px;
    padding: 3rem 4rem;
    max-width: 900px;
}

.docs-header {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--color-border);
}

.docs-header h1 {
    font-family: 'ivyora-display', serif;
    font-size: 2.5rem;
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -0.01em;
    margin-bottom: 0.75rem;
}

.docs-header .lead {
    font-size: 1.125rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

/* ===========================================
   Documentation Content Styling
   =========================================== */
.docs-body h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 3rem 0 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    letter-spacing: -0.01em;
}

.docs-body h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.docs-body h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 2rem 0 0.75rem;
    color: var(--color-text);
}

.docs-body h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
    color: var(--color-text);
}

.docs-body p {
    margin-bottom: 1rem;
    color: var(--color-text-secondary);
    line-height: 1.7;
}

.docs-body ul,
.docs-body ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    color: var(--color-text-secondary);
}

.docs-body li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.docs-body strong {
    color: var(--color-text);
    font-weight: 600;
}

/* ===========================================
   Code Blocks
   =========================================== */
.docs-body pre {
    background: #1e1e1e;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin: 1rem 0 1.5rem;
    overflow-x: auto;
    position: relative;
}

.docs-body pre code {
    font-size: 0.8125rem;
    line-height: 1.7;
    color: #d4d4d4;
}

.docs-body code {
    font-family: 'JetBrains Mono', monospace;
    /* JSON payloads and KEY=value strings offer no break opportunities, so
       they must be allowed to break mid-token rather than push the page. */
    overflow-wrap: anywhere;
    font-size: 0.875em;
    background: var(--color-surface-elevated);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    color: var(--color-text);
}

.docs-body pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

/* Code block with copy button */
.code-block {
    position: relative;
}

.code-block .copy-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.375rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 4px;
    color: #888;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.code-block .copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Syntax highlighting */
.token-comment {
    color: #6a9955;
}

.token-keyword {
    color: #569cd6;
}

.token-string {
    color: #ce9178;
}

.token-function {
    color: #dcdcaa;
}

.token-number {
    color: #b5cea8;
}

.token-prompt {
    color: #4ec9b0;
}

.token-output {
    color: #9cdcfe;
}

/* ===========================================
   Documentation index cards
   =========================================== */
.docs-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    gap: 1rem;
    margin: 1rem 0 1.5rem;
}

.docs-card {
    display: block;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    text-decoration: none;
    color: var(--color-text);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.docs-card:hover {
    border-color: var(--color-accent);
    background: var(--color-bg);
}

.docs-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1.0625rem;
}

.docs-card p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ===========================================
   Collapsible long listing (a whole config file)
   =========================================== */
.docs-details {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    margin: 1rem 0 1.5rem;
    background: var(--color-surface);
}

.docs-details > summary {
    cursor: pointer;
    padding: 0.75rem 1rem;
    font-family: var(--font-mono, monospace);
    font-size: 0.9375rem;
    color: var(--color-text);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    box-sizing: border-box;
}

.docs-details > summary::-webkit-details-marker { display: none; }

.docs-details > summary::before {
    content: "\25B8";
    color: var(--color-text-secondary);
    transition: transform 0.15s ease;
}

.docs-details[open] > summary::before { content: "\25BE"; }

.docs-details > summary:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

/* The listing inside must not widen the page; it scrolls in place. */
.docs-details > .code-block {
    margin: 0 0.75rem 0.75rem;
    min-width: 0;
}

/* ===========================================
   Note Callout
   =========================================== */
.docs-note {
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-accent);
    background: var(--color-surface);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    margin: 1rem 0 1.5rem;
    font-size: 0.9375rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

.docs-note strong {
    color: var(--color-text);
}

/* ===========================================
   Tables
   =========================================== */
.docs-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 1.5rem;
    font-size: 0.875rem;
    /* A table cannot shrink below its min-content width, so on a narrow
       screen it scrolls in place rather than widening the document. */
    display: block;
    overflow-x: auto;
    max-width: 100%;
}

.docs-body th,
.docs-body td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.docs-body th {
    font-weight: 600;
    color: var(--color-text);
    background: var(--color-surface);
}

.docs-body td {
    color: var(--color-text-secondary);
}

.docs-body td code {
    background: var(--color-surface-elevated);
    font-size: 0.8125rem;
}

/* ===========================================
   Horizontal Rule
   =========================================== */
.docs-body hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 3rem 0;
}

/* ===========================================
   Terminal Output Block
   =========================================== */
.terminal-output {
    background: #1e1e1e;
    border-radius: 8px;
    overflow: hidden;
    margin: 1rem 0 1.5rem;
    border: 1px solid #333;
}

.terminal-output .terminal-header {
    background: #2d2d2d;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid #333;
}

.terminal-output .terminal-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.terminal-output .terminal-dot.red {
    background: #ff5f56;
}

.terminal-output .terminal-dot.yellow {
    background: #ffbd2e;
}

.terminal-output .terminal-dot.green {
    background: #27c93f;
}

.terminal-output pre {
    margin: 0;
    padding: 1rem 1.25rem;
    background: transparent;
    border-radius: 0;
}

/* ===========================================
   Responsive
   =========================================== */
@media (max-width: 1024px) {
    .docs-content {
        padding: 2rem 3rem;
    }
}

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

    .docs-content {
        margin-left: 0;
        padding: 2rem 1.5rem;
    }

    .docs-header h1 {
        font-size: 2rem;
    }

    .docs-body h2 {
        font-size: 1.25rem;
    }

    .docs-body pre {
        padding: 1rem;
        margin-left: -1.5rem;
        margin-right: -1.5rem;
        border-radius: 0;
    }
}

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    background: var(--color-text);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    font-size: 1.25rem;
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
/* Version links: the crawlable equivalent of the switcher (docs/versions.js
   renders them when more than one line is published). */
.version-links {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
}

.version-links li { margin: 0.25rem 0; }

.version-links a {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
}

.version-links a:hover,
.version-links a[aria-current="page"] { color: var(--color-accent); }

/* Reading an archived line. */
.docs-archive-note {
    background: #fff8e6;
    border: 1px solid #e6d4a3;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* ===========================================
   Phones
   =========================================== */
@media (max-width: 768px) {
    /* 16px stops iOS zooming the page when the control takes focus. */
    .version-select,
    .docs-body input,
    .docs-body select {
        font-size: 16px;
    }

    /* The copy button belongs to the code block, not on top of its first
       line: full-bleed code and an absolutely-positioned button disagree
       about where the right edge is. */
    .docs-body pre {
        margin-left: 0;
        margin-right: 0;
        border-radius: 8px;
    }

    /* On a phone the button gets a comfortable 44px and its own strip at
       the top of the block, so it never sits on a line of code. */
    .code-block .copy-btn {
        top: 0.5rem;
        right: 0.5rem;
        min-height: 44px;
        padding: 0 0.875rem;
    }

    .code-block pre {
        padding-top: 3.5rem;
    }

    /* The badge is a sentence on a phone, not a pill. */
    .docs-version-badge {
        display: block;
        border-radius: 8px;
        line-height: 1.5;
    }

    .docs-content {
        padding: 2rem 1.25rem;
    }

    /* The drawer covers most of a phone screen: a shadow and a scrim so it
       reads as a panel over the page rather than a rendering glitch. */
    .sidebar-scrim {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1001;
    }

    .docs-sidebar {
        width: min(280px, 85vw);
        box-shadow: 0 0 24px rgba(0, 0, 0, 0.18);
        z-index: 1002;
    }
}

/* Above the breakpoint the fixed sidebar would sit on top of the footer's
   first column (the footer is outside .docs-layout). */
@media (min-width: 769px) {
    body > footer {
        margin-left: 280px;
    }
}
