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

:root {
    --bg-light: #F0EBE0;
    --bg-dark: #1C1917;
    --text-primary: #3D3530;
    --text-secondary: #8A7E71;
    --accent-warm: #5B4A3F;
    --accent-red: #8B5E4B;
    --highlight: #A39B8B;
    --accent-cold: #4A6670;
    --text-on-dark: #C4B9A8;
    --text-on-dark-heading: #F0EBE0;
}

html {
    font-size: 16px;
    scroll-behavior: auto;
}

body {
    background: var(--bg-light);
    color: var(--text-primary);
    font-family: 'Source Serif 4', Georgia, serif;
    overflow: hidden;
}

/* === Scroll Container === */
.scroll-container {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
}

/* === Panels === */
.panel {
    min-height: 100vh;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
    padding: 64px;
}

@media (min-width: 769px) {
    .panel {
        padding: 128px;
    }
}

/* === Navigation Rail === */
.nav-rail {
    position: fixed;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.nav-number {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    transition: color 0.3s ease, transform 0.3s ease;
}

.nav-item.active .nav-number {
    color: var(--accent-warm);
    transform: scale(1.2);
}

.nav-icon {
    opacity: 0;
    transition: opacity 0.4s ease;
    width: 24px;
    height: 24px;
}

.nav-item.active .nav-icon {
    opacity: 1;
}

@media (max-width: 768px) {
    .nav-rail {
        display: none;
    }
}

/* === Progress Bar (Mobile) === */
.progress-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: var(--accent-warm);
    z-index: 100;
    transition: width 0.2s ease;
}

@media (max-width: 768px) {
    .progress-bar {
        display: block;
    }
}

/* === Typography === */
.section-heading {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--bg-dark);
    margin-bottom: 48px;
}

.body-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.8;
    letter-spacing: 0.01em;
    color: var(--text-primary);
    margin-bottom: 24px;
}

.body-text em {
    font-weight: 600;
    font-style: italic;
}

.equation-text {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-feature-settings: 'tnum';
}

.equation-display {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    letter-spacing: 0.05em;
    color: var(--accent-red);
    text-align: center;
    padding: 32px 0;
}

.caption-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

/* === Panel 0 — The Hypothesis === */
.panel-0 {
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-0-content {
    text-align: center;
    position: relative;
    z-index: 2;
}

.title-main {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 300;
    font-size: clamp(2.5rem, 8vw, 6rem);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--bg-dark);
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .title-main {
        letter-spacing: 0.08em;
    }
}

.subtitle-italic {
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: var(--text-secondary);
}

/* Ripple Container */
.ripple-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1;
}

.ripple-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    border-radius: 50%;
    border: 1px solid var(--accent-warm);
    width: 100px;
    height: 100px;
    opacity: 0.3;
    animation: rippleExpand 8s ease-out infinite;
}

.ripple-ring:nth-child(2) { animation-delay: 4s; }
.ripple-ring:nth-child(3) { animation-delay: 8s; }

@keyframes rippleExpand {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0.3;
    }
    100% {
        transform: translate(-50%, -50%) scale(50);
        opacity: 0;
    }
}

/* === Panel 1 — The Mathematics === */
.panel-1 {
    background: var(--bg-light);
    display: flex;
    align-items: center;
}

.panel-1-inner {
    display: flex;
    gap: 64px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.panel-1-illustration {
    flex: 0 0 35%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.radial-field {
    width: 100%;
    max-width: 400px;
    height: auto;
}

.panel-1-text {
    flex: 0 0 65%;
}

@media (max-width: 768px) {
    .panel-1 {
        align-items: flex-start;
        padding-top: 80px;
    }
    .panel-1-inner {
        flex-direction: column;
        gap: 32px;
    }
    .panel-1-illustration {
        flex: none;
    }
    .panel-1-text {
        flex: none;
    }
    .radial-field {
        max-width: 200px;
    }
}

/* === Panel 2 — The Search === */
.panel-2 {
    background: var(--bg-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 80px;
    padding-bottom: 80px;
    min-height: 100vh;
    scroll-snap-align: start;
}

.panel-2-heading {
    margin-bottom: 64px;
}

.timeline-container {
    position: relative;
    width: 100%;
    max-width: 800px;
}

.timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--accent-cold);
    transform: translateX(-50%);
}

.timeline-card {
    position: relative;
    width: 45%;
    padding: 24px;
    margin-bottom: 48px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.timeline-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.timeline-card:nth-child(odd) {
    margin-left: 0;
    text-align: right;
    padding-right: 48px;
}

.timeline-card:nth-child(even) {
    margin-left: 55%;
    text-align: left;
    padding-left: 48px;
}

.card-year {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--accent-cold);
    margin-bottom: 8px;
}

.card-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(0.875rem, 1.4vw, 1rem);
    line-height: 1.7;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.bubble-art {
    width: 60px;
    height: 40px;
    opacity: 0.6;
}

.timeline-card:nth-child(odd) .bubble-art {
    float: right;
}

/* Card ripple on hover */
.timeline-card::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--accent-warm);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    pointer-events: none;
    transition: none;
}

.timeline-card:hover::before {
    animation: cardRipple 0.8s ease-out forwards;
}

@keyframes cardRipple {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0.4; }
    100% { transform: translate(-50%, -50%) scale(8); opacity: 0; }
}

@media (max-width: 768px) {
    .timeline-line {
        left: 16px;
    }
    .timeline-card,
    .timeline-card:nth-child(odd),
    .timeline-card:nth-child(even) {
        width: calc(100% - 48px);
        margin-left: 48px;
        text-align: left;
        padding-left: 0;
        padding-right: 0;
    }
    .timeline-card:nth-child(odd) .bubble-art {
        float: none;
    }
}

/* === Panel 3 — The Absence === */
.panel-3 {
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
}

.noise-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.breathing-text {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    text-align: center;
    position: relative;
    z-index: 2;
    animation: breathe 6s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% {
        color: var(--highlight);
        transform: scale(1);
    }
    50% {
        color: var(--accent-warm);
        transform: scale(1.02);
    }
}

/* === Panel 4 — The Implications === */
.panel-4 {
    background: var(--bg-light);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.panel-4-heading {
    text-align: center;
}

.columns-container {
    display: flex;
    gap: 0;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

.column {
    flex: 1;
    padding: 0 32px;
}

.column-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    font-size: clamp(1.25rem, 3vw, 2rem);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-red);
    margin-bottom: 24px;
}

.column-divider {
    width: 1px;
    background: var(--accent-warm);
    position: relative;
    animation: dividerRipple 4s ease-in-out infinite;
}

@keyframes dividerRipple {
    0%, 100% { transform: scaleX(1); opacity: 0.6; }
    50% { transform: scaleX(2); opacity: 1; }
}

.panel-4-footer {
    text-align: center;
    margin-top: 64px;
}

@media (max-width: 768px) {
    .columns-container {
        flex-direction: column;
        gap: 32px;
    }
    .column-divider {
        width: 100%;
        height: 1px;
    }
    .column {
        padding: 0;
    }
}

/* === Scroll-triggered ripple === */
.section-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 1px solid var(--accent-warm);
    opacity: 0.3;
    pointer-events: none;
    animation: sectionRipple 2s ease-out forwards;
}

@keyframes sectionRipple {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0.3; }
    100% { transform: translate(-50%, -50%) scale(30); opacity: 0; }
}

/* Nav rail theme for dark panels */
.nav-rail.dark-theme .nav-number {
    color: var(--text-on-dark);
}
.nav-rail.dark-theme .nav-item.active .nav-number {
    color: var(--text-on-dark-heading);
}
