/* ════════════════════════════════════════
   THEME: Ivory & Forest (Light)
   ════════════════════════════════════════ */
[data-theme="light"] {
    --bg: #F5F1E8;
    --bg-card: #FDFBF5;
    --ink: #2C3328;
    --ink-light: #5C5A4E;
    --ink-faint: #969284;
    --accent: #4A6741;
    --accent-hover: #5B7D51;
    --rule: #DDD8CC;
    --rule-light: #E8E4D9;
    --card-border: #DDD8CC;
    --card-border-hover: #4A6741;
    --shadow: rgba(44, 51, 40, 0.06);
    --nav-gradient: linear-gradient(to bottom, #F5F1E8 60%, transparent);
    --toggle-bg: #E8E4D9;
    --toggle-icon: #969284;
    --toggle-hover: #DDD8CC;
}

/* ════════════════════════════════════════
   THEME: Deep Study (Dark)
   ════════════════════════════════════════ */
[data-theme="dark"] {
    --bg: #1A1815;
    --bg-card: #22201C;
    --ink: #EDE4D3;
    --ink-light: #8A8070;
    --ink-faint: #6B6355;
    --accent: #B8845C;
    --accent-hover: #CFA070;
    --rule: #3D3830;
    --rule-light: #2E2A24;
    --card-border: #3D3830;
    --card-border-hover: #B8845C;
    --shadow: rgba(0, 0, 0, 0.2);
    --nav-gradient: linear-gradient(to bottom, #1A1815 60%, transparent);
    --toggle-bg: #2E2A24;
    --toggle-icon: #6B6355;
    --toggle-hover: #3D3830;
}

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

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

body {
    font-family: 'Newsreader', Georgia, serif;
    background-color: var(--bg);
    color: var(--ink);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Subtle noise texture */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    z-index: 9999;
}

/* ─── Navigation ─── */
nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    padding: 1rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--nav-gradient);
    transition: background 0.4s ease;
}

nav .name {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 1.15rem;
    color: var(--ink);
    text-decoration: none;
    transition: color 0.4s ease;
}

nav .nav-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

nav .links {
    display: flex;
    gap: 2rem;
}

nav .links a {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-faint);
    text-decoration: none;
    transition: color 0.3s ease;
}

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

/* ─── Theme Toggle ─── */
.theme-toggle {
    background: var(--toggle-bg);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--toggle-hover);
    transform: scale(1.08);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--toggle-icon);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.3s ease;
}

.theme-toggle:hover svg {
    stroke: var(--accent);
}

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

/* ─── Layout Shell ─── */
.page-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 3rem;
}

/* ─── Marginalia Grid ───
   On wide screens: 200px left margin column | flexible content column
   Section labels and metadata sit in the left margin.
*/
.margin-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 2.5rem;
    align-items: start;
}

.margin-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-faint);
    padding-top: 0.2rem;
    text-align: right;
    transition: color 0.4s ease;
    position: sticky;
    top: 4rem;
}

.margin-content {
    min-width: 0;
}

/* ─── Hero ─── */
.hero {
    padding-top: 8rem;
    padding-bottom: 4rem;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 4rem;
    transition: border-color 0.4s ease;
}

.hero h1 {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 3.6rem;
    font-weight: 400;
    line-height: 1.15;
    color: var(--ink);
    margin-bottom: 1.5rem;
    transition: color 0.4s ease;
}

.hero p {
    font-size: 1.05rem;
    color: var(--ink-light);
    max-width: 560px;
    line-height: 1.8;
    transition: color 0.4s ease;
}

.hero .ornament {
    display: block;
    margin-top: 2rem;
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 1.4rem;
    color: var(--rule);
    letter-spacing: 0.3em;
    transition: color 0.4s ease;
}

/* ─── Section ─── */
.section {
    margin-bottom: 5rem;
}

.section-header {
    border-bottom: 1px solid var(--rule-light);
    padding-bottom: 0.5rem;
    margin-bottom: 2rem;
    transition: border-color 0.4s ease;
}

/* ─── Recommendation Cards — 2-col grid ─── */
.rec-group-label {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 1.05rem;
    font-style: italic;
    color: var(--ink-light);
    margin-bottom: 1.2rem;
    margin-top: 2.5rem;
    transition: color 0.4s ease;
}

.rec-group-label:first-child {
    margin-top: 0;
}

.filter-chips {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
    align-items: baseline;
}

.filter-chip {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    font-weight: 300;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0;
    padding-bottom: 0.2rem;
    border: none;
    border-bottom: 1px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--ink-faint);
    cursor: pointer;
    transition: color 0.3s ease, border-color 0.3s ease;
    line-height: 1;
}

.filter-chip:hover {
    color: var(--ink-light);
}

.filter-chip.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.rec-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.rec-card {
    background: var(--bg-card);
    border-left: 3px solid var(--card-border);
    padding: 1.25rem 1.5rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.4s ease;
}

.rec-card:hover {
    border-left-color: var(--card-border-hover);
    box-shadow: 0 2px 12px var(--shadow);
}

.rec-card .title {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 1.15rem;
    color: var(--ink);
    margin-bottom: 0.15rem;
    transition: color 0.4s ease;
}

.rec-card .author {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    font-weight: 300;
    color: var(--ink-faint);
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
    transition: color 0.4s ease;
}

.rec-card .blurb {
    font-size: 0.88rem;
    color: var(--ink-light);
    line-height: 1.7;
    transition: color 0.4s ease;
}

.rec-link {
    display: inline-block;
    margin-top: 0.6rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 0.03em;
    transition: color 0.3s ease;
}

.rec-link:hover {
    color: var(--ink);
}

/* ─── Entries (Studies / Writing) with margin dates ─── */
.entry-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 2.5rem;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--rule-light);
    transition: border-color 0.4s ease;
}

.entry-row:last-child {
    border-bottom: none;
}

.entry-meta {
    text-align: right;
    padding-top: 0.35rem;
}

.entry-meta .date {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    font-weight: 300;
    color: var(--ink-faint);
    letter-spacing: 0.05em;
    transition: color 0.4s ease;
}

.entry-meta .tag {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.5rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    margin-top: 0.3rem;
    margin-left: 0;
    transition: color 0.4s ease;
}

.entry-body .entry-title {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 1.35rem;
    color: var(--ink);
    margin-bottom: 0.5rem;
    text-decoration: none;
    display: block;
    transition: color 0.2s ease;
}

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

.entry-body .excerpt {
    font-size: 0.9rem;
    color: var(--ink-light);
    line-height: 1.7;
    transition: color 0.4s ease;
}

.entry-body .read-more {
    display: inline-block;
    margin-top: 0.6rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

.entry-body .read-more:hover {
    color: var(--accent-hover);
}

/* ─── Projects — wider grid ─── */
.project-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.project-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border: 1px solid var(--rule-light);
    text-decoration: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease, background-color 0.4s ease;
}

.project-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px var(--shadow);
    transform: translateY(-2px);
}

.project-card .project-name {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 1.25rem;
    color: var(--ink);
    margin-bottom: 0.4rem;
    transition: color 0.4s ease;
}

.project-card .project-desc {
    font-size: 0.82rem;
    color: var(--ink-light);
    line-height: 1.6;
    transition: color 0.4s ease;
}

.project-card .project-tag {
    display: inline-block;
    margin-top: 0.8rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.5rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-faint);
    border: 1px solid var(--rule);
    padding: 0.15rem 0.5rem;
    transition: color 0.4s ease, border-color 0.4s ease;
}

/* ─── Dividers ─── */
.divider {
    text-align: center;
    margin: 4rem 0;
    color: var(--rule);
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 1.2rem;
    letter-spacing: 0.4em;
    transition: color 0.4s ease;
}

/* ─── Footer ─── */
footer {
    max-width: 1100px;
    margin: 0 auto;
    padding: 3rem 3rem 4rem;
    border-top: 1px solid var(--rule);
    text-align: center;
    transition: border-color 0.4s ease;
}

footer p {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    font-weight: 300;
    color: var(--ink-faint);
    letter-spacing: 0.1em;
    transition: color 0.4s ease;
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
    .margin-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .margin-label {
        text-align: left;
        position: static;
        margin-bottom: 1.5rem;
        padding-top: 0;
        border-bottom: 1px solid var(--rule-light);
        padding-bottom: 0.5rem;
    }

    .entry-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .entry-meta {
        text-align: left;
        margin-bottom: 0.4rem;
        padding-top: 0;
    }

    .entry-meta .tag {
        display: inline-block;
        margin-left: 0.6rem;
    }

    .rec-grid {
        grid-template-columns: 1fr;
    }

    .project-grid {
        grid-template-columns: 1fr;
    }

    .page-wrap {
        padding: 0 1.5rem;
    }

    nav {
        padding: 0.8rem 1.5rem;
    }
}

@media (max-width: 600px) {
    html { font-size: 16px; }
    .hero h1 { font-size: 2.4rem; }
    .hero { padding-top: 6rem; }
    nav .links { gap: 1rem; }
    nav .links a { font-size: 0.55rem; }
}

@media (min-width: 901px) and (max-width: 1050px) {
    .project-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ─── View All Link ─── */
.view-all {
    display: inline-block;
    margin-top: 1.5rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

.view-all:hover {
    color: var(--accent-hover);
}

/* ─── Section Landing Page ─── */
.section-page-title {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 2.4rem;
    font-weight: 400;
    line-height: 1.2;
    color: var(--ink);
    margin-bottom: 2rem;
}

/* ─── Detail Page ─── */
.detail-back {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    text-decoration: none;
    text-align: right;
    display: block;
    position: sticky;
    top: 4rem;
    transition: color 0.2s ease;
}

.detail-back:hover {
    color: var(--accent-hover);
}

.detail-title {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 2.4rem;
    font-weight: 400;
    line-height: 1.2;
    color: var(--ink);
    margin-bottom: 0.5rem;
}

.detail-date {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    font-weight: 300;
    color: var(--ink-faint);
    letter-spacing: 0.05em;
    margin-bottom: 2rem;
}

.detail-body {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--ink-light);
    max-width: 680px;
}

.detail-body h2 {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--ink);
    margin: 2.5rem 0 1rem;
}

.detail-body h3 {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--ink);
    margin: 2rem 0 0.8rem;
}

.detail-body p {
    margin-bottom: 1.2rem;
}

.detail-body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.2rem;
    margin: 1.5rem 0;
    color: var(--ink-faint);
    font-style: italic;
}

.detail-body ul, .detail-body ol {
    margin: 1rem 0 1rem 1.5rem;
}

.detail-body li {
    margin-bottom: 0.4rem;
}

.detail-body code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85em;
    background: var(--bg-card);
    padding: 0.1rem 0.4rem;
    border-radius: 2px;
}
