/* meltdown.quest — Surreal Glitch Documentary */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #E8ECF0;
    --text: #1B2A3D;
    --accent: #5B7B99;
    --crisis-bg: #2A2A2A;
    --crisis-text: #F0E6D3;
    --crisis-accent: #FF4500;
    --aftermath-bg: #0A0A0A;
    --aftermath-text: #39FF14;
    --aftermath-accent: #FF00FF;
    --silence-bg: #F5F5F0;
    --silence-text: #999999;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Literata', serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    transition: background-color 0.8s ease, color 0.6s ease;
}

/* Progress Bar */
#progress-bar {
    position: fixed;
    right: 12px;
    top: 0;
    width: 2px;
    height: 100%;
    background: rgba(91, 123, 153, 0.15);
    z-index: 100;
}

#progress-fill {
    width: 100%;
    height: 0%;
    background: var(--accent);
    transition: height 0.1s linear, background-color 0.8s ease;
}

#progress-labels {
    position: absolute;
    left: -28px;
    top: 0;
    width: 24px;
    height: 100%;
    pointer-events: none;
}

.progress-label {
    position: absolute;
    font-family: 'Overpass Mono', monospace;
    font-weight: 700;
    font-size: 9px;
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.3s ease;
    text-align: right;
    width: 100%;
}

#progress-bar:hover .progress-label {
    opacity: 1;
}

/* Scan Lines */
#scan-lines {
    position: fixed;
    inset: 0;
    z-index: 50;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    transition: opacity 1s ease;
}

.scan-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    background: #39FF14;
    opacity: 0.2;
    animation: scanSweep var(--duration) linear infinite;
    animation-delay: var(--delay);
}

@keyframes scanSweep {
    0% { transform: translateY(-100vh); opacity: 0; }
    10% { opacity: 0.2; }
    90% { opacity: 0.2; }
    100% { transform: translateY(100vh); opacity: 0; }
}

/* Crack Overlay */
#crack-overlay {
    position: fixed;
    inset: 0;
    z-index: 45;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease;
}

#crack-overlay svg {
    width: 100%;
    height: 100%;
}

.crack {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s ease;
}

#crack-overlay.visible .crack {
    stroke-dashoffset: 0;
}

/* Particle Container */
#particle-container {
    position: fixed;
    inset: 0;
    z-index: 40;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease;
}

.dust-particle {
    position: absolute;
    width: var(--size);
    height: var(--size);
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: dustFall var(--fall-duration) linear infinite;
    animation-delay: var(--delay);
    left: var(--x);
    top: -10px;
}

@keyframes dustFall {
    0% { transform: translateY(0) translateX(0); opacity: 0; }
    10% { opacity: 0.6; }
    90% { opacity: 0.3; }
    100% { transform: translateY(110vh) translateX(20px); opacity: 0; }
}

/* Chapters */
.chapter {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.chapter-inner {
    max-width: 680px;
    width: 100%;
    padding: 40px 24px;
    position: relative;
    z-index: 5;
}

/* Chapter Titles */
.chapter-title {
    font-family: 'Teko', sans-serif;
    font-weight: 600;
    font-size: 64px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 32px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.chapter-title.reveal {
    opacity: 1;
    transform: translateY(0);
}

/* Opening (Chapter 1) */
.opening {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: none;
}

#opening-line {
    width: 0;
    height: 1px;
    background: #5B7B99;
    margin-bottom: 24px;
    transition: width 0.8s ease;
}

#opening-line.drawn {
    width: 300px;
}

.opening-title {
    font-family: 'Teko', sans-serif;
    font-weight: 600;
    font-size: 80px;
    color: #1B2A3D;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.5s ease;
    margin-bottom: 0;
}

.opening-title.reveal {
    opacity: 1;
    transform: none;
}

.opening-subtitle {
    font-family: 'Teko', sans-serif;
    font-weight: 600;
    font-size: 40px;
    color: #1B2A3D;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0;
    margin-left: 20%;
    transition: opacity 0.5s ease;
}

.opening-subtitle.reveal {
    opacity: 1;
}

.opening-tagline {
    font-family: 'Overpass Mono', monospace;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.2em;
    color: #5B7B99;
    margin-top: 32px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.opening-tagline.reveal {
    opacity: 1;
}

.scroll-chevron {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: none;
}

.scroll-chevron.reveal {
    opacity: 1;
    animation: chevronBounce 2s ease-in-out infinite;
}

@keyframes chevronBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(8px); }
}

/* Institutional (Chapters 1-2) */
.institutional .narrative-text {
    font-family: 'Literata', serif;
    font-size: 18px;
    line-height: 1.8;
    color: #1B2A3D;
    margin-bottom: 24px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.institutional .narrative-text.reveal {
    opacity: 1;
    transform: translateY(0);
}

.data-readout {
    font-family: 'Overpass Mono', monospace;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #5B7B99;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.data-readout.reveal {
    opacity: 1;
    transform: translateY(0);
}

.reactor-diagram {
    max-width: 400px;
    margin: 0 auto 32px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reactor-diagram.reveal {
    opacity: 1;
    transform: translateY(0);
}

/* Crisis (Chapters 3-4) */
.crisis .chapter-title {
    color: #F0E6D3;
}

.crisis-title {
    color: #FF4500;
}

.crisis .narrative-text {
    font-family: 'Literata', serif;
    font-size: 18px;
    line-height: 1.8;
    color: #F0E6D3;
    margin-bottom: 24px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.crisis .narrative-text.reveal {
    opacity: 1;
    transform: translateY(0);
}

.crisis .narrative-text.reveal.shake {
    animation: crisisShake 0.1s ease 2;
}

@keyframes crisisShake {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(3px); }
}

.rotated {
    transform: rotate(-2deg) translateY(20px);
}

.rotated.reveal {
    transform: rotate(-2deg) translateY(0);
}

.offset-left {
    margin-left: -40px;
}

.offset-right {
    margin-left: 60px;
    font-style: italic;
}

.radiation-counter {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 32px;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 69, 0, 0.3);
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.radiation-counter.reveal {
    opacity: 1;
}

.counter-label {
    font-family: 'Overpass Mono', monospace;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #FF4500;
}

.counter-value {
    font-family: 'Overpass Mono', monospace;
    font-weight: 700;
    font-size: 32px;
    color: #FF4500;
    font-variant-numeric: tabular-nums;
}

.counter-unit {
    font-family: 'Overpass Mono', monospace;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: #FF4500;
    opacity: 0.7;
}

.radiation-counter.large .counter-value {
    font-size: 48px;
    color: #39FF14;
}

.radiation-counter.large .counter-label,
.radiation-counter.large .counter-unit {
    color: #39FF14;
}

/* Aftermath (Chapters 5-6) */
.aftermath .chapter-title {
    color: #39FF14;
}

.aftermath-title {
    color: #39FF14;
    text-shadow: 0 0 20px rgba(57, 255, 20, 0.3);
}

.glitch-text {
    animation: glitchFlicker 3s ease-in-out infinite;
}

@keyframes glitchFlicker {
    0%, 95%, 100% { opacity: 1; }
    96% { opacity: 0.1; }
    97% { opacity: 0.8; transform: translateX(2px) translateY(0); }
    98% { opacity: 0.3; transform: translateX(-3px) translateY(0); }
    99% { opacity: 1; transform: translateX(1px) translateY(0); }
}

.scattered-text {
    position: relative;
    min-height: 300px;
}

.fragment {
    font-family: 'Literata', serif;
    font-size: 18px;
    line-height: 1.8;
    color: #39FF14;
    position: absolute;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.fragment.reveal {
    opacity: 1;
    animation: glitchIn 0.2s ease;
}

@keyframes glitchIn {
    0% { opacity: 1; }
    25% { opacity: 0; }
    50% { opacity: 1; }
    75% { opacity: 0.3; }
    100% { opacity: 1; }
}

.frag-1 {
    top: 0;
    left: 0;
    max-width: 400px;
}

.frag-2 {
    top: 80px;
    right: -60px;
    max-width: 380px;
    transform: rotate(1deg);
}

.frag-3 {
    top: 180px;
    left: -30px;
    max-width: 350px;
    transform: rotate(-2deg);
}

.frag-4 {
    top: 0;
    left: -100px;
    max-width: 400px;
    transform: rotate(3deg);
}

.frag-5 {
    top: 80px;
    right: -120px;
    max-width: 420px;
    transform: rotate(-1deg);
}

.frag-6 {
    top: 180px;
    left: 40px;
    max-width: 350px;
    transform: rotate(2deg);
}

.frag-7 {
    top: 260px;
    right: -40px;
    max-width: 380px;
    transform: rotate(-3deg);
    font-style: italic;
}

.wide {
    min-height: 360px;
}

#chapter-5 .radiation-counter,
#chapter-6 .radiation-counter {
    border-color: rgba(57, 255, 20, 0.3);
    background: rgba(0, 0, 0, 0.6);
}

#chapter-6 .counter-value {
    color: #39FF14;
}

#chapter-6 .counter-label,
#chapter-6 .counter-unit {
    color: #39FF14;
}

/* Silence (Chapter 7) */
.silence {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: none;
    text-align: center;
}

.silence-text {
    font-family: 'Literata', serif;
    font-size: 24px;
    color: #999999;
    opacity: 0;
    transition: opacity 2s ease;
}

.silence-text.reveal {
    opacity: 1;
}

/* Transition zones */
.chapter::before {
    content: '';
    position: absolute;
    inset: 0;
    background: inherit;
    z-index: -1;
    transition: background-color 0.8s ease;
}

/* Responsive */
@media (max-width: 768px) {
    .chapter-title {
        font-size: 48px;
    }

    .opening-title {
        font-size: 56px;
    }

    .opening-subtitle {
        font-size: 28px;
    }

    .chapter-inner {
        padding: 24px 16px;
    }

    .offset-left {
        margin-left: 0;
    }

    .offset-right {
        margin-left: 20px;
    }

    .fragment {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        margin-bottom: 20px;
        transform: none;
        max-width: 100%;
    }

    .scattered-text {
        min-height: auto;
        display: flex;
        flex-direction: column;
    }
}
