/* ============================================================
   Global Space Explorer — Mission Console theme
   ============================================================ */

:root {
    --bg:            #05070d;
    --panel:         #0b0f1a;
    --panel-2:       #101623;
    --border:        #1c2537;
    --border-hi:     #2b3a55;
    --text:          #c9d4e3;
    --text-dim:      #7d8aa0;
    --text-faint:    #55617a;
    --accent:        #4cc9f0;
    --accent-dim:    #2a7fa8;
    --amber:         #f0b429;
    --green:         #7ee787;
    --red:           #ff6a5e;
    --mono:          "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", Menlo, monospace;
    --sans:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --panel-w:       380px;
    --topbar-h:      52px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
}

/* ---------------- Top bar ---------------- */

#topbar {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    background: linear-gradient(180deg, #0c1220 0%, #090d17 100%);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 30;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand h1 {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: #e8f1fb;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand h1 span { color: var(--accent); font-weight: 400; letter-spacing: 1.5px; }

.topbar-status {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 18px;
}

.utc-clock {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.link-status {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 1.5px;
    color: var(--text-dim);
}

.link-status .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-faint);
}

.link-status[data-state="live"] .dot   { background: var(--green);  box-shadow: 0 0 8px var(--green); }
.link-status[data-state="live"]        { color: var(--green); }
.link-status[data-state="error"] .dot  { background: var(--red);    box-shadow: 0 0 8px var(--red); }
.link-status[data-state="error"]       { color: var(--red); }
.link-status[data-state="busy"] .dot   { background: var(--amber);  box-shadow: 0 0 8px var(--amber); animation: pulse 1s infinite; }
.link-status[data-state="busy"]        { color: var(--amber); }

@keyframes pulse { 50% { opacity: 0.35; } }

/* Hamburger (mobile) */
#menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 34px; height: 34px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 8px;
}
#menu-toggle span { display: block; height: 2px; background: var(--text-dim); border-radius: 1px; }

/* ---------------- Layout ---------------- */

#layout {
    display: flex;
    height: calc(100% - var(--topbar-h));
}

#panel {
    width: var(--panel-w);
    min-width: var(--panel-w);
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 20;
}

#viewport-container {
    flex: 1;
    position: relative;
    min-width: 0;
    background: radial-gradient(ellipse at 60% 40%, #0a1020 0%, var(--bg) 65%);
}

#scene-canvas { display: block; width: 100%; height: 100%; }

/* ---------------- Tabs ---------------- */

#tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--panel-2);
}

.tab {
    flex: 1;
    padding: 11px 4px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.tab:hover  { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.panel-body {
    overflow-y: auto;
    padding: 18px 16px 28px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.panel-body::-webkit-scrollbar { width: 6px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.tab-page { display: none; }
.tab-page.active { display: block; animation: fadein 0.25s ease; }

@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }

.lede {
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--text-dim);
    margin: 0 0 16px;
}

/* ---------------- Cards ---------------- */

.card {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 15px;
    margin-bottom: 14px;
}

.card h3 {
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 600;
    color: #eef4fb;
    letter-spacing: 0.3px;
}

.card p {
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-dim);
    margin: 0 0 10px;
}
.card p:last-child { margin-bottom: 0; }

.card .meta {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--accent);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.card code { font-family: var(--mono); font-size: 11px; color: var(--accent); }

label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-faint);
    margin: 12px 0 5px;
}

select, button {
    width: 100%;
    background: #0d1322;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 9px 10px;
    font-size: 12.5px;
    font-family: var(--sans);
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

select:hover, select:focus { border-color: var(--accent-dim); }

button.primary {
    margin-top: 14px;
    background: linear-gradient(180deg, #143349 0%, #0e2536 100%);
    border: 1px solid var(--accent-dim);
    color: #bfeaff;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    font-size: 11px;
    padding: 10px;
}

button.primary:hover {
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 14px rgba(76, 201, 240, 0.25);
}

button.ghost {
    margin-top: 10px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 11px;
    letter-spacing: 0.6px;
}
button.ghost:hover { border-color: var(--accent-dim); color: var(--accent); }

.mission-meta {
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.7;
    color: var(--text-dim);
    background: #0d1322;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 12px;
    white-space: pre-line;
}

/* Legend */
.legend { list-style: none; margin: 4px 0 10px; padding: 0; }
.legend li {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12px;
    color: var(--text-dim);
    padding: 3px 0;
}
.swatch {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--c);
    box-shadow: 0 0 7px var(--c);
    flex-shrink: 0;
}

.hint { font-size: 11.5px; color: var(--text-faint); line-height: 1.6; margin: 0; }

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
    font-size: 12px;
    text-transform: none;
    letter-spacing: 0.2px;
    color: var(--text-dim);
    cursor: pointer;
}
.toggle input {
    accent-color: var(--accent);
    width: 14px; height: 14px;
    margin: 0;
    cursor: pointer;
}

a.mail {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dotted var(--accent-dim);
}
a.mail:hover { color: #bfeaff; border-bottom-style: solid; }

.status-note { margin-left: auto; color: var(--text-faint); opacity: 0.8; }

.toggle-note { color: var(--text-faint); font-size: 10.5px; margin-left: 4px; }

.legend-toggle { margin: 2px 0; }
.legend-toggle input { flex-shrink: 0; }

/* ---------------- Controls hint (viewport overlay) ---------------- */

#controls-hint {
    position: absolute;
    left: 16px;
    bottom: 40px;
    display: flex;
    gap: 16px;
    padding: 7px 12px;
    background: rgba(9, 13, 23, 0.66);
    backdrop-filter: blur(6px);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.6px;
    color: var(--text-faint);
    pointer-events: none;
    z-index: 9;
    white-space: nowrap;
}
#controls-hint b { color: var(--text-dim); font-weight: 600; }

/* ---------------- Launch timeline ---------------- */

#launch-timeline {
    position: relative;
    padding: 6px 0 2px;
    max-height: 300px;
    overflow-y: auto;
}

#launch-timeline::before {
    content: '';
    position: absolute;
    left: 46px;
    top: 0; bottom: 0;
    width: 1px;
    background: var(--border);
}

.tl-item {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding: 5px 4px 5px 0;
    cursor: pointer;
    border-radius: 5px;
}
.tl-item:hover { background: rgba(76, 201, 240, 0.06); }

.tl-year {
    width: 38px;
    text-align: right;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-faint);
    flex-shrink: 0;
}

.tl-item::after {
    content: '';
    position: absolute;
    left: 43.5px;
    top: 50%;
    width: 6px; height: 6px;
    margin-top: -3px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.15s, box-shadow 0.15s;
}

.tl-name {
    font-size: 12px;
    color: var(--text-dim);
    padding-left: 8px;
}

.tl-item.active .tl-name { color: var(--accent); }
.tl-item.active .tl-year { color: var(--text-dim); }
.tl-item.active::after { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* ---------------- Probe tracker overlay ---------------- */

#probe-tracker {
    position: absolute;
    left: 50%;
    bottom: 44px;
    transform: translateX(-50%);
    width: min(560px, calc(100% - 32px));
    background: rgba(9, 13, 23, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px 10px;
    z-index: 12;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
#probe-tracker.hidden { display: none; }

.tracker-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

#tracker-play {
    width: 28px; height: 28px;
    padding: 0;
    flex-shrink: 0;
    background: #0d1322;
    border: 1px solid var(--accent-dim);
    border-radius: 50%;
    color: var(--accent);
    font-size: 10px;
    line-height: 1;
}
#tracker-play:hover { border-color: var(--accent); color: #fff; }

#tracker-name {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--accent);
    letter-spacing: 0.5px;
}

.tracker-year {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 16px;
    color: #eef4fb;
    font-variant-numeric: tabular-nums;
}

.tracker-slider-wrap { position: relative; height: 22px; }

#tracker-ticks {
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 8px;
    pointer-events: none;
}
.tracker-tick {
    position: absolute;
    top: 0;
    left: var(--x);
    width: 2px; height: 8px;
    margin-left: -1px;
    background: var(--amber);
    opacity: 0.8;
    border-radius: 1px;
}

#tracker-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    margin: 12px 0 0;
    background: #1c2537;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
#tracker-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px rgba(76, 201, 240, 0.6);
    cursor: grab;
}
#tracker-slider::-moz-range-thumb {
    width: 14px; height: 14px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px rgba(76, 201, 240, 0.6);
    cursor: grab;
}

.tracker-readouts {
    display: flex;
    gap: 24px;
    margin-top: 8px;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.8px;
    color: var(--text-faint);
}
.tracker-readouts b {
    color: #eef4fb;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

.tracker-gauge { margin-top: 10px; }

.gauge-track {
    position: relative;
    height: 26px;
    border-top: 1px solid var(--border);
}
.gauge-mark {
    position: absolute;
    left: var(--x);
    top: 4px;
    transform: translateX(-50%);
    font-family: var(--mono);
    font-size: 8.5px;
    letter-spacing: 0.4px;
    color: var(--text-faint);
    white-space: nowrap;
}
.gauge-mark::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -5px;
    width: 1px; height: 4px;
    background: var(--text-faint);
}

#gauge-needle {
    position: absolute;
    left: 0;
    top: -5px;
    width: 2px; height: 9px;
    margin-left: -1px;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    border-radius: 1px;
    transition: left 0.2s linear;
}

/* ---------------- Moon cards ---------------- */

.moon-card .crew {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

@media (max-width: 900px) {
    #controls-hint { display: none; }
    #probe-tracker { bottom: 36px; padding: 10px 12px 8px; }
    .gauge-mark { font-size: 7.5px; }
}

kbd {
    font-family: var(--mono);
    font-size: 10px;
    background: #171f30;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--text);
}

/* ---------------- HUD & overlays ---------------- */

.hud {
    position: absolute;
    top: 16px;
    right: 16px;
    min-width: 230px;
    max-width: 300px;
    background: rgba(9, 13, 23, 0.88);
    backdrop-filter: blur(6px);
    border: 1px solid var(--border);
    border-left: 2px solid var(--accent);
    border-radius: 6px;
    padding: 11px 14px;
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.7;
    color: var(--text);
    pointer-events: none;
    z-index: 10;
}

.hud-title {
    font-size: 9.5px;
    letter-spacing: 2px;
    color: var(--accent);
    margin-bottom: 4px;
}

#statusbar {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    display: flex;
    gap: 24px;
    padding: 7px 16px;
    background: rgba(7, 10, 18, 0.85);
    backdrop-filter: blur(6px);
    border-top: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--text-faint);
    z-index: 10;
    overflow-x: auto;
    white-space: nowrap;
}
#statusbar span b { color: var(--text-dim); font-weight: 400; }

/* Selected satellite card */
.sat-card {
    position: absolute;
    right: 16px;
    bottom: 44px;
    width: 270px;
    background: rgba(9, 13, 23, 0.92);
    backdrop-filter: blur(8px);
    border: 1px solid var(--accent-dim);
    border-radius: 8px;
    padding: 13px 15px;
    z-index: 11;
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
    animation: fadein 0.2s ease;
}

.sat-card.hidden { display: none; }

.sat-name {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--accent);
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-right: 20px;
}

.sat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 14px;
}

.sat-grid label {
    margin: 0 0 2px;
    font-size: 9px;
    letter-spacing: 1px;
}

.sat-grid span {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text);
}

.card-close {
    position: absolute;
    top: 6px; right: 6px;
    width: 24px; height: 24px;
    padding: 0;
    background: none;
    border: none;
    color: var(--text-faint);
    font-size: 16px;
    line-height: 1;
}
.card-close:hover { color: var(--text); }

/* ---------------- Responsive ---------------- */

@media (max-width: 900px) {
    #menu-toggle { display: flex; }

    #panel {
        position: absolute;
        top: var(--topbar-h);
        bottom: 0;
        left: 0;
        width: min(var(--panel-w), 86vw);
        min-width: 0;
        transform: translateX(-102%);
        transition: transform 0.25s ease;
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.5);
    }

    body.panel-open #panel { transform: translateX(0); }

    .utc-clock { display: none; }
    .hud { max-width: 55vw; min-width: 0; }
    .sat-card { width: min(270px, 80vw); }
}
