:root {
    --bg-primary: #F5EDDF;
    --bg-deep: #2B2117;
    --bg-footnote: #EDE5D5;
    --bg-deckle: #E8DFD0;
    --text-primary: #3A2E23;
    --text-secondary: #7A6B5A;
    --accent-gilt: #C4956A;
    --accent-leather: #8B6F47;
    --accent-foxing: #B8A48C;
    --accent-rubric: #9B4F3A;
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Crimson Pro', Georgia, serif;
    --font-margin: 'Libre Baskerville', Georgia, serif;
    --spine-left: 120px;
    --content-offset: calc(var(--spine-left) + 3rem);
    --content-measure: 680px;
    --baseline: 1.5rem;
}

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

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

body {
    background-color: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
}

/* =============================================
   ENTRANCE SEQUENCE
   ============================================= */

#entrance-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--bg-deep);
    z-index: 1000;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.4s ease-out;
}

#entrance-overlay.fade-out {
    opacity: 0;
}

#radial-reveal {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, var(--bg-primary) 0%, var(--bg-primary) 0%, var(--bg-deep) 0%);
    z-index: 999;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.6s ease-out;
}

#radial-reveal.complete {
    opacity: 0;
}

body.revealed {
    background-color: var(--bg-primary);
}

/* =============================================
   DECKLED EDGE TEXTURE
   ============================================= */

.deckled-edge {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, transparent 0%, var(--bg-deckle) 100%);
    z-index: 50;
    pointer-events: none;
}

.deckled-edge::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 3px,
            rgba(200, 185, 160, 0.15) 3px,
            rgba(200, 185, 160, 0.15) 4px
        );
    mix-blend-mode: multiply;
    opacity: 0.6;
}

.deckled-edge::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            180deg,
            transparent,
            transparent 7px,
            rgba(180, 164, 140, 0.1) 7px,
            rgba(180, 164, 140, 0.1) 9px
        );
    mix-blend-mode: multiply;
    opacity: 0.5;
}

/* =============================================
   TIMELINE SPINE
   ============================================= */

.timeline-spine {
    position: fixed;
    left: var(--spine-left);
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: rgba(92, 74, 58, 0.4);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.8s ease-out 2.5s;
}

body.revealed .timeline-spine {
    opacity: 1;
}

/* =============================================
   HERO / TITLE SEQUENCE
   ============================================= */

.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 100;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5rem);
    color: var(--text-primary);
    letter-spacing: 0.12em;
    margin-bottom: 1rem;
    opacity: 0;
}

.hero-title.animate-in .title-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    animation: letterReveal 0.5s ease-out forwards;
}

.hero-subtitle {
    font-family: var(--font-body);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.hero-subtitle.visible {
    opacity: 1;
}

@keyframes letterReveal {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =============================================
   CONTENT AREA
   ============================================= */

.content-area {
    max-width: var(--content-measure);
    padding: 0 2rem 4rem;
    margin-left: var(--content-offset);
    position: relative;
    z-index: 20;
}

/* =============================================
   EPOCH SECTIONS
   ============================================= */

.epoch {
    padding: 96px 0;
    position: relative;
}

/* =============================================
   TIMELINE NODES
   ============================================= */

.timeline-node {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--accent-leather);
    background-color: transparent;
    position: absolute;
    left: calc(-3rem - 6px);
    top: 96px;
    transition: background-color 0.4s ease-out, box-shadow 0.4s ease-out;
    z-index: 11;
}

.timeline-node.filled {
    background-color: var(--accent-leather);
}

.timeline-node.active {
    background-color: var(--accent-leather);
    animation: nodePulse 2s ease-in-out infinite;
}

@keyframes nodePulse {
    0% {
        box-shadow: 0 0 0 4px rgba(139, 111, 71, 0.3);
    }
    100% {
        box-shadow: 0 0 0 8px rgba(139, 111, 71, 0);
    }
}

/* =============================================
   MARGIN ANNOTATIONS
   ============================================= */

.margin-annotation {
    position: absolute;
    left: calc(-3rem - var(--spine-left) + 12px);
    top: 100px;
    width: calc(var(--spine-left) - 24px);
    text-align: right;
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

.margin-annotation.visible {
    opacity: 1;
}

.margin-date {
    display: block;
    font-family: var(--font-margin);
    font-weight: 400;
    font-size: clamp(0.7rem, 0.85vw, 0.8rem);
    color: var(--accent-leather);
    letter-spacing: 0.03em;
}

.margin-note {
    display: block;
    font-family: var(--font-margin);
    font-weight: 400;
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    letter-spacing: 0.02em;
}

.margin-line {
    display: block;
    width: 100%;
    height: 1px;
    background-color: var(--accent-foxing);
    opacity: 0.5;
    margin: 0.3rem 0;
}

/* =============================================
   DATE LABELS & HEADINGS
   ============================================= */

.date-label {
    font-family: var(--font-margin);
    font-weight: 400;
    font-size: clamp(0.75rem, 0.9vw, 0.85rem);
    color: var(--accent-leather);
    display: block;
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}

.era-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.8rem, 3vw, 2.8rem);
    color: var(--text-primary);
    line-height: 1.15;
    margin-bottom: var(--baseline);
}

/* =============================================
   DROP CAPS
   ============================================= */

.drop-cap-paragraph::first-letter {
    float: left;
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 4.2em;
    line-height: 0.78;
    padding-right: 0.08em;
    padding-top: 0.05em;
    color: var(--accent-gilt);
}

/* =============================================
   BODY TEXT
   ============================================= */

.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1.05rem, 1.2vw, 1.15rem);
    line-height: 1.65;
    color: var(--text-primary);
    margin-bottom: 1.5em;
    letter-spacing: 0.01em;
}

.body-text + .body-text {
    text-indent: 1.5em;
}

/* =============================================
   PULL QUOTES
   ============================================= */

.pull-quote {
    margin: 2rem 1.5rem;
    padding-left: 1.5rem;
    border-left: 2px solid var(--accent-foxing);
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    line-height: 1.5;
    color: var(--text-primary);
}

.pull-quote p {
    margin-bottom: 0;
}

.pull-quote cite {
    display: block;
    font-family: var(--font-margin);
    font-size: 0.75rem;
    font-style: normal;
    font-variant: small-caps;
    text-align: right;
    margin-top: 0.75rem;
    color: var(--text-secondary);
}

/* =============================================
   FOOTNOTES
   ============================================= */

.footnote-indicator {
    font-family: var(--font-margin);
    font-size: 0.7em;
    color: var(--accent-rubric);
    cursor: pointer;
    vertical-align: super;
    line-height: 0;
    padding: 0 0.15em;
    transition: color 0.2s ease;
}

.footnote-indicator:hover {
    color: var(--accent-gilt);
}

.footnote-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
    margin-bottom: 1em;
}

.footnote-panel.open {
    max-height: 200px;
}

.footnote-content {
    background-color: var(--bg-footnote);
    padding: 1rem 1.25rem;
    position: relative;
    border-left: 2px solid var(--accent-foxing);
    opacity: 0;
    transition: opacity 0.3s ease-out 0.15s;
}

.footnote-panel.open .footnote-content {
    opacity: 1;
}

.footnote-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    font-family: var(--font-margin);
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.footnote-close:hover {
    color: var(--text-primary);
}

.footnote-text {
    font-family: var(--font-margin);
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text-secondary);
    padding-right: 1.5rem;
}

/* =============================================
   ORNAMENT DIVIDERS
   ============================================= */

.ornament-divider {
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--accent-foxing);
    padding: 1rem 0;
    letter-spacing: 0.5em;
}

/* =============================================
   COLOPHON / FOOTER
   ============================================= */

.colophon {
    text-align: center;
    padding: 6rem 2rem 8rem;
    max-width: 520px;
    margin: 0 auto;
    position: relative;
    z-index: 20;
}

.colophon-ornament {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--accent-foxing);
    margin-bottom: 1.5rem;
}

.colophon-block {
    border-top: 1px solid var(--accent-foxing);
    border-bottom: 1px solid var(--accent-foxing);
    padding: 2rem 1.5rem;
}

.colophon-title {
    font-family: var(--font-margin);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--accent-leather);
    margin-bottom: 1rem;
}

.colophon-text {
    font-family: var(--font-margin);
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.75;
    margin-bottom: 1rem;
}

.colophon-device {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--accent-foxing);
    letter-spacing: 0.5em;
    margin-bottom: 1rem;
}

.colophon-imprint {
    font-family: var(--font-margin);
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
    font-style: italic;
}

/* =============================================
   FADE-REVEAL ANIMATIONS
   ============================================= */

.fade-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Drop cap entrance: scale from 0.85 to 1 */
.drop-cap-paragraph.fade-reveal {
    transform: translateY(20px) scale(1);
}

.drop-cap-paragraph.fade-reveal.visible {
    transform: translateY(0) scale(1);
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 1200px) {
    .content-area {
        margin-left: auto;
        margin-right: auto;
    }
    .timeline-spine {
        display: none;
    }
    .timeline-node {
        display: none;
    }
    .margin-annotation {
        position: relative;
        left: auto;
        top: auto;
        width: auto;
        text-align: left;
        opacity: 1;
        margin-bottom: 0.5rem;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    .margin-line {
        width: 2rem;
        display: inline-block;
        margin: 0;
    }
    .margin-note {
        display: inline;
        margin-top: 0;
    }
    .margin-date {
        display: inline;
    }
    .deckled-edge {
        display: none;
    }
}

@media (max-width: 768px) {
    .content-area {
        padding: 0 1.5rem 4rem;
    }
    .drop-cap-paragraph::first-letter {
        font-size: 3.2em;
    }
    .epoch {
        padding: 64px 0;
    }
    .colophon {
        padding: 4rem 1.5rem 6rem;
    }
    .colophon-block {
        padding: 1.5rem 1rem;
    }
}

@media (max-width: 480px) {
    .body-text {
        font-size: 1rem;
    }
    .pull-quote {
        font-size: 1.1rem;
        margin: 1.5rem 0.5rem;
    }
    .era-heading {
        font-size: clamp(1.5rem, 5vw, 2rem);
    }
    .hero-title {
        letter-spacing: 0.06em;
    }
    .epoch {
        padding: 48px 0;
    }
}
