@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700;900&family=Barlow:wght@300;400;500;600&family=Share+Tech+Mono&display=swap');

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

:root {
    --console-dark: #1C1C28;
    --console-deeper: #0A0A14;
    --panel-surface: #22222E;
    --panel-border: #3D3D52;
    --label-bar-bg: #2A2A3A;
    --amber: #F59E0B;
    --green: #4ADE80;
    --cream: #E8E0D4;
    --alert-red: #FF6B6B;
    --dim-readout: #6B7B8D;
    --header-bg: #18182A;
    --grid-color: #2A2A3A;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--console-deeper);
    color: var(--cream);
    font-family: 'Barlow', sans-serif;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    line-height: 1.75;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Boot Overlay */
.boot-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--console-deeper);
    z-index: 9999;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.8s ease-out;
}

.boot-overlay.fade-out {
    opacity: 0;
}

/* Console Surface with Grid */
.console-surface {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background-color: var(--console-dark);
    pointer-events: none;
}

.console-surface::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.08;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 40px 40px;
}

/* Mission Header */
.mission-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
    padding: 0 24px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--amber);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.mission-header.visible {
    opacity: 1;
}

.mission-header .header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-mission-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.06em;
    color: var(--cream);
    white-space: nowrap;
    overflow: hidden;
    border-right: 2px solid var(--amber);
    width: 0;
    animation: none;
}

.header-mission-text.typing {
    animation: typewriter 0.8s steps(30, end) forwards, blink-caret 0.5s step-end 4;
    width: 100%;
}

@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink-caret {
    50% { border-color: transparent; }
}

.header-center {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-clock {
    font-family: 'Share Tech Mono', monospace;
    font-size: 16px;
    letter-spacing: 0.08em;
    color: var(--amber);
}

.header-clock-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--dim-readout);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-met-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--dim-readout);
}

.header-met {
    font-family: 'Share Tech Mono', monospace;
    font-size: 16px;
    letter-spacing: 0.08em;
    color: var(--green);
}

.header-met.flash {
    color: var(--amber);
}

/* Mission Patch SVG */
.mission-patch {
    flex-shrink: 0;
}

/* Dashboard Grid */
.dashboard-grid {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto;
    gap: 8px;
    padding: 80px 16px 16px;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 64px - 48px);
}

/* Bento Panels */
.bento-panel {
    background: var(--panel-surface);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.97);
    cursor: pointer;
}

.bento-panel.boot-ready {
    transition: opacity 0.4s ease, transform 0.4s ease, border-color 0.2s ease;
}

.bento-panel.visible {
    opacity: 1;
    transform: scale(1);
}

.bento-panel.border-drawn {
    border-color: var(--panel-border);
}

.bento-panel:hover {
    border-color: var(--amber);
}

/* Panel Label Bar */
.panel-label-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 28px;
    padding: 0 10px;
    background: var(--label-bar-bg);
    border-bottom: 1px solid var(--panel-border);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bento-panel.label-visible .panel-label-bar {
    opacity: 1;
}

.panel-id {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--dim-readout);
}

.panel-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 400;
    font-size: 9px;
    letter-spacing: 0.12em;
    color: var(--dim-readout);
    text-transform: uppercase;
    flex: 1;
}

/* Status Lights */
.status-light {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bento-panel.light-active .status-light {
    opacity: 1;
}

.status-light.active {
    background: var(--green);
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
    animation: pulse-green 2s ease-in-out infinite;
}

.status-light.standby {
    background: var(--amber);
    box-shadow: 0 0 4px rgba(245, 158, 11, 0.4);
}

@keyframes pulse-green {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.bento-panel:hover .status-light.active {
    animation-duration: 0.8s;
}

/* Panel Content */
.panel-content {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.bento-panel.content-visible .panel-content {
    opacity: 1;
}

/* Star Map Panel (spans 2 cols and 2 rows) */
.starmap-panel {
    grid-column: span 2;
    grid-row: span 2;
    min-height: 350px;
}

.starmap-content {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 300px;
}

#starmap-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.starmap-label-aiice {
    position: absolute;
    top: 50%;
    left: 55%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.15em;
    color: var(--amber);
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease;
}

.starmap-label-aiice.visible {
    opacity: 1;
}

/* Gauge Panels */
.gauge-panel {
    min-height: 260px;
}

.gauge-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    height: calc(100% - 28px);
}

.gauge-svg {
    width: 150px;
    height: 150px;
}

.gauge-track {
    opacity: 0.6;
}

.gauge-needle {
    transition: transform 1.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: 100px 100px;
}

.gauge-readout {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-top: 8px;
}

.gauge-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 22px;
    letter-spacing: 0.04em;
    color: var(--amber);
}

.gauge-value.green {
    color: var(--green);
}

.gauge-unit {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--dim-readout);
}

.gauge-unit.green {
    color: var(--green);
}

.gauge-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.06em;
    color: var(--dim-readout);
    margin-top: 4px;
    opacity: 0.6;
}

/* Gauge Tick Marks */
.gauge-tick {
    stroke: var(--cream);
    stroke-width: 1;
    opacity: 0.4;
}

/* Waveform Panels */
.waveform-panel {
    min-height: 140px;
}

.wave-content {
    position: relative;
    width: 100%;
    height: calc(100% - 28px);
    min-height: 100px;
}

.wave-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.waveform-panel:hover .wave-canvas {
    filter: brightness(1.3);
}

/* Narrative Panel */
.narrative-panel {
    grid-column: span 2;
    min-height: 180px;
}

.narrative-content {
    padding: 20px;
}

.narrative-text {
    font-family: 'Barlow', sans-serif;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    line-height: 1.75;
    color: var(--cream);
    margin-bottom: 12px;
}

.narrative-text.secondary {
    font-weight: 300;
    color: rgba(232, 224, 212, 0.6);
}

.narrative-meta {
    display: flex;
    gap: 20px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--panel-border);
}

.meta-item {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--dim-readout);
}

/* Telemetry Panel */
.telemetry-content {
    padding: 10px;
}

.telemetry-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 6px;
    border-bottom: 1px solid rgba(61, 61, 82, 0.3);
}

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

.telem-key {
    font-family: 'Orbitron', sans-serif;
    font-weight: 400;
    font-size: 9px;
    letter-spacing: 0.08em;
    color: var(--dim-readout);
}

.telem-val {
    font-family: 'Share Tech Mono', monospace;
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--amber);
}

.telem-val.green {
    color: var(--green);
}

/* Status Panel */
.status-content {
    padding: 10px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    border-bottom: 1px solid rgba(61, 61, 82, 0.2);
}

.status-item:last-child {
    border-bottom: none;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.active {
    background: var(--green);
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
    animation: pulse-green 2s ease-in-out infinite;
}

.status-dot.standby {
    background: var(--amber);
    box-shadow: 0 0 4px rgba(245, 158, 11, 0.3);
}

.status-dot.alert {
    background: var(--alert-red);
    box-shadow: 0 0 4px rgba(255, 107, 107, 0.4);
    animation: pulse-red 1.5s ease-in-out infinite;
}

@keyframes pulse-red {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.status-name {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--dim-readout);
    flex: 1;
}

.status-val {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.04em;
    color: var(--green);
}

.status-val.standby {
    color: var(--amber);
}

.status-val.alert {
    color: var(--alert-red);
}

/* Trajectory Lines Overlay */
.trajectory-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease;
}

.trajectory-overlay.visible {
    opacity: 1;
}

.trajectory-line {
    fill: none;
    stroke: var(--amber);
    stroke-width: 1;
    opacity: 0.25;
}

.trajectory-dot {
    fill: var(--green);
    r: 3;
}

/* Telemetry Footer */
.telemetry-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 48px;
    display: flex;
    align-items: center;
    background: var(--header-bg);
    border-top: 1px solid var(--panel-border);
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.telemetry-footer.visible {
    opacity: 1;
}

.telemetry-ticker {
    display: flex;
    align-items: center;
    white-space: nowrap;
    animation: ticker-scroll 60s linear infinite;
    gap: 60px;
    padding-left: 100%;
}

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

.ticker-item {
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.06em;
    color: var(--dim-readout);
    flex-shrink: 0;
}

.ticker-item.amber {
    color: var(--amber);
}

.ticker-item.green {
    color: var(--green);
}

/* Panel Expand Overlay */
.panel-expand-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 20, 0.85);
    z-index: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.panel-expand-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Expanded Panel State */
.bento-panel.expanded {
    position: fixed;
    top: 80px;
    left: 24px;
    right: 24px;
    bottom: 64px;
    z-index: 600;
    border-color: var(--amber);
    transform: none;
    grid-column: unset;
    grid-row: unset;
}

.bento-panel.dimmed {
    opacity: 0.15;
    pointer-events: none;
}

/* Radar Ping */
@keyframes radar-ping {
    0% {
        r: 5;
        opacity: 0.8;
    }
    100% {
        r: 30;
        opacity: 0;
    }
}

/* Tablet layout */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .starmap-panel {
        grid-column: span 2;
        grid-row: span 1;
        min-height: 280px;
    }

    .narrative-panel {
        grid-column: span 2;
    }
}

/* Mobile layout */
@media (max-width: 640px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        padding: 76px 8px 60px;
        gap: 6px;
    }

    .starmap-panel,
    .narrative-panel {
        grid-column: 1;
        grid-row: span 1;
    }

    .mission-header {
        height: 52px;
        padding: 0 12px;
    }

    .header-center {
        display: none;
    }

    .telemetry-footer {
        height: 36px;
    }

    .gauge-svg {
        width: 120px;
        height: 120px;
    }
}
