/**
 * Interstellar Voyage - Cybernetic Cockpit & Sci-Fi HUD Stylesheet
 * Kamos Pure Aesthetic: Outfit, JetBrains Mono, Glassmorphism, Emerald/Cyan Glow
 */

:root {
  --hud-cyan: #38bdf8;
  --hud-emerald: #10b981;
  --hud-purple: #c084fc;
  --hud-amber: #f59e0b;
  --hud-bg-glass: rgba(15, 23, 42, 0.72);
  --hud-border-glass: rgba(255, 255, 255, 0.12);
  --hud-glow-cyan: 0 0 16px rgba(56, 189, 248, 0.35);
  --hud-glow-emerald: 0 0 16px rgba(16, 185, 129, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: #020617;
  color: #f8fafc;
  font-family: 'Outfit', 'Noto Sans JP', sans-serif;
  user-select: none;
}

/* Fullscreen 3D Viewport */
#interstellar-viewport {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#interstellar-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* HUD Overlay Layer */
.hud-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(12px, 2vw, 24px);
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.35s;
}

/* Hide all panels when ESC is toggled */
body.hud-hidden .hud-layer,
body.hud-hidden .hud-crosshair,
body.hud-hidden #knav-root,
body.hud-hidden #kfooter-root {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: scale(0.98);
  visibility: hidden;
}

/* Minimal HUD Restore Pill (Appears when HUD is hidden) */
#hud-reveal-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
  color: #94a3b8;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#hud-reveal-btn:hover {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(15, 23, 42, 0.85);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.25);
}

body.hud-hidden #hud-reveal-btn {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.hud-interactive {
  pointer-events: auto;
}

/* Glass Panels */
.hud-glass-panel {
  background: var(--hud-bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--hud-border-glass);
  border-radius: 16px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.7);
}

/* Top Telemetry Header */
.hud-telemetry-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  margin-top: 50px; /* Clearance for kamos-nav */
}

.telemetry-item {
  display: flex;
  flex-direction: column;
}

.telemetry-label {
  font-size: 0.65rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #94a3b8;
  text-transform: uppercase;
}

.telemetry-value {
  font-size: 1.15rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--hud-cyan);
  text-shadow: var(--hud-glow-cyan);
}

.hud-badge {
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.08em;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: var(--hud-glow-emerald);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  animation: pulse-dot 1.5s infinite;
}

.hud-badge.mode-manual {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}
.hud-badge.mode-manual::before {
  background: #fbbf24;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* Center Crosshair for Cockpit/Manual Aiming */
.hud-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  pointer-events: none;
  opacity: 0.4;
  transition: opacity 0.3s ease, transform 0.2s ease;
}

.hud-crosshair::before, .hud-crosshair::after {
  content: '';
  position: absolute;
  background: var(--hud-cyan);
}
.hud-crosshair::before {
  top: 23px; left: 0; width: 48px; height: 2px;
}
.hud-crosshair::after {
  top: 0; left: 23px; width: 2px; height: 48px;
}

/* Right Planet Info Card */
.hud-info-card {
  position: absolute;
  right: clamp(16px, 2.5vw, 32px);
  top: 130px;
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100vh - 270px);
  overflow-y: auto;
  padding: 22px 24px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.hud-info-card::-webkit-scrollbar {
  width: 4px;
}
.hud-info-card::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.info-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.info-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0;
  line-height: 1.2;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.info-subtitle {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--hud-cyan);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-desc {
  font-size: 0.88rem;
  line-height: 1.65;
  color: #cbd5e1;
  margin-bottom: 16px;
}

.info-specs-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.8rem;
  font-family: 'JetBrains Mono', monospace;
  background: rgba(0, 0, 0, 0.35);
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.spec-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.spec-label {
  color: #94a3b8;
}

.spec-val {
  color: #f1f5f9;
  font-weight: 600;
  text-align: right;
}

/* Bottom Controls & Selector */
.hud-bottom-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

/* Planet Waypoint Horizontal Selector Bar */
.planet-selector-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 12px;
  scrollbar-width: none;
}
.planet-selector-scroll::-webkit-scrollbar {
  display: none;
}

.selector-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 9999px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.selector-pill:hover {
  background: rgba(30, 41, 59, 0.8);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.selector-pill.active {
  background: rgba(16, 185, 129, 0.2);
  color: #ffffff;
  border-color: #10b981;
  box-shadow: var(--hud-glow-emerald);
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Action Controls Dock */
.hud-dock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 18px;
}

.hud-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f8fafc;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hud-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--hud-cyan);
  color: #ffffff;
  box-shadow: var(--hud-glow-cyan);
  transform: translateY(-1px);
}

.hud-btn.active {
  background: rgba(16, 185, 129, 0.25);
  border-color: var(--hud-emerald);
  color: #34d399;
}

.hud-btn-primary {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  border-color: #34d399;
  color: #ffffff;
  box-shadow: var(--hud-glow-emerald);
}

.hud-btn-primary:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

/* Left Bottom Minimap Radar */
.hud-minimap-box {
  position: absolute;
  left: clamp(16px, 2.5vw, 32px);
  bottom: clamp(16px, 2.5vw, 32px);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.minimap-title {
  font-size: 0.65rem;
  font-family: 'JetBrains Mono', monospace;
  color: #94a3b8;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

#hud-minimap-canvas {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(2, 6, 23, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: inset 0 0 20px rgba(56, 189, 248, 0.1);
}

/* Cockpit Visor Vignette Overlay (FPS Mode) */
#cockpit-hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  background: radial-gradient(circle, transparent 55%, rgba(0, 0, 0, 0.65) 90%, rgba(0, 0, 0, 0.9) 100%);
  border: 1px solid rgba(56, 189, 248, 0.15);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 10;
}

#cockpit-hud-overlay.active {
  opacity: 1;
}

/* Mobile Touch Controls */
.mobile-touch-controls {
  display: none;
  position: absolute;
  bottom: 120px;
  right: 20px;
  flex-direction: column;
  gap: 12px;
  z-index: 30;
}

.btn-touch-action {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.75);
  border: 1.5px solid var(--hud-cyan);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  backdrop-filter: blur(10px);
}

@media (max-width: 768px) {
  .hud-info-card {
    top: auto;
    bottom: 120px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: 220px;
    padding: 14px 16px;
  }
  .hud-minimap-box {
    display: none;
  }
  .mobile-touch-controls {
    display: flex;
  }
}
