/* ===========================
   ORBITAL WATCH — STYLES
   Aesthetic: Dark Ops / Military Radar
   =========================== */

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

:root {
  --bg: #020408;
  --surface: #060d14;
  --surface2: #0a1520;
  --border: rgba(0, 200, 150, 0.18);
  --border-bright: rgba(0, 200, 150, 0.45);
  --green: #00e5a0;
  --green-dim: #00a870;
  --green-glow: rgba(0, 229, 160, 0.3);
  --orange: #ff6b35;
  --orange-dim: #cc4a1a;
  --blue: #00aaff;
  --blue-dim: #0077cc;
  --yellow: #ffd060;
  --red: #ff3355;
  --text: #c0ddd0;
  --text-dim: #5a8070;
  --text-bright: #e8fff5;
  --font-mono: 'Share Tech Mono', monospace;
  --font-display: 'Orbitron', sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
}

/* ---- CANVAS ---- */
#globe-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
}
#globe-canvas:active { cursor: grabbing; }

/* ---- LOADER ---- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s;
}
.loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loader-inner {
  position: relative;
  width: 260px;
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loader-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--border-bright);
}
.loader-ring:nth-child(1) {
  width: 260px; height: 260px;
  border-top-color: var(--green);
  border-right-color: transparent;
  animation: spin 2.5s linear infinite;
}
.loader-ring.r2 {
  width: 200px; height: 200px;
  border-bottom-color: var(--green-dim);
  border-left-color: transparent;
  animation: spin 1.8s linear infinite reverse;
}
.loader-ring.r3 {
  width: 140px; height: 140px;
  border-top-color: var(--blue);
  border-right-color: transparent;
  animation: spin 3.2s linear infinite;
}
.loader-earth {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #1a5fa8, #0a2a50 60%, #050f20);
  box-shadow: 0 0 20px rgba(0, 100, 200, 0.5), 0 0 60px rgba(0, 50, 150, 0.2);
  animation: pulse 2s ease-in-out infinite;
}
.loader-text {
  position: absolute;
  bottom: -70px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: 280px;
}
.loader-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--green);
  letter-spacing: 0.3em;
  margin-bottom: 8px;
}
.loader-status {
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  margin-bottom: 12px;
  min-height: 1em;
}
.loader-bar {
  width: 100%;
  height: 2px;
  background: var(--surface2);
  border-radius: 1px;
  overflow: hidden;
}
.loader-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  transition: width 0.3s ease;
}

/* ---- HUD HEADER ---- */
.hud-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 56px;
  background: linear-gradient(180deg, rgba(2,4,8,0.98) 0%, rgba(6,13,20,0.85) 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 24px;
  backdrop-filter: blur(8px);
}

.hud-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.logo-icon {
  font-size: 1.4rem;
  color: var(--green);
  filter: drop-shadow(0 0 6px var(--green));
  animation: pulse 3s ease-in-out infinite;
}
.logo-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 0.15em;
}
.logo-accent { color: var(--green); }

.hud-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}
.stat-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.stat-label {
  font-size: 0.55rem;
  color: var(--text-dim);
  letter-spacing: 0.15em;
}
.stat-value {
  font-size: 0.85rem;
  color: var(--green);
  font-weight: 700;
  min-width: 60px;
}
.stat-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

.hud-controls {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.hud-btn {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
  clip-path: polygon(6px 0%, 100% 0%, calc(100% - 6px) 100%, 0% 100%);
}
.hud-btn:hover { border-color: var(--green-dim); color: var(--green); }
.hud-btn.active {
  background: rgba(0, 229, 160, 0.12);
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 10px rgba(0, 229, 160, 0.15);
}

/* ---- INFO PANEL ---- */
.info-panel {
  position: fixed;
  right: 0;
  top: 56px;
  bottom: 0;
  width: 320px;
  background: linear-gradient(180deg, rgba(6,13,20,0.97) 0%, rgba(2,4,8,0.97) 100%);
  border-left: 1px solid var(--border);
  z-index: 90;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
}
.info-panel.open { transform: translateX(0); }

.panel-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.panel-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.panel-dot.active { background: var(--green); box-shadow: 0 0 6px var(--green); animation: blink 1.5s ease-in-out infinite; }
.panel-dot.debris { background: var(--orange); box-shadow: 0 0 6px var(--orange); }
.panel-dot.rocket { background: var(--blue); box-shadow: 0 0 6px var(--blue); }

.panel-title {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 0.08em;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.panel-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  transition: color 0.2s;
  flex-shrink: 0;
}
.panel-close:hover { color: var(--text-bright); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.panel-placeholder {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-dim);
  text-align: center;
  font-size: 0.75rem;
  line-height: 1.6;
}
.placeholder-icon {
  font-size: 2.5rem;
  opacity: 0.3;
}

/* Telemetry rows */
.telem-section {
  margin-bottom: 20px;
}
.telem-section-title {
  font-family: var(--font-display);
  font-size: 0.55rem;
  color: var(--green-dim);
  letter-spacing: 0.2em;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.telem-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.telem-key {
  font-size: 0.62rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}
.telem-val {
  font-size: 0.75rem;
  color: var(--text-bright);
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}
.telem-val.highlight { color: var(--green); }
.telem-val.warn { color: var(--yellow); }
.telem-val.danger { color: var(--orange); }

.orbit-vis {
  margin: 16px 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.orbit-canvas { width: 100%; aspect-ratio: 1; max-width: 240px; }
.orbit-label {
  font-size: 0.58rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

/* ---- SEARCH ---- */
.search-container {
  position: fixed;
  top: 66px;
  left: 20px;
  z-index: 90;
  width: 280px;
}
.search-box {
  display: flex;
  align-items: center;
  background: rgba(6,13,20,0.92);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  padding: 0 10px;
  gap: 8px;
  clip-path: polygon(8px 0%, 100% 0%, calc(100% - 8px) 100%, 0% 100%);
}
.search-icon { font-size: 1rem; color: var(--text-dim); flex-shrink: 0; }
.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  padding: 9px 0;
}
.search-box input::placeholder { color: var(--text-dim); }
.search-clear { color: var(--text-dim); cursor: pointer; font-size: 0.7rem; display: none; }
.search-results {
  margin-top: 4px;
  background: rgba(6,13,20,0.96);
  border: 1px solid var(--border);
  max-height: 260px;
  overflow-y: auto;
  display: none;
  backdrop-filter: blur(8px);
}
.search-results.open { display: block; }
.search-result-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}
.search-result-item:hover { background: rgba(0,229,160,0.07); }
.search-result-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.search-result-name { font-size: 0.68rem; color: var(--text-bright); flex: 1; }
.search-result-type { font-size: 0.58rem; color: var(--text-dim); }

/* ---- LEGEND ---- */
.legend {
  position: fixed;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 80;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.62rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-active { background: var(--green); box-shadow: 0 0 5px var(--green); }
.dot-debris { background: var(--orange); box-shadow: 0 0 5px var(--orange); }
.dot-rocket { background: var(--blue); box-shadow: 0 0 5px var(--blue); }
.dot-unknown { background: var(--yellow); box-shadow: 0 0 5px var(--yellow); }

/* ---- TOOLTIP ---- */
.tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  background: rgba(6,13,20,0.95);
  border: 1px solid var(--border-bright);
  padding: 6px 10px;
  font-size: 0.65rem;
  color: var(--text-bright);
  letter-spacing: 0.06em;
  max-width: 200px;
  display: none;
  clip-path: polygon(6px 0%, 100% 0%, calc(100% - 6px) 100%, 0% 100%);
}
.tooltip.visible { display: block; }
.tooltip-name { font-weight: 700; color: var(--green); margin-bottom: 2px; font-family: var(--font-display); font-size: 0.6rem; }
.tooltip-sub { color: var(--text-dim); }

/* ---- CORNER DECORATIONS ---- */
.hud-header::before {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--green), transparent);
  opacity: 0.4;
}

/* Scanline overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 500;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

/* ---- ANIMATIONS ---- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .hud-stats { display: none; }
  .search-container { width: calc(100vw - 40px); }
  .info-panel { width: 100%; top: auto; bottom: 0; height: 60vh; transform: translateY(100%); }
  .info-panel.open { transform: translateY(0); }
  .legend { bottom: auto; top: 66px; right: 10px; left: auto; align-items: flex-end; }
}

/* Axis indicator */
.axis-label {
  position: fixed;
  font-size: 0.55rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  pointer-events: none;
  z-index: 80;
}

/* Data freshness indicator */
.freshness {
  position: fixed;
  bottom: 20px;
  right: 20px;
  font-size: 0.58rem;
  color: var(--text-dim);
  z-index: 80;
  text-align: right;
  line-height: 1.6;
}
.freshness .fresh { color: var(--green); }
.freshness .stale { color: var(--yellow); }
