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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Lora', serif;
    background: #0a0e1a;
    color: #e8dfd2;
    overflow-x: hidden;
    min-height: 100vh;
    /* palette refs: #7a8ba8 #4a5568 */
}

/* === GRAIN OVERLAY === */
#grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.04;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* === FOG DRIFT === */
.fog {
    position: fixed;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    opacity: 0.08;
}

.fog-1 {
    background: linear-gradient(90deg, transparent, rgba(138, 149, 168, 0.08), transparent);
    animation: drift 30s linear infinite;
}

.fog-2 {
    background: linear-gradient(90deg, transparent, rgba(212, 165, 90, 0.05), transparent);
    animation: drift 45s linear infinite reverse;
    top: 30%;
}

@keyframes drift {
    from { transform: translateX(-50%); }
    to { transform: translateX(0%); }
}

/* === RAIN === */
#rain-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
    overflow: hidden;
}

.rain-line {
    position: absolute;
    width: 1px;
    background: linear-gradient(180deg, transparent, #8b95a8, transparent);
    opacity: 0.15;
    left: var(--x);
    height: var(--h);
    animation: rain var(--duration) var(--delay) linear infinite;
}

@keyframes rain {
    from { transform: translateY(-100vh); }
    to { transform: translateY(100vh); }
}

/* === SECTIONS === */
.section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* === STORM CANOPY === */
#storm-canopy {
    background: linear-gradient(180deg, #0a0e1a 0%, #0a0e1a 30%, #16213e 70%, #0a0e1a 100%);
    z-index: 10;
}

.canopy-content {
    text-align: center;
    position: relative;
}

.hero-title {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(4rem, 10vw, 12rem);
    letter-spacing: -0.02em;
    color: #e8dfd2;
    text-shadow: 0 0 20px rgba(232, 223, 210, 0.5);
    position: relative;
    display: inline-block;
}

.hero-title::after {
    content: attr(data-text);
    position: absolute;
    top: 1px;
    left: 1px;
    opacity: 0.3;
    filter: blur(1px);
    z-index: -1;
    color: #e8dfd2;
}

.amber-line {
    width: 120px;
    height: 2px;
    background: #d4a55a;
    margin: 2rem auto 0;
    box-shadow: 0 0 20px rgba(212, 165, 90, 0.4);
    animation: pulse-glow 8s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(212, 165, 90, 0.3); }
    50% { box-shadow: 0 0 40px rgba(212, 165, 90, 0.6); }
}

/* === RAIN PANELS (Slide-Reveal) === */
.rain-panel {
    position: sticky;
    top: 0;
    overflow: hidden;
}

#panel-fire {
    background: #16213e;
    z-index: 20;
}

#panel-silence {
    background: #182640;
    z-index: 30;
}

#panel-permanent {
    background: #1a2a45;
    z-index: 40;
}

.rain-panel::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(180deg, transparent 0%, rgba(10, 14, 26, 0.6) 100%);
    pointer-events: none;
}

.panel-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4rem;
    width: 90%;
    max-width: 1200px;
    z-index: 2;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.panel-content.visible {
    opacity: 1;
    transform: translateY(0);
}

/* === CONTRADICTION TEXT === */
.contradiction-text {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.warm-text {
    color: #d4a55a;
    text-shadow: 0 0 30px rgba(22, 33, 62, 0.4);
}

.cool-text {
    color: #8b95a8;
    text-shadow: 0 0 30px rgba(212, 165, 116, 0.3);
}

/* === PANEL VISUALS === */
.panel-visual {
    position: relative;
    width: 200px;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-rain-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* === CANDLE FLAME === */
.flame-layer {
    position: absolute;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    will-change: transform;
}

.flame-inner {
    width: 14px;
    height: 28px;
    background: #d4a55a;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    animation: flicker-inner 3s ease-in-out infinite;
    z-index: 3;
}

.flame-middle {
    width: 22px;
    height: 40px;
    background: #c4873a;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    animation: flicker-middle 5s ease-in-out infinite;
    z-index: 2;
}

.flame-outer {
    width: 34px;
    height: 54px;
    background: rgba(212, 165, 90, 0.2);
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    animation: flicker-outer 7s ease-in-out infinite;
    z-index: 1;
    box-shadow: 0 0 60px 20px rgba(212, 165, 90, 0.15);
}

.solo-flame, .candle {
    position: relative;
    width: 34px;
    height: 80px;
}

.candle-body {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 40px;
    background: #e8dfd2;
    opacity: 0.3;
    border-radius: 2px;
}

@keyframes flicker-inner {
    0%, 100% { transform: translateX(-50%) translateX(0); }
    25% { transform: translateX(-50%) translateX(2px); }
    50% { transform: translateX(-50%) translateX(-1px); }
    75% { transform: translateX(-50%) translateX(1px); }
}

@keyframes flicker-middle {
    0%, 100% { transform: translateX(-50%) translateX(0); }
    33% { transform: translateX(-50%) translateX(-2px); }
    66% { transform: translateX(-50%) translateX(2px); }
}

@keyframes flicker-outer {
    0%, 100% { transform: translateX(-50%) translateX(0); box-shadow: 0 0 60px 20px rgba(212, 165, 90, 0.15); }
    50% { transform: translateX(-50%) translateX(-1px); box-shadow: 0 0 80px 30px rgba(212, 165, 90, 0.25); }
}

/* === WAVEFORM === */
.waveform-container {
    width: 100%;
    max-width: 500px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.waveform {
    width: 60%;
    height: auto;
}

.waveform-path {
    stroke: #1a3a5c;
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    animation: draw-wave 4s ease-in-out infinite alternate;
}

@keyframes draw-wave {
    to { stroke-dashoffset: 0; }
}

/* === DISSOLVING TEXT === */
.dissolving-text {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: -0.02em;
    color: #c5bfb3;
    text-shadow: 0 0 30px rgba(212, 165, 116, 0.3);
}

.dissolve-letter {
    display: inline-block;
    animation: dissolve 4s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.2s);
}

@keyframes dissolve {
    0%, 30%, 100% { opacity: 1; }
    50%, 70% { opacity: 0.1; }
}

/* === CANDLELIT GROUND === */
#candlelit-ground {
    background: linear-gradient(180deg, #2a1a0a 0%, #1a0e05 30%, #0a0e1a 100%);
    flex-direction: column;
    z-index: 50;
    position: relative;
}

.candle-glow-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(ellipse at center, rgba(212, 165, 90, 0.3) 0%, rgba(212, 165, 90, 0.05) 40%, transparent 70%);
    pointer-events: none;
}

.ground-content {
    text-align: center;
    z-index: 2;
}

.candle-cluster {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 24px;
    margin-bottom: 3rem;
}

.candle-1 { height: 90px; }
.candle-2 { height: 70px; }
.candle-3 { height: 80px; }

.candle-2 .flame-inner { animation-delay: 0.5s; }
.candle-2 .flame-middle { animation-delay: 0.7s; }
.candle-2 .flame-outer { animation-delay: 0.3s; }
.candle-3 .flame-inner { animation-delay: 1s; }
.candle-3 .flame-middle { animation-delay: 1.2s; }
.candle-3 .flame-outer { animation-delay: 0.8s; }

.closing-aphorism {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: -0.02em;
    color: #d4a55a;
    text-shadow: 0 0 30px rgba(22, 33, 62, 0.4);
    margin-bottom: 2rem;
}

.timestamp-line {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6b6560;
}

.separator {
    margin: 0 0.5em;
    opacity: 0.5;
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
    .rain-line,
    .fog,
    .flame-layer,
    .dissolve-letter,
    .waveform-path,
    .amber-line {
        animation: none;
    }
}
