/* ═══════════════════════════════════════════════════════════════
   OtherU Doc Template — V2 Shared Styles
   Loaded by every individual doc page via doc-template.js
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
    --bg: #09090b;
    --surface: #0f0f13;
    --surface-2: #151519;
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --text: #fafafa;
    --text-2: #a1a1aa;
    --text-3: #52525b;
    --accent: #818cf8;
    --accent-2: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.12);
    --radius: 16px;
    --nav-h: 60px;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    overflow-y: scroll;
    /* Force vertical scrollbar gutter to prevent layout shifting */
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    line-height: 1.65;
    overflow-x: hidden;
}

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

a:hover {
    text-decoration: underline;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ── Ambient ── */
.doc-ambient {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.doc-ambient::before {
    content: '';
    position: absolute;
    top: -20%;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 600px;
    background: radial-gradient(ellipse, rgba(99, 102, 241, 0.05) 0%, transparent 70%);
}

/* ── Nav ── */
#doc-nav nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
}

#doc-nav nav.scrolled {
    background: rgba(9, 9, 11, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
}

.nav-brand .u {
    color: var(--accent);
}

.nav-brand:hover {
    text-decoration: none;
}

.nav-logo {
    width: 28px;
    height: 28px;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    list-style: none;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.3rem;
}

.nav-links a {
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    color: var(--text-2);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.nav-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0.5rem 1.2rem;
    border-radius: 10px;
    background: var(--accent);
    color: var(--on-accent, white);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.2s;
    border: none;
}

.nav-cta:hover {
    background: var(--accent-light);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ── Doc Layout: 3-column grid ── */
#doc-layout {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: calc(var(--nav-h) + 2rem) 1.5rem 4rem;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 220px;
    gap: 2rem;
    align-items: start;
}

/* ── Left Sidebar ── */
#doc-sidebar {
    position: sticky;
    top: calc(var(--nav-h) + 1.5rem);
    max-height: calc(100vh - var(--nav-h) - 2rem);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

#doc-sidebar::-webkit-scrollbar {
    width: 4px;
}

#doc-sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.sidebar-section {
    margin-bottom: 1.75rem;
}

.sidebar-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    padding: 0 0.5rem;
    margin-bottom: 0.5rem;
}

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

.sidebar-nav a {
    display: block;
    padding: 0.35rem 0.6rem;
    border-radius: 7px;
    color: var(--text-2);
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.sidebar-nav a.active {
    color: var(--text);
    background: rgba(99, 102, 241, 0.1);
    border-left: 2px solid var(--accent);
    padding-left: calc(0.6rem - 2px);
}

.sidebar-divider {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 1.25rem 0;
}

/* ── Main Content ── */
#doc-main {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 3rem;
}

/* Breadcrumb */
.doc-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--text-3);
    margin-bottom: 1.75rem;
}

.doc-breadcrumb a {
    color: var(--text-3);
    text-decoration: none;
    transition: color 0.2s;
}

.doc-breadcrumb a:hover {
    color: var(--text-2);
}

.doc-breadcrumb .sep {
    color: var(--text-3);
}

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

/* Page title */
#doc-main h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.doc-meta {
    font-size: 0.8rem;
    color: var(--text-3);
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

/* ── Prose ── */
.doc-prose {
    max-width: 72ch;
}

.doc-prose h2 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 2.25rem 0 0.75rem;
    color: var(--text);
    line-height: 1.3;
    padding-top: 0.5rem;
    /* offset for scroll-spy */
}

.doc-prose h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 1.75rem 0 0.5rem;
    color: var(--text);
    line-height: 1.3;
}

.doc-prose h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 1.25rem 0 0.4rem;
    color: var(--text-2);
}

.doc-prose p {
    color: var(--text-2);
    margin: 0.75rem 0;
    line-height: 1.75;
}

.doc-prose strong {
    color: var(--text);
    font-weight: 600;
}

.doc-prose ul,
.doc-prose ol {
    margin: 0.75rem 0 0.75rem 1.25rem;
    color: var(--text-2);
}

.doc-prose li {
    margin: 0.3rem 0;
    line-height: 1.7;
}

.doc-prose li::marker {
    color: var(--accent);
}

.doc-prose a {
    color: var(--accent);
}

.doc-prose a:hover {
    text-decoration: underline;
}

/* Code */
.doc-prose code {
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', ui-monospace, monospace;
    font-size: 0.85em;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: 5px;
    padding: 0.1em 0.4em;
    color: var(--accent);
}

.doc-prose pre {
    background: #0a0a10;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    overflow-x: auto;
    margin: 1.25rem 0;
    position: relative;
}

.doc-prose pre code {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-2);
    font-size: 0.82rem;
    line-height: 1.75;
}

/* Tables */
.doc-prose table {
    border-collapse: collapse;
    width: 100%;
    display: block;
    overflow-x: auto;
    margin: 1.25rem 0;
    font-size: 0.9rem;
}

.doc-prose thead th {
    text-align: left;
    font-weight: 600;
    color: var(--text);
    background: var(--surface-2);
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border);
}

.doc-prose td {
    padding: 0.55rem 0.9rem;
    border: 1px solid var(--border);
    color: var(--text-2);
}

.doc-prose tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.015);
}

/* Callout / Blockquote */
.doc-prose blockquote {
    margin: 1.25rem 0;
    padding: 1rem 1.25rem;
    border-left: 3px solid var(--accent-2);
    background: rgba(99, 102, 241, 0.05);
    border-radius: 0 8px 8px 0;
}

.doc-prose blockquote p {
    color: var(--text-2);
    margin: 0;
}

/* Media */
.doc-prose img,
.doc-prose video {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    border: 1px solid var(--border);
    margin: 1rem 0;
    display: block;
}

/* ── Prev / Next Navigation ── */
#doc-nav-prev-next {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.doc-prev-next-link {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    background: var(--bg);
}

.doc-prev-next-link:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    text-decoration: none;
}

.doc-prev-next-link.next {
    text-align: right;
}

.doc-prev-next-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-3);
}

.doc-prev-next-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.doc-prev-next-arrow {
    font-size: 0.75rem;
    color: var(--accent);
}

/* ── Right TOC ── */
#doc-toc {
    position: sticky;
    top: calc(var(--nav-h) + 1.5rem);
    max-height: calc(100vh - var(--nav-h) - 2rem);
    overflow-y: auto;
    scrollbar-width: none;
}

#doc-toc::-webkit-scrollbar {
    display: none;
}

.toc-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-3);
    padding: 0 0.5rem;
    margin-bottom: 0.75rem;
}

.toc-list {
    list-style: none;
}

.toc-link {
    display: block;
    padding: 0.28rem 0.6rem;
    border-radius: 5px;
    font-size: 0.8rem;
    color: var(--text-3);
    text-decoration: none;
    transition: all 0.15s;
    border-left: 2px solid transparent;
}

.toc-link:hover {
    color: var(--text-2);
}

.toc-link.active {
    color: var(--accent);
    border-left-color: var(--accent);
}

.toc-link.h3 {
    padding-left: 1.2rem;
    font-size: 0.75rem;
}

/* ── Footer ── */
#doc-footer {
    border-top: 1px solid var(--border);
    padding: 2.5rem 2rem;
    text-align: center;
    position: relative;
    z-index: 1;
}

.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-3);
    text-decoration: none;
    font-size: 0.78rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--text-2);
    text-decoration: none;
}

.footer-copy {
    font-size: 0.72rem;
    color: var(--text-3);
}

/* ── Responsive ── */
@media (max-width: 1200px) {
    #doc-toc {
        display: none;
    }

    #doc-layout {
        grid-template-columns: 240px minmax(0, 1fr);
    }
}

@media (max-width: 900px) {
    #doc-layout {
        grid-template-columns: 1fr;
        padding: calc(var(--nav-h) + 1rem) 1rem 3rem;
    }

    #doc-sidebar {
        position: static;
        max-height: none;
        display: none;
    }

    #doc-sidebar.open {
        display: block;
    }

    #doc-main {
        padding: 1.75rem;
    }
}

@media (max-width: 640px) {
    #doc-main {
        padding: 1.25rem;
    }

    .nav-links,
    .nav-cta {
        display: none;
    }

    #dt-theme-select {
        display: none;
    }

    .nav-toggle {
        display: block;
    }

    .nav-links.open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: calc(var(--nav-h) + 1px);
        left: 1rem;
        right: 1rem;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 0.5rem;
        gap: 0.25rem;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    }

    #doc-nav-prev-next {
        grid-template-columns: 1fr;
    }

    .doc-prose h2 {
        font-size: 1.2rem;
    }
}

/* ── Docs Card Grid (Index) ── */
.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-top: 2rem;
}

.docs-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    text-decoration: none !important;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.25s;
    color: var(--text);
}

.docs-card:hover {
    border-color: rgba(99, 102, 241, 0.25);
    transform: translateY(-2px);
    background: linear-gradient(135deg, var(--surface) 0%, rgba(99, 102, 241, 0.03) 100%);
}

.docs-card-icon {
    width: 42px;
    height: 42px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.docs-card-icon svg {
    width: 22px;
    height: 22px;
}

.docs-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.docs-card-desc {
    font-size: 0.85rem;
    color: var(--text-2);
    line-height: 1.5;
}