/* ============================================================
   HELIOS 1:1 — mission-control instrument skin
   Michroma (display) + IBM Plex Mono (data) · amber/cyan on void
   ============================================================ */

:root {
  --bg: #020409;
  --panel: rgba(7, 11, 18, 0.78);
  --line: rgba(126, 164, 210, 0.16);
  --line-strong: rgba(126, 164, 210, 0.35);
  --txt: #c8d6e8;
  --dim: #5d6f85;
  --amber: #f0a93c;
  --cyan: #7fd2ff;
  font-size: 14px;
}

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

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--txt);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  user-select: none;
}

#app, #app canvas { position: fixed; inset: 0; }

/* subtle vignette over the whole viewport */
body::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 5, 0.5) 100%);
  z-index: 5;
}

/* ---------------------------------------------------- labels (CSS2D) */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

.body-label {
  pointer-events: auto;
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--txt);
  text-shadow: 0 0 6px #000, 0 0 2px #000;
  white-space: nowrap;
  padding: 2px 4px;
  transition: color 0.15s;
}
.body-label:hover { color: var(--amber); }
.body-label i {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: 1px;
}
.body-label.moon { font-size: 9px; color: var(--dim); }
.body-label.moon:hover { color: var(--cyan); }
.body-label.dwarf { color: #93a4ba; }

/* --------------------------------------------------------- panels */
.panel {
  position: fixed;
  z-index: 20;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 12px 14px;
}
/* corner brackets */
.panel::before, .panel::after {
  content: '';
  position: absolute;
  width: 9px; height: 9px;
  pointer-events: none;
}
.panel::before {
  top: -1px; left: -1px;
  border-top: 1px solid var(--amber);
  border-left: 1px solid var(--amber);
}
.panel::after {
  bottom: -1px; right: -1px;
  border-bottom: 1px solid var(--amber);
  border-right: 1px solid var(--amber);
}

.panel h2 {
  font-family: 'Michroma', 'IBM Plex Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--dim);
  margin-bottom: 10px;
}

/* ------------------------------------------------------ brand */
#brand { top: 16px; left: 16px; padding: 14px 18px; }
#brand h1 {
  font-family: 'Michroma', monospace;
  font-size: 19px;
  letter-spacing: 0.18em;
  color: #e8f0fa;
}
#brand h1 span { color: var(--amber); }
#brand .sub {
  font-size: 8.5px;
  letter-spacing: 0.32em;
  color: var(--dim);
  margin: 4px 0 10px;
}
#clock {
  font-size: 13px;
  font-weight: 600;
  color: var(--amber);
  letter-spacing: 0.08em;
}

/* ------------------------------------------------------ readout */
#readout { top: 16px; right: 16px; text-align: right; max-width: 320px; }
#camRange {
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
#readout .badge {
  font-size: 8.5px;
  letter-spacing: 0.2em;
  color: var(--dim);
  border-top: 1px dashed var(--line-strong);
  padding-top: 6px;
}

/* ------------------------------------------------------ body list */
#bodyPanel {
  top: 130px; left: 16px;
  width: 228px;
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
#bodyList { list-style: none; }
#bodyList li {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  padding: 3px 4px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
#bodyList li:hover { background: rgba(127, 210, 255, 0.07); }
#bodyList li.active {
  border-left-color: var(--amber);
  background: rgba(240, 169, 60, 0.09);
  color: var(--amber);
}
#bodyList li.group {
  cursor: default;
  font-size: 8px;
  letter-spacing: 0.28em;
  color: var(--dim);
  margin-top: 9px;
  border-left: none;
}
#bodyList li.group:hover { background: none; }
#bodyList li .num { color: var(--dim); font-size: 9px; }
#bodyList li i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
#bodyList li .nm {
  flex: 1;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;   /* truncation reads as deliberate, not clipped */
}
#bodyList li.moon-row { padding-left: 16px; }
#bodyList li.moon-row .nm { color: var(--dim); }
#bodyList li.moon-row.active .nm { color: var(--amber); }
#bodyList li .dist { font-size: 8.5px; color: var(--dim); }

/* ------------------------------------------------------ info panel */
#infoPanel { top: 130px; right: 16px; width: 252px; }
#infoPanel h2#infoName {
  font-family: 'Michroma', monospace;
  font-size: 15px;
  letter-spacing: 0.14em;
  color: #e8f0fa;
  margin-bottom: 6px;
  text-transform: uppercase;
}
#infoType {
  display: inline-block;
  font-size: 8px;
  letter-spacing: 0.22em;
  color: var(--cyan);
  border: 1px solid rgba(127, 210, 255, 0.3);
  padding: 2px 7px;
  margin-bottom: 12px;
}
#infoRows .row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  padding: 4px 0;
  border-bottom: 1px dotted rgba(126, 164, 210, 0.12);
}
#infoRows .row span { color: var(--dim); letter-spacing: 0.08em; }
#infoRows .row b { color: var(--txt); font-weight: 500; text-align: right; }
#btnSurface {
  width: 100%;
  margin-top: 14px;
  background: none;
  border: 1px solid var(--amber);
  color: var(--amber);
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.18em;
  padding: 9px 0;
  cursor: pointer;
  transition: all 0.15s;
}
#btnSurface:hover:not(:disabled) { background: rgba(240, 169, 60, 0.14); }
#btnSurface:disabled {
  border-color: var(--line);
  color: var(--dim);
  cursor: not-allowed;
}

/* ------------------------------------------------------ layers */
#layerPanel { bottom: 16px; left: 16px; }
#layerPanel label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--txt);
  padding: 3px 0;
  cursor: pointer;
}
#layerPanel input {
  appearance: none;
  width: 11px; height: 11px;
  border: 1px solid var(--line-strong);
  background: transparent;
  cursor: pointer;
  position: relative;
}
#layerPanel input:checked { border-color: var(--amber); }
#layerPanel input:checked::after {
  content: '';
  position: absolute; inset: 2px;
  background: var(--amber);
}

/* ------------------------------------------------------ transport */
#transport {
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
}
#transport button {
  background: none;
  border: 1px solid var(--line-strong);
  color: var(--txt);
  font-family: inherit;
  font-size: 12px;
  width: 38px; height: 30px;
  cursor: pointer;
  transition: all 0.15s;
}
#transport button:hover { border-color: var(--amber); color: var(--amber); }
#transport #btnNow { width: auto; padding: 0 10px; font-size: 9px; letter-spacing: 0.1em; }
.speed-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
}
#speedTicks { display: flex; gap: 3px; }
#speedTicks button {
  width: 13px; height: 8px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line-strong);
  cursor: pointer;
  transition: all 0.12s;
}
#speedTicks button:hover { border-color: var(--cyan); }
#speedTicks button.on { background: var(--amber); border-color: var(--amber); }
#speedLabel {
  min-width: 110px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--amber);
}

/* ------------------------------------------------------ hint + banner */
#hint {
  position: fixed;
  bottom: 18px; right: 16px;
  z-index: 20;
  font-size: 8.5px;
  line-height: 1.8;
  letter-spacing: 0.1em;
  text-align: right;
  color: var(--dim);
}

#surfaceBanner {
  position: fixed;
  bottom: 76px; left: 50%;
  transform: translate(-50%, 140px);
  z-index: 30;
  background: rgba(240, 169, 60, 0.12);
  border: 1px solid var(--amber);
  color: var(--amber);
  font-size: 10px;
  letter-spacing: 0.16em;
  padding: 8px 16px;
  white-space: nowrap;
  transition: transform 0.3s ease;
  pointer-events: none;
}
body.surface-mode #surfaceBanner { transform: translate(-50%, 0); }
body.surface-mode #bodyPanel,
body.surface-mode #layerPanel { opacity: 0.25; pointer-events: none; }
body.surface-mode #app canvas { cursor: grab; }

/* ------------------------------------------------------ loading */
#loading {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-family: 'Michroma', monospace;
  font-size: 11px;
  letter-spacing: 0.4em;
  color: var(--amber);
  transition: opacity 0.8s;
}
#loading.done { opacity: 0; pointer-events: none; }
.blink { animation: blink 0.9s steps(2) infinite; margin-left: 6px; }
@keyframes blink { to { opacity: 0; } }

/* ------------------------------------------------------ pane tabs (phones) */
#paneTabs {
  display: none;              /* desktop: every panel has its own corner */
  position: fixed;
  z-index: 30;
  left: 8px; right: 8px; bottom: 62px;
  gap: 6px;
}
#paneTabs button {
  flex: 1;
  font-family: inherit;
  font-size: 9px;
  letter-spacing: 0.1em;
  padding: 7px 0;
  color: var(--dim);
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
#paneTabs button.active { color: var(--amber); border-color: var(--amber); }

/* ------------------------------------------------- tablets / narrow windows */
@media (max-width: 900px) {
  #hint { display: none; }
  #readout .badge { display: none; }
  #bodyPanel { width: 196px; max-height: calc(100vh - 300px); }
  #infoPanel { width: 210px; top: auto; bottom: 92px; }
}

/* -------------------------------------------------------------------- phones */
/* At 375pt the desktop layout overlaps three ways at once: brand against
   readout, info against layers, layers against transport. Rather than shrink
   everything, the three reference panels share one bottom sheet and default to
   closed, so the scene starts unobstructed. */
@media (max-width: 700px) {
  #brand { top: 8px; left: 8px; padding: 8px 10px; max-width: 44vw; }
  #brand h1 { font-size: 16px; }
  #brand .sub { display: none; }
  /* nowrap: the UTC suffix orphans onto a second line otherwise */
  #brand #clock { font-size: 9px; margin-top: 3px; white-space: nowrap; }

  #readout {
    top: 8px; right: 8px;
    max-width: 50vw;
    padding: 8px 10px;
  }
  /* One line, truncated rather than wrapped: surface mode puts a much
     longer string here and it must not grow into the brand panel. */
  #readout #camRange {
    font-size: 9.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #paneTabs { display: flex; }

  /* one slot, one occupant */
  #bodyPanel, #layerPanel, #infoPanel {
    display: none;
    top: auto; bottom: 96px;
    left: 8px; right: 8px;
    width: auto; max-width: none;
    max-height: 46vh;
    overflow-y: auto;
    /* Vertical only. The rows themselves fit - measured 274px of content in a
       302px panel even at 320px wide - so this is not about overflowing
       content. It is that any scrollWidth excess at all, here a single pixel
       of border rounding, makes the browser treat the panel as horizontally
       scrollable, and iOS will then rubber-band it sideways off the stray
       horizontal component of a vertical swipe. touch-action commits the
       gesture to one axis before that can happen; overflow-x removes the
       stray pixel of range; overscroll-behavior keeps a flick from chaining
       out to whatever is behind the sheet. */
    overflow-x: hidden;
    touch-action: pan-y;
    overscroll-behavior: contain;
  }
  body.pane-bodyPanel  #bodyPanel,
  body.pane-layerPanel #layerPanel,
  body.pane-infoPanel  #infoPanel { display: block; }

  /* touch targets: 10.5px rows are not tappable at arm's length */
  #bodyList li { font-size: 12px; padding: 7px 4px; }
  #layerPanel label { padding: 6px 0; }

  #transport {
    left: 8px; right: 8px; bottom: 8px;
    transform: none;
    justify-content: space-between;
  }
  #surfaceBanner { font-size: 9px; padding: 6px 8px; }
}
