:root {
    --vellum-dark: #1C1610;
    --parchment-shadow: #2A2118;
    --foxed-cream: #D4C5A9;
    --faded-script: #9E8E72;
    --manuscript-sienna: #8B5E3C;
    --vermillion-ink: #C1440E;
    --oxidized-gold: #B8963E;
    --burnt-umber: #5C4033;
    --lapis-lazuli: #1F4E79;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--vellum-dark);
    color: var(--foxed-cream);
    font-family: 'EB Garamond', serif;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    font-weight: 400;
    line-height: 1.75;
    font-feature-settings: 'liga' 1, 'onum' 1;
    overflow-x: hidden;
    position: relative;
}

/* Paper texture overlay */
#paper-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.06;
    background:
        repeating-conic-gradient(
            from 0deg at 50% 50%,
            rgba(210, 197, 169, 0.03) 0deg,
            transparent 1deg,
            transparent 89deg,
            rgba(210, 197, 169, 0.02) 90deg
        ),
        repeating-conic-gradient(
            from 45deg at 30% 70%,
            rgba(158, 142, 114, 0.02) 0deg,
            transparent 2deg,
            transparent 88deg,
            rgba(158, 142, 114, 0.015) 90deg
        );
}

/* Candle light effect */
#candle-light {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(circle at 50% 40%, rgba(184, 150, 62, 0.03) 0%, transparent 60%);
}

/* Folio indicator */
#folio-indicator {
    position: fixed;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Noto Serif', serif;
    font-size: 0.7rem;
    color: var(--faded-script);
    letter-spacing: 0.1em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    z-index: 10;
    mix-blend-mode: multiply;
    opacity: 0.6;
}

/* Sigil navigation mark */
#sigil-mark {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 20;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.5s ease;
}

#sigil-mark:hover {
    opacity: 1;
}

/* Navigation overlay */
#nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100vh;
    background-color: var(--parchment-shadow);
    z-index: 30;
    padding: 4rem 2rem 2rem;
    transform: translateX(0);
    transition: transform 0.6s cubic-bezier(0.25, 0.1, 0.25, 1);
    border-right: 1px solid var(--burnt-umber);
}

#nav-overlay.hidden {
    transform: translateX(-100%);
}

.nav-content {
    position: relative;
}

.nav-close {
    position: absolute;
    top: -2rem;
    right: 0;
    font-size: 1.5rem;
    color: var(--faded-script);
    cursor: pointer;
    transition: color 0.3s ease;
}

.nav-close:hover {
    color: var(--foxed-cream);
}

#nav-overlay ul {
    list-style: none;
    padding: 0;
}

#nav-overlay li {
    margin-bottom: 1.2rem;
}

.nav-link {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.9rem, 1.5vw, 1.3rem);
    color: var(--manuscript-sienna);
    text-decoration: none;
    transition: color 0.3s ease;
    letter-spacing: 0.02em;
}

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

/* Timeline spine */
#timeline-spine {
    position: absolute;
    top: 100vh;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: calc(100% - 100vh);
    background-color: var(--burnt-umber);
    z-index: 3;
}

/* Folio sections */
.folio {
    min-height: 100vh;
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

/* FOLIO I: Colophon */
.folio-colophon {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.colophon-content {
    max-width: 90vw;
}

.colophon-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(2.5rem, 7vw, 8rem);
    font-weight: 300;
    letter-spacing: 0.04em;
    line-height: 1.15;
    color: var(--foxed-cream);
    opacity: 0;
    transform: translateY(10px);
    animation: colophonFadeIn 3s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

.colophon-epigraph {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    color: var(--faded-script);
    margin-top: 2rem;
    opacity: 0;
    animation: colophonFadeIn 2s 1.5s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
    overflow: hidden;
    white-space: nowrap;
    border-right: 1px solid var(--faded-script);
    width: 0;
    margin-left: auto;
    margin-right: auto;
    animation: typewriter 3s 2s steps(50) forwards, blinkCaret 0.8s 2s step-end 5;
}

.colophon-rule {
    width: 1px;
    height: 0;
    background-color: var(--burnt-umber);
    margin: 3rem auto 0;
    animation: ruleGrow 2s 3.5s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

@keyframes colophonFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typewriter {
    to {
        width: 100%;
    }
}

@keyframes blinkCaret {
    50% {
        border-color: transparent;
    }
}

@keyframes ruleGrow {
    to {
        height: 15vh;
    }
}

/* Folio split layout */
.folio-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    max-width: 1100px;
    width: 100%;
    align-items: center;
}

.folio-left {
    padding-right: 3rem;
    text-align: right;
}

.folio-right {
    padding-left: 3rem;
    text-align: left;
}

/* Text blocks */
.text-block {
    max-width: 420px;
}

.folio-left .text-block {
    margin-left: auto;
}

.folio-right .text-block {
    margin-right: auto;
}

.text-block p {
    margin-bottom: 1.2rem;
    color: var(--foxed-cream);
}

.rotated-slight {
    transform: rotate(1.5deg);
}

.rotated-counter {
    transform: rotate(-1deg);
}

/* Drop capitals */
.drop-cap-text::first-letter {
    font-size: 4em;
    float: left;
    line-height: 0.8;
    margin-right: 0.1em;
    color: var(--vermillion-ink);
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    outline: 1px solid var(--oxidized-gold);
    outline-offset: 4px;
    padding: 0.05em 0.1em;
}

.drop-cap-text::first-letter:hover {
    box-shadow: 0 0 20px rgba(184, 150, 62, 0.3);
}

/* Section headings */
h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.5rem, 3vw, 3rem);
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.15;
    color: var(--foxed-cream);
    margin-bottom: 2rem;
}

/* Timeline nodes */
.timeline-node {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 2rem;
    z-index: 6;
}

.rosette {
    display: block;
}

.rosette-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.rosette.drawn .rosette-path {
    stroke-dashoffset: 0;
}

/* Woodcut SVGs */
.woodcut {
    display: block;
    margin: 0 auto;
    opacity: 0.8;
}

/* Ornamental dividers */
.ornament {
    margin-top: 4rem;
    text-align: center;
    opacity: 0.6;
}

/* Marginalia */
.marginalia {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.3;
    transition: opacity 0.5s ease;
    z-index: 6;
}

.marginalia:hover {
    opacity: 1;
}

.marginalia-left {
    left: 2rem;
}

.marginalia-right {
    right: 2rem;
}

.manicule {
    display: block;
    font-size: 1.5rem;
    color: var(--manuscript-sienna);
    margin-bottom: 0.5rem;
}

.margin-note {
    font-family: 'Caveat', cursive;
    font-size: 0.9rem;
    color: var(--manuscript-sienna);
    display: block;
    text-align: center;
}

/* Border animate box */
.border-animate-box {
    position: relative;
    padding: 2rem;
}

.border-animate-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px solid var(--burnt-umber);
    clip-path: inset(0 100% 100% 0);
    transition: clip-path 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.border-animate-box.revealed::before {
    clip-path: inset(0 0 0 0);
}

/* Reveal fade animation */
.reveal-fade {
    opacity: 0;
    transition: opacity 2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.reveal-fade.visible {
    opacity: 1;
}

/* FOLIO VII: The Void */
.folio-void {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.void-manicule {
    font-size: 2.5rem;
    color: var(--faded-script);
    opacity: 0;
    transition: opacity 2s ease;
}

.void-manicule.visible {
    opacity: 0.4;
}

/* FOLIO VIII: The Seal */
.folio-seal {
    min-height: 100vh;
    text-align: center;
}

.seal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.seal-sigil {
    padding: 2rem;
}

.seal-colophon {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.9rem, 1.5vw, 1.3rem);
    color: var(--manuscript-sienna);
    max-width: 300px;
}

.seal-statement {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1rem, 2vw, 1.5rem);
    font-weight: 300;
    letter-spacing: 0.08em;
    color: var(--faded-script);
}

/* Ma-spacing between sections */
.folio + .folio {
    margin-top: 10vh;
}

.folio-void {
    margin-top: 20vh;
    margin-bottom: 20vh;
}

/* Links */
a {
    color: var(--manuscript-sienna);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--vermillion-ink);
}

a:visited {
    color: var(--lapis-lazuli);
}

/* Responsive */
@media (max-width: 768px) {
    .folio-split {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .folio-left, .folio-right {
        padding: 0 1rem;
        text-align: left;
    }

    .folio-left .text-block {
        margin-left: 0;
    }

    .rotated-slight, .rotated-counter {
        transform: none;
    }

    #timeline-spine {
        display: none;
    }

    .timeline-node {
        display: none;
    }

    .marginalia {
        display: none;
    }

    #folio-indicator {
        right: 0.5rem;
        font-size: 0.6rem;
    }

    #nav-overlay {
        width: 100%;
    }
}
