/* ============================================================
   FONT LOADING — all font work lives here.
   contentStyles.css
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&family=Manrope:wght@400;500;600;700;800&family=Montserrat:wght@500;600;700;800&family=Outfit:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

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

/* ============================================================
   ROOT — premium black (Vercel/Linear cool neutral)
   ============================================================ */
:root {
    --bg: #0a0a0a;
    --bg-secondary: #111111;
    --bg-tertiary: #171717;
    --border: #262626;
    --nav-bg: #0a0a0a;

    --text-primary:   #f5f5f5;
    --text-body:      #d4d4d4;
    --text-secondary: #a3a3a3;
    --text-muted:     #8a8a8a;

    --accent: #1f6feb;
    --accent-bg: #0d2137;
    --code-bg: #171717;
    --sidebar-width: 260px;
    --toc-width: 248px;

    --font: 'Sora', 'Outfit', system-ui, sans-serif;
    --font-heading: 'Manrope', 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
    --drop-speed: 0.22s;
}

/* ============================================================
   BASE
   ============================================================ */
html { font-size: 16px; scroll-behavior: smooth; }
body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1.2rem;
    line-height: 1.7;
    min-height: 100vh;
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a { color: #75b5fd; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── TOP NAV ── */
.top-nav {
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    gap: 16px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
    white-space: nowrap;
    text-decoration: none;
    letter-spacing: 0;
}
.logo-m { font-size: 1.3rem; color: #fff; }
.logo-mdn { color: #fff; }
.logo-cursor { color: #75b5fd; }

.scrimba-banner { display: none !important; }

.nav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
}
.nav-links a, .nav-links button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.875rem;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    text-decoration: none;
}
.nav-links a:hover, .nav-links button:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
}
.nav-links .chevron { font-size: 0.65rem; opacity: 0.7; }

.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.nav-icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-icon-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.blog-link { color: var(--text-secondary); font-size: 0.875rem; font-weight: 500; }
.blog-link:hover { color: var(--text-primary); text-decoration: none; }


/* ── Tablet: shrink the trigger ── */
@media (max-width: 1100px) {
    pagefind-modal-trigger {
        min-width: 0;
        max-width: 240px;
        padding: 6px 10px;
    }
}

/* ── Mobile: hide the desktop trigger entirely ──
   mobileNav.js injects its own trigger under the top nav at ≤768px. */
@media (max-width: 768px) {
    .top-nav .nav-right pagefind-modal-trigger {
        display: none;
    }
}

/* ── SCRIMBA BANNER ── */
.scrimba-banner {
    background: #1e2332;
    border-bottom: 1px solid var(--border);
    text-align: center;
    padding: 10px 16px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.scrimba-banner a { color: #75b5fd; }

/* ── BREADCRUMB ── */
.breadcrumb-bar {
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.1rem;
    color: var(--text-muted);
}
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: #75b5fd; }
.bc-sep { opacity: 0.5; }
.breadcrumb-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.breadcrumb-right button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.8125rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0;
}
.breadcrumb-right button:hover { color: var(--text-primary); }

/* ── HAMBURGER (mobile) ── */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
}
.hamburger:hover { background: var(--bg-tertiary); }

/* ── LAYOUT ── */
.page-layout {
    display: flex;
}

/* ── LEFT SIDEBAR ── */
.left-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
    border-right: 1px solid var(--border);
    padding: 16px 0;
    background: var(--nav-bg);
}
.left-sidebar::-webkit-scrollbar { width: 4px; }
.left-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.filter-wrap { padding: 0 12px 12px; position: relative; }
.filter-input {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.8125rem;
    padding: 7px 10px 7px 30px;
    outline: none;
}
.filter-icon {
    position: absolute;
    left: 22px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
    pointer-events: none;
}
.filter-input:focus { border-color: var(--accent); }

/* ── SIDEBAR NAV BASE ── */
.sidebar-nav { list-style: none; }

.sidebar-nav > li > a,
.sidebar-nav > li > button:not(.sidebar-drop-btn) {
    display: block;
    padding: 5px 16px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: var(--font);
    line-height: 1.4;
    border-radius: 0;
    text-decoration: none;
}
.sidebar-nav > li > a:hover,
.sidebar-nav > li > button:not(.sidebar-drop-btn):hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    text-decoration: none;
}

.sidebar-nav li.active > a,
.sidebar-nav li.active > .sidebar-drop-btn {
    color: #75b5fd;
    background: var(--accent-bg);
    border-left: 2px solid var(--accent);
    padding-left: 14px;
    font-weight: 500;
}

/* ── SIDEBAR SECTION LABEL ── */
.sidebar-section-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted) !important;
    padding: 10px 16px 5px !important;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: default;
    font-family: var(--font);
}
.sidebar-section-btn::before { content: '›'; font-size: 0.9rem; }

.sidebar-divider { height: 1px; background: var(--border); margin: 8px 0; }
.sidebar-label {
    padding: 10px 16px 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

/* ══════════════════════════════════════════════
   ── SIDEBAR DROPDOWN ──
══════════════════════════════════════════════ */
.sidebar-drop-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 5px 16px;
    font-size: 0.9rem;
    font-family: var(--font);
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1.4;
    text-align: left;
    border-radius: 0;
    transition: color var(--drop-speed), background var(--drop-speed);
    border-left: 2px solid transparent;
}
.sidebar-drop-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.sidebar-drop-btn .drop-arrow {
    font-size: 0.65rem;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform var(--drop-speed) ease;
    display: inline-block;
    transform: rotate(0deg);
}

.sidebar-drop-item.open > .sidebar-drop-btn .drop-arrow {
    transform: rotate(90deg);
}

.sidebar-drop-item.active > .sidebar-drop-btn {
    color: #75b5fd;
    background: var(--accent-bg);
    border-left-color: var(--accent);
    padding-left: 14px;
}

.sidebar-drop-menu {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--drop-speed) ease;
    margin-left: 16px;
}

.sidebar-drop-item.open > .sidebar-drop-menu {
    max-height: 600px;
}

.sidebar-drop-menu li a {
    display: block;
    padding: 5px 14px;
    font-size: 0.83rem;
    color: var(--text-muted);
    text-decoration: none;
    line-height: 1.4;
    transition: color 0.15s, background 0.15s;
}
.sidebar-drop-menu li a:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    text-decoration: none;
}

.sidebar-drop-menu li.active > a {
    color: #75b5fd;
    font-weight: 500;
}

/* ── MAIN CONTENT ── */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 40px 48px;
}

/* ── RIGHT TOC ── */
.right-toc {
    width: var(--toc-width);
    flex-shrink: 0;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
    padding: 32px 20px;
}
.right-toc::-webkit-scrollbar { width: 4px; }
.right-toc::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.toc-heading {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.toc-list { list-style: none; }
.toc-list li { margin-bottom: 2px; }
.toc-list li a {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 4px 0 4px 10px;
    border-left: 2px solid transparent;
    line-height: 1.4;
    text-decoration: none;
}
.toc-list li a:hover { color: var(--text-primary); text-decoration: none; }
.toc-list li.active a { color: #75b5fd; border-left-color: var(--accent); font-weight: 500; }

/* ══════════════════════════════════════════════
   ── ARTICLE / HEADINGS ──
══════════════════════════════════════════════ */
h1 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 2.2rem;
    letter-spacing: -0.01em;
    line-height: 1.2;
    margin: 0 0 0.4rem 0;
}

h2 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.35;
    margin: 40px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.005em;
    line-height: 1.4;
    margin: 28px 0 12px;
    color: var(--text-primary, #fff);
    text-transform: uppercase;
}

h4 {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0 0 0.8rem 0;
    color: var(--text-primary, #fff);
    letter-spacing: -0.2px;
}

p {
    margin: 0;
    color: var(--text-body);
    font-size: 1rem;
    line-height: 1.5;
}

p strong { font-weight: 700; }
p em { font-style: italic; }

@media (max-width: 640px) {
    .page-body {
        padding: 1rem 0;
    }
    h1 {
        font-size: 1.6rem;
    }
}

code {
    background: var(--code-bg);
    border-radius: 3px;
    padding: 2px 5px;
    font-size: 0.875em;
    font-family: var(--font-mono);
    color: #d4d4d4;
    border: 1px solid #444;
}

.code-block {
    background: var(--code-bg);
    border-radius: 6px;
    margin: 16px 0 24px;
    overflow: hidden;
}
.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.copy-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.75rem;
    padding: 3px 10px;
    cursor: pointer;
}
.copy-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.copy-btn.copied { color: #4ade80; border-color: #4ade80; }
.code-block pre {
    padding: 16px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.6;
    color: #d4d4d4;
}
.kw { color: #569cd6; }
.fn { color: #dcdcaa; }
.str { color: #ce9178; }
.cm { color: #6a9955; font-style: italic; }
.num { color: #b5cea8; }
.punc { color: #d4d4d4; }

/* ── SIDEBAR OVERLAY (mobile) ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 200;
}
.sidebar-overlay.active { display: block; }

ul { margin-left: 2rem; }

.circled-number { border: 2px solid #ff8888; padding: 5px 10px;  border-radius: 50%;}
.indent { margin-left: 2rem; }
.indent-p { margin-left: 1.3rem; }
.indent-p2 { margin-left: 2.6rem; }
.indent-p3 { margin-left: 3.9rem; }
.indent-p4 { margin-left: 4.2rem; }

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
    .right-toc { display: none; }
    .left-sidebar {
        position: fixed;
        left: -270px;
        top: 0;
        height: 100vh;
        z-index: 300;
        transition: left 0.25s ease;
        width: 270px;
        border-right: 1px solid var(--border);
        background: var(--nav-bg);
        padding-top: 60px;
    }
    .left-sidebar.open { left: 0; }
    .hamburger { display: flex; }
    .nav-links { display: none; }
    .main-content { padding: 32px 24px; }
    .inline-toc { display: block; }
    .breadcrumb-bar { font-size: 0.875rem; }
    .scrimba-banner { display: none; }
}

@media (max-width: 768px) {
    .main-content { padding: 24px 16px; }
    h1 { font-size: 2.1rem; }
    h2 { font-size: 1.35rem; }
    .breadcrumb-right { display: none; }
    .breadcrumb-bar { font-size: 0.8125rem; }
}

@media (min-width: 1101px) {
    .inline-toc { display: none; }
}

@media (max-width: 1100px) {
    .inline-toc {
        display: block;
        border: 1px solid var(--border);
        border-radius: 6px;
        padding: 16px 20px;
        margin: 0 0 32px;
        background: var(--bg-secondary);
    }
    .inline-toc .toc-heading {
        font-size: 0.85rem;
        color: var(--text-primary);
        margin-bottom: 10px;
    }
    .inline-toc .toc-list li a {
        padding: 5px 0 5px 12px;
        font-size: 0.875rem;
    }
}

table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    margin: 1.5rem 0;
}

.math-table th, .math-table td {
    font-size: clamp(14px, 4vw, 18px);
    box-sizing: border-box;
}

@media screen and (max-width: 600px) {
    .math-table th, .math-table td {
        font-size: 13px !important;
        padding: 8px 6px !important;
    }
}

.math-table-container {
    margin: 1.5rem 0; width: 100%; box-sizing: border-box;
}

.version { color: #fff !important; }

/* ── FOOTER ── */
.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 2rem 2rem 1.5rem;
    width: 100%;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

.footer-section h4 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.footer-section ul { list-style: none; margin: 0; padding: 0; }
.footer-section ul li { margin-bottom: 0.4rem; }
.footer-section ul li a {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color 0.15s;
}
.footer-section ul li a:hover { color: var(--text-primary); text-decoration: none; }

.footer-bottom {
    max-width: 1200px;
    margin: 1.5rem auto 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.footer-bottom p { margin: 0; font-size: 0.75rem; color: var(--text-muted); }
.footer-bottom a { color: var(--text-muted); text-decoration: none; font-size: 0.75rem; }
.footer-bottom a:hover { color: var(--text-primary); text-decoration: underline; }

@media (max-width: 640px) {
    .footer-content { grid-template-columns: 1fr 1fr; gap: 1.5rem; }
    .footer-bottom { flex-direction: column; text-align: center; }
}
@media (max-width: 480px) {
    .footer-content { grid-template-columns: 1fr; gap: 1rem; }
    .site-footer { padding: 1.5rem 1rem 1rem; }
}