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

:root {
    --night: #0d1117;
    --parchment-dark: #1a1714;
    --treaty-gold: #c9a84c;
    --vellum: #f5e6c8;
    --archive-green: #1c2418;
    --deep-blue: #0f1b2d;
    --steel: #6b7a8d;
    --antique-gold: #8b7340;
    --margin-width: 38%;
    --body-width: 62%;
}

html {
    scroll-behavior: smooth;
    scroll-snap-type: y mandatory;
    overflow-x: hidden;
}

body {
    background-color: var(--night);
    color: var(--vellum);
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    font-weight: 300;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* === Chapter Sections === */
.chapter {
    min-height: 100vh;
    scroll-snap-align: start;
    position: relative;
}

#chapter-0 { background-color: var(--night); }
#chapter-1 { background-color: var(--parchment-dark); }
#chapter-2 { background-color: var(--deep-blue); }
#chapter-3 { background-color: var(--archive-green); }
#chapter-4 { background-color: var(--night); }
#chapter-5 { background-color: var(--parchment-dark); }

.chapter-inner {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* === Margin Column (Left) === */
.margin-col {
    width: var(--margin-width);
    position: relative;
    border-right: 1px solid rgba(201, 168, 76, 0.15);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 4rem 3rem 4rem 2rem;
}

.margin-content {
    position: sticky;
    top: 50%;
    transform: translateY(-50%);
    max-width: 280px;
    opacity: 0;
    transition: opacity 0.8s ease 0.3s;
}

.chapter.is-visible .margin-content {
    opacity: 1;
}

.article-num {
    display: block;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--treaty-gold);
    margin-bottom: 1.5rem;
}

.date-marker {
    display: block;
    font-family: 'Alegreya Sans', sans-serif;
    font-weight: 300;
    font-size: 0.8rem;
    color: var(--steel);
    letter-spacing: 0.08em;
    margin-bottom: 2rem;
}

.footnote {
    font-family: 'Alegreya Sans', sans-serif;
    font-weight: 300;
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--steel);
    margin-bottom: 1rem;
    font-style: italic;
}

/* === Body Column (Right) === */
.body-col {
    width: var(--body-width);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6rem 6rem 6rem 5rem;
}

.body-content {
    max-width: 600px;
    position: relative;
    padding: 3rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.9s ease, transform 0.9s ease;
}

.chapter.is-visible .body-content {
    opacity: 1;
    transform: translateY(0);
}

/* === Animated SVG Borders === */
.border-animate {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.border-animate rect {
    fill: none;
    stroke: var(--treaty-gold);
    stroke-width: 0.5;
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 2s ease;
}

.chapter.is-visible .border-animate rect {
    stroke-dashoffset: 0;
}

/* === Typography === */
.chapter-label {
    display: block;
    font-family: 'Cinzel', serif;
    font-weight: 400;
    font-size: 0.65rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--antique-gold);
    margin-bottom: 1.5rem;
}

.chapter-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(2.5rem, 6vw, 5rem);
    line-height: 1.1;
    letter-spacing: 0.04em;
    color: var(--vellum);
    margin-bottom: 2rem;
    font-feature-settings: 'liga' 1, 'onum' 1;
}

.opening-title {
    font-size: clamp(3rem, 7vw, 6rem);
}

.opening-title .title-line {
    display: block;
}

.closing-title {
    text-align: center;
    margin-bottom: 2.5rem;
}

.provocation {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    color: var(--treaty-gold);
    line-height: 1.5;
    margin-bottom: 2rem;
}

.body-text {
    font-family: 'Source Serif 4', serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    color: var(--vellum);
    margin-bottom: 1.5rem;
    opacity: 0.9;
}

.pull-quote {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1.3rem, 2.2vw, 1.8rem);
    line-height: 1.4;
    color: var(--treaty-gold);
    border-left: 2px solid var(--antique-gold);
    padding-left: 1.5rem;
    margin: 2.5rem 0;
}

/* === Seal Mark === */
.seal-mark {
    font-size: 2rem;
    color: var(--treaty-gold);
    opacity: 0.5;
    margin-top: 2rem;
    text-align: center;
}

/* === Closing Seal === */
.closing-seal {
    display: flex;
    justify-content: center;
    margin-top: 3rem;
}

.seal-svg {
    width: 120px;
    height: 120px;
    opacity: 0;
    transition: opacity 1.5s ease 0.5s;
}

.chapter.is-visible .seal-svg {
    opacity: 0.8;
}

/* === Progress Track === */
.progress-track {
    position: fixed;
    right: 0;
    top: 0;
    width: 2px;
    height: 100vh;
    background-color: rgba(201, 168, 76, 0.1);
    z-index: 100;
}

.progress-fill {
    width: 100%;
    height: 0%;
    background-color: var(--treaty-gold);
    transition: height 0.3s ease;
}

/* === Responsive === */
@media (max-width: 900px) {
    .chapter-inner {
        flex-direction: column;
    }

    .margin-col {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(201, 168, 76, 0.15);
        padding: 2rem 2rem 1.5rem;
        justify-content: flex-start;
    }

    .margin-content {
        position: static;
        transform: none;
        max-width: none;
    }

    .body-col {
        width: 100%;
        padding: 2rem;
    }

    .body-content {
        max-width: none;
        padding: 2rem;
    }

    html {
        scroll-snap-type: none;
    }
}

@media (max-width: 600px) {
    .chapter-title {
        font-size: clamp(2rem, 8vw, 3rem);
    }

    .opening-title {
        font-size: clamp(2.5rem, 10vw, 3.5rem);
    }

    .body-col {
        padding: 1.5rem;
    }

    .body-content {
        padding: 1.5rem;
    }
}
