/* === DESIGN TOKENS === */
:root {
    --bg-void: #0a0a0f;
    --bg-surface: #141420;
    --neon-cyan: #00e5ff;
    --neon-magenta: #e040fb;
    --neon-gold: #ffd740;
    --neon-violet: #7c4dff;
    --text-primary: #e8e8f0;
    --text-secondary: #8888a0;

    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --space-1: 8vmin;
    --space-2: 16vmin;
    --space-3: 24vmin;
    --space-5: 40vmin;

    --active-chapter: 1;
}

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

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    background: var(--bg-void);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.75;
    overflow-x: hidden;
}

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

/* === PARTICLE CANVAS === */
#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* === CHAPTERS === */
.chapter {
    min-height: 100vh;
    position: relative;
    overflow: hidden;
    display: grid;
    place-items: center;
    z-index: 2;
}

/* === WATERMARKS === */
.watermark {
    position: absolute;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 20vw;
    color: var(--text-secondary);
    opacity: 0.04;
    pointer-events: none;
    user-select: none;
    z-index: 0;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

/* === CHAPTER CONTENT === */
.chapter-content {
    position: relative;
    z-index: 3;
    max-width: 640px;
    padding: 0 var(--space-1);
}

.chapter-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--neon-cyan);
    display: block;
    margin-bottom: 2rem;
}

.chapter-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 5rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
    text-shadow: 0 0 40px rgba(0, 229, 255, 0.03);
    margin-bottom: 2rem;
}

.chapter-body {
    color: var(--text-secondary);
    max-width: 480px;
    margin-bottom: 1.5rem;
}

/* Stagger reveal */
.chapter-label,
.chapter-title,
.chapter-body,
.proof-step,
.conclusion-title {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.chapter.is-visible .chapter-label { transition-delay: 0ms; opacity: 1; transform: translateY(0); }
.chapter.is-visible .chapter-title { transition-delay: 150ms; opacity: 1; transform: translateY(0); }
.chapter.is-visible .chapter-body:nth-of-type(1) { transition-delay: 300ms; opacity: 1; transform: translateY(0); }
.chapter.is-visible .chapter-body:nth-of-type(2) { transition-delay: 450ms; opacity: 1; transform: translateY(0); }

/* === CHAPTER 1 — PREMISE === */
#chapter-premise .chapter-content {
    justify-self: start;
    padding-left: 20%;
}

.ribbon-premise {
    position: absolute;
    bottom: 30%;
    left: 0;
    width: 100%;
    height: 20px;
    z-index: 2;
}

/* === AURORA RIBBONS === */
.aurora-ribbon {
    position: absolute;
    pointer-events: none;
}

.ribbon-core {
    animation: ribbon-shimmer 8s ease-in-out infinite;
}

.ribbon-glow {
    animation: ribbon-shimmer 8s ease-in-out infinite;
}

@keyframes ribbon-shimmer {
    0%, 100% { stroke-dashoffset: 0; opacity: 0.8; }
    50% { stroke-dashoffset: 200; opacity: 1; }
}

.ribbon-core, .ribbon-glow {
    stroke-dasharray: 600 200;
}

/* === CHAPTER 2 — INFERENCE === */
.ribbon-fork {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    z-index: 1;
}

.inference-content {
    margin-top: 5vh;
}

/* === CHAPTER 3 — PROOF === */
.lens-flare {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    height: 320px;
    z-index: 1;
    mix-blend-mode: screen;
    animation: flare-pulse 6s ease-in-out infinite;
}

@keyframes flare-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.05); }
}

.flare-core {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, var(--neon-gold) 0%, transparent 70%);
    box-shadow: 0 0 20px var(--neon-gold), 0 0 60px rgba(255, 215, 64, 0.4);
}

.flare-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    border: 1px solid;
}

.flare-ring-1 {
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
    border-color: rgba(255, 215, 64, 0.6);
    box-shadow: 0 0 15px rgba(255, 215, 64, 0.3);
}

.flare-ring-2 {
    width: 80px;
    height: 80px;
    transform: translate(-50%, -50%);
    border-color: rgba(255, 215, 64, 0.3);
    box-shadow: 0 0 25px rgba(255, 215, 64, 0.15);
}

.flare-ring-3 {
    width: 160px;
    height: 160px;
    transform: translate(-50%, -50%);
    border-color: rgba(255, 215, 64, 0.1);
    box-shadow: 0 0 40px rgba(255, 215, 64, 0.08);
}

/* Bokeh elements */
.bokeh {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    opacity: 0.2;
}

.bokeh-1 { top: 20%; left: 25%; background: var(--neon-cyan); }
.bokeh-2 { top: 70%; left: 15%; background: var(--neon-magenta); }
.bokeh-3 { top: 15%; left: 75%; background: var(--neon-magenta); }
.bokeh-4 { top: 65%; left: 80%; background: var(--neon-cyan); }
.bokeh-5 { top: 45%; left: 10%; background: var(--neon-violet); }

/* Converging ribbons */
.ribbon-converge {
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    z-index: 0;
}

/* Proof fragments */
.proof-fragments {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    z-index: 3;
}

.proof-step {
    position: absolute;
    top: 50%;
    left: 50%;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    width: 140px;
    line-height: 1.4;
}

.proof-step .chapter-label {
    margin-bottom: 0.25rem;
    font-size: 0.65rem;
}

#chapter-proof.is-visible .proof-step:nth-child(1) { transition-delay: 0ms; opacity: 1; transform: translateY(0); }
#chapter-proof.is-visible .proof-step:nth-child(2) { transition-delay: 150ms; opacity: 1; transform: translateY(0); }
#chapter-proof.is-visible .proof-step:nth-child(3) { transition-delay: 300ms; opacity: 1; transform: translateY(0); }
#chapter-proof.is-visible .proof-step:nth-child(4) { transition-delay: 450ms; opacity: 1; transform: translateY(0); }
#chapter-proof.is-visible .proof-step:nth-child(5) { transition-delay: 600ms; opacity: 1; transform: translateY(0); }
#chapter-proof.is-visible .proof-step:nth-child(6) { transition-delay: 750ms; opacity: 1; transform: translateY(0); }

.proof-center-label {
    position: absolute;
    bottom: 10%;
    z-index: 4;
}

/* === CHAPTER 4 — CONCLUSION === */
.conclusion-content {
    text-align: center;
}

.conclusion-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--text-primary);
    text-shadow: 0 0 40px rgba(0, 229, 255, 0.03);
}

#chapter-conclusion.is-visible .chapter-label { transition-delay: 0ms; opacity: 1; transform: translateY(0); }
#chapter-conclusion.is-visible .conclusion-title { transition-delay: 200ms; opacity: 1; transform: translateY(0); }

.aurora-band {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-violet), var(--neon-magenta), var(--neon-gold), var(--neon-cyan));
    background-size: 300% 100%;
    animation: aurora-cycle 12s linear infinite;
    box-shadow:
        0 0 10px rgba(0, 229, 255, 0.4),
        0 0 30px rgba(0, 229, 255, 0.2),
        0 0 60px rgba(0, 229, 255, 0.1);
}

@keyframes aurora-cycle {
    0% { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

/* === NEON GLOW UTILITY === */
.glow-cyan {
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.25), 0 0 30px rgba(0, 229, 255, 0.12), 0 0 60px rgba(0, 229, 255, 0.06);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    #chapter-premise .chapter-content {
        padding-left: 8%;
        padding-right: 8%;
    }

    .proof-fragments {
        width: 320px;
        height: 320px;
    }

    .proof-step {
        width: 110px;
        font-size: 0.75rem;
    }
}
