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

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

body {
    background: #2b2520;
    color: #5c524a;
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    line-height: 1.65;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* === SCROLL PROGRESS BAR === */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: #c4553a;
    z-index: 1000;
    transition: width 0.05s linear;
}

/* === SECTION INDICATOR === */
#section-indicator {
    position: fixed;
    top: 16px;
    right: 20px;
    font-family: 'Inconsolata', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #8a7d6b;
    z-index: 999;
    text-transform: uppercase;
}

/* === SCENES === */
.scene {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* === SCENE HEADERS === */
.scene-header {
    font-family: 'Inconsolata', monospace;
    font-size: clamp(0.75rem, 1vw, 0.95rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8a7d6b;
    padding: 16px 24px;
    position: relative;
    z-index: 5;
}

.signal-value {
    color: #5a7a62;
}
.signal-value.warn {
    color: #c4553a;
}
.signal-value.danger {
    color: #c4553a;
}
.signal-value.critical {
    color: #c4553a;
}

/* === SCENE 1 — SUMMIT SIGNAL === */
#scene-1 {
    background-image:
        radial-gradient(ellipse at 20% 50%, #d4c8b0 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, #cfc3a8 0%, transparent 40%),
        linear-gradient(180deg, #e8ddc8 0%, #e2d5bc 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.contour-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

#contour-hero {
    width: 140%;
    height: 100%;
    position: absolute;
    bottom: 0;
    left: -20%;
    animation: contourDrift 60s linear infinite;
}

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

.scene-1-content {
    position: relative;
    z-index: 3;
    text-align: center;
    animation: fadeUp 800ms ease-out both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero-title {
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: clamp(3rem, 8vw, 7rem);
    line-height: 1.0;
    letter-spacing: -0.02em;
    color: #2b2520;
    display: inline-flex;
    align-items: baseline;
}

.hero-title span {
    display: inline-block;
}

.hero-title .glitch-char {
    transform: translateY(-8px);
    color: #c4553a;
}

.hero-title .dot {
    color: #8a7d6b;
}

.hero-subtitle {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 600;
    font-size: clamp(0.75rem, 1vw, 0.95rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #5c524a;
    margin-top: 16px;
}

/* === GLITCH BANDS === */
.glitch-band {
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    background: #c4553a;
    opacity: 0.8;
    z-index: 10;
    pointer-events: none;
}

.glitch-band.large {
    height: 8px;
    mix-blend-mode: difference;
}

/* === SCENE 2 — INSTRUMENT CLUSTER === */
#scene-2 {
    background: #2b2520;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.instrument-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    flex: 1;
    min-height: 0;
}

.panel {
    border: 1px solid #3d3632;
    background-image:
        radial-gradient(ellipse at 20% 50%, #d4c8b0 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, #cfc3a8 0%, transparent 40%),
        linear-gradient(180deg, #e8ddc8 0%, #e2d5bc 100%);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

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

.panel-header {
    height: 24px;
    background: #3d3632;
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 8px;
    flex-shrink: 0;
}

.panel-id {
    font-family: 'Inconsolata', monospace;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #c8bda8;
    text-transform: uppercase;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.status-dot.active { background: #5a7a62; }
.status-dot.error { background: #c4553a; }

.panel-close {
    margin-left: auto;
    color: #8a7d6b;
    font-size: 0.8rem;
    cursor: default;
}

.panel-body {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.panel-label {
    font-family: 'Inconsolata', monospace;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8a7d6b;
    margin-bottom: 8px;
}

/* Altitude Panel */
.panel-altitude {
    align-items: center;
    justify-content: center;
}

.altitude-value {
    font-family: 'Inconsolata', monospace;
    font-size: clamp(2rem, 4vw, 3.5rem);
    font-weight: 700;
    color: #2b2520;
    letter-spacing: 0.04em;
}

/* Pressure Panel */
.panel-pressure {
    align-items: center;
}

.pressure-gauge {
    width: 80%;
    max-width: 180px;
    flex-shrink: 0;
}

.gauge-text {
    font-family: 'Inconsolata', monospace;
    font-size: 10px;
    fill: #8a7d6b;
}

.pressure-reading {
    font-family: 'Inconsolata', monospace;
    font-size: 1.2rem;
    font-weight: 700;
    color: #2b2520;
    margin-top: 4px;
}

#pressure-needle {
    animation: needleSwing 4s ease-in-out infinite;
    transform-origin: 100px 110px;
}

@keyframes needleSwing {
    0%   { transform: rotate(-35deg); }
    50%  { transform: rotate(-25deg); }
    100% { transform: rotate(-35deg); }
}

/* Signal Bars Panel */
.panel-signal {
    justify-content: center;
}

.signal-bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 60%;
    padding-top: 8px;
}

.signal-bar {
    flex: 1;
    background: #5a7a62;
    min-width: 0;
}

.signal-bar.flicker {
    animation: barFlicker 1.5s steps(2) infinite;
}

@keyframes barFlicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

/* Log Panel */
.panel-log {
    overflow: hidden;
}

.log-entries {
    flex: 1;
    overflow: hidden;
    font-size: 0.75rem;
    line-height: 1.6;
}

.log-entry {
    margin-bottom: 4px;
    color: #5c524a;
    font-family: 'Nunito Sans', sans-serif;
    font-size: 0.72rem;
}

.log-time {
    font-family: 'Inconsolata', monospace;
    color: #8a7d6b;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-right: 6px;
}

/* Terrain Panel */
.panel-terrain {
    align-items: center;
}

.terrain-chart {
    width: 70%;
    max-width: 140px;
}

.terrain-legend {
    display: flex;
    gap: 10px;
    margin-top: 6px;
    font-family: 'Inconsolata', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    color: #5c524a;
    text-transform: uppercase;
    flex-wrap: wrap;
    justify-content: center;
}

.terrain-legend i {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 3px;
    vertical-align: middle;
}

/* Corrupted Panel */
.panel-corrupted {
    position: relative;
}

.noise-field {
    flex: 1;
    background: repeating-linear-gradient(
        0deg,
        #9e9588 0px,
        #e8ddc8 1px,
        #3d3632 2px,
        #c8bda8 3px
    );
    background-size: 4px 4px;
    animation: noiseShift 0.15s steps(5) infinite;
    opacity: 0.7;
}

@keyframes noiseShift {
    0% { background-position: 0 0; }
    20% { background-position: -3px 2px; }
    40% { background-position: 2px -1px; }
    60% { background-position: -1px 3px; }
    80% { background-position: 3px -2px; }
    100% { background-position: 0 0; }
}

/* === SCENE 3 — CARTOGRAPHIC SURVEY === */
#scene-3 {
    background-image:
        radial-gradient(ellipse at 20% 50%, #d4c8b0 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, #cfc3a8 0%, transparent 40%),
        linear-gradient(180deg, #e8ddc8 0%, #e2d5bc 100%);
}

.map-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

#contour-map {
    width: 160%;
    height: 100%;
    position: absolute;
    top: 0;
    left: -30%;
    animation: mapPan 60s linear infinite;
}

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

.map-callout {
    position: absolute;
    border: 1px solid #3d3632;
    background: #f2ece0;
    padding: 8px 12px;
    z-index: 5;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.map-callout.visible {
    opacity: 1;
    transform: translateY(0);
}

.callout-1 { top: 25%; left: 15%; }
.callout-2 { top: 55%; left: 55%; }
.callout-3 { top: 70%; left: 30%; }

.callout-label {
    display: block;
    font-family: 'Inconsolata', monospace;
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: #2b2520;
    text-transform: uppercase;
}

.callout-data {
    display: block;
    font-family: 'Inconsolata', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    color: #8a7d6b;
}

/* === SCENE 4 — TRANSMISSION LOG === */
#scene-4 {
    background: #2b2520;
    display: flex;
    flex-direction: column;
}

.transmission-layout {
    display: flex;
    flex: 1;
    min-height: 0;
}

.transmission-log {
    width: 60%;
    background-image:
        radial-gradient(ellipse at 20% 50%, #d4c8b0 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, #cfc3a8 0%, transparent 40%),
        linear-gradient(180deg, #e8ddc8 0%, #e2d5bc 100%);
    padding: 24px;
    overflow-y: auto;
}

.tx-entry {
    margin-bottom: 16px;
    max-width: 55ch;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.tx-entry.visible {
    opacity: 1;
    transform: translateY(0);
}

.tx-time {
    display: block;
    font-family: 'Inconsolata', monospace;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #8a7d6b;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.tx-entry p {
    font-family: 'Nunito Sans', sans-serif;
    font-size: clamp(0.82rem, 1vw, 0.95rem);
    line-height: 1.65;
    color: #5c524a;
}

.glitch-line {
    width: 100%;
    height: 2px;
    background: #c4553a;
    opacity: 0.6;
    margin: 8px 0;
}

.elevation-profile {
    width: 40%;
    background: #2b2520;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#elevation-chart {
    width: 100%;
    height: 80%;
}

.chart-title {
    font-family: 'Inconsolata', monospace;
    font-size: 11px;
    font-weight: 700;
    fill: #c8bda8;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.axis-label {
    font-family: 'Inconsolata', monospace;
    font-size: 9px;
    fill: #8a7d6b;
}

.elevation-corrupt {
    animation: corruptFlash 3s steps(2) infinite;
}

@keyframes corruptFlash {
    0%, 70% { opacity: 0; }
    75%, 95% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* === SCENE 5 — SIGNAL LOST === */
#scene-5 {
    background-image:
        radial-gradient(ellipse at 20% 50%, #d4c8b0 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, #cfc3a8 0%, transparent 40%),
        linear-gradient(180deg, #e8ddc8 0%, #e2d5bc 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.5s;
}

#scene-5.dark {
    background: #2b2520;
}

.signal-lost-content {
    position: relative;
    z-index: 5;
    text-align: center;
    padding: 40px;
    max-width: 700px;
}

.lost-body {
    font-family: 'Nunito Sans', sans-serif;
    color: #5c524a;
    max-width: 55ch;
    margin: 16px auto;
    line-height: 1.65;
}

#scene-5.dark .lost-body,
#scene-5.dark .scene-header {
    color: #c8bda8;
}

.end-transmission {
    font-family: 'Inconsolata', monospace;
    font-weight: 700;
    font-size: clamp(0.9rem, 1.5vw, 1.3rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #c4553a;
    margin-top: 40px;
    position: relative;
    z-index: 20;
}

.dissolve-text {
    transition: all 0.3s;
}

.dissolve-text.glitching {
    text-shadow:
        2px 0 #c4553a,
        -2px 0 #5a7a62;
    animation: dissolveFlicker 0.3s steps(3) infinite;
}

@keyframes dissolveFlicker {
    0% { opacity: 1; clip-path: inset(0 0 0 0); }
    33% { opacity: 0.8; clip-path: inset(10% 0 20% 0); }
    66% { opacity: 0.6; clip-path: inset(30% 0 5% 0); }
    100% { opacity: 0.9; clip-path: inset(5% 0 40% 0); }
}

.static-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    background: repeating-linear-gradient(
        0deg,
        #9e9588 0px,
        #2b2520 1px,
        #e8ddc8 2px,
        #5c524a 3px
    );
    background-size: 4px 4px;
    animation: noiseShift 0.1s steps(8) infinite;
    transition: opacity 2s;
}

.static-overlay.active {
    opacity: 0.85;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .instrument-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }

    .transmission-layout {
        flex-direction: column;
    }

    .transmission-log {
        width: 100%;
        height: 60%;
    }

    .elevation-profile {
        width: 100%;
        height: 40%;
    }

    .callout-1 { top: 20%; left: 5%; }
    .callout-2 { top: 50%; left: 45%; }
    .callout-3 { top: 72%; left: 10%; }
}
