/* ─── Paper noise textures (SVG feTurbulence grain) ─────────────────────────
   Light: dark grain at 7 % opacity over a warm cream field.
   Dark:  light grain at 4 % opacity over a warm near-black field.           */
:root {
    --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.07'/%3E%3C/svg%3E");

    /* ── Palette ── */
    --color-text: #2b2116; /* warm dark-brown ink          */
    --color-bg: #f5f0e6; /* aged cream paper             */
    --color-link: #7a4419; /* sienna — readable on cream   */
    --color-muted: #8a7a65; /* warm taupe                   */
    --color-border: #ddd3ba; /* tan rule                     */
    --color-sidebar-bg: #ede8db; /* slightly deeper cream        */

    /* ── Type ── */
    --font-body: "Lora", Georgia, "Times New Roman", serif;
    --font-heading:
        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica,
        Arial, sans-serif;

    /* ── Layout ── */
    --max-width: 960px;
    --content-width: 640px;
    --space: 1.5rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");

        --color-text: #e5ddd0; /* warm off-white — candlelit   */
        --color-bg: #1c1912; /* aged dark parchment          */
        --color-link: #d4a06a; /* amber — warm & accessible    */
        --color-muted: #9e9080; /* warm mid-taupe               */
        --color-border: #3d3529; /* deep warm rule               */
        --color-sidebar-bg: #231f18; /* slightly lighter dark cream  */
    }
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ─── Base ───────────────────────────────────────────────────────────────── */
body {
    margin: 0;
    padding: var(--space);
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.75;
    color: var(--color-text);

    /* Cream/dark base with paper-grain overlay */
    background-color: var(--color-bg);
    background-image: var(--paper-grain);
    background-repeat: repeat;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.layout {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    gap: 3rem;
}

main {
    flex: 1;
    min-width: 0;
    margin: 4rem 0;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    margin-top: 4rem;
    padding-left: 2rem;
    border-left: 1px solid var(--color-border);
}

.sidebar h3 {
    font-family: var(--font-heading);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-muted);
    margin: 0 0 1rem;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar li {
    margin-bottom: 1rem;
}

.sidebar a {
    display: block;
    font-size: 0.9rem;
    line-height: 1.4;
}

.sidebar time {
    display: block;
    font-size: 0.75rem;
    color: var(--color-muted);
}

/* ─── Typography ─────────────────────────────────────────────────────────── */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-body);
    line-height: 1.2;
    margin-top: 0;
    margin-bottom: 0.75em;
    color: var(--color-text);
}

/* Mid-content headings need breathing room above the preceding paragraph */
main h2,
main h3,
main h4,
main h5,
main h6 {
    margin-top: 2em;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--space);
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

h4 {
    font-size: 1rem;
    font-weight: 600;
}

h5 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

h6 {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
}

p {
    margin-top: 0;
    margin-bottom: 1.25em;
}

a {
    color: var(--color-link);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover {
    text-decoration-thickness: 2px;
}

/* ─── Nav ────────────────────────────────────────────────────────────────── */
nav {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space) 0;
    border-bottom: 1px solid var(--color-border);
}

nav .site-name {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--color-text);
    text-decoration: none;
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: var(--space);
}

nav ul a {
    font-family: var(--font-heading);
    font-size: 0.9375rem;
    text-decoration: none;
    color: var(--color-muted);
    transition: color 0.15s ease;
}

nav ul a:hover {
    color: var(--color-text);
    text-decoration: none;
}

/* ─── Post list ──────────────────────────────────────────────────────────── */
.post-list {
    list-style: none;
    padding: 0;
}

.post-list li {
    margin-bottom: var(--space);
}

.post-list a {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    text-decoration: none;
}

.post-list a:hover {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

.post-list time {
    font-size: 0.875rem;
    color: var(--color-muted);
}

/* ─── Post ───────────────────────────────────────────────────────────────── */
.post-header {
    margin-bottom: 2rem;
}

.post-header time {
    font-size: 0.875rem;
    color: var(--color-muted);
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
footer {
    max-width: var(--max-width);
    margin: 4rem auto 2rem;
    font-family: var(--font-heading);
    font-size: 0.875rem;
    color: var(--color-muted);
    border-top: 1px solid var(--color-border);
    padding-top: var(--space);
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
        gap: 2rem;
    }

    .sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--color-border);
        padding-left: 0;
        padding-top: 1.5rem;
        margin-top: 0;
    }
}
