/* ===== CSS Custom Properties ===== */
:root {
    --primary-surface: #c8793e;
    --deep-ground: #2b3a67;
    --text-primary: #2d2a26;
    --text-inverse: #f5ece0;
    --accent: #b84a2f;
    --data-positive: #5e8c61;
    --data-negative: #a63d40;
    --data-neutral: #8a897c;
    --bg-tint: #f0e4d4;
    --scroll-progress: 0;
    --scroll-weight: 0;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Libre Baskerville', Georgia, serif;
    color: var(--text-primary);
    background-color: var(--bg-tint);
    line-height: 1.72;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    overflow-x: hidden;
}

/* ===== Progress Bar ===== */
#progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent);
    transform-origin: left;
    transform: scaleX(var(--scroll-progress));
    z-index: 1000;
}

#progress-labels {
    position: fixed;
    top: 3px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 4px 2%;
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.6rem, 0.75vw, 0.75rem);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1000;
    pointer-events: none;
}

#progress-bar:hover ~ #progress-labels,
#progress-labels:hover {
    opacity: 1;
}

/* ===== Chapter Watermarks ===== */
.chapter-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 20vw;
    color: var(--text-primary);
    opacity: 0.06;
    pointer-events: none;
    z-index: 0;
    line-height: 1;
}

.chapter-watermark.light {
    color: var(--text-inverse);
    opacity: 0.08;
}

/* ===== Viewport Sections ===== */
.viewport-section {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ===== Opening Gavel ===== */
#opening-gavel {
    background-color: var(--primary-surface);
}

.gavel-content {
    position: relative;
    z-index: 1;
    text-align: left;
    padding: 0 8%;
    width: 100%;
}

#hero-title .word {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(3rem, 10vw, 8rem);
    letter-spacing: -0.03em;
    display: inline-block;
    color: var(--text-primary);
    margin-right: 0.15em;
    clip-path: inset(0);
    background-color: var(--text-primary);
    color: transparent;
    transition: clip-path 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                background-color 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                color 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#hero-title .word.revealed {
    clip-path: inset(0);
    background-color: transparent;
    color: var(--text-primary);
}

.subtitle {
    margin-top: 1.5rem;
}

.subtitle .word {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: clamp(1.1rem, 2vw, 1.6rem);
    display: inline-block;
    margin-right: 0.25em;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.subtitle .word.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Chevron */
.chevron-down {
    position: absolute;
    bottom: 3rem;
    left: 50%;
    transform: translateX(-50%);
    animation: pulse-chevron 2s ease-in-out infinite;
    z-index: 1;
}

@keyframes pulse-chevron {
    0%, 100% { opacity: 0.4; transform: translateX(-50%) translateY(0); }
    50% { opacity: 1; transform: translateX(-50%) translateY(6px); }
}

/* ===== Argument Corridor ===== */
#argument-corridor {
    position: relative;
    padding: 6rem 0;
    background: var(--bg-tint);
}

.argument-row {
    display: grid;
    grid-template-columns: 62% 34%;
    gap: 4%;
    padding: 4rem 8%;
    align-items: start;
}

.argument-row.reverse {
    grid-template-columns: 34% 62%;
}

.proposition {
    position: relative;
    padding: 2.5rem;
    background: var(--bg-tint);
    border-left: 3px solid var(--accent);
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.proposition.visible {
    opacity: 1;
    transform: translateX(0);
}

.argument-row.reverse .proposition {
    border-left: none;
    border-right: 3px solid var(--accent);
}

.proposition h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: -0.02em;
    margin-bottom: 1.2rem;
    line-height: 1.2;
}

.proposition h2 .word {
    display: inline-block;
    margin-right: 0.12em;
}

.proposition p {
    margin-bottom: 1rem;
}

.proposition p:last-child {
    margin-bottom: 0;
}

/* Marginalia */
.marginalia {
    position: absolute;
    left: -2.5rem;
    top: 2.5rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.2rem;
    color: var(--accent);
    cursor: default;
    transition: transform 0.3s;
}

.marginalia:hover {
    transform: scale(1.3);
}

.argument-row.reverse .marginalia {
    left: auto;
    right: -2.5rem;
}

/* Evidence blocks */
.evidence {
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.7s ease 0.2s, transform 0.7s ease 0.2s;
}

.argument-row.reverse .evidence {
    transform: translateX(-40px);
}

.evidence.visible {
    opacity: 1;
    transform: translateX(0);
}

.data-viz {
    padding: 1.5rem;
    background: #fff;
    border: 2px solid var(--text-primary);
}

.viz-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: clamp(0.7rem, 0.85vw, 0.875rem);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.parliament-svg, .tree-svg {
    width: 100%;
    height: auto;
    display: block;
    margin-bottom: 1rem;
}

.viz-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.65rem, 0.8vw, 0.8rem);
}

.legend-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 4px;
    vertical-align: middle;
}

.legend-swatch.sage { background: var(--data-positive); }
.legend-swatch.carmine { background: var(--data-negative); }
.legend-swatch.stone { background: var(--data-neutral); }

/* Timeline Ribbon */
.timeline-track {
    display: flex;
    height: 48px;
    border: 2px solid var(--text-primary);
    overflow: hidden;
}

.timeline-segment {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-inverse);
    border-right: 2px solid var(--text-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.timeline-segment.visible {
    transform: scaleX(1);
}

.timeline-segment:last-child {
    border-right: none;
}

.timeline-segment.sage { background: var(--data-positive); }
.timeline-segment.carmine { background: var(--data-negative); }
.timeline-segment.stone { background: var(--data-neutral); }

.timeline-segment::after {
    content: attr(data-label);
    font-weight: 500;
}

/* ===== Pull Quote ===== */
.pull-quote-block {
    padding: 5rem 8%;
    background: var(--bg-tint);
    text-align: center;
}

.pull-quote {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-style: italic;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    line-height: 1.6;
    max-width: 700px;
    margin: 0 auto;
    padding: 2rem 2.5rem;
    border: 3px solid var(--accent);
    background: var(--primary-surface);
    color: var(--text-primary);
}

/* ===== Crossroads ===== */
#crossroads {
    background: var(--deep-ground);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    transition: clip-path 1.2s cubic-bezier(0.77, 0, 0.175, 1);
}

#crossroads.morphed {
    clip-path: polygon(5% 3%, 95% 3%, 98% 97%, 2% 97%);
}

.crossroads-content {
    position: relative;
    z-index: 1;
    padding: 0 8%;
    text-align: left;
}

.crossroads-heading .word {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 8vw, 7rem);
    letter-spacing: -0.03em;
    color: var(--text-inverse);
    display: inline-block;
    margin-right: 0.12em;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.crossroads-heading .word.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Geometric Divider */
.geometric-divider {
    width: 100%;
    height: 16px;
    background-image:
        repeating-linear-gradient(
            90deg,
            var(--accent) 0px,
            var(--accent) 8px,
            transparent 8px,
            transparent 16px
        );
    background-size: 16px 8px;
    background-repeat: repeat-x;
    background-position: center;
    position: absolute;
    bottom: 0;
    left: 0;
    opacity: 0.5;
}

.geometric-divider.bottom {
    bottom: 2rem;
}

/* ===== Evidence Library ===== */
#evidence-library {
    position: relative;
    background: var(--deep-ground);
    padding: 8rem 8%;
}

.evidence-card {
    background: var(--bg-tint);
    border: 2px solid var(--text-primary);
    padding: 3rem;
    margin-bottom: 4rem;
    max-width: 680px;
    position: relative;
    opacity: 0;
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.evidence-card[data-reveal="left"] {
    margin-right: auto;
    transform: translateX(-60px);
}

.evidence-card[data-reveal="right"] {
    margin-left: auto;
    transform: translateX(60px);
}

.evidence-card.visible {
    opacity: 1;
    transform: translateX(0);
}

.card-number {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 3rem;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.evidence-card h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.3rem, 2vw, 1.8rem);
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}

.evidence-card p {
    margin-bottom: 1.5rem;
}

/* Bar Charts */
.card-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.bar-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.65rem, 0.8vw, 0.8rem);
    width: 130px;
    flex-shrink: 0;
    text-align: right;
}

.bar {
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 6px;
    border: 2px solid var(--text-primary);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-inverse);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.bar.visible {
    transform: scaleX(1);
}

.bar.sage { background: var(--data-positive); }
.bar.carmine { background: var(--data-negative); }
.bar.stone { background: var(--data-neutral); }

.bar-value {
    opacity: 0;
    transition: opacity 0.3s 0.6s;
}

.bar.visible .bar-value {
    opacity: 1;
}

/* ===== Resolution ===== */
#resolution {
    background: var(--primary-surface);
}

.resolution-content {
    position: relative;
    z-index: 1;
    padding: 0 8%;
    text-align: left;
    width: 100%;
}

.resolution-heading .word {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 6vw, 5rem);
    letter-spacing: -0.03em;
    color: var(--text-primary);
    display: inline-block;
    margin-right: 0.12em;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.resolution-heading .word.revealed {
    opacity: 1;
    transform: translateY(0);
}

.resolution-sub {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-style: italic;
    font-size: clamp(1rem, 1.8vw, 1.4rem);
    margin-top: 2rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease 0.5s, transform 0.8s ease 0.5s;
    color: var(--text-primary);
}

.resolution-sub.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Baseline Drift Animation ===== */
@keyframes drift {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.drift-active .word {
    animation: drift 3s ease-in-out infinite;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .argument-row,
    .argument-row.reverse {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 2rem 5%;
    }

    .marginalia {
        position: static;
        display: block;
        margin-bottom: 0.5rem;
    }

    .argument-row.reverse .marginalia {
        left: auto;
        right: auto;
    }

    .gavel-content,
    .crossroads-content,
    .resolution-content {
        padding: 0 5%;
    }

    #evidence-library {
        padding: 4rem 5%;
    }

    .evidence-card {
        max-width: 100%;
    }

    .evidence-card[data-reveal="right"] {
        margin-left: 0;
    }

    .bar-label {
        width: 90px;
        font-size: 0.6rem;
    }
}
