:root {
    --cloud-vellum: #E8ECF1;
    --linen-frost: #F2F5F8;
    --ink-pool: #1E2A3A;
    --signal-violet: #6C5CE7;
    --stochastic-teal: #00B8A9;
    --prior-amber: #F5A623;
    --slate-mist: #7B8BA3;
    --penumbra: #A6B4C8;
    --evidence-white: #FFFFFF;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-snap-type: y proximity; }

body {
    background-color: var(--cloud-vellum);
    color: var(--ink-pool);
    font-family: 'Source Serif 4', serif;
    font-size: clamp(1rem, 1.15vw, 1.2rem);
    font-weight: 400;
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
}

/* Dot-grid substrate */
#dot-grid {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image: radial-gradient(circle, #C8D0DC 1.5px, transparent 1.5px);
    background-size: 32px 32px;
    opacity: 0.12;
}

/* Isoline contour fields */
#isoline-field {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}

.isoline {
    position: absolute;
    border-radius: 50%;
    animation: isoDrift 180s ease-in-out infinite;
}

.iso-1 {
    width: 80vw; height: 80vw;
    top: -10vh; left: -15vw;
    background: radial-gradient(ellipse at 45% 40%, #DDE3EB 0%, #E8ECF1 40%, transparent 70%);
    opacity: 0.6;
}

.iso-2 {
    width: 60vw; height: 60vw;
    top: 40vh; right: -20vw;
    background: radial-gradient(ellipse at 55% 50%, #D0D8E4 0%, #E8ECF1 45%, transparent 70%);
    opacity: 0.5;
    animation-delay: -60s;
    animation-direction: reverse;
}

.iso-3 {
    width: 70vw; height: 70vw;
    bottom: -20vh; left: 10vw;
    background: radial-gradient(ellipse at 50% 55%, #DDE3EB 0%, #E8ECF1 35%, transparent 65%);
    opacity: 0.4;
    animation-delay: -120s;
}

@keyframes isoDrift {
    0% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(3vw, -2vh) scale(1.05); }
    50% { transform: translate(-2vw, 3vh) scale(0.97); }
    75% { transform: translate(4vw, 1vh) scale(1.03); }
    100% { transform: translate(0, 0) scale(1); }
}

/* Nav pill */
#nav-pill {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background-color: var(--linen-frost);
    border-radius: 24px;
    padding: 0.5rem 1.25rem;
    z-index: 100;
    box-shadow:
        6px 6px 16px rgba(166, 180, 200, 0.35),
        -4px -4px 12px rgba(255, 255, 255, 0.72);
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--slate-mist);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: all 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

#nav-pill:hover {
    box-shadow:
        8px 8px 20px rgba(166, 180, 200, 0.4),
        -5px -5px 14px rgba(255, 255, 255, 0.8),
        0 0 20px rgba(108, 92, 231, 0.15);
}

/* Sections */
.bab-section {
    min-height: 100vh;
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: start;
}

.section-inner {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 4vw;
    position: relative;
}

.section-inner-wide {
    max-width: 100%;
    padding: 3rem 0;
}

/* Lateral drift */
.drift-left .section-inner {
    transform: translateX(-5vw);
}

.drift-right .section-inner {
    transform: translateX(5vw);
}

/* Hero section */
.section-prior {
    min-height: 110vh;
}

.hero-curve {
    position: absolute;
    bottom: 15%;
    left: 0;
    width: 100%;
    height: 300px;
    z-index: 0;
}

.hero-content {
    text-align: center;
    position: relative;
    z-index: 1;
}

.hero-title {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(4rem, 10vw, 8rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.08;
    color: var(--ink-pool);
}

.hero-subscript {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1rem;
    font-weight: 400;
    color: var(--slate-mist);
    opacity: 0.3;
    letter-spacing: 0.04em;
    margin-top: 0.5rem;
}

/* Neomorphic panels */
.neo-panel {
    background-color: var(--linen-frost);
    border-radius: 24px;
    padding: clamp(2rem, 4vw, 3.5rem);
    position: relative;
    max-width: 600px;
    box-shadow:
        0 20px 60px rgba(166, 180, 200, 0.35),
        inset 0 -2px 6px rgba(255, 255, 255, 0.72);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 600ms cubic-bezier(0.05, 0.7, 0.1, 1.0),
                transform 600ms cubic-bezier(0.05, 0.7, 0.1, 1.0);
}

.bab-section.visible .neo-panel {
    opacity: 1;
    transform: translateY(0);
}

.neo-panel-resolved {
    max-width: 700px;
    margin: 0 auto;
    box-shadow:
        0 30px 80px rgba(166, 180, 200, 0.5),
        inset 0 -2px 6px rgba(255, 255, 255, 0.72);
}

/* Marginalia */
.marginalia {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--slate-mist);
    position: absolute;
}

.marginalia-tl { top: 1.5rem; left: 1.5rem; }
.marginalia-tr { top: 1.5rem; right: 1.5rem; }

/* Section sigils */
.section-sigil {
    margin-bottom: 1.5rem;
}

/* Section headings */
.section-heading {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.2rem, 2vw, 2rem);
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.08;
    color: var(--ink-pool);
    margin-bottom: 1.25rem;
}

.body-text {
    margin-bottom: 1rem;
    color: var(--ink-pool);
}

.amber-highlight {
    color: var(--prior-amber);
    font-weight: 600;
}

/* Void separators */
.void-separator {
    height: 40vh;
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.void-curve {
    width: 60%;
    height: 60px;
}

/* Likelihood section */
.section-likelihood {
    min-height: 120vh;
    flex-direction: column;
}

.likelihood-viz {
    width: 100%;
    height: 200px;
    margin-bottom: 3rem;
}

.likelihood-line {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s cubic-bezier(0.05, 0.7, 0.1, 1.0);
}

.bab-section.visible .likelihood-line {
    stroke-dashoffset: 0;
}

.likelihood-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 4vw;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms 300ms cubic-bezier(0.05, 0.7, 0.1, 1.0),
                transform 600ms 300ms cubic-bezier(0.05, 0.7, 0.1, 1.0);
}

.bab-section.visible .likelihood-content {
    opacity: 1;
    transform: translateY(0);
}

/* Posterior section - isoline tightening handled via JS class */
.section-posterior {
    min-height: 100vh;
}

/* Prediction (footer) section */
.section-prediction {
    min-height: 60vh;
    background-color: #F5F7FA;
}

.prediction-content {
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms cubic-bezier(0.05, 0.7, 0.1, 1.0),
                transform 600ms cubic-bezier(0.05, 0.7, 0.1, 1.0);
}

.bab-section.visible .prediction-content {
    opacity: 1;
    transform: translateY(0);
}

.prediction-domain {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--ink-pool);
    margin-bottom: 0.5rem;
}

.prediction-line {
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    font-size: 1.1rem;
    color: var(--slate-mist);
    margin-bottom: 2rem;
}

/* Confidence interval */
.confidence-interval {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.ci-tick {
    width: 1px;
    height: 12px;
    background-color: var(--slate-mist);
}

.ci-line {
    width: 40vw;
    max-width: 300px;
    height: 1px;
    background-color: var(--slate-mist);
}

/* Drift animation for evidence panels */
.drift-left .neo-panel {
    transform: translateX(-30px) translateY(30px);
}

.drift-left.visible .neo-panel {
    transform: translateX(0) translateY(0);
}

.drift-right .neo-panel {
    transform: translateX(30px) translateY(30px);
}

.drift-right.visible .neo-panel {
    transform: translateX(0) translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
    .drift-left .section-inner,
    .drift-right .section-inner {
        transform: translateX(0);
    }

    .neo-panel {
        max-width: 100%;
        border-radius: 16px;
    }

    #nav-pill {
        top: 1rem;
        right: 1rem;
        padding: 0.4rem 1rem;
        font-size: 0.7rem;
    }

    .void-separator {
        height: 20vh;
    }

    .section-likelihood {
        min-height: 100vh;
    }

    .ci-line {
        width: 60vw;
    }
}
