
/* Dark theme (default) */
[data-theme="dark"] {
    --bg-primary: #1e1e1e;
    --bg-secondary: #262626;
    --bg-sidebar: #1a1a1a;
    --text-primary: #dcddde;
    --text-secondary: #999;
    --text-muted: #888;
    --text-footer: #aaa;
    --accent: #7f6df2;
    --accent-light: #a594f9;
    --link: #7f6df2;
    --link-hover: #a594f9;
    --border: #333;
    --callout-bg: #2a2a3a;
    --callout-border: #7f6df2;
    --code-bg: #2d2d2d;
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-sidebar: #fafafa;
    --text-primary: #1a1a1a;
    --text-secondary: #555;
    --text-muted: #777;
    --text-footer: #666;
    --accent: #6c5ce7;
    --accent-light: #5a4bd1;
    --link: #6c5ce7;
    --link-hover: #4a3ab5;
    --border: #e0e0e0;
    --callout-bg: #f0eeff;
    --callout-border: #6c5ce7;
    --code-bg: #f0f0f0;
}

:root {
    --font-text: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font-text);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    line-height: 1.7;
}

/* Sidebar */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 2rem 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.site-title {
    padding: 0 1.5rem 1.5rem;
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-title a {
    color: var(--text-primary);
    text-decoration: none;
}

.title-buttons {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.sidebar-collapse,
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
    transition: all 0.15s;
    line-height: 1;
}

.sidebar-collapse:hover,
.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* Show sun in dark mode, moon in light mode */
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }

/* Hamburger button (mobile + collapsed desktop) */
.hamburger {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 0.5rem;
    width: 40px;
    height: 36px;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 1px;
    transition: all 0.2s;
}

.hamburger:hover span {
    background: var(--text-primary);
}

/* Overlay for mobile menu */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar li {
    margin: 0;
}

.sidebar li a {
    display: block;
    padding: 0.4rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.sidebar li a:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.sidebar li.active a {
    color: var(--accent-light);
    border-left-color: var(--accent);
    background: rgba(127, 109, 242, 0.08);
}

/* Nav groups (collapsible) */
.nav-group details {
    margin: 0;
}

.nav-group summary {
    display: block;
    padding: 0.4rem 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.15s;
    list-style: none;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-group summary::before {
    content: "\203A";
    display: inline-block;
    margin-right: 0.4rem;
    transition: transform 0.15s;
    font-size: 0.9rem;
}

.nav-group details[open] > summary::before {
    transform: rotate(90deg);
}

.nav-group summary:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.nav-group details > ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-group details > ul > li a {
    padding-left: 2.5rem;
}

/* Download link */
.nav-download {
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

.nav-download a {
    display: block;
    padding: 0.4rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.nav-download a::before {
    content: none;
}

.nav-download a:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

/* Sidebar footer */
.sidebar-footer {
    margin-top: auto;
    padding: 1.5rem 1.5rem 0.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-footer);
}

.sidebar-footer a {
    color: var(--text-footer);
    text-decoration: underline;
    text-decoration-color: var(--border);
}

.sidebar-footer a:hover {
    color: var(--accent-light);
}

/* Main content */
.content {
    margin-left: 260px;
    flex: 1;
    max-width: 800px;
    padding: 3rem 4rem;
}

article {
    max-width: 100%;
}

/* Page updated timestamp */
.page-updated {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Typography */
h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}

h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

p {
    margin-bottom: 1rem;
}

/* Links */
a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* Lists */
ul, ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.4rem;
}

li > ul, li > ol {
    margin-top: 0.3rem;
    margin-bottom: 0.3rem;
}

/* Bold and italic */
strong {
    font-weight: 600;
    color: var(--text-primary);
}

em {
    font-style: italic;
}

/* Callouts */
.callout {
    background: var(--callout-bg);
    border-left: 4px solid var(--callout-border);
    border-radius: 4px;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
}

.callout-title {
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-light);
    margin-bottom: 0.5rem;
}

.callout-content p {
    margin-bottom: 0.5rem;
}

.callout-content p:last-child {
    margin-bottom: 0;
}

/* Code */
code {
    font-family: var(--font-mono);
    background: var(--code-bg);
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    font-size: 0.88em;
}

pre {
    background: var(--code-bg);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

pre code {
    background: none;
    padding: 0;
}

/* Blockquotes (non-callout) */
blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1rem;
    color: var(--text-secondary);
    margin: 1rem 0;
}

/* Tables */
table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1rem;
}

th, td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

th {
    background: var(--bg-secondary);
    font-weight: 600;
}

/* Horizontal rules */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* Desktop: sidebar toggle */
.sidebar {
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.content {
    transition: margin-left 0.25s ease;
}

body.sidebar-hidden .sidebar {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

body.sidebar-hidden .content {
    margin-left: 0;
}

body.sidebar-hidden .hamburger {
    display: flex;
}

body.sidebar-hidden .sidebar-collapse {
    display: none;
}

/* Responsive: mobile */
@media (max-width: 900px) {
    .sidebar-collapse {
        display: none;
    }

    .hamburger {
        display: flex;
    }

    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        z-index: 100;
        width: 280px;
        min-width: 280px;
    }

    body.sidebar-hidden .sidebar {
        transform: translateX(-100%);
        opacity: 1;
    }

    body:not(.sidebar-hidden) .sidebar {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    body:not(.sidebar-hidden) .sidebar-overlay {
        display: block;
    }

    .content {
        margin-left: 0;
        padding: 2rem 1.5rem;
    }

    .content {
        padding-top: 3.5rem;
    }
}
