/* ═══════════════════════════════════════════════════════════
   TWINKLE SURVEILLANCE — Brutalist Interface
   ═══════════════════════════════════════════════════════════ */

:root {
    --black: #000000;
    --white: #ffffff;
    --gray-1: #111111;
    --gray-2: #1a1a1a;
    --gray-3: #333333;
    --gray-4: #666666;
    --gray-5: #999999;
    --gray-6: #cccccc;
    --panel-bg: rgba(0, 0, 0, 0.94);
    --border-color: #333333;
    --border-hard: #ffffff;
}

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

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    background: var(--black);
    font-family: 'JetBrains Mono', monospace;
    color: var(--white);
    -webkit-font-smoothing: antialiased;
}

/* ── Map Container ── */
#map {
    position: absolute;
    inset: 0;
    z-index: 0;
}

#deck-canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

/* ── HUD Bar ── */
#hud-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 44px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--black);
    border-bottom: 2px solid var(--white);
}

.hud-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    margin-right: auto;
    height: 100%;
}

.hud-brand .logo {
    font-size: 14px;
    color: var(--white);
    line-height: 1;
}

.hud-brand .name {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--white);
}

.hud-metric {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    height: 100%;
    border-left: 1px solid var(--border-color);
}

.hud-metric .label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--gray-5);
}

.hud-metric .value {
    font-size: 16px;
    font-weight: 700;
    color: var(--white);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.hud-link:hover .value { text-decoration: underline; }

.hud-divider {
    display: none;
}

/* WS Status */
.ws-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    height: 100%;
    border-left: 1px solid var(--border-color);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.ws-dot {
    width: 8px; height: 8px;
    background: var(--white);
    transition: background 0.3s;
}

.ws-status.connected .ws-dot { background: var(--white); }
.ws-status.connected .ws-text { color: var(--white); }
.ws-status.reconnecting .ws-dot { background: var(--gray-5); animation: blink 1s step-end infinite; }
.ws-status.reconnecting .ws-text { color: var(--gray-5); }
.ws-status.disconnected .ws-dot { background: var(--gray-4); }
.ws-status.disconnected .ws-text { color: var(--gray-4); }

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

/* ── Aircraft Panel ── */
#aircraft-panel {
    position: fixed;
    top: 44px;
    left: 0;
    width: 360px;
    bottom: 0;
    z-index: 90;
    background: var(--panel-bg);
    border-right: 2px solid var(--white);
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--border-color);
}

.panel-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--gray-5);
    margin-bottom: 8px;
}

.panel-search {
    width: 100%;
    padding: 7px 10px;
    background: var(--gray-1);
    border: 1px solid var(--border-color);
    border-radius: 0;
    color: var(--white);
    font-family: inherit;
    font-size: 11px;
    outline: none;
    transition: border-color 0.15s;
}

.panel-search::placeholder { color: var(--gray-4); }
.panel-search:focus { border-color: var(--white); }

/* Aircraft Table */
.ac-table-wrap {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.ac-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.ac-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--black);
}

.ac-table th {
    padding: 8px 8px 6px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--gray-4);
    text-align: left;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    transition: color 0.15s;
}

.ac-table th:hover { color: var(--white); }
.ac-table th.sorted { color: var(--white); }
.ac-table th .sort-arrow { margin-left: 3px; font-size: 8px; }

.ac-table td {
    padding: 6px 8px;
    font-weight: 400;
    color: var(--gray-6);
    border-bottom: 1px solid var(--gray-2);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ac-table tr {
    cursor: pointer;
    transition: background 0.1s;
}

.ac-table tr:hover { background: var(--gray-2); }
.ac-table tr.selected { background: var(--gray-3); }
.ac-table tr.selected td { color: var(--white); }
.ac-table tr.stale td { color: var(--gray-4); }

.ac-table .col-icao { font-weight: 700; color: var(--white); }
.ac-table tr.stale .col-icao { color: var(--gray-4); }

/* Custom Scrollbar */
.ac-table-wrap::-webkit-scrollbar { width: 3px; }
.ac-table-wrap::-webkit-scrollbar-track { background: transparent; }
.ac-table-wrap::-webkit-scrollbar-thumb { background: var(--gray-3); }
.ac-table-wrap::-webkit-scrollbar-thumb:hover { background: var(--gray-5); }

/* ── Detail Card ── */
#detail-card {
    position: fixed;
    bottom: 0; left: 360px; right: 0;
    z-index: 90;
    background: var(--panel-bg);
    border-top: 2px solid var(--white);
    display: none;
    padding: 16px 24px;
    gap: 32px;
}

#detail-card.visible {
    display: flex;
    align-items: flex-start;
}

.detail-identity {
    min-width: 140px;
}

.detail-icao {
    font-size: 24px;
    font-weight: 700;
    color: var(--white);
    letter-spacing: 3px;
}

.detail-callsign {
    font-size: 12px;
    color: var(--gray-5);
    margin-top: 4px;
    letter-spacing: 1px;
}

.detail-close {
    position: absolute;
    top: 12px; right: 16px;
    background: none;
    border: 1px solid var(--gray-3);
    color: var(--gray-5);
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 4px 12px;
    border-radius: 0;
    cursor: pointer;
    text-transform: uppercase;
    transition: color 0.15s, border-color 0.15s;
}

.detail-close:hover {
    color: var(--white);
    border-color: var(--white);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px 28px;
    flex: 1;
}

.detail-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-stat .label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--gray-4);
}

.detail-stat .value {
    font-size: 15px;
    font-weight: 500;
    color: var(--white);
    font-variant-numeric: tabular-nums;
}

/* ── Vert Rate indicator ── */
.vr-up { color: var(--white); }
.vr-down { color: var(--gray-5); }

/* ── Init Overlay ── */
#init-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: var(--black);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s;
}
#init-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}
.init-content { text-align: center; }
.init-logo {
    font-size: 28px;
    color: var(--white);
    margin-bottom: 16px;
}
.init-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 6px;
    color: var(--white);
    margin-bottom: 24px;
}
.init-status {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--gray-5);
    margin-bottom: 16px;
}
.init-bar {
    width: 240px;
    height: 2px;
    background: var(--gray-3);
    margin: 0 auto 16px;
    overflow: hidden;
}
.init-bar-fill {
    width: 0%;
    height: 100%;
    background: var(--white);
    transition: width 0.5s linear;
}
.init-sub {
    font-size: 9px;
    color: var(--gray-4);
    letter-spacing: 1px;
}

/* ── Refuel Overlay ── */
#refuel-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
}
.refuel-card {
    background: var(--black);
    border: 2px solid var(--white);
    padding: 32px 40px;
    max-width: 420px;
    text-align: center;
}
.refuel-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 4px;
    margin-bottom: 20px;
}
.refuel-body { margin-bottom: 24px; font-size: 12px; color: var(--gray-5); line-height: 1.8; }
.refuel-btn {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    background: none;
    border: 1px solid var(--gray-3);
    color: var(--white);
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 3px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}
.refuel-btn:hover { border-color: var(--white); }

/* ── MapLibre Overrides ── */
.maplibregl-ctrl-top-right {
    top: 52px;
}

.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right {
    opacity: 0.2;
    transition: opacity 0.3s;
}
.maplibregl-ctrl-bottom-left:hover,
.maplibregl-ctrl-bottom-right:hover { opacity: 0.6; }

.maplibregl-ctrl-group {
    background: var(--black) !important;
    border: 1px solid var(--gray-3) !important;
    border-radius: 0 !important;
}

.maplibregl-ctrl-group button {
    filter: invert(0.9);
}

.maplibregl-ctrl-attrib-inner {
    color: var(--gray-4) !important;
    font-size: 9px !important;
}

/* ── Responsive: <768px ── */
@media (max-width: 768px) {
    #aircraft-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0; right: 0;
        width: 100%;
        height: 40vh;
        border-right: none;
        border-top: 2px solid var(--white);
    }

    #detail-card {
        left: 0;
        flex-wrap: wrap;
        bottom: 40vh;
    }

    .hud-brand .name {
        font-size: 9px;
        letter-spacing: 2px;
    }

    .hud-metric .value { font-size: 14px; }
    .hud-metric { padding: 0 12px; }
}
