/* ── Deep Space Observatory · layout & HUD ──────────────── */

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-mono);
  user-select: none;
}

#galaxy-canvas {
  position: fixed;
  inset: 0;
  display: block;
  cursor: grab;
}
#galaxy-canvas.dragging { cursor: grabbing; }
#galaxy-canvas.hovering { cursor: pointer; }

/* ── HUD corners ── */
.hud { position: fixed; z-index: 10; pointer-events: none; }
.hud button { pointer-events: auto; }

.hud-top-left { top: 20px; left: 24px; }
.hud-title {
  font-family: var(--font-terminal);
  font-size: 2.4rem;
  letter-spacing: 0.18em;
  color: var(--neon-cyan);
  text-shadow: var(--glow-cyan);
  line-height: 1;
  position: relative;
  pointer-events: auto;
  cursor: default;
}

/* hover: RGB-split glitch — two clipped copies jitter over the title */
.hud-title::before,
.hud-title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0;
  text-shadow: none;
  pointer-events: none;
}
.hud-title:hover { animation: title-flicker 1.6s steps(1) infinite; }
.hud-title:hover::before {
  opacity: 0.8;
  color: var(--cyber-pink);
  animation: glitch-shift-a 0.5s steps(2, jump-none) infinite;
}
.hud-title:hover::after {
  opacity: 0.8;
  color: var(--terminal-green);
  animation: glitch-shift-b 0.4s steps(2, jump-none) infinite reverse;
}
@keyframes glitch-shift-a {
  0%   { transform: translate(-3px, -2px); clip-path: inset(0 0 62% 0); }
  25%  { transform: translate(3px, 1px);   clip-path: inset(28% 0 40% 0); }
  50%  { transform: translate(-2px, 2px);  clip-path: inset(55% 0 12% 0); }
  75%  { transform: translate(2px, -1px);  clip-path: inset(10% 0 72% 0); }
  100% { transform: translate(-3px, 1px);  clip-path: inset(40% 0 30% 0); }
}
@keyframes glitch-shift-b {
  0%   { transform: translate(3px, 2px);   clip-path: inset(64% 0 8% 0); }
  25%  { transform: translate(-3px, -1px); clip-path: inset(18% 0 58% 0); }
  50%  { transform: translate(2px, -2px);  clip-path: inset(4% 0 78% 0); }
  75%  { transform: translate(-2px, 1px);  clip-path: inset(46% 0 22% 0); }
  100% { transform: translate(3px, -1px);  clip-path: inset(30% 0 44% 0); }
}
@keyframes title-flicker {
  0%, 100% { opacity: 1; }
  7%  { opacity: 0.65; }
  9%  { opacity: 1; }
  48% { opacity: 0.8; }
  50% { opacity: 1; }
  83% { opacity: 0.55; }
  85% { opacity: 1; }
}

.hud-sub {
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  color: var(--text-dim);
  margin-top: 6px;
  pointer-events: auto;
  cursor: default;
  transition:
    letter-spacing 0.5s cubic-bezier(0.2, 0.8, 0.2, 1),
    color 0.3s ease,
    text-shadow 0.3s ease;
}

/* hover: the readout powers up — tracking expands, terminal green glow */
.hud-sub:hover {
  letter-spacing: 0.48em;
  color: var(--terminal-green);
  text-shadow: 0 0 8px var(--terminal-green), 0 0 20px rgba(82, 255, 154, 0.4);
  animation: sub-scan 1.8s linear infinite;
}
@keyframes sub-scan {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.75; }
  52%      { opacity: 1; }
  54%      { opacity: 0.85; }
  56%      { opacity: 1; }
}

.hud-top-right { top: 24px; right: 24px; text-align: right; }
.hud-readout {
  font-family: var(--font-terminal);
  font-size: 1.05rem;
  color: var(--terminal-green);
  letter-spacing: 0.06em;
}
.hud-readout .label {
  color: var(--hud-dim);
  margin-right: 8px;
  font-size: 0.85rem;
}

.hud-bottom-right {
  bottom: 24px; right: 24px;
  display: flex; gap: 10px;
}

.hud-bottom-left { bottom: 20px; left: 24px; }
.legend { list-style: none; display: flex; gap: 18px; margin-bottom: 8px; }
.legend li {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 6px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-galaxy    { background: var(--neon-cyan);    box-shadow: 0 0 6px var(--neon-cyan); }
.dot-nebula    { background: var(--neon-purple);  box-shadow: 0 0 6px var(--neon-purple); }
.dot-cluster   { background: var(--ice-blue);     box-shadow: 0 0 6px var(--ice-blue); }
.dot-star      { background: var(--golden-yellow); box-shadow: 0 0 6px var(--golden-yellow); }
.dot-neutron   { background: var(--terminal-green); box-shadow: 0 0 6px var(--terminal-green); }
.dot-system    { background: var(--star-white);   box-shadow: 0 0 6px var(--star-white); }
.dot-blackhole { background: var(--cyber-pink);   box-shadow: 0 0 6px var(--cyber-pink); }
.dot-void      { background: var(--void-blue);    box-shadow: 0 0 6px var(--void-blue); }
.hud-hint {
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  opacity: 0.7;
}

/* ── Glow buttons ── */
.glow-btn {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  padding: 9px 14px;
  color: var(--neon-cyan);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.glow-btn:hover {
  box-shadow: var(--glow-cyan);
  background: rgba(0, 240, 255, 0.12);
  text-shadow: 0 0 6px var(--neon-cyan);
}

/* ── Destinations nav ── */
.destinations {
  position: fixed;
  top: 110px; left: 24px;
  z-index: 10;
  width: 230px;
}
.dest-toggle { width: 100%; text-align: left; }
.dest-list {
  list-style: none;
  margin-top: 8px;
  max-height: calc(100vh - 300px);
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  display: none;
}
.destinations.open .dest-list { display: block; }
.dest-group {
  font-family: var(--font-terminal);
  font-size: 0.95rem;
  letter-spacing: 0.2em;
  color: var(--hud-dim);
  padding: 10px 12px 4px;
}
.dest-item {
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  padding: 7px 12px 7px 22px;
  color: var(--text-primary);
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease, text-shadow 0.15s ease;
}
.dest-item::before {
  content: '›';
  position: absolute; left: 10px;
  color: var(--hud-dim);
}
.dest-item.child {
  padding-left: 38px;
  color: var(--text-dim);
}
.dest-item.child::before {
  content: '└';
  left: 24px;
}
.dest-item.child:hover { color: var(--text-primary); }
.dest-item:hover {
  background: rgba(0, 240, 255, 0.1);
  text-shadow: 0 0 8px var(--neon-cyan);
}
.dest-list::-webkit-scrollbar { width: 4px; }
.dest-list::-webkit-scrollbar-thumb { background: var(--panel-border); }

/* ── Info panel (holographic card) ── */
.info-panel {
  position: fixed;
  top: 50%; right: 28px;
  transform: translateY(-50%);
  width: 350px;
  z-index: 20;
  padding: 22px 22px 26px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.15), inset 0 0 40px rgba(0, 240, 255, 0.04);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  overflow: hidden;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.info-panel.hidden {
  opacity: 0;
  transform: translateY(-50%) translateX(40px);
  pointer-events: none;
}

/* holographic scanlines sweeping the card */
.info-panel::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 240, 255, 0.05) 0px,
    rgba(0, 240, 255, 0.05) 1px,
    transparent 1px,
    transparent 4px
  );
  animation: scanline 7s linear infinite;
}
@keyframes scanline {
  from { background-position: 0 0; }
  to   { background-position: 0 120px; }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.type-badge {
  font-size: 0.6rem;
  letter-spacing: 0.24em;
  padding: 4px 10px;
  border: 1px solid currentColor;
  color: var(--neon-cyan);
}
.type-badge.galaxy    { color: var(--neon-cyan); }
.type-badge.nebula    { color: var(--neon-purple); }
.type-badge.cluster   { color: var(--ice-blue); }
.type-badge.star      { color: var(--golden-yellow); }
.type-badge.neutron   { color: var(--terminal-green); }
.type-badge.system    { color: var(--star-white); }
.type-badge.blackhole { color: var(--cyber-pink); }
.type-badge.void      { color: var(--void-blue); }
.panel-close { padding: 5px 10px; }

.panel-name {
  font-family: var(--font-terminal);
  font-size: 2rem;
  letter-spacing: 0.08em;
  color: var(--neon-cyan);
  text-shadow: var(--glow-cyan);
  line-height: 1.05;
}
.panel-class {
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  color: var(--text-dim);
  margin: 6px 0 16px;
}

.panel-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.panel-stats .stat {
  border: 1px solid rgba(0, 240, 255, 0.2);
  padding: 8px 10px;
}
.panel-stats dt {
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  color: var(--hud-dim);
  margin-bottom: 4px;
}
.panel-stats dd {
  font-family: var(--font-terminal);
  font-size: 0.95rem;
  color: var(--terminal-green);
}

.panel-desc {
  font-family: var(--font-terminal);
  font-size: 1.12rem;
  line-height: 1.4;
  color: var(--terminal-green);
  min-height: 120px;
}
.panel-desc::after {
  content: '█';
  animation: caret 0.9s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* ── Atmosphere overlays ── */
.crt-overlay {
  position: fixed; inset: 0;
  z-index: 30;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.08) 0px,
    rgba(0, 0, 0, 0.08) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.5;
}
.vignette {
  position: fixed; inset: 0;
  z-index: 29;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(2, 4, 12, 0.65) 100%);
}

/* ── Small screens ── */
@media (max-width: 720px) {
  .destinations { display: none; }
  .info-panel { right: 12px; left: 12px; width: auto; top: auto; bottom: 12px; transform: none; }
  .info-panel.hidden { transform: translateY(30px); }
  .hud-bottom-left { display: none; }
}
