/* ═══════════════════════════════════════════
   Crest Documentation Theme
   Colors and typography from tomitribe.com
   ═══════════════════════════════════════════ */

:root {
    --orange: #e57125;
    --orange-hover: #cf6520;
    --orange-glow: rgba(229, 113, 37, 0.12);
    --dark: #1e1e1e;
    --darker: #161616;
    --charcoal: #2b2b2b;
    --gray-light: #f5f5f5;
    --gray-mid: #888;
    --gray-border: #333;
    --white: #ffffff;
    --code-bg: #0d1117;
    --code-border: #30363d;
    --sidebar-width: 280px;
    --nav-height: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Lato', sans-serif;
    color: #d4d4d4;
    background: var(--dark);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

/* ── Navigation ── */
.site-nav {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
    background: rgba(22, 22, 22, 0.97);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--gray-border);
    height: var(--nav-height);
}

.site-nav .nav-inner {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    height: var(--nav-height);
    gap: 2rem;
}

.site-nav .logo {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--white);
    text-decoration: none;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.site-nav .logo span { color: var(--orange); }

.site-nav .nav-links {
    list-style: none;
    display: flex;
    gap: 0.25rem;
    margin-left: auto;
}

.site-nav .nav-links a {
    color: var(--gray-mid);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 400;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.site-nav .nav-links a:hover { color: var(--white); background: rgba(255,255,255,0.05); }
.site-nav .nav-links a.active { color: var(--orange); }

.site-nav .nav-links .nav-cta {
    background: var(--orange);
    color: var(--white);
    font-weight: 600;
    margin-left: 0.5rem;
}

.site-nav .nav-links .nav-cta:hover { background: var(--orange-hover); color: var(--white); }

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
    padding: 0.25rem;
}

/* ── Layout ── */
.page-wrapper {
    display: flex;
    margin-top: var(--nav-height);
    min-height: calc(100vh - var(--nav-height));
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--darker);
    border-right: 1px solid var(--gray-border);
    padding: 2rem 0;
    position: fixed;
    top: var(--nav-height);
    bottom: 0;
    overflow-y: auto;
    z-index: 50;
}

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

.sidebar-section h4 {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gray-mid);
    padding: 0 1.5rem;
    margin-bottom: 0.5rem;
}

.sidebar-section h4 a {
    color: inherit;
    text-decoration: none;
    border-left: none;
    padding: 0;
    font-size: inherit;
}

.sidebar-section h4 a:hover {
    color: var(--white);
    background: none;
}

.sidebar-section ul {
    list-style: none;
}

.sidebar-section a {
    display: block;
    padding: 0.35rem 1.5rem;
    color: #999;
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 2px solid transparent;
    transition: all 0.15s;
}

.sidebar-section a:hover {
    color: var(--white);
    background: rgba(255,255,255,0.03);
}

.sidebar-section a.active {
    color: var(--orange);
    border-left-color: var(--orange);
    background: rgba(229, 113, 37, 0.06);
}

/* ── Main content ── */
.content-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

.content-with-toc {
    display: flex;
    max-width: 1100px;
    margin: 0 auto;
}

.content {
    flex: 1;
    min-width: 0;
    max-width: 860px;
    padding: 3rem 3rem 6rem;
}

/* ── Typography ── */
.content h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.content .page-description {
    font-size: 1.15rem;
    color: var(--gray-mid);
    margin-bottom: 2.5rem;
    font-weight: 300;
    line-height: 1.6;
}

.content h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--white);
    margin-top: 3rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-border);
    letter-spacing: -0.3px;
}

.content h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--white);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.content h4 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #ccc;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.content p {
    margin-bottom: 1rem;
    color: #bbb;
}

.content a {
    color: var(--orange);
    text-decoration: none;
}

.content a:hover {
    text-decoration: underline;
}

.content strong { color: #ddd; }

.content ul, .content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    color: #bbb;
}

.content li {
    margin-bottom: 0.35rem;
}

.content li code,
.content p code,
.content td code,
.content h3 code,
.content h4 code {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    color: #e6edf3;
}

.content blockquote {
    border-left: 3px solid var(--orange);
    margin: 1.5rem 0;
    padding: 0.75rem 1.25rem;
    background: rgba(229, 113, 37, 0.06);
    border-radius: 0 8px 8px 0;
}

.content blockquote p {
    color: #ccc;
    margin-bottom: 0;
}

.content hr {
    border: none;
    border-top: 1px solid var(--gray-border);
    margin: 2.5rem 0;
}

/* ── Code Blocks ── */
.content .highlight {
    margin-bottom: 1.5rem;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--code-border);
}

.content .highlight pre {
    background: var(--code-bg) !important;
    padding: 1.25rem 1.5rem;
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.84rem;
    line-height: 1.7;
    margin: 0;
}

.content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
}

/* ── Tables ── */
.content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.content thead {
    background: var(--charcoal);
}

.content th {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-mid);
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-border);
}

.content td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: #bbb;
}

.content tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

/* ── Callout boxes ── */
.callout {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    border-left: 3px solid;
}

.callout-tip {
    background: rgba(40, 200, 64, 0.06);
    border-left-color: #28c840;
}

.callout-tip .callout-title { color: #28c840; }

.callout-warning {
    background: rgba(254, 188, 46, 0.06);
    border-left-color: #febc2e;
}

.callout-warning .callout-title { color: #febc2e; }

.callout-info {
    background: rgba(88, 166, 255, 0.06);
    border-left-color: #58a6ff;
}

.callout-info .callout-title { color: #58a6ff; }

.callout-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
}

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

/* ── Table of Contents (right rail) ── */
.toc-rail {
    display: none;
    width: 200px;
    flex-shrink: 0;
    padding-top: 3rem;
    padding-right: 1rem;
}

.toc-rail-inner {
    position: sticky;
    top: calc(var(--nav-height) + 2rem);
    max-height: calc(100vh - var(--nav-height) - 4rem);
    overflow-y: auto;
}

@media (min-width: 1300px) {
    .toc-rail {
        display: block;
    }
}

.toc-rail h5 {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gray-mid);
    margin-bottom: 0.75rem;
}

.toc-rail ul {
    list-style: none;
    padding: 0;
}

.toc-rail li {
    margin-bottom: 0.25rem;
}

.toc-rail a {
    display: block;
    color: #666;
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.2rem 0;
    transition: color 0.15s;
    line-height: 1.4;
}

.toc-rail a:hover { color: var(--white); }
.toc-rail a.active { color: var(--orange); }

.toc-rail ul ul {
    padding-left: 0.75rem;
}

/* ── Prev/Next Navigation ── */
.page-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--gray-border);
}

.page-nav a {
    display: block;
    padding: 1.25rem;
    background: var(--charcoal);
    border: 1px solid var(--gray-border);
    border-radius: 10px;
    text-decoration: none;
    transition: border-color 0.2s;
}

.page-nav a:hover {
    border-color: var(--orange);
    text-decoration: none;
}

.page-nav .nav-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-mid);
    margin-bottom: 0.25rem;
}

.page-nav .nav-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    color: var(--white);
    font-size: 0.95rem;
}

.page-nav .next { text-align: right; }
.page-nav .prev-only { grid-column: 1; }
.page-nav .next-only { grid-column: 2; }

/* ── Footer ── */
footer {
    margin-left: var(--sidebar-width);
    padding: 3rem 3rem 2rem;
    border-top: 1px solid var(--gray-border);
}

.footer-inner {
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--gray-mid);
}

.footer-inner a {
    color: var(--gray-mid);
    text-decoration: none;
}

.footer-inner a:hover { color: var(--orange); }

/* ── Section index pages ── */
.section-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}

.section-card {
    display: block;
    padding: 1.5rem;
    background: var(--charcoal);
    border: 1px solid var(--gray-border);
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.2s;
}

.section-card:hover {
    border-color: var(--orange);
    transform: translateY(-2px);
    text-decoration: none;
}

.section-card h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--white);
    margin: 0 0 0.5rem;
}

.section-card p {
    color: var(--gray-mid);
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.5;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content-area {
        margin-left: 0;
    }

    footer {
        margin-left: 0;
    }

    .hamburger {
        display: block;
    }

    .nav-links {
        display: none !important;
    }

    .content {
        padding: 2rem 1.5rem 4rem;
    }

    .section-cards {
        grid-template-columns: 1fr;
    }

    .page-nav {
        grid-template-columns: 1fr;
    }

    .page-nav .next-only { grid-column: 1; }
}
