/* ============================================
   genpatsu.quest - Cyberpunk Nuclear Quest
   Palette:
     Void Black:    #0A0A0E
     Gold Neon:     #FFD700
     Reactor Cyan:  #00E5FF
     Danger Red:    #FF1744
     Steel Gray:    #4A4A58
     Warm Amber:    #E8A840
     Core White:    #F0F0E8
   Fonts: Rajdhani, Saira, Source Code Pro
   ============================================ */

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

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

body {
    background: #0A0A0E;
    color: #F0F0E8;
    font-family: 'Saira', sans-serif;
    font-weight: 400;
    font-size: clamp(15px, 1.5vw, 18px);
    line-height: 1.75;
    overflow-x: hidden;
}

/* ---- Scan-line overlay ---- */
#scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        transparent 0%,
        transparent 50%,
        rgba(0, 0, 0, 0.03) 50%,
        rgba(0, 0, 0, 0.03) 100%
    );
    background-size: 100% 4px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

#scanline-overlay.active {
    opacity: 1;
}

/* ---- Quest progress indicator (side dots) ---- */
#quest-progress {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.progress-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #4A4A58;
    background: transparent;
    transition: all 0.5s ease;
    position: relative;
}

.progress-dot.active {
    border-color: #FFD700;
    background: #FFD700;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.6), 0 0 24px rgba(255, 215, 0, 0.3);
}

.progress-dot.completed {
    border-color: #00E5FF;
    background: #00E5FF;
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

/* ---- Deep background reactor layer ---- */
#bg-reactor-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    pointer-events: none;
    will-change: transform;
}

#reactor-tower {
    width: 40vw;
    max-width: 500px;
    height: auto;
    opacity: 0;
    transform: translateY(100%);
    transition: transform 0.8s ease-out, opacity 0.8s ease-out;
}

#reactor-tower.visible {
    opacity: 0.25;
    transform: translateY(0%);
}

.tower-outline {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.5s ease-out 0.4s;
}

#reactor-tower.visible .tower-outline {
    stroke-dashoffset: 0;
}

.window-light {
    animation: windowPulse 3s ease-in-out infinite alternate;
}

.window-light:nth-child(odd) {
    animation-delay: -1.5s;
}

@keyframes windowPulse {
    0% { opacity: 0.15; }
    100% { opacity: 0.6; }
}

/* ---- Stages (general) ---- */
.stage {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 80px 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stage-header {
    margin-bottom: 48px;
}

.stage-label {
    display: block;
    margin-bottom: 8px;
    color: #00E5FF;
    font-size: 13px;
    letter-spacing: 0.15em;
}

.stage-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: clamp(28px, 5.5vw, 64px);
    letter-spacing: 0.01em;
    color: #FFD700;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

/* ---- HUD text ---- */
.hud-text {
    font-family: 'Source Code Pro', monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #4A4A58;
}

/* ============================================
   STAGE 1: HERO
   ============================================ */
#stage-hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

#stage-hero .stage-content {
    position: relative;
    z-index: 2;
}

#hero-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: clamp(48px, 10vw, 120px);
    letter-spacing: 0.05em;
    line-height: 1;
    margin-bottom: 8px;
}

#hero-title .char {
    display: inline-block;
    color: #FFD700;
    opacity: 0;
    text-shadow: 0 0 0px rgba(255, 215, 0, 0);
    transition: opacity 0.1s ease, text-shadow 0.6s ease;
}

#hero-title .char.powered {
    opacity: 1;
    text-shadow:
        0 0 10px rgba(255, 215, 0, 0.8),
        0 0 30px rgba(255, 215, 0, 0.5),
        0 0 60px rgba(255, 215, 0, 0.3);
}

#hero-subtitle {
    margin-bottom: 16px;
}

.quest-text {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: clamp(24px, 5vw, 56px);
    letter-spacing: 0.15em;
    color: #00E5FF;
    opacity: 0;
    position: relative;
    display: inline-block;
}

.quest-text.holographic {
    opacity: 0.9;
    text-shadow:
        0 0 10px rgba(0, 229, 255, 0.8),
        0 0 30px rgba(0, 229, 255, 0.4),
        0 0 60px rgba(0, 229, 255, 0.2);
    animation: hologramFlicker 4s ease-in-out infinite;
}

@keyframes hologramFlicker {
    0%, 100% { opacity: 0.9; }
    5% { opacity: 0.3; }
    6% { opacity: 0.9; }
    50% { opacity: 0.85; }
    52% { opacity: 0.4; }
    53% { opacity: 0.9; }
}

#hero-tagline {
    margin-bottom: 24px;
}

#hero-tagline .hud-text {
    color: #E8A840;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#hero-tagline .hud-text.visible {
    opacity: 1;
}

#stage-indicator {
    opacity: 0;
    transition: opacity 0.6s ease;
}

#stage-indicator.visible {
    opacity: 1;
}

#stage-indicator .hud-text {
    color: #00E5FF;
}

/* Hero data-viz */
#hero-dataviz {
    position: absolute;
    bottom: 60px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 60px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
    z-index: 2;
}

#hero-dataviz.visible {
    opacity: 1;
    transform: translateY(0);
}

.dataviz-bar-group {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    height: 120px;
}

.dataviz-bar {
    width: 32px;
    height: 0%;
    background: linear-gradient(to top, #00E5FF, #FFD700);
    border-radius: 2px 2px 0 0;
    position: relative;
    transition: height 0.8s ease-out;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

.dataviz-bar::after {
    content: attr(data-label);
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Source Code Pro', monospace;
    font-size: 8px;
    color: #4A4A58;
    white-space: nowrap;
    letter-spacing: 0.05em;
}

.dataviz-gauge-wrap {
    width: 120px;
    height: 120px;
}

.dataviz-gauge {
    width: 100%;
    height: 100%;
}

.gauge-fill {
    transition: stroke-dashoffset 1.5s ease-out;
    filter: drop-shadow(0 0 6px rgba(0, 229, 255, 0.5));
}

/* ============================================
   STAGE 2: PHYSICS
   ============================================ */
#stage-physics {
    background: linear-gradient(180deg, transparent 0%, rgba(0, 229, 255, 0.02) 50%, transparent 100%);
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
}

.col-text p {
    margin-bottom: 20px;
    color: #F0F0E8;
    opacity: 0.9;
}

.data-readout {
    margin-top: 32px;
    border: 1px solid rgba(255, 215, 0, 0.2);
    padding: 20px;
    background: rgba(10, 10, 14, 0.8);
}

.readout-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(74, 74, 88, 0.3);
}

.readout-row:last-child {
    border-bottom: none;
}

.readout-label {
    font-family: 'Source Code Pro', monospace;
    font-size: 13px;
    color: #4A4A58;
}

.readout-value {
    font-family: 'Source Code Pro', monospace;
    font-size: 13px;
    font-weight: 600;
    color: #00E5FF;
}

/* Chain reaction visualization */
#chain-reaction-viz {
    width: 100%;
    height: 400px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 229, 255, 0.1);
    background: rgba(10, 10, 14, 0.6);
    border-radius: 4px;
}

.neutron-origin {
    position: absolute;
    left: 50%;
    top: 20px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #00E5FF;
    transform: translateX(-50%);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.8);
}

.neutron-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #FFD700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.neutron-dot.visible {
    opacity: 1;
}

.fission-line {
    position: absolute;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 229, 255, 0.4), transparent);
    transform-origin: left center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.fission-line.visible {
    opacity: 1;
}

/* ============================================
   STAGE 3: TIMELINE
   ============================================ */
#stage-timeline {
    padding-bottom: 120px;
}

.timeline-container {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    padding-left: 60px;
}

.timeline-line {
    position: absolute;
    left: 30px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, #00E5FF, #FFD700, #FF1744);
    opacity: 0.3;
}

.timeline-event {
    position: relative;
    margin-bottom: 80px;
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.timeline-event.visible {
    opacity: 1;
    transform: translateX(0);
}

.event-year {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: clamp(20px, 3vw, 36px);
    color: #FFD700;
    margin-bottom: 8px;
}

.event-dot {
    position: absolute;
    left: -42px;
    top: 8px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #00E5FF;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.6);
    animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(0, 229, 255, 0.4); }
    50% { box-shadow: 0 0 20px rgba(0, 229, 255, 0.8); }
}

.event-card {
    background: rgba(10, 10, 14, 0.85);
    border: 1px solid rgba(74, 74, 88, 0.3);
    border-left: 3px solid #FFD700;
    padding: 24px 28px;
}

.event-card h3 {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: clamp(18px, 2.5vw, 28px);
    color: #F0F0E8;
    margin-bottom: 12px;
    letter-spacing: 0.01em;
}

.event-card p {
    color: rgba(240, 240, 232, 0.8);
    margin-bottom: 16px;
    font-size: clamp(14px, 1.3vw, 16px);
}

.event-severity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.severity-bar {
    display: block;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, #FFD700, #FF1744);
    width: 0;
    transition: width 1s ease-out;
}

.timeline-event.visible .severity-bar {
    width: calc(var(--severity-pct, 0) * 1%);
}

.severity-label {
    color: #FF1744;
    font-size: 11px;
}

/* ============================================
   STAGE 4: CULTURAL CONTEXT (warm section)
   ============================================ */
.stage-warm {
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(232, 168, 64, 0.04) 20%,
        rgba(232, 168, 64, 0.08) 50%,
        rgba(232, 168, 64, 0.04) 80%,
        transparent 100%
    );
}

.stage-warm .stage-label {
    color: #E8A840;
}

.stage-warm .stage-title {
    color: #E8A840;
    text-shadow: 0 0 30px rgba(232, 168, 64, 0.3);
}

.culture-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 60px;
    align-items: center;
}

.culture-symbol {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.torii-svg {
    width: 200px;
    height: auto;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.stage-warm.in-view .torii-svg {
    opacity: 1;
    transform: translateY(0);
}

/* Cherry blossom petals */
.petal {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #E8A840;
    border-radius: 50% 0 50% 0;
    opacity: 0;
    animation: petalFall 6s ease-in-out infinite;
}

.stage-warm.in-view .petal {
    opacity: 0.6;
}

.petal-1 { top: 0; left: 30%; animation-delay: 0s; }
.petal-2 { top: -10px; left: 60%; animation-delay: 1.2s; }
.petal-3 { top: 5px; left: 80%; animation-delay: 2.4s; }
.petal-4 { top: -20px; left: 20%; animation-delay: 3.6s; }
.petal-5 { top: -5px; left: 50%; animation-delay: 4.8s; }

@keyframes petalFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 0; }
    10% { opacity: 0.6; }
    90% { opacity: 0.6; }
    100% { transform: translateY(250px) rotate(360deg); opacity: 0; }
}

.culture-text p {
    margin-bottom: 20px;
    color: rgba(240, 240, 232, 0.9);
}

.culture-text p:last-child {
    color: #E8A840;
    font-weight: 600;
    font-style: italic;
}

/* ============================================
   STAGE 5: RISK ASSESSMENT
   ============================================ */
#stage-risk {
    padding-bottom: 60px;
}

.risk-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    margin-bottom: 60px;
}

.risk-panel {
    background: rgba(10, 10, 14, 0.8);
    border: 1px solid rgba(74, 74, 88, 0.3);
    padding: 32px;
    text-align: center;
}

.risk-panel h3 {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 16px;
    color: #4A4A58;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.risk-big-number {
    font-family: 'Source Code Pro', monospace;
    font-size: clamp(36px, 6vw, 72px);
    font-weight: 600;
    color: #FFD700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    line-height: 1.1;
    margin-bottom: 8px;
}

.risk-panel .hud-text {
    color: #00E5FF;
}

.risk-bars-section {
    max-width: 700px;
    margin: 0 auto;
}

.risk-bars-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 20px;
    color: #F0F0E8;
    margin-bottom: 32px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.risk-bar-item {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.risk-bar-label {
    flex: 0 0 220px;
    font-family: 'Saira', sans-serif;
    font-size: 14px;
    color: #F0F0E8;
    text-align: right;
}

.risk-bar-track {
    flex: 1;
    height: 8px;
    background: rgba(74, 74, 88, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.risk-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    background: linear-gradient(90deg, #00E5FF, #FFD700);
    transition: width 1.2s ease-out;
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
}

.risk-bar-fill[data-value="91"],
.risk-bar-fill[data-value="82"] {
    background: linear-gradient(90deg, #FFD700, #FF1744);
    box-shadow: 0 0 8px rgba(255, 23, 68, 0.3);
}

.risk-bar-val {
    flex: 0 0 40px;
    color: #FFD700;
    font-size: 13px;
}

/* Quest Complete section */
#quest-complete {
    margin-top: 80px;
    padding: 60px;
    text-align: center;
    border: 1px solid rgba(255, 215, 0, 0.2);
    background: rgba(10, 10, 14, 0.9);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

#quest-complete.visible {
    opacity: 1;
    transform: translateY(0);
}

#quest-complete .hud-text {
    color: #00E5FF;
    display: block;
    margin-bottom: 16px;
    font-size: 14px;
}

#quest-complete h2 {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: clamp(24px, 4vw, 48px);
    color: #FFD700;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
    margin-bottom: 16px;
}

#quest-complete p {
    color: rgba(240, 240, 232, 0.8);
    max-width: 600px;
    margin: 0 auto;
}

#quest-complete::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #FFD700, transparent);
    animation: scanHorizontal 3s linear infinite;
}

@keyframes scanHorizontal {
    0% { transform: translateX(-50%); }
    100% { transform: translateX(50%); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .stage {
        padding: 60px 24px;
    }

    .two-col {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .culture-content {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .culture-symbol {
        order: -1;
    }

    .risk-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .risk-bar-item {
        flex-wrap: wrap;
    }

    .risk-bar-label {
        flex: 0 0 100%;
        text-align: left;
        margin-bottom: 4px;
    }

    #quest-progress {
        right: 12px;
    }

    .timeline-container {
        padding-left: 40px;
    }

    .event-dot {
        left: -30px;
    }

    .timeline-line {
        left: 16px;
    }

    #hero-dataviz {
        flex-direction: column;
        align-items: center;
        gap: 30px;
        bottom: 30px;
    }

    .dataviz-bar-group {
        height: 80px;
    }
}

@media (max-width: 600px) {
    .stage {
        padding: 40px 16px;
    }

    #hero-title {
        font-size: clamp(36px, 12vw, 64px);
    }

    .quest-text {
        font-size: clamp(18px, 6vw, 36px);
    }

    .event-card {
        padding: 16px 20px;
    }

    #quest-complete {
        padding: 32px 20px;
    }

    .risk-panel {
        padding: 20px;
    }
}

/* ============================================
   REACTOR TOWER PARALLAX SCALING
   ============================================ */
#bg-reactor-layer {
    transition: transform 0.1s linear;
}

/* ============================================
   CHAIN REACTION ANIMATION DOTS
   ============================================ */
.chain-atom {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #00E5FF;
    background: rgba(0, 229, 255, 0.1);
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chain-atom.split {
    opacity: 1;
    transform: scale(1);
    animation: atomSplit 0.4s ease-out;
}

@keyframes atomSplit {
    0% { transform: scale(1.5); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}
