/* ==========================================================================
   星軌探尋者 3D - 樣式表 (style.css)
   ========================================================================== */

:root {
  --bg-color: #02020a;
  --panel-bg: rgba(10, 10, 25, 0.45);
  --panel-border: rgba(255, 255, 255, 0.09);
  --panel-shadow: rgba(0, 0, 0, 0.45);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-color: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.4);
  --accent-success: #10b981;
  --accent-comet: #a78bfa;
  --accent-neo: #fb923c;
  --accent-neo-glow: rgba(251, 146, 60, 0.4);
  
  --font-title: 'Outfit', 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
  
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ==========================================================================
   基礎樣式 & 重設
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

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

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

/* ==========================================================================
   玻璃擬態面板元件 (Glassmorphism)
   ========================================================================== */
.glass {
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--panel-border);
  box-shadow: 0 12px 40px 0 var(--panel-shadow);
  border-radius: 16px;
  z-index: 10;
}

/* ==========================================================================
   載入動畫層
   ========================================================================== */
#loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #020207;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

#loader.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loader-content {
  text-align: center;
}

.loader-content h2 {
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 1.5rem;
  margin-top: 2rem;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.loader-content p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.progress-bar-container {
  width: 280px;
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 2px;
  margin: 1.5rem auto 0;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #a78bfa);
  border-radius: 2px;
  transition: width 0.1s ease;
}

/* 太陽系旋轉載入動畫 */
.orrery-loader {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto;
}

.loader-sun {
  position: absolute;
  top: 30px;
  left: 30px;
  width: 20px;
  height: 20px;
  background: #f59e0b;
  border-radius: 50%;
  box-shadow: 0 0 20px #f59e0b;
}

.loader-orbit-1, .loader-orbit-2 {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  animation: spin linear infinite;
}

.loader-orbit-1 {
  top: 15px;
  left: 15px;
  width: 50px;
  height: 50px;
  animation-duration: 2s;
}

.loader-orbit-2 {
  top: 0px;
  left: 0px;
  width: 80px;
  height: 80px;
  animation-duration: 4s;
}

.loader-planet-1, .loader-planet-2 {
  position: absolute;
  border-radius: 50%;
  background: #3b82f6;
}

.loader-planet-1 {
  top: 4px;
  left: 20px;
  width: 6px;
  height: 6px;
  box-shadow: 0 0 8px #3b82f6;
}

.loader-planet-2 {
  top: 8px;
  left: 60px;
  width: 8px;
  height: 8px;
  background: #a78bfa;
  box-shadow: 0 0 10px #a78bfa;
}

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

/* ==========================================================================
   HUD: 頂部資訊列
   ========================================================================== */
.hud-header {
  position: absolute;
  top: 24px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.icon-orbit {
  display: flex;
  color: var(--accent-color);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo h1 {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 3px;
  color: var(--text-primary);
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.logo h1 span {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--accent-color);
  border: 1.5px solid var(--accent-color);
  padding: 1px 4px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 4px;
}

.time-hud {
  pointer-events: auto;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  padding: 8px 18px;
  border-radius: 12px;
  text-align: right;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.hud-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 2px;
}

.hud-value {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

/* ==========================================================================
   控制面板 (Control Panel)
   ========================================================================== */
.control-panel {
  position: absolute;
  bottom: 24px;
  left: 24px;
  width: 320px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.play-controls {
  flex-direction: row;
  align-items: center;
  gap: 16px;
}

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

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

#speed-value {
  font-family: var(--font-title);
  color: var(--accent-color);
  font-weight: 600;
}

/* 按鈕樣式 */
.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: var(--transition-smooth);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  transform: translateY(-1px);
}

.btn-icon.circle {
  border-radius: 50%;
  width: 44px;
  height: 44px;
}

.btn-icon.circle.active {
  background: var(--accent-color);
  border-color: var(--accent-color);
  box-shadow: 0 0 15px var(--accent-glow);
}

.btn-icon.circle.active:hover {
  filter: brightness(1.1);
}

.btn-icon.mini {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

/* 滑桿樣式 */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent-color);
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 0 8px var(--accent-glow);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 12px var(--accent-color);
}

/* 分割線 */
.control-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

/* 開關切換樣式 */
.toggle-controls {
  gap: 12px;
}

.toggle-switch {
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

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

.slider-round {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 18px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  transition: var(--transition-smooth);
  margin-right: 12px;
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  border-radius: 50%;
  transition: var(--transition-smooth);
}

input:checked + .slider-round {
  background-color: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-glow);
}

input:checked + .slider-round:before {
  transform: translateX(18px);
}

.toggle-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 400;
  transition: var(--transition-smooth);
}

.toggle-switch:hover .toggle-text {
  color: var(--text-primary);
}

/* 行星快速導航 */
.navigation {
  gap: 12px;
}

.section-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.navigator-buttons {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.nav-btn {
  grid-column: span 2;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  transition: var(--transition-smooth);
  text-align: center;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.nav-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent-color);
  color: var(--accent-color);
  font-weight: 600;
  box-shadow: inset 0 0 6px rgba(59, 130, 246, 0.2);
}

.nav-btn.comet {
  grid-column: span 6;
  background: rgba(167, 139, 250, 0.08);
  border-color: rgba(167, 139, 250, 0.15);
  color: var(--accent-comet);
}

.nav-btn.comet:hover {
  background: rgba(167, 139, 250, 0.15);
  border-color: var(--accent-comet);
  color: #fff;
}

.nav-btn.comet.active {
  background: rgba(167, 139, 250, 0.2);
  border-color: var(--accent-comet);
  color: #fff;
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.3);
}

.nav-btn.neo {
  grid-column: span 3;
  background: rgba(251, 146, 60, 0.07);
  border-color: rgba(251, 146, 60, 0.12);
  color: var(--accent-neo);
}

.nav-btn.neo:hover {
  background: rgba(251, 146, 60, 0.14);
  border-color: var(--accent-neo);
  color: #fff;
}

.nav-btn.neo.active {
  background: rgba(251, 146, 60, 0.18);
  border-color: var(--accent-neo);
  color: #fff;
  box-shadow: 0 0 8px rgba(251, 146, 60, 0.28);
}

/* ==========================================================================
   右側天體資訊面板 (Info Panel)
   ========================================================================== */
.info-panel {
  position: absolute;
  top: 96px;
  right: 24px;
  width: 340px;
  padding: 24px;
  max-height: calc(100% - 150px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.info-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.info-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.badge {
  align-self: flex-start;
  font-size: 0.65rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent-color);
  color: #fff;
}

/* 針對哈雷彗星的徽章顏色 */
.badge.badge-comet {
  background: var(--accent-comet);
}

.badge.badge-neo {
  background: var(--accent-neo);
}

.info-panel h2 {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  margin-top: 4px;
}

#info-body-english {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.description {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* 網格數據 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 8px;
}

.stat-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 10px 12px;
}

.stat-item.full-width {
  grid-column: span 2;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* 星際簡記卡片 */
.fact-box {
  background: rgba(59, 130, 246, 0.05);
  border-left: 3px solid var(--accent-color);
  border-radius: 0 8px 8px 0;
  padding: 12px;
  font-size: 0.8rem;
  line-height: 1.5;
}

/* 當選擇彗星時的簡記卡片邊框 */
.fact-box.fact-comet {
  background: rgba(167, 139, 250, 0.05);
  border-left-color: var(--accent-comet);
}

/* 當選擇近地天體時的簡記卡片邊框 */
.fact-box.fact-neo {
  background: rgba(251, 146, 60, 0.05);
  border-left-color: var(--accent-neo);
}

.fact-title {
  display: block;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   頁尾說明列 (HUD Footer)
   ========================================================================== */
.hud-footer {
  position: absolute;
  bottom: 16px;
  left: 360px;
  right: 24px;
  display: flex;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}

.interaction-tip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.dot {
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

/* ==========================================================================
   捲軸優化
   ========================================================================== */
.info-panel::-webkit-scrollbar {
  width: 4px;
}

.info-panel::-webkit-scrollbar-track {
  background: transparent;
}

.info-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.info-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   全局重置視角與衛星列表樣式
   ========================================================================== */
.hud-time-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.btn-global-reset {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-global-reset:hover {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
  box-shadow: 0 0 10px var(--accent-glow);
  transform: translateY(-1px);
}

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

/* 衛星板塊 */
.moons-section {
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  margin-top: 16px;
  padding-top: 14px;
}

.moons-title {
  display: block;
  font-family: var(--font-title);
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.moons-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.moon-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.78rem;
  transition: var(--transition-smooth);
}

.moon-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
}

.moon-name {
  color: var(--text-primary);
  font-weight: 500;
}

.moon-details {
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-family: var(--font-title);
}

/* ==========================================================================
   響應式設計 (Media Queries)
   ========================================================================== */
@media (max-width: 900px) {
  .hud-header {
    top: 16px;
    left: 16px;
    right: 16px;
  }
  
  .logo h1 {
    font-size: 1.1rem;
  }
  
  .time-hud {
    padding: 6px 12px;
  }
  
  .hud-value {
    font-size: 1rem;
  }
  
  .control-panel {
    bottom: 16px;
    left: 16px;
    width: calc(100% - 32px);
    max-height: 250px;
    overflow-y: auto;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 16px;
  }
  
  .control-section {
    flex: 1 1 200px;
  }
  
  .control-divider {
    display: none;
  }
  
  .info-panel {
    top: 80px;
    right: 16px;
    width: calc(100% - 32px);
    left: 16px;
    max-height: 40%;
  }
  
  .hud-footer {
    display: none;
  }
}

/* ==========================================================================
   太陽方向指示器
   ========================================================================== */
.sun-indicator {
  position: absolute;
  z-index: 99;
  width: 54px;
  height: 54px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.8));
  transition: opacity 0.2s ease;
}

.sun-indicator-arrow {
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 12px solid #fb923c; /* 亮橘色箭頭 */
  margin-bottom: 3px;
}

.sun-indicator-text {
  font-family: var(--font-title);
  font-size: 0.65rem;
  font-weight: 700;
  color: #fb923c;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  letter-spacing: 1px;
}

.nav-btn.spacecraft {
  grid-column: span 6;
  background: rgba(229, 231, 235, 0.08);
  border-color: rgba(229, 231, 235, 0.15);
  color: #e5e7eb;
}

.nav-btn.spacecraft:hover {
  background: rgba(229, 231, 235, 0.15);
  border-color: #fff;
  color: #fff;
}

.nav-btn.spacecraft.active {
  background: rgba(229, 231, 235, 0.22);
  border-color: #fff;
  color: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
}

.badge.badge-spacecraft {
  background: #6b7280;
}

