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

:root {
    --bg: #fff;
    --bg-secondary: #f8f9fa;
    --text: #343a40;
    --text-secondary: #6c757d;
    --border: #dee2e6;
    --accent: #2780e3;
    --accent-hover: #1f4eb6;
    --code-bg: #f8f9fa;
    --nav-bg: rgba(255, 255, 255, 0.95);
}

[data-theme="dark"] {
    --bg: #222;
    --bg-secondary: #2d2d2d;
    --text: #fff;
    --text-secondary: rgba(255, 255, 255, 0.75);
    --border: #444;
    --accent: #00bc8c;
    --accent-hover: #009670;
    --code-bg: #303030;
    --nav-bg: rgba(34, 34, 34, 0.95);
}

html { font-size: 17px; scroll-behavior: smooth; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    transition: background 0.2s ease, color 0.2s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Nav ── */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0.6rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.site-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.nav-toggle-input { display: none; }
.nav-burger { display: none; }

.nav-links {
    display: flex;
    gap: 1.25rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    transition: color 0.15s;
}

.nav-links a:hover { color: var(--text); }

.nav-tools {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.nav-icon {
    color: var(--text-secondary);
    transition: color 0.15s;
    display: flex;
    align-items: center;
}

.nav-icon:hover { color: var(--text); }

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

.theme-toggle:hover { color: var(--text); }

[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* ── Mobile nav ── */
@media (max-width: 640px) {
    .nav-burger {
        display: flex;
        align-items: center;
        cursor: pointer;
        padding: 0.25rem;
    }

    .nav-burger span,
    .nav-burger span::before,
    .nav-burger span::after {
        display: block;
        width: 18px;
        height: 2px;
        background: var(--text-secondary);
        transition: 0.2s;
        position: relative;
    }

    .nav-burger span::before,
    .nav-burger span::after {
        content: '';
        position: absolute;
    }

    .nav-burger span::before { top: -6px; }
    .nav-burger span::after { top: 6px; }

    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
        padding-top: 0.5rem;
    }

    .nav-inner { flex-wrap: wrap; }

    .nav-toggle-input:checked ~ .nav-links { display: flex; }
}

/* ── Content ── */
.content {
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    flex: 1;
}

/* ── Typography ── */
h1 { font-size: 1.85rem; line-height: 1.25; margin-bottom: 1rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.35rem; margin-top: 2.5rem; margin-bottom: 0.75rem; font-weight: 600; }
h3 { font-size: 1.1rem; margin-top: 1.75rem; margin-bottom: 0.5rem; font-weight: 600; }
p { margin-bottom: 1.2rem; }

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

strong { font-weight: 600; }
em { font-style: italic; }

ul, ol { margin-bottom: 1.2rem; padding-left: 1.5rem; }
li { margin-bottom: 0.35rem; }

blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    color: var(--text-secondary);
    margin: 1.5rem 0;
    font-style: italic;
}

hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ── Code ── */
code {
    background: var(--code-bg);
    padding: 0.15em 0.35em;
    border-radius: 3px;
    font-size: 0.88em;
    font-family: "SF Mono", "Cascadia Code", "Fira Code", monospace;
}

pre {
    background: var(--code-bg);
    padding: 1rem 1.25rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1.5rem 0;
    line-height: 1.5;
}

pre code {
    background: none;
    padding: 0;
    font-size: 0.85rem;
}

/* ── Essays ── */
.essay-header { margin-bottom: 2rem; }
.essay-header h1 { margin-bottom: 0.4rem; }
.essay-header time { color: var(--text-secondary); font-size: 0.88rem; }

.essay-item {
    margin-bottom: 1.75rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid var(--border);
}

.essay-item:last-child { border-bottom: none; margin-bottom: 0; }
.essay-item h2, .essay-item h3 { margin-top: 0; margin-bottom: 0.2rem; }
.essay-item h2 { font-size: 1.2rem; }
.essay-item h3 { font-size: 1.1rem; }
.essay-item time { font-size: 0.82rem; color: var(--text-secondary); }
.essay-item p { margin-top: 0.4rem; margin-bottom: 0; color: var(--text-secondary); font-size: 0.92rem; }

/* ── Homepage sections ── */
.home-section { margin-top: 2.5rem; }
.home-section h2 { margin-top: 0; margin-bottom: 1rem; font-size: 1.2rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); }

.book-feature h3 { margin-top: 0; margin-bottom: 0.3rem; font-size: 1.1rem; }
.book-feature p { margin-top: 0.4rem; margin-bottom: 0; color: var(--text-secondary); font-size: 0.92rem; }
.book-status { font-style: italic; font-size: 0.85rem !important; }

/* ── Placeholder notice ── */
.placeholder-notice { color: var(--text-secondary); font-size: 0.85rem; border-left: 3px solid var(--border); padding-left: 0.75rem; margin-bottom: 1.5rem; }

/* ── Footer ── */
.site-footer {
    border-top: 1px solid var(--border);
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin-top: auto;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .content { padding: 1.5rem 1rem; }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.2rem; }
}
