/*
 * Mote — cockpit HUD.
 *
 * Area map (docs/fig/possible-hud-areas.png): orange top-left = nav
 * readouts · blue top-right = vitals (hull + power) · red/green bottom
 * corners = thruster sticks · teal edge tabs = sliding hex panels
 * (cargo top, map left, rig right). Every rendered section is at least
 * one part of a hexagon (120°/60° cuts throughout); dark metal, small
 * white sans text, bold colour glows, faint connective seam lines.
 */

html, body { margin: 0; padding: 0; overflow: hidden; background: #05060f; }
canvas { display: block; }

#hud {
    position: fixed; inset: 0;
    pointer-events: none; /* interactive children opt back in */
    font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #e8ecf6;
    user-select: none;
    -webkit-user-select: none;
    z-index: 10;
}

/* faint cockpit vignette — the sense of glass in a frame */
.vignette {
    position: absolute; inset: 0;
    background: radial-gradient(ellipse 120% 105% at 50% 45%,
        transparent 62%, rgba(2, 4, 9, 0.42) 100%);
}

/* ---------------- shared chrome ---------------- */

.panel {
    position: absolute;
    background: linear-gradient(160deg, #1b212c 0%, #12161f 55%, #0c0f16 100%);
    box-shadow: inset 0 0 0 1px rgba(160, 190, 230, 0.10),
                inset 0 14px 22px -16px rgba(180, 210, 255, 0.25),
                inset 0 -10px 18px -14px rgba(0, 0, 0, 0.9);
    padding: 10px 14px 9px;
}

.label, .bar-label, .stick-tag, .pop-title, .pop-foot, .tab span {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: rgba(232, 236, 246, 0.55);
    text-transform: uppercase;
}

/* the glowing accent seam along a panel's outer edge */
.edge {
    position: absolute; left: 0; right: 0; top: 0; height: 2px;
    pointer-events: none;
}
.edge-orange {
    background: linear-gradient(90deg, #ffab26, rgba(255, 171, 38, 0.15));
    box-shadow: 0 0 9px 1px rgba(255, 171, 38, 0.55);
}
.edge-blue {
    background: linear-gradient(270deg, #35a7ff, rgba(53, 167, 255, 0.15));
    box-shadow: 0 0 9px 1px rgba(53, 167, 255, 0.55);
}

/* fake connective seam lines between sections */
.trace {
    position: absolute;
    background: linear-gradient(90deg, rgba(70, 150, 190, 0), rgba(70, 150, 190, 0.55), rgba(70, 150, 190, 0));
    box-shadow: 0 0 6px rgba(70, 170, 210, 0.35);
    height: 1px;
}
.trace-top-l { top: 8px; left: 216px; width: calc(50% - 286px); }
.trace-top-r { top: 8px; right: 236px; width: calc(50% - 306px); }
.trace-side-l, .trace-side-r {
    width: 1px; height: calc(50% - 190px); top: calc(28% + 90px);
    background: linear-gradient(180deg, rgba(70, 150, 190, 0), rgba(70, 150, 190, 0.5), rgba(70, 150, 190, 0));
}
.trace-side-l { left: 9px; }
.trace-side-r { right: 9px; }

/* ---------------- top-left: nav (orange) ---------------- */

.coords {
    top: 0; left: 0;
    width: 208px;
    /* hex part: flat top, 60° cut into the bottom-right corner */
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 26px), calc(100% - 46px) 100%, 0 100%);
    padding-top: 12px;
}
.readout {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.14em;
    color: #f4f7ff;
    text-shadow: 0 0 7px rgba(255, 190, 90, 0.35);
    line-height: 1.55;
    display: flex; justify-content: space-between;
}
.readout.dim {
    font-size: 10px; color: rgba(232, 236, 246, 0.6); text-shadow: none;
    padding-right: 40px; /* keep SEC clear of the hex cut */
}

/* ---------------- top-right: vitals (blue) ---------------- */

.vitals {
    top: 0; right: 0;
    width: 228px;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 46px 100%, 0 calc(100% - 26px));
    padding-top: 13px; padding-left: 22px;
}
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.bar-label { width: 30px; text-align: right; flex: none; }
.bar {
    position: relative; flex: 1; height: 10px;
    background: #0a0d13;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.9), inset 0 0 0 1px rgba(160, 190, 230, 0.10);
    /* hex-sliced bar ends */
    clip-path: polygon(5px 0, 100% 0, 100% 100%, 0 100%, 0 5px);
}
.fill {
    position: absolute; inset: 1px;
    transform-origin: left center;
    transform: scaleX(1);
    transition: transform 0.35s ease-out;
}
.fill-hull {
    background: linear-gradient(180deg, #ff7a86, #e63946 60%, #a4131f);
    box-shadow: 0 0 8px rgba(230, 57, 70, 0.7);
}
.fill-pwr {
    background: linear-gradient(180deg, #ffe9a0, #ffc233 60%, #cc8a00);
    box-shadow: 0 0 8px rgba(255, 194, 51, 0.7);
}
.notches {
    position: absolute; inset: 0;
    background: repeating-linear-gradient(90deg,
        transparent 0 14px, rgba(5, 7, 12, 0.85) 14px 16px);
}
.lamp-row { display: flex; gap: 14px; margin-top: 2px; }
.lamp {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 8px; font-weight: 600; letter-spacing: 0.16em;
    color: rgba(232, 236, 246, 0.35);
}
.lamp i {
    width: 7px; height: 8px; display: inline-block;
    background: #232a36;
    /* tiny hexagon lamp */
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
    transition: background 0.2s, box-shadow 0.2s;
}
.lamp.on { color: rgba(232, 236, 246, 0.8); }
#lampDock.on i { background: #4ade80; box-shadow: 0 0 8px 1px rgba(74, 222, 128, 0.8); }
#lampChg.on i { background: #ffc233; box-shadow: 0 0 8px 1px rgba(255, 194, 51, 0.8); }
#lampLow.on i { background: #ff3b4d; box-shadow: 0 0 8px 1px rgba(255, 59, 77, 0.9); }
.lamp.warn.on { animation: lowblink 0.9s steps(2, jump-none) infinite; }
@keyframes lowblink { 50% { opacity: 0.35; } }

/* ---------------- teal tabs ---------------- */

.tab {
    position: absolute;
    pointer-events: auto;
    cursor: pointer;
    border: 0;
    background: linear-gradient(180deg, #2c5a60, #1d3f45 70%, #16323a);
    box-shadow: inset 0 0 0 1px rgba(120, 220, 230, 0.18),
                0 0 12px rgba(40, 160, 175, 0.25);
    color: rgba(200, 240, 244, 0.85);
    transition: filter 0.15s;
}
.tab:hover, .tab:active { filter: brightness(1.35); }
.tab span { color: inherit; }

.tab-top {
    top: 0; left: 50%;
    width: 148px; height: 26px;
    transform: translateX(-50%);
    /* the top half of a flat-top hexagon */
    clip-path: polygon(0 0, 100% 0, calc(100% - 22px) 100%, 22px 100%);
}
.tab-left, .tab-right {
    top: 28%;
    width: 26px; height: 128px;
    writing-mode: vertical-rl;
}
.tab-left {
    left: 0;
    clip-path: polygon(0 0, 100% 22px, 100% calc(100% - 22px), 0 100%);
    transform: rotate(180deg);
}
.tab-right {
    right: 0;
    clip-path: polygon(100% 0, 100% 100%, 0 calc(100% - 22px), 0 22px);
}

/* ---------------- sliding hex panels ---------------- */

.pop {
    position: absolute;
    pointer-events: auto;
    background: linear-gradient(165deg, rgba(23, 29, 39, 0.96), rgba(11, 14, 20, 0.96));
    box-shadow: inset 0 0 0 1px rgba(120, 220, 230, 0.16),
                inset 0 0 60px rgba(20, 90, 105, 0.18);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 12px;
    text-align: center;
    transition: transform 0.28s cubic-bezier(0.22, 0.9, 0.3, 1);
    z-index: 5;
}
.pop-title { font-size: 11px; color: rgba(160, 235, 242, 0.9);
    text-shadow: 0 0 8px rgba(60, 200, 215, 0.5); }
.pop-foot { font-size: 8px; color: rgba(232, 236, 246, 0.35); }
.hexghosts {
    font-size: 26px; line-height: 1.35; letter-spacing: 0.2em;
    color: rgba(120, 220, 230, 0.22);
    text-shadow: 0 0 12px rgba(60, 200, 215, 0.25);
}

.pop-top {
    left: 50%; top: 0;
    width: 380px; height: 300px;
    margin-left: -190px;
    /* flat-top hexagon, squashed */
    clip-path: polygon(25% 0, 75% 0, 100% 38%, 75% 100%, 25% 100%, 0 38%);
    transform: translateY(-110%);
}
.pop-top.open { transform: translateY(-12%); }

.pop-left, .pop-right {
    top: 50%;
    width: 330px; height: 420px;
    margin-top: -210px;
    /* pointy-top hexagon on its side */
    clip-path: polygon(0 20%, 55% 0, 100% 32%, 100% 68%, 55% 100%, 0 80%);
}
.pop-left { left: 0; transform: translateX(-115%); }
.pop-left.open { transform: translateX(-8%); }
.pop-right {
    right: 0;
    clip-path: polygon(100% 20%, 45% 0, 0 32%, 0 68%, 45% 100%, 100% 80%);
    transform: translateX(115%);
}
.pop-right.open { transform: translateX(8%); }

/* ---------------- thruster sticks ---------------- */

.stick {
    position: absolute; bottom: 0;
    width: 168px; height: 156px;
    pointer-events: auto;
    touch-action: none;
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-end;
    padding-bottom: 10px;
    background: linear-gradient(0deg, #12161f 0%, rgba(18, 22, 31, 0.55) 70%, rgba(18, 22, 31, 0) 100%);
}
.stick-l {
    left: 0;
    clip-path: polygon(0 0, calc(100% - 52px) 0, 100% 34%, 100% 100%, 0 100%);
}
.stick-r {
    right: 0;
    clip-path: polygon(52px 0, 100% 0, 100% 100%, 0 100%, 0 34%);
}
.stick-tag { margin-top: 6px; }

.socket {
    position: relative;
    width: 108px; height: 108px;
    background: radial-gradient(circle at 50% 42%, #1d2430, #0b0e14 72%);
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
    box-shadow: inset 0 0 0 1px rgba(160, 190, 230, 0.12),
                inset 0 6px 14px rgba(0, 0, 0, 0.9);
    display: flex; align-items: center; justify-content: center;
}
.nub {
    width: 46px; height: 46px;
    background: radial-gradient(circle at 40% 32%, #39424f, #1a202b 70%);
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
    transition: transform 0.07s linear;
    will-change: transform;
}
/* colour-keyed glow (Phil's red/green reserved areas) */
.stick-l .nub { box-shadow: 0 0 14px 2px rgba(255, 70, 80, 0.55), inset 0 0 0 1px rgba(255, 120, 130, 0.35); }
.stick-r .nub { box-shadow: 0 0 14px 2px rgba(60, 230, 110, 0.55), inset 0 0 0 1px rgba(120, 255, 160, 0.35); }
.stick-l .socket { box-shadow: inset 0 0 22px rgba(255, 70, 80, 0.10), inset 0 0 0 1px rgba(255, 120, 130, 0.14); }
.stick-r .socket { box-shadow: inset 0 0 22px rgba(60, 230, 110, 0.10), inset 0 0 0 1px rgba(120, 255, 160, 0.14); }

/* ---------------- connect/death overlay ---------------- */

#overlay {
    position: fixed; inset: 0; display: flex;
    align-items: center; justify-content: center;
    font: 600 22px/1 -apple-system, "Segoe UI", Roboto, sans-serif;
    letter-spacing: 0.3em; text-transform: uppercase;
    color: #e8ecf6;
    background: rgba(5, 6, 15, 0.55); text-shadow: 0 0 18px rgba(255, 80, 90, 0.6);
    z-index: 20;
}
#overlay.hidden { display: none; }

/* small screens: tighter chrome */
@media (max-width: 760px) {
    .coords { width: 168px; }
    .vitals { width: 190px; }
    .trace-top-l, .trace-top-r { display: none; }
}
