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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'EB Garamond', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw, 1.2rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: #3d2b1a;
    overflow-x: hidden;
    background: #1a1409;
}

/* === GRAIN OVERLAY (body-level) === */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: var(--grain-texture);
    background-repeat: repeat;
    background-size: 200px 200px;
    mix-blend-mode: multiply;
    opacity: 0.15;
    animation: grainPulse 4s ease-in-out infinite, grainShift 0.1s steps(1) infinite;
    z-index: 1000;
}

@keyframes grainPulse {
    0%, 100% { opacity: 0.12; }
    50% { opacity: 0.18; }
}

@keyframes grainShift {
    0% { background-position: 0 0; }
    100% { background-position: 37px 53px; }
}

/* === SPLIT CONTAINER === */
.split-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* === LEFT PANEL === */
.left-panel {
    width: 55%;
    background-color: #f2e8d5;
    position: relative;
    overflow-y: auto;
    z-index: 1;
    background-image:
        linear-gradient(to right, #d4c4a820 1px, transparent 1px),
        linear-gradient(to bottom, #d4c4a820 1px, transparent 1px);
    background-size: 24px 24px;
}

.left-content {
    padding: 4rem 3rem 4rem 4rem;
    max-width: 680px;
    margin: 0 auto;
}

/* === RIGHT PANEL === */
.right-panel {
    width: 45%;
    background-color: #1a1409;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    z-index: 1;
}

.right-panel::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: var(--grain-texture-dark);
    background-repeat: repeat;
    background-size: 200px 200px;
    mix-blend-mode: screen;
    opacity: 0.15;
    animation: grainPulse 4s ease-in-out infinite, grainShift 0.1s steps(1) infinite;
}

.viz-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

.viz-container svg,
.viz-container canvas {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
}

.grain-burst {
    position: absolute;
    inset: 0;
    background-image: var(--grain-texture-dark);
    background-repeat: repeat;
    background-size: 200px 200px;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.2s ease;
}

.grain-burst.active {
    opacity: 0.85;
}

.viz-labels {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    right: 2rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.7rem, 0.85vw, 0.9rem);
    letter-spacing: 0.08em;
    color: #b8783d;
    z-index: 5;
}

/* === TORN EDGE === */
.torn-edge {
    position: fixed;
    top: 0;
    left: 55%;
    width: 3px;
    height: 100vh;
    z-index: 100;
    pointer-events: none;
}

.torn-edge svg {
    width: 100%;
    height: 100%;
}

/* === CHAPTERS === */
.chapter {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem 0;
    position: relative;
}

.chapter-sentinel {
    position: absolute;
    top: 30%;
    width: 1px;
    height: 1px;
}

.chapter-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(2.6rem, 5.5vw, 5.8rem);
    letter-spacing: 0.03em;
    line-height: 1.08;
    color: #2e1f0f;
    margin-bottom: 2rem;
}

.chapter-body {
    margin-bottom: 1.5rem;
    max-width: 580px;
}

/* === TICK FRAME === */
.tick-frame {
    position: relative;
    padding: 2rem 0 2rem 1.5rem;
}

.tick-frame::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 12px;
    height: 12px;
    border-left: 2px solid #6b4e2f;
    border-top: 2px solid #6b4e2f;
}

.tick-frame::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 12px;
    height: 12px;
    border-left: 2px solid #6b4e2f;
    border-bottom: 2px solid #6b4e2f;
}

/* === TIMELINE === */
.timeline-entry {
    margin-bottom: 2.5rem;
    padding-left: 1rem;
    border-left: 1px solid #6b4e2f;
}

.timeline-date {
    font-family: 'EB Garamond', serif;
    font-feature-settings: "smcp";
    font-weight: 500;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    color: #6b4e2f;
    display: block;
    margin-bottom: 0.5rem;
}

/* === DATA CARDS === */
.data-card {
    background: #2e1f0f0d;
    border: 1px solid #6b4e2f44;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.data-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.7rem, 0.85vw, 0.9rem);
    letter-spacing: 0.08em;
    color: #6b4e2f;
    text-transform: uppercase;
}

.data-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1rem;
    color: #b8783d;
    letter-spacing: 0.02em;
}

/* Teal accent for secondary highlights */
.teal-accent {
    color: #4a7a72;
}

/* === FADE TEXT (Chapter 5) === */
.fade-text {
    opacity: 0.7;
}
.fade-text.deeper {
    opacity: 0.45;
}
.fade-text.deepest {
    opacity: 0.25;
    font-style: italic;
}

/* === CHAPTER NAV DOTS === */
.chapter-nav {
    position: fixed;
    bottom: 2rem;
    left: 55%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 200;
}

.nav-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid #b8783d;
    background: transparent;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s ease;
    padding: 0;
}

.nav-dot.active {
    background: #b8783d;
    transform: scale(1.3);
}

.nav-dot:hover {
    background: #e8a83e;
    border-color: #e8a83e;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .split-container {
        flex-direction: column;
    }

    .left-panel {
        width: 100%;
        overflow: visible;
    }

    .right-panel {
        width: 100%;
        position: relative;
        height: 60vh;
        sticky: unset;
    }

    .torn-edge {
        display: none;
    }

    .chapter-nav {
        left: 50%;
    }

    .left-content {
        padding: 2rem 1.5rem;
    }

    body::after {
        opacity: 0.08;
    }
}
