/* ==========================================================================
   COSMOS: 3D Solar System Simulation - Stylesheet
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Reset & Global Variables
   -------------------------------------------------------------------------- */
:root {
  --bg-deep-space: #03030c;
  --accent-cyan: #00f3ff;
  --accent-blue: #0077ff;
  --accent-orange: #ff7700;
  --accent-magenta: #f72585;
  --text-primary: #ffffff;
  --text-secondary: #a0a5c0;
  --glass-bg: rgba(10, 10, 25, 0.55);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: rgba(0, 0, 0, 0.5);
  --font-hud: 'Orbitron', sans-serif;
  --font-body: 'Outfit', sans-serif;
  --sidebar-width: 420px;
}

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep-space);
  font-family: var(--font-body);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 3D Viewport */
#canvas-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* --------------------------------------------------------------------------
   2. Glassmorphism Helper & Transitions
   -------------------------------------------------------------------------- */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px 0 var(--glass-shadow);
  border-radius: 12px;
}

/* --------------------------------------------------------------------------
   3. HUD & Overlay Elements
   -------------------------------------------------------------------------- */

/* Header HUD */
#hud-header {
  position: absolute;
  top: 25px;
  left: 25px;
  z-index: 10;
  pointer-events: none;
  animation: fadeIn 1s ease-out;
}

#hud-header h1 {
  font-family: var(--font-hud);
  font-weight: 900;
  font-size: 2.2rem;
  letter-spacing: 6px;
  background: linear-gradient(45deg, #ffffff 30%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(0, 243, 255, 0.2);
}

#hud-header .subtitle {
  font-family: var(--font-hud);
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 4px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
}

/* Date HUD */
#date-hud {
  position: absolute;
  top: 25px;
  right: 25px;
  z-index: 10;
  padding: 12px 24px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

#date-hud.hud-hidden {
  opacity: 0;
  transform: translateY(-20px);
  pointer-events: none;
}

#date-hud.hud-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

#date-hud .hud-label {
  font-family: var(--font-hud);
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--accent-cyan);
  text-transform: uppercase;
  margin-bottom: 4px;
  text-shadow: 0 0 8px rgba(0, 243, 255, 0.4);
}

#date-string {
  font-family: var(--font-hud);
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 1px;
}

/* Bottom center interaction hint */
#interaction-hint {
  position: absolute;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 300;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(10, 10, 25, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: pulseHint 2.5s infinite alternate;
}

.hint-icon {
  color: var(--accent-cyan);
  font-size: 1.1rem;
  animation: spinSlow 4s linear infinite;
}

/* --------------------------------------------------------------------------
   4. Controls Panel
   -------------------------------------------------------------------------- */
#controls-panel {
  position: absolute;
  bottom: 25px;
  left: 25px;
  z-index: 10;
  width: 280px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px 0 var(--glass-shadow);
  border-radius: 12px;
  transition: opacity 0.3s ease;
}

#controls-panel h3 {
  font-family: var(--font-hud);
  font-size: 0.9rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-group.toggle-group {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.control-group label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.glass-select {
  background: rgba(15, 18, 36, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
}

.glass-select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
}

.glass-select option {
  background: #0f1224;
  color: var(--text-primary);
}

#speed-val {
  color: var(--accent-cyan);
  font-weight: 600;
}

/* Slider Custom Styling */
input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
}

input[type=range]:focus {
  outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  transition: background 0.3s;
}

input[type=range]::-webkit-slider-thumb {
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -5px;
  box-shadow: 0 0 10px var(--accent-cyan);
  transition: transform 0.1s, background-color 0.2s;
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #ffffff;
}

/* Toggle Switch Custom Styling */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
}

input:checked + .slider {
  background-color: var(--accent-cyan);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--accent-cyan);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Button Primary UI */
.btn-primary {
  font-family: var(--font-body);
  background: transparent;
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-primary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(0, 243, 255, 0.15);
}

.btn-primary:active {
  transform: scale(0.97);
}

/* --------------------------------------------------------------------------
   5. Educational Sidebar Panel
   -------------------------------------------------------------------------- */
#sidebar {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: 100%;
  z-index: 100;
  padding: 40px 30px;
  display: flex;
  flex-direction: column;
  background: rgba(6, 6, 18, 0.72);
  border-left: 1px solid var(--glass-border);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease;
  overflow-y: auto;
}

.sidebar-hidden {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.sidebar-visible {
  transform: translateX(0);
  opacity: 1;
  pointer-events: all;
}

/* Close Button */
.close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  font-size: 2rem;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s, transform 0.2s;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.close-btn:hover {
  color: #ff3366;
  transform: rotate(90deg);
  background: rgba(255, 51, 102, 0.05);
}

/* Sidebar Content Styling */
.sidebar-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

.planet-header {
  margin-top: 20px;
  margin-bottom: 24px;
}

.planet-header h2 {
  font-family: var(--font-hud);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #ffffff;
  margin-bottom: 8px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  border-radius: 4px;
  background: rgba(0, 243, 255, 0.15);
  border: 1px solid rgba(0, 243, 255, 0.3);
  color: var(--accent-cyan);
}

.planet-summary {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
  font-weight: 300;
  margin-bottom: 30px;
}

/* Planet Stats Grid */
.planet-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.3s, border-color 0.3s;
}

.stat-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

.stat-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
}

/* Action Button inside Sidebar */
.btn-action {
  font-family: var(--font-hud);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-cyan) 100%);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(0, 119, 255, 0.3);
  margin-top: auto;
}

.btn-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 243, 255, 0.5);
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-blue) 100%);
}

.btn-action:active {
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   6. Keyframe Animations & Utilities
   -------------------------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseHint {
  from { opacity: 0.6; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); }
  to { opacity: 1; box-shadow: 0 4px 25px rgba(0, 243, 255, 0.15); }
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Custom Scrollbars for Sidebar */
#sidebar::-webkit-scrollbar {
  width: 5px;
}

#sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

/* --------------------------------------------------------------------------
   7. Responsive adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  #sidebar {
    width: 100%;
  }
  
  #hud-header h1 {
    font-size: 1.8rem;
  }
  
  #controls-panel {
    width: calc(100% - 50px);
  }

  #interaction-hint {
    display: none; /* Hide hint on small screens to save space */
  }

  #date-hud {
    top: 95px; /* Stack below the title header on small screens */
    left: 25px;
    right: auto;
    align-items: flex-start;
    text-align: left;
    min-width: calc(100% - 50px);
  }
}

/* Tour Autopilot Button */
.btn-tour {
  background: linear-gradient(135deg, var(--accent-magenta) 0%, #7b2cbf 100%) !important;
  border: 1px solid rgba(247, 37, 133, 0.4) !important;
  margin-top: 10px;
}

.btn-tour:hover {
  box-shadow: 0 0 15px rgba(247, 37, 133, 0.4) !important;
}

/* Tour Narration Overlay (Glassmorphic, bottom-center HUD) */
#tour-overlay {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 480px;
  max-width: 90vw;
  background: rgba(10, 12, 28, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 20px;
  color: var(--text-primary);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.tour-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 40px) scale(0.9) !important;
}

.tour-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

.tour-badge {
  font-size: 0.7rem;
  color: var(--accent-magenta);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 2px;
}

#tour-title {
  margin: 0;
  font-size: 1.15rem;
  color: var(--text-primary);
  font-weight: 600;
}

#tour-narration {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.tour-controls {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
}

.tour-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-grow: 1;
}

.tour-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.tour-exit-btn {
  background: rgba(230, 57, 70, 0.2);
  border-color: rgba(230, 57, 70, 0.4);
  color: #ff4d6d;
}

.tour-exit-btn:hover {
  background: rgba(230, 57, 70, 0.35);
  border-color: rgba(230, 57, 70, 0.6);
}

.tour-progress {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 5px;
}

#tour-progress-bar {
  height: 100%;
  background: var(--accent-magenta);
  box-shadow: 0 0 8px var(--accent-magenta);
  transition: width 0.5s ease;
}

/* ── Interactive HUDs & Tool Panels ── */
#measure-hud {
  position: absolute;
  top: 25px;
  left: 320px;
  z-index: 10;
  width: 280px;
  padding: 16px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#measure-hud.hud-hidden {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}
#measure-hud.hud-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}
#measure-details {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-top: 10px;
}
#measure-details strong {
  color: var(--text-primary);
}
.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hud-header h4 {
  font-family: var(--font-hud);
  font-size: 0.85rem;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#conjunctions-hud {
  position: absolute;
  top: 120px;
  right: 25px;
  z-index: 10;
  width: 220px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: all;
}
.conjunction-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  font-size: 0.75rem;
  font-family: inherit;
  color: inherit;
  text-align: left;
  appearance: none;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.conjunction-item:hover {
  background: rgba(255,255,255,0.08);
}
.conjunction-item:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}
.conjunction-item:not(button) {
  cursor: default;
}
.conj-names {
  font-weight: 600;
  color: var(--text-primary);
}
.conj-date {
  color: var(--text-secondary);
  font-size: 0.7rem;
}
.conj-arrow {
  color: var(--accent-cyan);
  font-size: 0.85rem;
  transition: transform 0.2s ease;
}
.conjunction-item:hover .conj-arrow {
  transform: translateX(2px);
}

/* Modals */
#launch-modal, #shortcuts-modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1000;
  background: rgba(3, 3, 12, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.modal-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}
.modal-content {
  width: 90%;
  max-width: 440px;
  padding: 30px;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 10px;
}
.modal-header h3 {
  font-family: var(--font-hud);
  font-size: 1.2rem;
  color: var(--accent-cyan);
}
.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  cursor: pointer;
  transition: color 0.2s ease;
}
.close-btn:hover {
  color: var(--text-primary);
}

.glass-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 8px 12px;
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.3s ease;
}
.glass-input:focus {
  border-color: var(--accent-cyan);
}
.form-group {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.form-group-row {
  display: flex;
  gap: 15px;
}
.form-group-row .form-group {
  flex: 1;
}
.btn-submit {
  margin-top: 10px;
  width: 100%;
}

.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}
kbd {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--accent-cyan);
  box-shadow: 0 2px 0 rgba(0,0,0,0.5);
}
