/* ═══════════════════════════════════════════════
   ERRATA.INK — Global Stylesheet
   A clean, minimal blog on history, philosophy & economics
   ═══════════════════════════════════════════════ */

:root {
    --transition-speed: 0.4s;
}

[data-theme="light"] {
    --bg-primary: #FAF8F5;
    --bg-secondary: #F0EDE8;
    --bg-card: #FFFFFF;
    --bg-sidebar: #F5F2EE;
    --text-primary: #1A1A1A;
    --text-secondary: #6B6560;
    --text-tertiary: #9A9490;
    --accent: #B85C38;
    --accent-hover: #A04E2E;
    --accent-soft: rgba(184, 92, 56, 0.08);
    --border: #E8E4DF;
    --border-hover: #D4CFC9;
    --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
    --shadow-hover: 0 2px 8px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.05);
    --tag-bg: #F0EDE8;
    --tag-text: #6B6560;
    --toggle-bg: #E8E4DF;
    --toggle-icon: #6B6560;
    --divider: #E8E4DF;
    --sidebar-active: rgba(184, 92, 56, 0.08);
    --code-bg: #F0EDE8;
}

[data-theme="dark"] {
    --bg-primary: #141210;
    --bg-secondary: #1E1C19;
    --bg-card: #1E1C19;
    --bg-sidebar: #1A1816;
    --text-primary: #E8E4DF;
    --text-secondary: #9A9490;
    --text-tertiary: #6B6560;
    --accent: #D4845A;
    --accent-hover: #E09468;
    --accent-soft: rgba(212, 132, 90, 0.1);
    --border: #2A2724;
    --border-hover: #3A3633;
    --shadow: 0 1px 3px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.15);
    --shadow-hover: 0 2px 8px rgba(0,0,0,0.25), 0 8px 24px rgba(0,0,0,0.2);
    --tag-bg: #2A2724;
    --tag-text: #9A9490;
    --toggle-bg: #2A2724;
    --toggle-icon: #9A9490;
    --divider: #2A2724;
    --sidebar-active: rgba(212, 132, 90, 0.1);
    --code-bg: #1E1C19;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

/* ─── Theme Toggle ─── */
.theme-toggle {
    position: fixed;
    top: 28px;
    right: 32px;
    z-index: 100;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--toggle-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

.theme-toggle:hover {
    border-color: var(--border-hover);
    transform: scale(1.05);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    color: var(--toggle-icon);
    transition: color var(--transition-speed) ease;
}

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

/* ─── Mobile Menu Toggle ─── */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 28px;
    left: 20px;
    z-index: 200;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--toggle-bg);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

.mobile-menu-btn svg {
    width: 18px;
    height: 18px;
    color: var(--toggle-icon);
}

/* ─── Layout ─── */
.site-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--divider);
    padding: 40px 28px;
    overflow-y: auto;
    transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease, transform 0.3s ease;
    z-index: 150;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    margin-bottom: 36px;
}

.sidebar-title {
    font-family: 'Newsreader', serif;
    font-size: 1.8rem;
    font-weight: 400;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    text-decoration: none;
    transition: color var(--transition-speed) ease;
    display: block;
    line-height: 1.2;
}

.sidebar-title:hover {
    color: var(--accent);
}

.sidebar-tagline {
    font-family: 'Newsreader', serif;
    font-size: 0.85rem;
    font-style: italic;
    font-weight: 300;
    color: var(--text-tertiary);
    margin-top: 8px;
    line-height: 1.5;
    transition: color var(--transition-speed) ease;
}

/* ─── Sidebar Navigation ─── */
.sidebar-nav {
    flex: 1;
}

.sidebar-section {
    margin-bottom: 28px;
}

.sidebar-section-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    padding-left: 12px;
    transition: color var(--transition-speed) ease;
}

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

.sidebar-links li {
    margin-bottom: 2px;
}

.sidebar-links a {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.sidebar-links a:hover {
    color: var(--text-primary);
    background: var(--sidebar-active);
}

.sidebar-links a.active {
    color: var(--accent);
    background: var(--sidebar-active);
    font-weight: 500;
}

.sidebar-links a .link-icon {
    width: 16px;
    height: 16px;
    opacity: 0.5;
    flex-shrink: 0;
}

.sidebar-links a:hover .link-icon,
.sidebar-links a.active .link-icon {
    opacity: 0.8;
}

.sidebar-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-tertiary);
    margin-left: auto;
    transition: color var(--transition-speed) ease;
}

/* ─── Sidebar Footer ─── */
.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid var(--divider);
    margin-top: auto;
    transition: border-color var(--transition-speed) ease;
}

.sidebar-footer-links {
    display: flex;
    gap: 16px;
}

.sidebar-footer-links a {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-decoration: none;
    letter-spacing: 0.04em;
    transition: color 0.25s ease;
}

.sidebar-footer-links a:hover {
    color: var(--accent);
}

.sidebar-copyright {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-tertiary);
    margin-top: 12px;
    transition: color var(--transition-speed) ease;
}

/* ─── Sidebar Overlay (mobile) ─── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 140;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
}

/* ─── Main Content ─── */
.main-content {
    margin-left: 260px;
    flex: 1;
    min-height: 100vh;
}

.content-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 60px 40px 80px;
}

/* ─── Page Header ─── */
.page-header {
    margin-bottom: 48px;
}

.page-title {
    font-family: 'Newsreader', serif;
    font-size: 2.4rem;
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-primary);
    margin-bottom: 12px;
    transition: color var(--transition-speed) ease;
}

.page-description {
    font-family: 'Newsreader', serif;
    font-size: 1.1rem;
    font-weight: 300;
    font-style: italic;
    color: var(--text-secondary);
    line-height: 1.6;
    transition: color var(--transition-speed) ease;
}

/* ─── Section Label ─── */
.section-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 28px;
    transition: color var(--transition-speed) ease;
}

/* ─── Post Cards (list view) ─── */
.posts {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.post {
    padding: 32px 0;
    border-bottom: 1px solid var(--divider);
    transition: border-color var(--transition-speed) ease;
    cursor: pointer;
    position: relative;
}

.post:first-child {
    padding-top: 0;
}

.post:last-child {
    border-bottom: none;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.post-date {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    transition: color var(--transition-speed) ease;
}

.post-tag {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 3px;
    background: var(--tag-bg);
    color: var(--tag-text);
    text-decoration: none;
    transition: all var(--transition-speed) ease;
}

.post-tag:hover {
    color: var(--accent);
}

.post-title {
    font-family: 'Newsreader', serif;
    font-size: 1.55rem;
    font-weight: 400;
    line-height: 1.35;
    color: var(--text-primary);
    margin-bottom: 10px;
    transition: color 0.25s ease;
    letter-spacing: -0.01em;
}

.post-title a {
    color: inherit;
    text-decoration: none;
}

.post:hover .post-title,
.post-title a:hover {
    color: var(--accent);
}

.post-excerpt {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-secondary);
    transition: color var(--transition-speed) ease;
}

.post-read-more {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    transition: gap 0.25s ease;
}

.post:hover .post-read-more {
    gap: 10px;
}

.post-read-more svg {
    width: 14px;
    height: 14px;
    transition: transform 0.25s ease;
}

.post:hover .post-read-more svg {
    transform: translateX(2px);
}

/* ─── Article Page ─── */
.article-header {
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--divider);
    transition: border-color var(--transition-speed) ease;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.article-title {
    font-family: 'Newsreader', serif;
    font-size: 2.2rem;
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.25;
    color: var(--text-primary);
    transition: color var(--transition-speed) ease;
}

.article-subtitle {
    font-family: 'Newsreader', serif;
    font-size: 1.15rem;
    font-weight: 300;
    font-style: italic;
    color: var(--text-secondary);
    margin-top: 12px;
    line-height: 1.6;
    transition: color var(--transition-speed) ease;
}

.article-body {
    font-family: 'Newsreader', serif;
    font-size: 1.12rem;
    line-height: 1.85;
    color: var(--text-primary);
    transition: color var(--transition-speed) ease;
}

.article-body p {
    margin-bottom: 1.5em;
}

.article-body h2 {
    font-family: 'Newsreader', serif;
    font-size: 1.5rem;
    font-weight: 400;
    margin-top: 2.5em;
    margin-bottom: 0.8em;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.article-body h3 {
    font-family: 'DM Sans', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-top: 2em;
    margin-bottom: 0.6em;
    color: var(--text-secondary);
}

.article-body blockquote {
    border-left: 2px solid var(--accent);
    padding-left: 24px;
    margin: 2em 0;
    font-style: italic;
    color: var(--text-secondary);
}

.article-body a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(184, 92, 56, 0.3);
    transition: text-decoration-color 0.2s ease;
}

.article-body a:hover {
    text-decoration-color: var(--accent);
}

.article-body code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 3px;
}

.article-body hr {
    border: none;
    height: 1px;
    background: var(--divider);
    margin: 2.5em 0;
}

/* ─── Article Footer ─── */
.article-footer {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--divider);
    transition: border-color var(--transition-speed) ease;
}

.article-nav {
    display: flex;
    justify-content: space-between;
    gap: 24px;
}

.article-nav a {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    color: var(--accent);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: gap 0.25s ease;
}

.article-nav a:hover {
    gap: 12px;
}

.article-nav a svg {
    width: 16px;
    height: 16px;
}

.back-to-top {
    text-align: center;
    margin-top: 32px;
}

.back-to-top a {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color 0.25s ease;
}

.back-to-top a:hover {
    color: var(--accent);
}

/* ─── Interlude Quote ─── */
.interlude {
    margin: 48px 0;
    padding: 36px 0;
    border-top: 1px solid var(--divider);
    border-bottom: 1px solid var(--divider);
    transition: border-color var(--transition-speed) ease;
}

.interlude blockquote {
    font-family: 'Newsreader', serif;
    font-size: 1.25rem;
    font-style: italic;
    font-weight: 300;
    line-height: 1.65;
    color: var(--text-secondary);
    transition: color var(--transition-speed) ease;
}

.interlude cite {
    display: block;
    margin-top: 14px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-style: normal;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    transition: color var(--transition-speed) ease;
}

/* ─── About Page ─── */
.about-content {
    font-family: 'Newsreader', serif;
    font-size: 1.12rem;
    line-height: 1.85;
    color: var(--text-primary);
}

.about-content p {
    margin-bottom: 1.5em;
}

/* ─── Animations ─── */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-header { animation: fadeUp 0.6s ease both; }
.section-label { animation: fadeUp 0.6s ease 0.1s both; }
.post:nth-child(1) { animation: fadeUp 0.6s ease 0.15s both; }
.post:nth-child(2) { animation: fadeUp 0.6s ease 0.22s both; }
.post:nth-child(3) { animation: fadeUp 0.6s ease 0.29s both; }
.post:nth-child(4) { animation: fadeUp 0.6s ease 0.36s both; }
.post:nth-child(5) { animation: fadeUp 0.6s ease 0.43s both; }
.post:nth-child(6) { animation: fadeUp 0.6s ease 0.50s both; }
.article-header { animation: fadeUp 0.6s ease both; }
.article-body { animation: fadeUp 0.6s ease 0.15s both; }

/* ─── Responsive ─── */
@media (max-width: 900px) {
    .mobile-menu-btn {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-overlay.active {
        display: block;
    }

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

    .content-container {
        padding: 80px 24px 60px;
    }

    .theme-toggle {
        top: 28px;
        right: 20px;
    }
}

@media (max-width: 640px) {
    .page-title {
        font-size: 1.8rem;
    }

    .article-title {
        font-size: 1.7rem;
    }

    .post-title {
        font-size: 1.3rem;
    }

    .article-nav {
        flex-direction: column;
    }
}
