/* ===== Earth Explorer — Google Earth inspired UI ===== */
:root {
  --bg: #02040a;
  --panel: rgba(8, 14, 28, 0.72);
  --panel-border: rgba(120, 180, 255, 0.18);
  --text: #e8f0ff;
  --muted: rgba(200, 220, 255, 0.55);
  --accent: #4db8ff;
  --accent-2: #7c5cff;
  --danger: #ff5c7a;
  --success: #3dffa8;
  --glow: 0 0 40px rgba(77, 184, 255, 0.25);
  --radius: 18px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
}

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

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

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background: #02040a;
}

/* Hide default MapLibre attribution (we show our own) */
.maplibregl-ctrl-attrib,
.maplibregl-ctrl-logo {
  display: none !important;
}

/* Nudge MapLibre nav so it doesn't clash with our buttons */
.maplibregl-ctrl-bottom-right {
  bottom: 5.5rem !important;
  right: 0.75rem !important;
}
.maplibregl-ctrl-group {
  background: rgba(8, 14, 28, 0.75) !important;
  border: 1px solid rgba(120, 180, 255, 0.18) !important;
  border-radius: 12px !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35) !important;
  overflow: hidden;
}
.maplibregl-ctrl-group button {
  width: 36px !important;
  height: 36px !important;
  background-color: transparent !important;
}
.maplibregl-ctrl-group button + button {
  border-top-color: rgba(120, 180, 255, 0.12) !important;
}
.maplibregl-ctrl-group button:hover {
  background-color: rgba(77, 184, 255, 0.12) !important;
}
.maplibregl-ctrl-icon {
  filter: invert(1) brightness(1.2);
}

.vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 50%, transparent 45%, rgba(0, 0, 8, 0.4) 100%),
    linear-gradient(180deg, rgba(0, 8, 20, 0.28) 0%, transparent 16%, transparent 84%, rgba(0, 4, 12, 0.4) 100%);
  z-index: 1;
}

/* Compact location pin (not a huge square) */
.geo-marker {
  position: relative;
  width: 18px;
  height: 18px;
  pointer-events: none;
}
.geo-marker-dot {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #ff5c7a;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 0 12px rgba(255, 92, 122, 0.8);
  z-index: 2;
}
.geo-marker-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(77, 184, 255, 0.85);
  animation: markerPulse 1.6s ease-out infinite;
  z-index: 1;
}
@keyframes markerPulse {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}

.map-attrib {
  position: absolute;
  bottom: 0.45rem;
  left: 0.75rem;
  z-index: 10;
  font-size: 0.58rem;
  color: rgba(180, 200, 230, 0.35);
  max-width: 42%;
  line-height: 1.3;
  pointer-events: none;
}

/* ===== Loader ===== */
#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  background: radial-gradient(ellipse at center, #0a1630 0%, #02040a 70%);
  transition: opacity 0.8s ease, visibility 0.8s;
}
#loader.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-orbit {
  position: relative;
  width: 90px;
  height: 90px;
}
.loader-planet {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #6ec8ff, #1a5f9e 55%, #0a2a4a);
  box-shadow: 0 0 30px rgba(77, 184, 255, 0.45), inset -8px -4px 16px rgba(0, 0, 0, 0.4);
}
.loader-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-right-color: rgba(124, 92, 255, 0.5);
  animation: spin 1.1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loader-text {
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.loader-bar {
  width: 180px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.loader-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ===== Top bar ===== */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  pointer-events: none;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  pointer-events: auto;
}
.brand-icon {
  font-size: 1.6rem;
  filter: drop-shadow(0 0 8px rgba(77, 184, 255, 0.5));
}
.brand h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, #9ecfff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand p {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 1px;
}
.top-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: auto;
}
.coords {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
}
.detail-badge {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #b8ffe0;
  background: rgba(20, 50, 40, 0.75);
  border: 1px solid rgba(61, 255, 168, 0.35);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
}

/* ===== Search ===== */
.search-panel {
  position: absolute;
  top: 5.2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  width: min(520px, calc(100% - 2rem));
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.4rem 0.4rem 1rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: var(--glow), 0 8px 32px rgba(0, 0, 0, 0.4);
  transition: border-color 0.25s, box-shadow 0.25s;
}
.search-box:focus-within {
  border-color: rgba(77, 184, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(77, 184, 255, 0.12), var(--glow);
}
.search-box.listening {
  border-color: rgba(255, 92, 122, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 92, 122, 0.15), 0 0 40px rgba(255, 92, 122, 0.2);
}
.search-box.flying {
  border-color: rgba(61, 255, 168, 0.5);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex-shrink: 0;
}

#searchInput {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 400;
  padding: 0.55rem 0.4rem;
}
#searchInput::placeholder { color: rgba(180, 200, 230, 0.4); }

.mic-btn, .go-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform 0.15s, background 0.2s;
}
.mic-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}
.mic-btn:hover { background: rgba(255, 255, 255, 0.12); transform: scale(1.05); }
.mic-btn.active {
  background: linear-gradient(135deg, #ff5c7a, #ff8a5c);
  color: #fff;
  box-shadow: 0 0 20px rgba(255, 92, 122, 0.5);
}
.mic-btn svg { width: 18px; height: 18px; position: relative; z-index: 1; }
.mic-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255, 92, 122, 0.4);
  opacity: 0;
  transform: scale(1);
}
.mic-btn.active .mic-pulse {
  animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse {
  0% { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.8); }
}

.go-btn {
  background: linear-gradient(135deg, #4db8ff 0%, #7c5cff 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(77, 184, 255, 0.35);
}
.go-btn:hover { transform: scale(1.06); }
.go-btn:active { transform: scale(0.96); }
.go-btn svg { width: 18px; height: 18px; }

/* Suggestions */
.suggestions {
  margin-top: 0.5rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  max-height: 280px;
  overflow-y: auto;
}
.suggestions[hidden] { display: none; }
.suggestion-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover, .suggestion-item:focus {
  background: rgba(77, 184, 255, 0.1);
  outline: none;
}
.suggestion-item .s-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.suggestion-item .s-title { font-weight: 500; }
.suggestion-item .s-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Voice status */
.voice-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
  font-size: 0.8rem;
  color: #ffb0bc;
  animation: fadeIn 0.3s ease;
}
.voice-status[hidden] { display: none; }
.voice-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: blink 1s ease infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Quick chips */
.quick-chips {
  position: absolute;
  top: 9.6rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  width: min(560px, calc(100% - 2rem));
  pointer-events: none;
}
.quick-chips button {
  pointer-events: auto;
  border: 1px solid var(--panel-border);
  background: rgba(8, 14, 28, 0.55);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.2s;
}
.quick-chips button:hover {
  color: var(--text);
  border-color: rgba(77, 184, 255, 0.4);
  background: rgba(77, 184, 255, 0.12);
  transform: translateY(-1px);
}

/* Place card */
.place-card {
  position: absolute;
  bottom: 4.5rem;
  left: 1.25rem;
  z-index: 12;
  width: min(320px, calc(100% - 2.5rem));
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.1rem 1.2rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), var(--glow);
  animation: cardIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.place-card[hidden] { display: none; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.place-close {
  position: absolute;
  top: 0.55rem;
  right: 0.65rem;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.place-close:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

.place-card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding-right: 1.4rem;
}
.place-flag {
  flex-shrink: 0;
  width: 3.1rem;
  height: 3.1rem;
  display: grid;
  place-items: center;
  font-size: 2.15rem;
  line-height: 1;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.place-info h2 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.place-role {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.28rem;
  line-height: 1.35;
}
.place-details {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.15rem;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.place-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.82rem;
}
.place-row[hidden] { display: none; }
.place-row-label {
  color: var(--muted);
  flex-shrink: 0;
}
.place-row-value {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}
.place-stats {
  display: flex;
  gap: 0.75rem;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.place-reset {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}
.place-reset:hover { background: rgba(77, 184, 255, 0.12); }

/* Side controls */
.controls {
  position: absolute;
  right: 1.1rem;
  bottom: 4.5rem;
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.controls button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 400;
  cursor: pointer;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.controls button:hover {
  border-color: rgba(77, 184, 255, 0.4);
  background: rgba(77, 184, 255, 0.12);
  transform: scale(1.05);
}
.controls button.active {
  color: var(--accent);
  border-color: rgba(77, 184, 255, 0.45);
  box-shadow: 0 0 16px rgba(77, 184, 255, 0.25);
}

/* Toast */
.toast {
  position: absolute;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  max-width: min(400px, calc(100% - 2rem));
  padding: 0.7rem 1.2rem;
  background: rgba(20, 10, 20, 0.85);
  border: 1px solid rgba(255, 92, 122, 0.35);
  border-radius: 12px;
  color: #ffc8d0;
  font-size: 0.85rem;
  text-align: center;
  backdrop-filter: blur(12px);
  animation: cardIn 0.3s ease;
}
.toast[hidden] { display: none; }
.toast.success {
  border-color: rgba(61, 255, 168, 0.35);
  color: #b8ffe0;
}

/* Footer hint */
.hint {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-size: 0.7rem;
  color: rgba(180, 200, 230, 0.35);
  white-space: nowrap;
  pointer-events: none;
}

/* Mobile */
@media (max-width: 640px) {
  .top-bar { padding: 0.85rem 1rem; }
  .brand p { display: none; }
  .coords { font-size: 0.65rem; padding: 0.3rem 0.55rem; }
  .search-panel { top: 4.2rem; }
  .quick-chips {
    top: 8.4rem;
    gap: 0.3rem;
  }
  .quick-chips button { font-size: 0.68rem; padding: 0.28rem 0.55rem; }
  .place-card {
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    bottom: 4rem;
  }
  .controls {
    right: 0.75rem;
    bottom: 4rem;
  }
  .controls button { width: 38px; height: 38px; font-size: 1.05rem; }
  .hint { font-size: 0.62rem; }
}
