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

:root {
    --parchment: #f4ede4;
    --parchment-dark: #e8ddd0;
    --muted: #c4b8a8;
    --walnut: #3b2f2a;
    --walnut-deep: #2c2420;
    --ink: #3b2f2a;
    --ink-light: #7a6e63;
    --brass: #b8944f;
    --brass-bright: #e8c84a;
}

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

body {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    color: var(--ink);
    background: var(--parchment);
    line-height: 1.85;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== Grain Overlay ===== */
#grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px 200px;
}

/* ===== Navigation ===== */
#nav-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    transition: transform 0.3s ease;
}

#nav-toggle:hover {
    transform: rotate(10deg);
}

#nav-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100vh;
    z-index: 999;
    background: var(--parchment);
    border-left: 1px solid var(--muted);
    box-shadow: -4px 0 24px rgba(44, 36, 32, 0.1);
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 4rem 2rem 2rem;
}

#nav-panel.open {
    right: 0;
}

.nav-inner {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.nav-title {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--ink-light);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--muted);
}

.nav-link {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
    color: var(--ink);
    text-decoration: none;
    padding: 0.3rem 0;
    transition: color 0.2s ease, padding-left 0.2s ease;
}

.nav-link:hover {
    color: var(--brass);
    padding-left: 0.5rem;
}

/* ===== Sections ===== */
.section {
    min-height: 90vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

.section-inner {
    max-width: 720px;
    width: 100%;
    position: relative;
}

/* Section Variants */
.section--parchment {
    background: var(--parchment);
}

.section--linen {
    background: var(--parchment-dark);
    border-top: 1px solid var(--muted);
    border-bottom: 1px solid var(--muted);
}

.section--walnut {
    background: var(--walnut);
    color: var(--parchment);
}

.section--walnut .marginalia-heading,
.section--walnut .margin-note p,
.section--walnut .margin-label {
    color: var(--parchment);
}

.section--cork {
    background: var(--parchment-dark);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(184, 148, 79, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 30%, rgba(184, 148, 79, 0.04) 0%, transparent 50%);
}

/* ===== Section Dividers (shadow lines) ===== */
.section + .section {
    box-shadow: inset 0 2px 8px rgba(44, 36, 32, 0.06);
}

/* ===== The Desk (Hero) ===== */
#desk {
    min-height: 100vh;
    text-align: center;
}

.desk-lamp {
    width: 6px;
    height: 60px;
    background: linear-gradient(to bottom, var(--brass), var(--brass-bright));
    border-radius: 3px;
    margin: 0 auto 2rem;
    opacity: 0.6;
    box-shadow: 0 0 20px rgba(232, 200, 74, 0.15);
}

.desk-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin-bottom: 0.5rem;
    line-height: 1.1;
}

.desk-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    font-weight: 400;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--ink-light);
    margin-bottom: 2rem;
}

.desk-tagline {
    font-family: 'Inter', sans-serif;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    font-weight: 300;
    color: var(--ink-light);
    max-width: 480px;
    margin: 0 auto 3rem;
    line-height: 1.85;
}

.scroll-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--ink-light);
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    opacity: 0.5;
    animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { opacity: 0.3; transform: translateY(0); }
    50% { opacity: 0.6; transform: translateY(4px); }
}

/* ===== A Thought ===== */
.thought-card {
    background: var(--parchment);
    border: 1px solid var(--muted);
    border-radius: 2px;
    padding: 3rem;
    position: relative;
    box-shadow: 0 2px 16px rgba(44, 36, 32, 0.06);
}

.thought-number {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 4rem;
    font-weight: 700;
    color: var(--brass);
    opacity: 0.15;
    position: absolute;
    top: 1rem;
    right: 2rem;
    line-height: 1;
}

.thought-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--ink);
}

.thought-body {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.85rem, 1.5vw, 0.95rem);
    color: var(--ink-light);
    margin-bottom: 1.2rem;
    line-height: 1.85;
}

.thought-body:last-child {
    margin-bottom: 0;
}

/* ===== Marginalia ===== */
#marginalia .section-inner {
    max-width: 900px;
    display: grid;
    grid-template-columns: 180px 1fr 180px;
    gap: 2rem;
    align-items: start;
}

.margin-note {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.7;
    padding-top: 2rem;
}

.margin-label {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--brass);
    margin-bottom: 0.5rem;
}

.marginalia-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--parchment);
}

.marginalia-body {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.85rem, 1.5vw, 0.95rem);
    color: var(--muted);
    margin-bottom: 1.2rem;
    line-height: 1.85;
}

/* ===== The Collection ===== */
.collection-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 600;
    text-align: center;
    margin-bottom: 3rem;
    color: var(--ink);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.card {
    background: var(--parchment);
    border: 1px solid var(--muted);
    padding: 2rem 1.5rem 1.5rem;
    position: relative;
    border-radius: 1px;
    box-shadow: 0 2px 8px rgba(44, 36, 32, 0.05);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.4s ease;
}

.card:hover {
    transform: translateY(-3px) rotate(-0.5deg);
    box-shadow: 0 8px 24px rgba(44, 36, 32, 0.1);
}

.card--pinned .card-pin {
    width: 12px;
    height: 12px;
    background: var(--brass);
    border-radius: 50%;
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.card--taped .card-tape {
    width: 60px;
    height: 18px;
    background: rgba(232, 200, 74, 0.3);
    position: absolute;
    top: -9px;
    left: 50%;
    transform: translateX(-50%) rotate(-2deg);
    border-radius: 1px;
}

.card-tag {
    display: inline-block;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--brass);
    border: 1px solid var(--brass);
    padding: 0.15rem 0.6rem;
    border-radius: 1px;
    margin-bottom: 1rem;
}

.card-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--ink-light);
    line-height: 1.8;
}

/* ===== Closing ===== */
#closing {
    min-height: 60vh;
    text-align: center;
}

.closing-stamp {
    margin: 0 auto 2rem;
    opacity: 0.6;
}

.closing-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 1rem;
}

.closing-sub {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--ink-light);
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.8;
}

/* ===== Reveal Animation ===== */
.section-inner {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-inner.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    #marginalia .section-inner {
        grid-template-columns: 1fr;
    }

    .margin-note {
        padding-top: 0;
        padding-left: 1rem;
        border-left: 2px solid var(--brass);
        opacity: 0.7;
    }

    .margin-note--left { order: 2; }
    .marginalia-content { order: 1; }
    .margin-note--right { order: 3; }

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

    .section {
        padding: 3rem 1.5rem;
    }

    .thought-card {
        padding: 2rem 1.5rem;
    }
}
