/* ============================================
   infra.limited — Orbital Infrastructure Monitor
   ============================================ */

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

:root {
    --void-black: #070B07;
    --panel-dark: #0A0F0A;
    --phosphor-dim: #1A2F1A;
    --phosphor-mid: #3A4F3A;
    --sage-mute: #5A7A5A;
    --pale-screen: #A8C4A8;
    --bright-phosphor: #4AE54A;
    --alert-amber: #E5A84A;
    --critical-red: #E54A4A;
    --signal-white: #D4E8D4;
    --grid-line: #0F1A0F;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--void-black);
    color: var(--pale-screen);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    letter-spacing: 0.04em;
    line-height: 1.7;
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Scanline Overlay --- */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 1px,
        rgba(0, 20, 0, 0.08) 1px,
        rgba(0, 20, 0, 0.08) 2px
    );
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.4s ease;
}

body.loaded::after {
    opacity: 1;
}

body.zone-signal-active::after {
    opacity: 1;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 1px,
        rgba(0, 20, 0, 0.16) 1px,
        rgba(0, 20, 0, 0.16) 2px
    );
}

/* --- Phosphor Flicker --- */
@keyframes phosphorPulse {
    0%, 100% { filter: brightness(0.97); }
    50% { filter: brightness(1.03); }
}

body.loaded {
    animation: phosphorPulse 4s ease-in-out infinite;
}

/* --- Grid Overlay --- */
/* Minor grid lines use #0F1A0F, major lines use #1A2F1A (set in SVG) */
#grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.03;
    color: #0F1A0F;
}

body.zone-archive-active #grid-overlay {
    opacity: 0.06;
    transition: opacity 1s ease;
}

/* --- HUD Frame --- */
#hud-frame {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    pointer-events: none;
}

#hud-border {
    width: 100%;
    height: 100%;
}

.hud-line {
    stroke: var(--phosphor-mid);
    stroke-width: 1;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.hud-line-top {
    x1: 500;
    y1: 24;
    x2: 500;
    y2: 24;
}

body.loaded .hud-line {
    transition: stroke-dashoffset 0.8s ease-in-out;
    stroke-dashoffset: 0;
}

.corner-ticks {
    opacity: 0;
}

body.loaded .corner-ticks {
    opacity: 1;
    transition: opacity 0.3s ease 0.9s;
}

/* --- Navigation Indicators --- */
#nav-indicators {
    position: fixed;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.nav-dot {
    width: 8px;
    height: 8px;
    background: var(--phosphor-dim);
    cursor: pointer;
    position: relative;
    transition: background 0.3s ease;
}

.nav-dot.active {
    background: var(--bright-phosphor);
    box-shadow: 0 0 6px rgba(74, 229, 74, 0.4);
}

.nav-tooltip {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Overpass Mono', monospace;
    font-size: 0.65rem;
    color: var(--sage-mute);
    letter-spacing: 0.06em;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.nav-dot:hover .nav-tooltip {
    opacity: 1;
}

/* --- Zone Delta (Fixed Status) --- */
#zone-delta {
    position: fixed;
    top: 32px;
    right: 32px;
    z-index: 150;
    text-align: right;
    font-family: 'Overpass Mono', monospace;
    font-size: clamp(0.65rem, 0.9vw, 0.78rem);
    color: var(--sage-mute);
    letter-spacing: 0.06em;
    opacity: 0;
}

body.loaded #zone-delta {
    opacity: 1;
    transition: opacity 0.5s ease 1.2s;
}

.delta-line {
    margin-bottom: 4px;
}

.delta-status {
    margin-top: 10px;
    font-weight: 500;
    color: var(--bright-phosphor);
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.7rem, 0.9vw, 0.8rem);
}

.delta-status.limited {
    color: var(--alert-amber);
    animation: amberPulse 2s ease-in-out infinite;
}

@keyframes amberPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* --- Zone Beta (Telemetry Sidebar) --- */
#zone-beta {
    position: fixed;
    top: 0;
    right: 0;
    width: 200px;
    height: 100vh;
    padding: 100px 16px 24px;
    z-index: 50;
    overflow-y: auto;
    overflow-x: hidden;
    border-left: 1px solid var(--phosphor-dim);
    background: rgba(7, 11, 7, 0.85);
    font-family: 'Overpass Mono', monospace;
    font-size: clamp(0.65rem, 0.9vw, 0.78rem);
    color: var(--sage-mute);
    letter-spacing: 0.06em;
    opacity: 0;
}

body.loaded #zone-beta {
    opacity: 1;
    transition: opacity 0.6s ease 1.5s;
}

#zone-beta::-webkit-scrollbar {
    width: 2px;
}
#zone-beta::-webkit-scrollbar-track {
    background: var(--void-black);
}
#zone-beta::-webkit-scrollbar-thumb {
    background: var(--phosphor-dim);
}

.telemetry-header {
    color: var(--phosphor-mid);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.telemetry-divider {
    height: 1px;
    background: var(--phosphor-dim);
    margin: 12px 0;
}

.telemetry-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0;
    gap: 4px;
}

.telemetry-label {
    color: var(--sage-mute);
    flex-shrink: 0;
}

.telemetry-value {
    color: var(--pale-screen);
    text-align: right;
    min-width: 36px;
}

.telemetry-unit {
    color: var(--phosphor-mid);
    flex-shrink: 0;
}

.telemetry-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#heartbeat-indicator {
    color: var(--bright-phosphor);
    animation: heartbeat 1.2s step-end infinite;
    font-size: 0.6rem;
}

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

/* --- Main Content --- */
#main-content {
    position: relative;
    z-index: 10;
    padding-left: 40px;
    padding-right: 220px;
}

/* --- Zone (Section) Styles --- */
.zone {
    min-height: 100vh;
    padding: 80px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

#zone-overview {
    background: var(--void-black);
}

#zone-capacity {
    background: var(--panel-dark);
}

#zone-network {
    background: var(--void-black);
}

#zone-archive {
    background: var(--panel-dark);
}

#zone-signal {
    background: var(--void-black);
    min-height: 200vh;
    justify-content: flex-start;
    padding-top: 120px;
}

/* --- Corner Bracket Motif --- */
.corner-bracket {
    position: relative;
    padding: 32px;
}

.corner-bracket::before,
.corner-bracket::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: var(--phosphor-mid);
    border-style: solid;
}

.corner-bracket::before {
    top: 0;
    left: 0;
    border-width: 1px 0 0 1px;
}

.corner-bracket::after {
    top: 0;
    right: 0;
    border-width: 1px 1px 0 0;
}

/* Additional corners via zone-content children */
.zone-content {
    position: relative;
}

.zone-content::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 16px;
    height: 16px;
    border-left: 1px solid var(--phosphor-mid);
    border-bottom: 1px solid var(--phosphor-mid);
}

.zone-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    border-right: 1px solid var(--phosphor-mid);
    border-bottom: 1px solid var(--phosphor-mid);
}

/* --- Zone Labels --- */
.zone-label {
    font-family: 'Overpass Mono', monospace;
    font-size: clamp(0.6rem, 0.8vw, 0.72rem);
    color: var(--phosphor-mid);
    letter-spacing: 0.1em;
    margin-bottom: 20px;
    text-transform: uppercase;
}

/* --- Zone Titles --- */
.zone-title {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: clamp(1.8rem, 3.5vw, 3.2rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--bright-phosphor);
    text-shadow: 0 0 8px rgba(74, 229, 74, 0.3);
    margin-bottom: 32px;
    line-height: 1.2;
}

.station-id {
    color: var(--bright-phosphor);
}

/* --- Zone Text --- */
.zone-text p,
.opening-text p {
    margin-bottom: 0;
    max-width: 680px;
}

.zone-text {
    margin-bottom: 40px;
}

/* --- Opening Sequence --- */
.opening-text .text-line {
    opacity: 0;
    transform: translateY(4px);
}

body.loaded .opening-text .text-line {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.opening-title {
    opacity: 0;
}

body.loaded .opening-title {
    opacity: 1;
    transition: opacity 0.4s ease 0.6s;
}

/* --- Capacity Meters --- */
.capacity-meter-group {
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 500px;
}

.capacity-meter {
    position: relative;
    cursor: default;
}

.meter-track {
    width: 100%;
    height: 3px;
    background: var(--panel-dark);
    border: 1px solid var(--phosphor-dim);
    position: relative;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    width: 0%;
    transition: width 1.2s ease-out;
    background: linear-gradient(90deg, var(--bright-phosphor) 0%, var(--alert-amber) 80%, var(--critical-red) 100%);
}

.capacity-meter.visible .meter-fill {
    width: var(--fill-width);
}

.capacity-meter.draining.visible .meter-fill {
    animation: drainMeter 8s ease-in-out forwards 2s;
}

@keyframes drainMeter {
    0% { width: var(--fill-width); }
    100% { width: 0%; }
}

.meter-tooltip {
    position: absolute;
    top: -24px;
    left: 0;
    font-family: 'Overpass Mono', monospace;
    font-size: clamp(0.6rem, 0.75vw, 0.7rem);
    color: var(--sage-mute);
    letter-spacing: 0.04em;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    pointer-events: none;
}

.capacity-meter:hover .meter-tooltip {
    opacity: 1;
}

/* --- Capacity Banner --- */
#capacity-banner {
    position: fixed;
    top: 80px;
    right: 220px;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.12em;
    color: var(--alert-amber);
    padding: 6px 16px;
    border: 1px solid var(--alert-amber);
    transform: translateX(120%);
    transition: transform 0.6s ease;
    z-index: 120;
    animation: none;
}

#capacity-banner.visible {
    transform: translateX(0);
    animation: amberPulse 2s ease-in-out infinite;
}

/* --- Network Visualization --- */
#network-viz {
    margin: 40px 0;
    max-width: 600px;
}

#network-svg {
    width: 100%;
    height: auto;
}

.net-link {
    stroke: var(--phosphor-mid);
    stroke-width: 1;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    fill: none;
}

.net-link.degraded {
    stroke-dasharray: 6 4;
    stroke-dashoffset: 1000;
}

.net-link.failed-link {
    stroke: var(--critical-red);
    opacity: 0.4;
    stroke-dasharray: 4 4;
    stroke-dashoffset: 1000;
}

.net-link.drawn {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 2s ease-in-out;
}

.net-link.degraded.drawn {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 2s ease-in-out;
}

.net-node {
    fill: var(--bright-phosphor);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.net-node.visible {
    opacity: 1;
}

.net-node.failed-node {
    fill: var(--critical-red);
    animation: failedPulse 1.5s ease-in-out infinite;
}

@keyframes failedPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* --- Degraded Text (Archive Zone) --- */
.degraded-text {
    position: relative;
}

/* --- Signal Zone Styles --- */
.signal-text .dim-text {
    color: var(--sage-mute);
}

.signal-text .dimmer-text {
    color: var(--phosphor-mid);
}

.signal-meters {
    margin-top: 40px;
}

/* --- Final Zone --- */
#final-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding-top: 200px;
}

#final-cursor {
    font-size: 1.2rem;
    color: var(--bright-phosphor);
    animation: cursorBlink 1.06s step-end infinite;
    margin-bottom: 24px;
}

@keyframes cursorBlink {
    0%, 49.9% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

#final-message {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.8rem, 1vw, 0.9rem);
    color: var(--phosphor-mid);
    letter-spacing: 0.08em;
    margin-bottom: 48px;
}

#final-line {
    width: 100%;
    height: 2px;
    background: var(--phosphor-dim);
    max-width: 100vw;
}

/* --- Text Critical --- */
.text-critical {
    color: var(--critical-red);
    font-weight: 500;
}

/* --- Diagonal Lines (Zone 3) --- */
#zone-network::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(12deg, transparent 48%, var(--phosphor-dim) 48%, var(--phosphor-dim) 48.15%, transparent 48.15%),
        linear-gradient(-12deg, transparent 48%, var(--phosphor-dim) 48%, var(--phosphor-dim) 48.15%, transparent 48.15%);
    pointer-events: none;
    opacity: 0.3;
    z-index: 0;
}

#zone-network .zone-content {
    position: relative;
    z-index: 1;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    #zone-beta {
        display: none;
    }
    #main-content {
        padding-right: 40px;
    }
    #capacity-banner {
        right: 20px;
    }
    #zone-delta {
        right: 16px;
        font-size: 0.6rem;
    }
}

@media (max-width: 600px) {
    .zone {
        padding: 60px 24px;
    }
    #main-content {
        padding-left: 28px;
        padding-right: 24px;
    }
    #nav-indicators {
        left: 4px;
    }
    .nav-dot {
        width: 6px;
        height: 6px;
    }
    .zone-title {
        font-size: clamp(1.2rem, 5vw, 1.8rem);
    }
}
