/*
 * Real Universe Explorer — interface styling.
 *
 * The look is a spacecraft navigation computer: near-black field, thin
 * luminous rules, monospaced numerals, and a restrained cyan accent that
 * marks anything interactive. Panels float over the 3D view rather than
 * boxing it in, so the space stays the subject.
 *
 * The one semantic use of colour: provenance badges. Calculated values are
 * violet, estimated values amber, and unknown values are greyed and
 * italicised, so a glance is enough to tell measurement from inference.
 */

:root {
  --void:        #04070f;
  --panel:       rgba(9, 15, 26, 0.86);
  --panel-solid: #0b1220;
  --edge:        rgba(99, 160, 200, 0.22);
  --edge-bright: rgba(99, 245, 200, 0.55);

  --text:        #d6e3f0;
  --text-dim:    #8ba3ba;
  --text-faint:  #5d7286;

  --accent:      #63f5c8;
  --accent-dim:  rgba(99, 245, 200, 0.14);
  --blue:        #4b9fd8;
  --violet:      #a794f0;
  --amber:       #f0c674;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 3px;
  --hud-gap: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Canvas and overlays -------------------------------------------------- */

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

#label-layer { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

.space-label {
  position: absolute; top: 0; left: 0;
  pointer-events: auto;
  padding: 2px 7px;
  background: rgba(6, 12, 22, 0.55);
  border: 1px solid transparent;
  border-left: 1px solid var(--edge);
  border-radius: 2px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
  backdrop-filter: blur(3px);
  transition: color 0.14s, border-color 0.14s, background 0.14s;
}
.space-label:hover { color: var(--accent); border-left-color: var(--accent); background: rgba(6, 12, 22, 0.85); }
.space-label.is-host { color: #9fd8c4; border-left-color: rgba(99, 245, 200, 0.5); }
.space-label.is-star { color: #f2dfae; border-left-color: rgba(240, 198, 116, 0.55); }
.space-label.is-home { color: var(--accent); border-left-color: var(--accent); }
.space-label.is-selected { color: var(--accent); border-color: var(--edge-bright); background: rgba(10, 30, 26, 0.9); }

/* The scale-transition veil: a fast iris-out that hides the scene swap. */
#transition-veil {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(120, 200, 255, 0.16), var(--void) 62%);
  opacity: 0;
  transition: opacity 0.42s ease-in;
}
#transition-veil.is-active { opacity: 1; transition: opacity 0.4s ease-out; }

/* --- HUD panels ----------------------------------------------------------- */

.hud {
  position: fixed;
  z-index: 10;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
}

.hud-top {
  top: var(--hud-gap); left: var(--hud-gap); right: var(--hud-gap);
  height: 46px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 14px;
}

.brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.brand-mark {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(99, 245, 200, 0.8), inset 0 0 0 3px rgba(4, 7, 15, 0.75);
}
.brand-text {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-dim); white-space: nowrap;
}

.breadcrumbs {
  flex: 1; display: flex; align-items: center; gap: 7px;
  overflow-x: auto; scrollbar-width: none;
}
.breadcrumbs::-webkit-scrollbar { display: none; }
.crumb {
  background: none; border: 0; padding: 3px 2px; cursor: pointer;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.05em;
  color: var(--text-dim); white-space: nowrap;
  border-bottom: 1px solid transparent;
}
button.crumb:hover { color: var(--accent); border-bottom-color: var(--edge-bright); }
.crumb.is-current { color: var(--text); }
.crumb-separator { color: var(--text-faint); font-size: 11px; opacity: 0.5; }

.top-actions { display: flex; gap: 7px; flex-shrink: 0; }

.ghost-button {
  background: rgba(99, 160, 200, 0.06);
  border: 1px solid var(--edge);
  border-radius: 2px;
  padding: 5px 11px;
  color: var(--text-dim);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em;
  cursor: pointer;
  transition: color 0.14s, border-color 0.14s, background 0.14s;
}
.ghost-button:hover { color: var(--accent); border-color: var(--edge-bright); background: var(--accent-dim); }

/* --- Left sidebar --------------------------------------------------------- */

.hud-left {
  top: 74px; left: var(--hud-gap); bottom: 62px;
  width: 314px;
  display: flex; flex-direction: column;
  overflow: hidden;
}

.search-block { padding: 12px; border-bottom: 1px solid var(--edge); position: relative; }

#search-input {
  width: 100%;
  background: rgba(4, 9, 18, 0.8);
  border: 1px solid var(--edge);
  border-radius: 2px;
  padding: 9px 11px;
  color: var(--text);
  font-family: var(--mono); font-size: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#search-input:focus { border-color: var(--edge-bright); box-shadow: 0 0 0 3px rgba(99, 245, 200, 0.08); }
#search-input::placeholder { color: var(--text-faint); }

.search-results { margin-top: 8px; max-height: 300px; overflow-y: auto; display: none; }
.search-results.has-results { display: block; }

.result {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none; border: 0; border-left: 2px solid transparent;
  padding: 6px 8px;
  text-align: left; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.result:hover { background: rgba(99, 160, 200, 0.08); border-left-color: var(--accent); }
.result-kind {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--text-faint);
  border: 1px solid var(--edge); border-radius: 2px;
  padding: 2px 0; text-align: center;
}
.kind-p { color: var(--accent); border-color: rgba(99, 245, 200, 0.4); }
.kind-s { color: var(--amber); border-color: rgba(240, 198, 116, 0.4); }
.kind-t { color: var(--blue); border-color: rgba(75, 159, 216, 0.4); }
.kind-g { color: var(--violet); border-color: rgba(167, 148, 240, 0.4); }
.result-name { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-secondary { font-family: var(--mono); font-size: 10px; color: var(--text-faint); white-space: nowrap; }

.tabs { display: flex; border-bottom: 1px solid var(--edge); flex-shrink: 0; }
.tab-button {
  flex: 1; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 9px 4px; cursor: pointer;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-faint);
  transition: color 0.14s, border-color 0.14s;
}
.tab-button:hover { color: var(--text-dim); }
.tab-button.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; flex: 1; overflow-y: auto; padding: 12px; }
.tab-panel.is-active { display: block; }

.panel-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 10px;
}
.count { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); letter-spacing: 0.04em; }

.mini-select, .field select, .field input {
  background: rgba(4, 9, 18, 0.8);
  border: 1px solid var(--edge);
  border-radius: 2px;
  padding: 5px 7px;
  color: var(--text-dim);
  font-family: var(--mono); font-size: 10.5px;
  outline: none;
}
.mini-select:focus, .field input:focus, .field select:focus { border-color: var(--edge-bright); color: var(--text); }

.planet-list { display: flex; flex-direction: column; gap: 1px; }

.planet-row {
  display: flex; flex-direction: column; gap: 3px;
  background: none; border: 0; border-left: 2px solid transparent;
  padding: 7px 9px; text-align: left; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.planet-row:hover { background: rgba(99, 160, 200, 0.08); border-left-color: var(--accent); }
.planet-row.is-selected { background: rgba(99, 245, 200, 0.1); border-left-color: var(--accent); }
.planet-row-name { font-size: 12px; color: var(--text); }
.planet-row-meta { display: flex; gap: 5px; }
.chip {
  font-family: var(--mono); font-size: 9.5px; color: var(--text-faint);
  background: rgba(99, 160, 200, 0.07);
  border-radius: 2px; padding: 1px 5px;
}
.chip.is-unknown { opacity: 0.4; font-style: italic; }

.list-note, .hint {
  font-size: 10.5px; color: var(--text-faint); line-height: 1.55;
  margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--edge);
}

.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-faint); }
.field-wide { grid-column: 1 / -1; }

.check { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; font-size: 11.5px; color: var(--text-dim); }
.check input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }

.time-block { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--edge); }
#time-scale { width: 100%; accent-color: var(--accent); }
.readout { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); margin-top: 5px; }

/* --- Right inspector ------------------------------------------------------ */

.hud-right {
  top: 74px; right: var(--hud-gap); bottom: 62px;
  width: 348px;
  overflow-y: auto;
  padding: 0;
  display: none;
}
.hud-right.is-open { display: block; }

.inspector-header { padding: 18px 18px 14px; border-bottom: 1px solid var(--edge); }
.inspector-kind {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 7px;
}
.inspector-header h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.inspector-subtitle { margin: 7px 0 0; font-size: 11.5px; color: var(--text-dim); line-height: 1.5; }

.inspector-close {
  position: absolute; top: 12px; right: 12px;
  width: 24px; height: 24px;
  background: none; border: 1px solid var(--edge); border-radius: 2px;
  color: var(--text-faint); font-size: 15px; line-height: 1; cursor: pointer;
}
.inspector-close:hover { color: var(--accent); border-color: var(--edge-bright); }

.inspector-actions { display: flex; flex-wrap: wrap; gap: 7px; padding: 14px 18px; border-bottom: 1px solid var(--edge); }
.action {
  background: rgba(99, 160, 200, 0.06);
  border: 1px solid var(--edge); border-radius: 2px;
  padding: 7px 12px; cursor: pointer;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.05em;
  color: var(--text-dim);
  transition: all 0.14s;
}
.action:hover { color: var(--accent); border-color: var(--edge-bright); background: var(--accent-dim); }
.action.is-primary { color: var(--void); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.action.is-primary:hover { background: #7dffd8; color: var(--void); }

.planet-preview { padding: 16px 18px; border-bottom: 1px solid var(--edge); }
.planet-swatch {
  width: 100%; aspect-ratio: 2.2 / 1; border-radius: 2px;
  border: 1px solid var(--edge);
}
.planet-preview-caption { margin-top: 8px; font-size: 10px; color: var(--text-faint); line-height: 1.55; font-style: italic; }

.panel-section { padding: 15px 18px; border-bottom: 1px solid var(--edge); }
.panel-section h3 {
  margin: 0 0 11px; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint);
}
.section-note { margin: 0 0 10px; font-size: 10.5px; line-height: 1.6; color: var(--text-dim); }

.fact { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 5px 0; align-items: baseline; }
.fact-label { font-size: 11.5px; color: var(--text-dim); }
.fact-value {
  font-family: var(--mono); font-size: 11.5px; color: var(--text);
  text-align: right; justify-self: end;
}
.fact-value.is-unknown { color: var(--text-faint); font-style: italic; opacity: 0.75; }
.fact-value.is-muted { color: var(--text-faint); }
.fact-uncertainty { color: var(--text-faint); font-size: 10px; }
.fact-note {
  grid-column: 1 / -1; font-size: 10px; line-height: 1.55;
  color: var(--text-faint); margin-top: 2px; padding-left: 0;
  border-left: 1px solid var(--edge); padding-left: 8px;
}

.badge {
  display: inline-block; margin-left: 6px; padding: 1px 5px;
  border-radius: 2px; font-size: 8.5px; letter-spacing: 0.09em;
  text-transform: uppercase; vertical-align: middle;
}
.badge-derived    { color: var(--violet); background: rgba(167, 148, 240, 0.13); border: 1px solid rgba(167, 148, 240, 0.3); }
.badge-estimated  { color: var(--amber);  background: rgba(240, 198, 116, 0.13); border: 1px solid rgba(240, 198, 116, 0.3); }
.badge-definition { color: var(--blue);   background: rgba(75, 159, 216, 0.13);  border: 1px solid rgba(75, 159, 216, 0.3); }

.planet-strip { display: flex; flex-wrap: wrap; gap: 5px; }
.planet-chip {
  background: rgba(99, 160, 200, 0.08); border: 1px solid var(--edge);
  border-radius: 2px; padding: 4px 9px; cursor: pointer;
  font-family: var(--mono); font-size: 10.5px; color: var(--text-dim);
  transition: all 0.14s;
}
.planet-chip:hover { color: var(--accent); border-color: var(--edge-bright); background: var(--accent-dim); }

.inspector-footer {
  padding: 13px 18px 20px; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: 0.06em; color: var(--text-faint);
}

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

.hud-bottom {
  left: var(--hud-gap); right: var(--hud-gap); bottom: var(--hud-gap);
  height: 38px;
  display: flex; align-items: center; gap: 22px;
  padding: 0 16px;
  overflow: hidden;
}
.status-item { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.status-grow { flex: 1; min-width: 0; }
.status-key {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-faint); flex-shrink: 0;
}
.status-value {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status-note {
  font-size: 9.5px; color: var(--text-faint); font-style: italic;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30%;
}

/* --- Loading and toast ---------------------------------------------------- */

.loading {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 45%, #0a1424, var(--void) 70%);
  transition: opacity 0.5s ease, visibility 0.5s;
}
.loading.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-inner { text-align: center; max-width: 380px; padding: 24px; }
.loading-title {
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 20px;
}
.loading-message { font-family: var(--mono); font-size: 11px; color: var(--text-dim); margin-bottom: 14px; }
.loading-track { height: 1px; background: var(--edge); overflow: hidden; }
.loading-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; box-shadow: 0 0 8px var(--accent); }
.loading-note { margin-top: 20px; font-size: 10px; color: var(--text-faint); line-height: 1.6; }

.toast {
  position: fixed; bottom: 68px; left: 50%; transform: translateX(-50%) translateY(8px);
  z-index: 50;
  background: var(--panel-solid); border: 1px solid var(--edge-bright);
  border-radius: 2px; padding: 9px 16px;
  font-family: var(--mono); font-size: 11px; color: var(--text);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-width: 70vw; text-align: center;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Scrollbars ----------------------------------------------------------- */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99, 160, 200, 0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99, 160, 200, 0.35); }

/* --- Narrow screens ------------------------------------------------------- */

@media (max-width: 1100px) {
  .hud-left { width: 268px; }
  .hud-right { width: 300px; }
  .status-note { display: none; }
}

@media (max-width: 860px) {
  .hud-top { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .breadcrumbs { order: 3; width: 100%; }
  .hud-left {
    top: auto; bottom: 58px; left: var(--hud-gap); right: var(--hud-gap);
    width: auto; max-height: 46vh;
  }
  .hud-right {
    top: 96px; bottom: auto; left: var(--hud-gap); right: var(--hud-gap);
    width: auto; max-height: 44vh;
  }
  .hud-bottom { gap: 14px; }
  .status-item:not(.status-grow) { display: none; }
}
