/* =====================================================================
   UNDERpunks — Sol System Orrery
   HUD chrome for the canvas chart. The map itself is drawn in
   js/renderer.js; everything here is the instrument panel around it.
   ===================================================================== */

:root {
    --bg: #03060c;
    --panel: linear-gradient(160deg, rgba(10, 24, 38, 0.92), rgba(4, 10, 18, 0.95));
    --ink: #e2f4ff;
    --ink-dim: #8fb0c3;
    --ink-faint: #5d7889;
    --cyan: #5fe8ff;
    --cyan-ghost: rgba(95, 232, 255, 0.09);
    --amber: #ffb648;
    --line: rgba(110, 190, 225, 0.2);
    --line-soft: rgba(110, 190, 225, 0.1);
    --danger: #ff7a5c;
    --font: "Cascadia Mono", "JetBrains Mono", "SF Mono", "Consolas", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html,
body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 12px;
    line-height: 1.45;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

#sky {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    cursor: grab;
}

#sky.dragging { cursor: grabbing; }

/* ---------------------------------------------------------------------
   HUD scaffold
   --------------------------------------------------------------------- */

.hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr) 318px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
        "top top top"
        "left mid right"
        "bottom bottom bottom";
}

/* Film grain-ish scanlines and a vignette, both inert. */
.hud::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 200px 30px rgba(0, 0, 0, 0.78);
}

.hud::after {
    content: "";
    position: absolute;
    inset: -3px 0 0;
    pointer-events: none;
    background: repeating-linear-gradient(180deg,
            rgba(255, 255, 255, 0.03) 0 1px,
            rgba(0, 0, 0, 0) 1px 3px);
    mix-blend-mode: overlay;
    animation: scan-drift 9s linear infinite;
}

@keyframes scan-drift {
    from { transform: translateY(0); }
    to { transform: translateY(3px); }
}

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

.topbar {
    grid-area: top;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 12px 18px 10px;
    background: linear-gradient(180deg, rgba(3, 8, 14, 0.94), rgba(3, 8, 14, 0.45) 72%, rgba(3, 8, 14, 0));
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    text-decoration: none;
    flex: 0 0 auto;
}

.brand-mark {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: var(--cyan);
    stroke-width: 1.1;
    filter: drop-shadow(0 0 6px rgba(95, 232, 255, 0.45));
}

.brand-mark circle { fill: var(--cyan); stroke: none; }

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-text b {
    font-size: 13px;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    font-weight: 700;
}

.brand-text i {
    font-style: normal;
    font-size: 8.5px;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.status {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px;
    border: 1px solid var(--line);
    background: rgba(6, 16, 26, 0.7);
    font-size: 8.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-dim);
    white-space: nowrap;
}

.pill.live { color: var(--cyan); border-color: rgba(95, 232, 255, 0.34); }

.led {
    width: 5px;
    height: 5px;
    background: var(--cyan);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--cyan);
    animation: led-pulse 2.4s ease-in-out infinite;
}

@keyframes led-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.dateblock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
    flex: 0 0 auto;
}

.date-main {
    font-size: 15px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.date-sub {
    font-size: 8.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
    white-space: nowrap;
}

/* ---------------------------------------------------------------------
   Panels
   --------------------------------------------------------------------- */

.panel {
    position: relative;
    pointer-events: auto;
    margin: 4px 10px 10px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow:
        inset 0 0 0 1px rgba(95, 232, 255, 0.035),
        0 24px 60px -40px #000;
    clip-path: polygon(0 14px, 14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%);
}

.panel-left { grid-area: left; }
.panel-right { grid-area: right; }

.panel::before {
    content: "";
    position: absolute;
    top: 6px;
    right: 6px;
    width: 16px;
    height: 1px;
    background: var(--cyan);
    opacity: 0.5;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px 9px;
    border-bottom: 1px solid var(--line-soft);
}

.panel-head.sub {
    border-top: 1px solid var(--line-soft);
    padding-top: 10px;
}

.panel-title {
    font-size: 8.5px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--ink-dim);
    font-weight: 700;
}

.panel-note {
    font-size: 8.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.panel-foot {
    padding: 10px 14px 12px;
    border-top: 1px solid var(--line-soft);
    background: rgba(2, 7, 12, 0.4);
}

.foot-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-faint);
    padding: 2px 0;
}

.foot-row b {
    color: var(--ink-dim);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.tiny {
    margin: 8px 0 0;
    font-size: 9.5px;
    line-height: 1.55;
    letter-spacing: 0.02em;
    color: var(--ink-faint);
}

code {
    font-family: inherit;
    color: var(--cyan);
    font-size: 0.95em;
}

/* ---------------------------------------------------------------------
   Body roster
   --------------------------------------------------------------------- */

.roster {
    list-style: none;
    margin: 0;
    padding: 4px 6px 6px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(95, 232, 255, 0.35) transparent;
}

.roster-row {
    position: relative;
    display: grid;
    grid-template-columns: 9px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 8px 9px 9px;
    cursor: pointer;
    border: 1px solid transparent;
    color: var(--ink-dim);
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.roster-row + .roster-row::before {
    content: "";
    position: absolute;
    left: 9px;
    right: 9px;
    top: 0;
    height: 1px;
    background: var(--line-soft);
}

.roster-row:hover,
.roster-row:focus-visible {
    background: var(--cyan-ghost);
    border-color: rgba(95, 232, 255, 0.28);
    color: var(--ink);
    outline: none;
}

.roster-row[aria-pressed="true"] {
    background: rgba(95, 232, 255, 0.12);
    border-color: rgba(95, 232, 255, 0.45);
    color: var(--ink);
}

.r-dot {
    width: 7px;
    height: 7px;
    background: var(--c, #fff);
    box-shadow: 0 0 8px var(--c, #fff);
}

.r-name {
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.r-meta {
    display: flex;
    gap: 6px;
    align-items: baseline;
    font-size: 9px;
    letter-spacing: 0.08em;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.r-meta b {
    color: var(--cyan);
    font-weight: 700;
}

.r-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 1px;
    width: var(--w, 0%);
    background: linear-gradient(90deg, transparent, var(--c, var(--cyan)));
    opacity: 0.55;
}

/* ---------------------------------------------------------------------
   Telemetry
   --------------------------------------------------------------------- */

.telemetry {
    padding: 12px 14px 14px;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(95, 232, 255, 0.35) transparent;
}

.tgt-head {
    display: flex;
    align-items: center;
    gap: 9px;
}

.tgt-swatch {
    width: 9px;
    height: 9px;
    background: var(--c, #fff);
    box-shadow: 0 0 12px var(--c, #fff);
    flex: 0 0 auto;
}

.tgt-name {
    font-size: 17px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-weight: 700;
    line-height: 1.1;
}

.tgt-sub {
    margin: 6px 0 0;
    font-size: 8.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    margin: 12px 0 0;
    background: var(--line-soft);
    border: 1px solid var(--line-soft);
}

.grid > div {
    background: rgba(3, 9, 15, 0.86);
    padding: 7px 9px 8px;
    min-width: 0;
}

.grid .wide { grid-column: span 2; }

.grid dt {
    font-size: 8px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.grid dd {
    margin: 3px 0 0;
    font-size: 11.5px;
    letter-spacing: 0.04em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid dd .unit {
    color: var(--ink-faint);
    font-size: 9.5px;
    margin-left: 3px;
}

.occupancy {
    margin: 12px 0 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.occ-row {
    display: flex;
    gap: 8px;
    font-size: 9.5px;
    color: var(--ink-dim);
    letter-spacing: 0.05em;
}

.occ-row b {
    color: var(--cyan);
    font-weight: 700;
    width: 20px;
    flex: 0 0 auto;
}

.occ-row span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note {
    margin: 12px 0 0;
    padding: 8px 10px;
    border-left: 2px solid rgba(95, 232, 255, 0.45);
    background: rgba(95, 232, 255, 0.05);
    font-size: 9.5px;
    line-height: 1.55;
    color: var(--ink-dim);
}

.warn {
    color: var(--danger);
    border-left-color: var(--danger);
    background: rgba(255, 122, 92, 0.07);
}

/* ---------------------------------------------------------------------
   Chips and buttons
   --------------------------------------------------------------------- */

.chips {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    padding: 10px 14px 12px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 9px;
    font-family: var(--font);
    font-size: 8.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-faint);
    background: rgba(5, 13, 21, 0.7);
    border: 1px solid var(--line-soft);
    cursor: pointer;
    transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.chip::before {
    content: "";
    width: 4px;
    height: 4px;
    background: currentColor;
    opacity: 0.5;
    flex: 0 0 auto;
}

.chip:hover {
    color: var(--ink);
    border-color: rgba(95, 232, 255, 0.32);
}

.chip[aria-pressed="true"] {
    color: var(--cyan);
    border-color: rgba(95, 232, 255, 0.42);
    background: rgba(95, 232, 255, 0.08);
}

.chip[aria-pressed="true"]::before { opacity: 1; box-shadow: 0 0 8px var(--cyan); }

.chip.cycle { grid-column: span 2; justify-content: center; color: var(--amber); border-color: rgba(255, 182, 72, 0.34); }
.chip.cycle:hover { border-color: rgba(255, 182, 72, 0.6); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 11px;
    font-family: var(--font);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-dim);
    background: rgba(6, 15, 24, 0.78);
    border: 1px solid var(--line);
    cursor: pointer;
    transition: color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.btn:hover {
    color: var(--ink);
    border-color: rgba(95, 232, 255, 0.42);
    box-shadow: 0 0 16px -8px var(--cyan);
}

.btn:focus-visible {
    outline: 1px solid var(--cyan);
    outline-offset: 2px;
}

.btn.icon {
    padding: 8px 9px;
    font-size: 13px;
    letter-spacing: 0;
    line-height: 1;
}

.btn.play {
    color: #04121a;
    background: var(--cyan);
    border-color: var(--cyan);
    min-width: 88px;
    justify-content: center;
}

.btn.play:hover { box-shadow: 0 0 22px -4px var(--cyan); }

.ico {
    width: 11px;
    height: 11px;
    fill: currentColor;
}

.btn.ghost {
    background: rgba(3, 9, 15, 0.6);
    font-weight: 600;
}

.mini {
    font-family: var(--font);
    font-size: 8px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-faint);
    background: none;
    border: 1px solid var(--line-soft);
    padding: 3px 7px;
    cursor: pointer;
}

.mini:hover { color: var(--cyan); border-color: rgba(95, 232, 255, 0.4); }

.panel-toggle { display: none; }

/* ---------------------------------------------------------------------
   Bottom bar
   --------------------------------------------------------------------- */

.bottombar {
    grid-area: bottom;
    pointer-events: auto;
    margin: 0 12px 12px;
    padding: 10px 14px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px));
    box-shadow: 0 24px 60px -40px #000;
}

.transport,
.tools {
    display: flex;
    align-items: center;
    gap: 5px;
}

.scrub {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.scrub-scale {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 8px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
}

.scrub-scale b { color: var(--cyan); font-weight: 700; }

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 14px;
    background: transparent;
    cursor: pointer;
    margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 3px;
    background: linear-gradient(90deg, rgba(95, 232, 255, 0.5), rgba(95, 232, 255, 0.12));
    border-top: 1px solid rgba(110, 190, 225, 0.3);
    border-bottom: 1px solid rgba(110, 190, 225, 0.14);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    margin-top: -4px;
    background: var(--cyan);
    border: none;
    box-shadow: 0 0 12px var(--cyan);
}

input[type="range"]::-moz-range-track {
    height: 3px;
    background: rgba(95, 232, 255, 0.28);
}

input[type="range"]::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border: none;
    border-radius: 0;
    background: var(--cyan);
    box-shadow: 0 0 12px var(--cyan);
}

input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 1px solid #031018; }

/* ---------------------------------------------------------------------
   Floating bits
   --------------------------------------------------------------------- */

.tooltip {
    position: fixed;
    z-index: 30;
    pointer-events: none;
    padding: 6px 9px 7px;
    background: rgba(3, 9, 15, 0.94);
    border: 1px solid rgba(95, 232, 255, 0.34);
    box-shadow: 0 10px 30px -16px #000;
    font-size: 9.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink);
    white-space: nowrap;
    transform: translate(14px, -50%);
}

.tooltip b { color: var(--cyan); font-weight: 700; }

.tooltip i {
    display: block;
    font-style: normal;
    font-size: 8px;
    color: var(--ink-faint);
    letter-spacing: 0.14em;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 104px;
    z-index: 40;
    transform: translateX(-50%);
    padding: 9px 15px;
    background: rgba(3, 9, 15, 0.95);
    border: 1px solid rgba(95, 232, 255, 0.42);
    color: var(--cyan);
    font-size: 8.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    box-shadow: 0 18px 40px -24px #000;
}

.toast[hidden],
.tooltip[hidden] { display: none; }

.fatal {
    margin: 40px auto;
    max-width: 520px;
    padding: 18px;
    border: 1px solid var(--danger);
    color: var(--danger);
    font-size: 11px;
    letter-spacing: 0.06em;
}

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

@media (max-width: 1240px) {
    .hud { grid-template-columns: 268px minmax(0, 1fr) 296px; }
}

@media (max-width: 1120px) {
    .hud {
        grid-template-columns: minmax(0, 1fr) 300px;
        grid-template-areas:
            "top top"
            "mid right"
            "bottom bottom";
    }

    .panel-left { display: none; }
}

@media (max-width: 920px) {
    .hud {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr) auto;
        grid-template-areas:
            "top"
            "mid"
            "bottom";
    }

    .panel { display: none; }

    .app.show-panel .panel-right {
        display: flex;
        position: fixed;
        z-index: 25;
        top: 64px;
        right: 8px;
        bottom: 118px;
        width: min(320px, 88vw);
        margin: 0;
    }

    .panel-toggle { display: inline-flex; }

    .brand-text i { display: none; }

    .status .pill.ghost { display: none; }

    .bottombar {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "scrub" "transport" "tools";
        gap: 8px;
        margin: 0 8px 8px;
    }

    .transport { grid-area: transport; justify-content: center; gap: 7px; }
    .tools { grid-area: tools; justify-content: flex-end; }
    .scrub { grid-area: scrub; }

    .btn.play { min-width: 104px; flex: 0 0 auto; }
}

@media (max-width: 640px) {
    .topbar { gap: 10px; padding: 10px 10px 8px; }
    .brand-mark { width: 22px; height: 22px; }
    .brand-text b { font-size: 11px; letter-spacing: 0.18em; }
    .date-main { font-size: 12px; }
    .status { display: none; }
    .transport .btn:not(.play):not(.icon) { display: none; }
    .toast { bottom: 150px; }
}

@media (max-height: 640px) {
    .panel-foot { display: none; }
    .date-main { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
    .hud::after,
    .led { animation: none; }
    * { transition-duration: 1ms !important; }
}
