/* ===== Custom Properties ===== */
:root {
    --bg-primary: #f4ede4;
    --fg-text: #1a1a2e;
    --accent-primary: #c85a24;
    --accent-secondary: #3d7a68;
    --surface-card: #e8e0d4;
    --annotation-text: #8a7e6b;
    --decorative-band: #3a3430;

    --font-display: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
    --font-body: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

    --spine-left: 33%;
    --content-left: 38%;
    --content-right: 8%;
    --margin-left: 4%;
    --margin-right: 30%;
    --entry-gap: 100px;

    --ease-pen: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--fg-text);
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    font-weight: 400;
    line-height: 1.72;
    letter-spacing: 0.005em;
    -webkit-font-smoothing: antialiased;
}

/* ===== Page Container ===== */
.page-container {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: 60px 0 120px;
    min-height: 100vh;
}

/* ===== Vertical Site Title ===== */
.site-title {
    position: fixed;
    top: 0;
    left: calc(50% - 600px + var(--spine-left) - 40px);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 700;
    color: var(--decorative-band);
    letter-spacing: 0.01em;
    height: 100vh;
    display: flex;
    align-items: flex-start;
    padding-top: 40px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 600ms var(--ease-pen), transform 600ms var(--ease-pen);
    z-index: 10;
    pointer-events: none;
}

.site-title.visible {
    opacity: 0.12;
    transform: translateY(0);
}

/* ===== The Spine ===== */
.spine {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--spine-left);
    width: 3px;
    background-color: var(--accent-primary);
    z-index: 1;
}

/* ===== Timeline ===== */
.timeline {
    position: relative;
    z-index: 2;
}

/* ===== Timeline Entry ===== */
.timeline-entry {
    position: relative;
    display: grid;
    grid-template-columns: var(--spine-left) 30px 1fr;
    min-height: 120px;
    margin-bottom: var(--entry-gap);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 400ms var(--ease-pen), transform 400ms var(--ease-pen);
}

.timeline-entry.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Entry Margin (left side) ===== */
.entry-margin {
    padding: 0 20px 0 var(--margin-left);
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: flex-start;
    padding-top: 8px;
}

.annotation {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 0.85vw, 0.85rem);
    line-height: 1.5;
    color: var(--annotation-text);
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 300ms var(--ease-pen) 400ms, transform 300ms var(--ease-pen) 400ms;
}

.timeline-entry.revealed .annotation {
    opacity: 1;
    transform: translateX(0);
}

.pull-quote {
    font-family: var(--font-display);
    font-style: italic;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    line-height: 1.5;
    color: var(--fg-text);
    transform: rotate(-2deg);
    opacity: 0;
    transition: opacity 400ms var(--ease-pen) 500ms;
}

.timeline-entry.revealed .pull-quote {
    opacity: 0.75;
}

/* ===== Node & Connector ===== */
.entry-node {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12px;
    z-index: 3;
}

.node-shape {
    display: block;
    position: relative;
    z-index: 4;
    transform: scale(0);
    transition: transform 200ms ease-out;
}

.timeline-entry.revealed .node-shape {
    transform: scale(1);
}

.node-circle {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--fg-text);
    border: 2px solid var(--accent-primary);
}

.node-diamond {
    width: 12px;
    height: 12px;
    background-color: var(--fg-text);
    border: 2px solid var(--accent-primary);
    transform: scale(0) rotate(45deg);
}

.timeline-entry.revealed .node-diamond {
    transform: scale(1) rotate(45deg);
}

.node-dash {
    width: 24px;
    height: 3px;
    background-color: var(--fg-text);
    border: none;
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.connector {
    position: absolute;
    top: 19px;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: var(--accent-primary);
    transition: width 150ms linear 200ms;
}

.timeline-entry.revealed .connector {
    width: 30px;
}

/* ===== Entry Content (right side) ===== */
.entry-content {
    padding: 0 var(--content-right) 0 16px;
    position: relative;
}

.entry-date {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 0.85vw, 0.85rem);
    color: var(--annotation-text);
    margin-bottom: 4px;
    letter-spacing: 0.04em;
}

.section-number {
    position: absolute;
    left: -24px;
    top: 24px;
    font-family: var(--font-display);
    font-size: 1.6em;
    font-weight: 700;
    color: var(--accent-primary);
    opacity: 0.35;
}

.entry-heading {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 3vw, 2.8rem);
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.25;
    margin-bottom: 16px;
    position: relative;
    display: inline-block;
}

.entry-heading::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -4px;
    height: 2px;
    width: 100%;
    background-color: var(--accent-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 400ms var(--ease-pen) 200ms;
}

.timeline-entry.revealed .entry-heading::after {
    transform: scaleX(1);
}

.entry-content p {
    margin-bottom: 14px;
    max-width: 600px;
}

.entry-content p:last-of-type {
    margin-bottom: 24px;
}

/* ===== Footnotes ===== */
.footnote {
    font-family: var(--font-mono);
    font-size: 0.75em;
    color: var(--accent-primary);
    cursor: pointer;
    position: relative;
    transition: color 200ms;
}

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

.footnote-highlight {
    animation: fnFlash 500ms ease-out;
}

@keyframes fnFlash {
    0% { background-color: rgba(200, 90, 36, 0.15); }
    100% { background-color: transparent; }
}

/* ===== Redaction ===== */
.redaction {
    position: relative;
    display: inline;
}

.redaction::after {
    content: '';
    position: absolute;
    left: 0;
    top: 40%;
    width: 100%;
    height: 3px;
    background-color: var(--accent-primary);
    opacity: 0.6;
}

/* ===== Links ===== */
a {
    color: var(--accent-secondary);
    text-decoration: none;
    position: relative;
}

a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    height: 2px;
    width: 100%;
    background-color: var(--accent-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 300ms var(--ease-pen);
}

a:hover::after {
    transform: scaleX(1);
}

/* ===== SVG Diagrams ===== */
.diagram {
    display: block;
    width: 100%;
    max-width: 400px;
    height: auto;
    margin: 20px 0 10px;
}

.diagram text {
    font-family: var(--font-mono);
    font-size: 10px;
}

.diagram .diagram-lines line,
.diagram .diagram-lines rect,
.diagram .diagram-lines circle,
.diagram .diagram-lines ellipse {
    opacity: 0;
    transition: opacity 200ms ease-out;
}

.diagram .diagram-labels text {
    opacity: 0;
    transition: opacity 150ms ease-out;
}

.timeline-entry.revealed .diagram .diagram-lines line,
.timeline-entry.revealed .diagram .diagram-lines rect,
.timeline-entry.revealed .diagram .diagram-lines circle,
.timeline-entry.revealed .diagram .diagram-lines ellipse {
    opacity: 1;
}

.timeline-entry.revealed .diagram .diagram-labels text {
    opacity: 1;
}

/* ===== Section Dividers ===== */
.section-divider {
    position: relative;
    margin: 40px 0;
    overflow: hidden;
}

.divider-band {
    width: 100%;
    height: 24px;
    background-image: repeating-linear-gradient(
        60deg,
        var(--accent-primary) 0px,
        var(--accent-primary) 12px,
        var(--bg-primary) 12px,
        var(--bg-primary) 24px,
        var(--decorative-band) 24px,
        var(--decorative-band) 36px,
        var(--bg-primary) 36px,
        var(--bg-primary) 48px
    );
    background-size: 48px 24px;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 600ms var(--ease-pen);
    animation: bandSlide 60s linear infinite paused;
}

.section-divider.revealed .divider-band {
    transform: scaleX(1);
    animation-play-state: running;
}

@keyframes bandSlide {
    0% { background-position: 0 0; }
    100% { background-position: 960px 0; }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .page-container {
        padding: 40px 16px 80px;
    }

    .site-title {
        left: 4px;
        font-size: 1.5rem;
        opacity: 0.08;
    }

    .site-title.visible {
        opacity: 0.08;
    }

    .spine {
        left: 12px;
    }

    .timeline-entry {
        display: block;
        padding-left: 36px;
        margin-bottom: 60px;
    }

    .entry-margin {
        padding: 0 0 12px 0;
    }

    .entry-node {
        position: absolute;
        left: -24px;
        top: 0;
    }

    .connector {
        display: none;
    }

    .entry-content {
        padding: 0;
    }

    .section-number {
        position: static;
        display: block;
        margin-bottom: 4px;
        opacity: 0.3;
    }

    .pull-quote {
        transform: rotate(0deg);
        font-size: 0.95rem;
        border-left: 3px solid var(--accent-primary);
        padding-left: 12px;
    }
}

@media (max-width: 600px) {
    .entry-heading {
        font-size: 1.3rem;
    }

    .diagram {
        max-width: 100%;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
