:root {
    --paper-ground: #ede6d8;
    --deep-loam: #3b3228;
    --dried-wheat: #c7a96e;
    --hedgerow-green: #7a8c6e;
    --aged-ink: #4a3f35;
    --foxing-stain: #b89f78;
    --faded-graphite: #7a6b5d;
    --parchment-light: #f5f0e4;
    --cooler-paper: #e8e3d6;
    --autumnal: #8a7a5e;

    --font-display: 'Jost', Arial, Helvetica, sans-serif;
    --font-body: 'EB Garamond', Georgia, 'Times New Roman', serif;
    --font-accent: 'Special Elite', 'Courier New', monospace;
}

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

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

body {
    background-color: var(--paper-ground);
    color: var(--aged-ink);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.75;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    position: relative;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Paper texture overlay */
.paper-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.5;
    background-image:
        repeating-linear-gradient(
            0deg,
            rgba(184, 159, 120, 0.01) 0px,
            rgba(184, 159, 120, 0.02) 1px,
            rgba(184, 159, 120, 0.01) 2px
        );
    filter: url(#paperTexture);
}

/* Foxing stains */
.foxing-stains {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    background:
        radial-gradient(ellipse 120px 100px at 15% 20%, rgba(184, 159, 120, 0.06), transparent),
        radial-gradient(ellipse 80px 90px at 75% 10%, rgba(184, 159, 120, 0.05), transparent),
        radial-gradient(ellipse 150px 120px at 85% 45%, rgba(184, 159, 120, 0.04), transparent),
        radial-gradient(ellipse 100px 80px at 25% 60%, rgba(184, 159, 120, 0.06), transparent),
        radial-gradient(ellipse 200px 150px at 50% 80%, rgba(184, 159, 120, 0.05), transparent),
        radial-gradient(ellipse 90px 110px at 10% 85%, rgba(184, 159, 120, 0.04), transparent),
        radial-gradient(ellipse 130px 100px at 65% 70%, rgba(184, 159, 120, 0.05), transparent),
        radial-gradient(ellipse 110px 90px at 40% 35%, rgba(184, 159, 120, 0.04), transparent),
        radial-gradient(ellipse 160px 130px at 90% 90%, rgba(184, 159, 120, 0.06), transparent),
        radial-gradient(ellipse 100px 80px at 55% 15%, rgba(184, 159, 120, 0.04), transparent);
}

/* Side navigation */
.side-nav {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem 0.5rem;
    opacity: 0;
    transition: opacity 0.8s ease;
    pointer-events: none;
}

.side-nav.visible {
    opacity: 1;
    pointer-events: all;
}

.nav-item {
    font-family: var(--font-accent);
    font-size: clamp(0.6rem, 0.8vw, 0.75rem);
    color: var(--faded-graphite);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    transition: color 0.3s ease;
    white-space: nowrap;
}

.nav-item:hover {
    color: var(--dried-wheat);
}

/* Section: Broadsheet */
.section-broadsheet {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 2rem;
    overflow: hidden;
}

.broadsheet-content {
    position: relative;
    width: 60%;
    z-index: 10;
    padding-left: 5%;
}

.title-double {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(3rem, 15vw, 12rem);
    color: var(--deep-loam);
    letter-spacing: -0.04em;
    line-height: 0.92;
    transform: rotate(-1.8deg);
    transform-origin: left center;
    opacity: 0;
}

.title-double.typed {
    opacity: 1;
}

.title-standard {
    font-family: var(--font-body);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(3rem, 15vw, 12rem);
    color: var(--deep-loam);
    letter-spacing: -0.04em;
    line-height: 0.92;
    transform: rotate(0.7deg);
    transform-origin: left center;
    margin-top: -0.1em;
    opacity: 0;
}

.title-standard.typed {
    opacity: 1;
}

.subtitle {
    font-family: var(--font-accent);
    font-size: clamp(0.75rem, 1.2vw, 1rem);
    color: var(--faded-graphite);
    letter-spacing: 0.08em;
    transform: rotate(-0.4deg);
    margin-top: 2rem;
    margin-left: 10%;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.subtitle.visible {
    opacity: 1;
}

.botanical-broadsheet {
    position: absolute;
    bottom: 0;
    left: 2%;
    width: 15%;
    max-width: 200px;
    height: auto;
    z-index: 5;
    opacity: 0.7;
}

/* Botanical paths */
.botanical-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2s ease-out;
}

.botanical-path.animate {
    stroke-dashoffset: 0;
}

/* Section: Meadow */
.section-meadow {
    position: relative;
    min-height: 150vh;
    padding: 5vh 2rem;
    overflow: hidden;
}

.meadow-container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 10;
}

/* Text blocks */
.text-block {
    padding: 2.5rem;
    margin-bottom: 3rem;
    position: relative;
    transform: rotate(var(--rotation, 0deg));
    box-shadow: 4px 6px 20px rgba(59, 50, 40, 0.08);
    background: var(--paper-ground);
    max-width: 55%;
}

.block-left {
    margin-right: auto;
    margin-left: var(--offset-x, 0);
    font-family: var(--font-body);
}

.block-right {
    margin-left: auto;
    margin-right: var(--offset-x, 0);
}

.jost-voice {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.4vw, 1.05rem);
    line-height: 1.6;
    letter-spacing: 0em;
    color: var(--deep-loam);
}

/* Torn edges */
.block-torn {
    clip-path: polygon(
        2px 5px,
        calc(100% - 4px) 0px,
        calc(100% - 1px) 3px,
        100% calc(100% - 6px),
        calc(100% - 3px) calc(100% - 2px),
        5px 100%,
        0px calc(100% - 3px),
        3px 2px
    );
}

/* Fade-in animation */
.fade-in {
    opacity: 0;
    transform: rotate(var(--rotation, 0deg)) translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: rotate(var(--rotation, 0deg)) translateY(0);
}

/* Double rule ornament */
.double-rule {
    position: relative;
    width: 60%;
    margin: 3rem auto;
    height: 8px;
}

.rule-thick {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--dried-wheat);
    transform: scaleX(0) rotate(0deg);
    transform-origin: left;
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.rule-thin {
    position: absolute;
    top: 7px;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--foxing-stain);
    transform: scaleX(0) rotate(0.3deg);
    transform-origin: left;
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s;
}

.double-rule.visible .rule-thick,
.double-rule.visible .rule-thin {
    transform: scaleX(1) rotate(0deg);
}

.double-rule.visible .rule-thin {
    transform: scaleX(1) rotate(0.3deg);
}

.botanical-meadow-center {
    display: block;
    width: 8%;
    max-width: 80px;
    margin: 2rem auto;
    opacity: 0.6;
}

.botanical-meadow-left {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 20%;
    max-width: 200px;
    height: auto;
    z-index: 5;
    opacity: 0.5;
}

/* Section: Ledger */
.section-ledger {
    position: relative;
    min-height: 120vh;
    padding: 8vh 2rem;
    overflow: hidden;
}

.section-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    color: var(--deep-loam);
    letter-spacing: -0.04em;
    line-height: 1.1;
    text-align: center;
    margin-bottom: 5vh;
    transform: rotate(-0.5deg);
}

.ledger-container {
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
    z-index: 10;
}

.ledger-entry {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    margin-bottom: 2rem;
    align-items: start;
}

.ledger-left {
    font-family: var(--font-body);
    font-style: normal;
    font-size: clamp(0.95rem, 1.6vw, 1.15rem);
    line-height: 1.75;
    color: var(--aged-ink);
    padding: 1.5rem;
    transform: rotate(-0.3deg);
}

.ledger-right {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.4vw, 1.05rem);
    line-height: 1.6;
    color: var(--deep-loam);
    padding: 1.5rem;
    transform: rotate(0.2deg);
}

/* Strike-through with annotation */
.struck-through {
    position: relative;
    text-decoration: none;
}

.struck-through::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1.5px;
    background: var(--faded-graphite);
    opacity: 0.6;
    transform: rotate(-0.5deg);
}

.annotation {
    position: relative;
    display: none;
}

.annotation.typed::after {
    content: attr(data-text);
    position: absolute;
    bottom: 100%;
    left: 0;
    font-family: var(--font-accent);
    font-style: normal;
    font-size: 0.8em;
    color: var(--faded-graphite);
    letter-spacing: 0.08em;
    white-space: nowrap;
    line-height: 1.2;
}

.annotation.typed {
    display: inline;
}

.ledger-rule {
    width: 80%;
}

.botanical-ledger-right {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12%;
    max-width: 150px;
    height: auto;
    z-index: 5;
    opacity: 0.5;
}

/* Section: Erosion */
.section-erosion {
    position: relative;
    min-height: 100vh;
    padding: 8vh 2rem;
    overflow: hidden;
    background-color: var(--cooler-paper);
}

.ghost-layer {
    position: absolute;
    pointer-events: none;
    z-index: 2;
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--foxing-stain);
    opacity: 0;
    transition: opacity 1s ease;
    white-space: nowrap;
}

.ghost-layer.visible {
    opacity: 0.1;
}

.ghost-1 {
    top: 15%;
    left: 5%;
    transform: rotate(-2deg);
}

.ghost-2 {
    top: 45%;
    right: 10%;
    transform: rotate(1.5deg);
}

.ghost-3 {
    top: 70%;
    left: 15%;
    transform: rotate(-1deg);
}

.erosion-container {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    z-index: 10;
}

.block-erosion {
    max-width: 70%;
    margin-top: var(--margin-neg, 0);
}

.block-erosion:nth-child(odd) {
    margin-left: 5%;
}

.block-erosion:nth-child(even) {
    margin-left: auto;
    margin-right: 5%;
}

.botanical-erosion-dense {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    z-index: 5;
    opacity: 0.4;
    pointer-events: none;
}

/* Section: Closing */
.section-closing {
    position: relative;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow: hidden;
    background: linear-gradient(to bottom, var(--paper-ground) 0%, var(--parchment-light) 100%);
}

.closing-content {
    position: relative;
    z-index: 10;
    text-align: center;
    width: 100%;
}

.closing-line {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    color: var(--deep-loam);
    letter-spacing: -0.02em;
    line-height: 1.4;
}

.botanical-closing {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    max-width: 400px;
    height: auto;
    z-index: 5;
    opacity: 0.3;
    transition: opacity 2s ease;
}

/* Ink splatter for typewriter effect */
.ink-splatter {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--deep-loam);
    border-radius: 50%;
    pointer-events: none;
    animation: splatFade 0.4s ease-out forwards;
}

@keyframes splatFade {
    0% { opacity: 0.8; transform: scale(1); }
    100% { opacity: 0; transform: scale(2.5); }
}

/* Character animation for typewriter */
.char {
    display: inline-block;
    opacity: 0;
}

.char.visible {
    opacity: 1;
}

em {
    font-style: italic;
    color: var(--dried-wheat);
}

/* Responsive */
@media (max-width: 768px) {
    .broadsheet-content {
        width: 90%;
        padding-left: 2%;
    }

    .text-block {
        max-width: 90%;
    }

    .ledger-entry {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .block-erosion {
        max-width: 90%;
    }

    .side-nav {
        display: none;
    }

    .title-double,
    .title-standard {
        font-size: clamp(2.5rem, 12vw, 6rem);
    }
}
