/* style.css - Space app visual theme */

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

:root {
  --bg: #000008;
  --panel-bg: rgba(0, 0, 8, 0.78);
  --panel-border: rgba(255, 255, 255, 0.09);
  --text-primary: rgba(255, 255, 255, 0.92);
  --text-secondary: rgba(255, 255, 255, 0.55);
  --text-dim: rgba(255, 255, 255, 0.35);
  --blue: rgba(80, 130, 255, 0.85);
  --green: rgba(50, 205, 100, 0.85);
  --green-bg: rgba(50, 205, 100, 0.15);
  --green-border: rgba(50, 205, 100, 0.55);
  --btn-bg: rgba(255, 255, 255, 0.06);
  --btn-border: rgba(255, 255, 255, 0.13);
  --btn-hover-bg: rgba(255, 255, 255, 0.14);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

/* ─── Canvas ──────────────────────────────────────────────────────────────── */
#main-canvas {
  display: block;
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ─── Transition overlay ─────────────────────────────────────────────────── */
#transition-overlay {
  position: fixed;
  inset: 0;
  background: #000008;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: opacity 0.3s ease;
}
#transition-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Views ──────────────────────────────────────────────────────────────── */
#globe-view,
#sky-view {
  position: fixed;
  top: 44px; right: 0; bottom: 0; left: 0;
  z-index: 10;
  pointer-events: none;
}

#globe-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 28px;
}

#sky-view {
  display: none;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  padding: 20px;
}

/* ─── Shared panel ───────────────────────────────────────────────────────── */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 16px 20px;
  pointer-events: auto;
}

.panel-sm {
  padding: 10px 14px;
}

/* ─── Button base ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 22px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
  user-select: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--btn-hover-bg);
  border-color: rgba(255, 255, 255, 0.25);
}

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

.btn.active {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: rgba(120, 230, 150, 0.95);
}

.btn.primary {
  background: rgba(80, 130, 255, 0.18);
  border-color: rgba(80, 130, 255, 0.5);
  color: rgba(140, 180, 255, 0.95);
}

.btn.primary:hover {
  background: rgba(80, 130, 255, 0.28);
  border-color: rgba(80, 130, 255, 0.7);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.btn.enabled {
  opacity: 1;
  pointer-events: auto;
}

.btn-icon {
  font-size: 14px;
  line-height: 1;
}

/* ─── Globe view UI ──────────────────────────────────────────────────────── */
#globe-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#app-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-align: center;
}

#app-subtitle {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
}

#globe-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 420px;
}

#location-display {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  width: 100%;
}

#location-name {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

#location-coords {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

#globe-hint {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
}

/* ─── Sky view UI ────────────────────────────────────────────────────────── */
#sky-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

#sky-top-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#sky-info-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#time-display {
  font-size: 18px;
  font-weight: 300;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

#sky-location {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

#sky-top-right {
  pointer-events: auto;
}

/* ─── Sky controls panel ─────────────────────────────────────────────────── */
#sky-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.controls-label {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  min-width: 40px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 10px;
  letter-spacing: 0.1em;
  border-radius: 18px;
}

.divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

/* ─── CSS2D label layer — below UI panels (z-index 10+) but above terrain (6) */
#sky-labels {
  z-index: 8;
}

/* ─── Constellation labels (CSS2D) ───────────────────────────────────────── */
.constellation-label {
  background: rgba(0, 0, 8, 0.55);
  border: 1px solid rgba(80, 130, 255, 0.2);
  border-radius: 6px;
  padding: 2px 7px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(140, 175, 255, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

/* ─── Planet labels (CSS2D) ──────────────────────────────────────────────── */
.planet-label {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(255, 230, 160, 0.85);
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 0 6px rgba(255, 180, 60, 0.5);
}

/* ─── Cardinal direction labels ──────────────────────────────────────────── */
.cardinal-label {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(100, 160, 255, 0.55);
  pointer-events: none;
}

.cardinal-primary {
  font-size: 14px;
  color: rgba(120, 180, 255, 0.75);
}

/* ─── Star name labels (CSS2D) ───────────────────────────────────────────── */
.star-label {
  position: absolute;
  left: 7px;
  top: -16px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: rgba(220, 230, 255, 0.70);
  pointer-events: none;
  white-space: nowrap;
}

/* ─── Constellation label — clickable ────────────────────────────────────── */
.constellation-label {
  cursor: pointer;
  pointer-events: auto;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, opacity 0.3s ease;
}
.constellation-label:hover {
  color: rgba(180, 210, 255, 1.0);
  border-color: rgba(80, 130, 255, 0.55);
  background: rgba(0, 0, 8, 0.75);
}

/* ─── Constellation info panel ───────────────────────────────────────────── */
#const-panel {
  position: fixed;
  top: 44px;
  right: 0;
  width: 300px;
  height: calc(100vh - 44px);
  height: calc(100dvh - 44px);
  z-index: 50;
  background: rgba(0, 0, 12, 0.88);
  border-left: 1px solid rgba(80, 130, 255, 0.18);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  padding: 24px 20px 32px;
  gap: 18px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

#const-panel.open {
  transform: translateX(0);
  pointer-events: auto;
}

#const-panel-close {
  align-self: flex-end;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.5);
  width: 28px;
  height: 28px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
#const-panel-close:hover {
  border-color: rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.85);
}

#const-panel-header {
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-bottom: 1px solid rgba(80, 130, 255, 0.15);
  padding-bottom: 16px;
}

#const-panel-name {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.95);
}

#const-panel-meaning {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(120, 165, 255, 0.75);
}

#const-panel-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#const-panel-lore {
  font-size: 13px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.68);
}

.const-panel-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.const-panel-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.28);
}

#const-panel-stars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.const-star-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.const-star-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.const-star-name {
  font-size: 12px;
  font-weight: 500;
  color: rgba(220, 230, 255, 0.85);
  flex: 1;
}

.const-star-mag {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.30);
  font-variant-numeric: tabular-nums;
}

.const-panel-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.const-panel-meta-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.const-panel-meta-item span:last-child {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.60);
}

@media (max-width: 600px) {
  #const-panel {
    width: 100%;
    height: 55%;
    top: auto;
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: 1px solid rgba(80, 130, 255, 0.18);
    transform: translateY(100%);
    border-radius: 16px 16px 0 0;
  }
  #const-panel.open {
    transform: translateY(0);
  }
}

/* ─── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

/* ─── Compass ─────────────────────────────────────────────────────────────── */
#sky-top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

#compass-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

#compass-canvas {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  display: block;
}

#compass-heading {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ─── Terrain horizon ─────────────────────────────────────────────────────── */
/* Position is set each frame by JS — top moves with the visual horizon */
#terrain-horizon {
  position: fixed;
  left: 0;
  right: 0;
  height: 220px;   /* tall enough to show far-mountain peaks well above horizon */
  z-index: 6;
  pointer-events: none;
  display: none;
}

#terrain-horizon.visible {
  display: block;
}

#terrain-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Solid ground: fills from visual horizon to bottom edge of viewport */
#ground-fill {
  position: fixed;
  left: 0;
  right: 0;
  background: #040c18;
  z-index: 6;
  pointer-events: none;
  display: none;
}

#ground-fill.visible {
  display: block;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #globe-view { padding: 16px; }
  #sky-view { padding: 12px; }
  #time-display { font-size: 14px; }
  .btn { padding: 7px 14px; font-size: 10px; }
  .constellation-label { font-size: 11px; }
}

/* ─── Loading state ───────────────────────────────────────────────────────── */
#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 200;
  gap: 16px;
  transition: opacity 0.5s ease;
}

#loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-text {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.loading-dots {
  display: flex;
  gap: 6px;
}

.loading-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(80, 130, 255, 0.7);
  animation: dotPulse 1.2s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}
