/* Sismos — dark UI for the 3D earthquake globe. */

:root {
  --bg: #0b0e17;
  --panel-bg: rgba(16, 20, 33, 0.92);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf4;
  --text-dim: #9aa3b5;
  --accent: #4da3ff;
  --green: #2ecc71;
  --yellow: #f1c40f;
  --orange: #e67e22;
  --red: #e74c3c;
  --magenta: #e040fb;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  overflow: hidden;
}

/* ---------- Top bar ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(rgba(11, 14, 23, 0.95), rgba(11, 14, 23, 0.75) 80%, transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.brand .subtitle {
  font-weight: 400;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-left: 6px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.counter {
  font-size: 0.85rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.counter strong { color: var(--text); }

.updated {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.btn {
  background: rgba(77, 163, 255, 0.15);
  color: var(--accent);
  border: 1px solid rgba(77, 163, 255, 0.4);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn:hover { background: rgba(77, 163, 255, 0.3); }
.btn:disabled { opacity: 0.5; cursor: wait; }

.btn-icon { display: none; }

/* ---------- Filters panel ---------- */

.panel {
  position: fixed;
  top: 64px;
  left: 16px;
  z-index: 25;
  width: 280px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 14px 16px;
}

/* Drag handle: only shown on mobile, where the panel is a bottom sheet */
.panel-handle { display: none; }

.panel h2 {
  margin: 0 0 10px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.panel-section + .panel-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--panel-border);
}

.field { display: block; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field-label {
  display: block;
  font-size: 0.83rem;
  margin-bottom: 6px;
  color: var(--text);
}
.field-label strong { color: var(--accent); }

.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.field select,
.field input[type="text"] {
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}
.field select:focus,
.field input[type="text"]:focus { border-color: var(--accent); }
.field select option { background: #141927; color: var(--text); }

.field-toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: center;
  cursor: pointer;
  font-size: 0.88rem;
}
.field-toggle input { accent-color: var(--magenta); width: 16px; height: 16px; }
.field-toggle .hint {
  grid-column: 2;
  color: var(--text-dim);
  font-size: 0.72rem;
  line-height: 1.35;
}

/* ---------- Legend ---------- */

.legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.82rem;
}
.legend-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
}
.dot-green { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-orange { background: var(--orange); }
.dot-red { background: var(--red); }
.dot-magenta { background: var(--magenta); }
.pulse { animation: pulse 1.6s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(224, 64, 251, 0.6); }
  100% { box-shadow: 0 0 0 8px rgba(224, 64, 251, 0); }
}

.legend-note {
  margin: 10px 0 0;
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.45;
}

/* ---------- Globe & overlays ---------- */

#globeWrap { position: fixed; inset: 0; }
#globe { width: 100%; height: 100%; }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(11, 14, 23, 0.85);
  text-align: center;
  padding: 20px;
  font-size: 0.95rem;
}
.hidden { display: none !important; }

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Quake detail card (tooltip / tap card) ---------- */

.quake-card,
.globe-tooltip {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 12px 14px;
  min-width: 230px;
  max-width: 300px;
  font-size: 0.83rem;
  line-height: 1.5;
  color: var(--text);
}

.quake-card {
  position: absolute;
  right: 16px;
  bottom: 84px; /* sits above the sponsor badge in the same corner */
  z-index: 26;
}

.qc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.qc-mag {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
}
.qc-place { font-weight: 600; }
.qc-row { color: var(--text-dim); }
.qc-row b { color: var(--text); font-weight: 600; }
.qc-badge {
  display: inline-block;
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--magenta);
  color: var(--magenta);
  margin-left: 6px;
  vertical-align: middle;
}
.qc-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.qc-link:hover { text-decoration: underline; }
.qc-close {
  float: right;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
}
.qc-close:hover { color: var(--text); }

/* Cluster picker (tap landed on several nearby quakes) */
.qc-pick-title {
  font-weight: 600;
  margin-bottom: 8px;
  padding-right: 18px;
}
.qc-pick {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
}
.qc-pick:hover { border-color: var(--accent); }
.qc-pick-mag { font-weight: 800; flex: none; }
.qc-pick-place {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qc-pick-time { color: var(--text-dim); flex: none; font-size: 0.72rem; }
.qc-pick-more { color: var(--text-dim); font-size: 0.72rem; margin-top: 2px; }

/* globe.gl injects the hover tooltip as .scene-tooltip */
.scene-tooltip { pointer-events: none; }

/* ---------- Sponsor badge ---------- */

.sponsor {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 24;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 8px 12px;
}
.sponsor-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
}
.sponsor-info {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.sponsor-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.sponsor-name {
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.sponsor-donate {
  text-decoration: none;
  font-weight: 700;
}

/* ---------- New-quake toast ---------- */

.toast {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 28;
  background: var(--panel-bg);
  border: 1px solid rgba(77, 163, 255, 0.5);
  border-radius: 999px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 0.85rem;
  padding: 8px 16px;
  cursor: pointer;
  animation: toast-in 0.3s ease;
}
.toast b { color: var(--accent); }
.toast:hover { border-color: var(--accent); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- Mobile ---------- */

@media (max-width: 720px) {
  .brand .subtitle { display: none; }
  .updated { display: none; }
  .btn-icon { display: inline-block; }

  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 60vh;
    border-radius: var(--radius) var(--radius) 0 0;
    transform: translateY(105%);
    transition: transform 0.25s ease;
  }
  .panel.open { transform: translateY(0); }

  .panel-handle {
    display: flex;
    justify-content: center;
    padding: 2px 0 12px;
    cursor: grab;
    touch-action: none; /* the handle owns the vertical gesture */
  }
  .panel-handle::before {
    content: '';
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.28);
  }

  .quake-card {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}
