/* =====================
   Argo — Base styles
   ===================== */

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }
#map { width: 100%; height: 100%; }

/* =====================
   Typography
   ===================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Abyss tokens */
  --color-ocean:     #060f1c;
  --color-land:      #0d1f30;
  --color-river:     #1a6aaa;
  --color-boundary:  #0f2438;
  --color-text-primary:   #e8f4ff;
  --color-text-secondary: #7ac4f0;
  --color-text-tertiary:  #2a5a7a;
  --color-ui-surface:     #040810;
  --color-ui-border:      #0f2030;
}

/* =====================
   Nav bar
   ===================== */

#navbar {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  z-index: 10;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#nav-wordmark {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
  white-space: nowrap;
  user-select: none;
}

#nav-search {
  flex: 1;
  max-width: 360px;
  margin: 0 auto;
  height: 32px;
  background: rgba(15, 32, 48, 0.7);
  border: 1px solid var(--color-ui-border);
  border-radius: 16px;
  padding: 0 14px;
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: 12px;
  outline: none;
}

#nav-search::placeholder {
  color: var(--color-text-tertiary);
}

#nav-search:focus {
  border-color: var(--color-river);
  background: rgba(15, 32, 48, 0.9);
}

#mode-toggle {
  height: 32px;
  padding: 0 14px;
  background: rgba(15, 32, 48, 0.7);
  border: 1px solid var(--color-ui-border);
  border-radius: 16px;
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: -0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
}

#mode-toggle:hover {
  background: rgba(26, 106, 170, 0.3);
  border-color: var(--color-river);
}

/* Surface mode overrides */
body.surface #navbar {
 background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

body.surface #nav-search {
  background: rgba(255, 255, 255, 0.7);
  border-color: #b8d4ec;
  color: #0c2a44;
}

body.surface #nav-search::placeholder {
  color: #7a9ab4;
}

body.surface #mode-toggle {
  background: rgba(255, 255, 255, 0.7);
  border-color: #b8d4ec;
  color: #0c2a44;
}

body.surface #nav-wordmark {
  color: #0c2a44;
}

/* =====================
   Station popup
   ===================== */

.argo-popup .maplibregl-popup-content {
  background: rgba(4, 8, 16, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid #0f2030;
  border-radius: 8px;
  padding: 14px 16px;
  color: #e8f4ff;
  font-family: var(--font-sans);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

.argo-popup .maplibregl-popup-tip {
  border-top-color: rgba(4, 8, 16, 0.92);
}

.argo-popup .maplibregl-popup-close-button {
  color: #2a5a7a;
  font-size: 16px;
  padding: 4px 8px;
}

.argo-popup .maplibregl-popup-close-button:hover {
  color: #e8f4ff;
  background: none;
}

.popup-river {
  font-size: 13px;
  font-weight: 600;
  color: #4fc3f7;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}

.popup-station {
  font-size: 11px;
  color: #7ac4f0;
  margin-bottom: 10px;
}

.popup-flow {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #e8f4ff;
  margin-bottom: 6px;
}

.popup-meta {
  font-size: 11px;
  color: #2a5a7a;
  margin-top: 2px;
}

body.surface .argo-popup .maplibregl-popup-content {
  background: rgba(255, 255, 255, 0.92);
  border-color: #b8d4ec;
  color: #0c2a44;
}

body.surface .argo-popup .maplibregl-popup-tip {
  border-top-color: rgba(255, 255, 255, 0.92);
}

body.surface .popup-river {
  color: #1a5a9c;
}

body.surface .popup-station {
  color: #3a6a8a;
}

body.surface .popup-flow {
  color: #0c2a44;
}

body.surface .popup-meta {
  color: #7a9ab4;
}

body.surface .argo-popup .maplibregl-popup-close-button {
  color: #7a9ab4;
}

.popup-flow-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.popup-trend {
  font-size: 18px;
  font-weight: 600;
}

.trend-up { color: #4fc3f7; }
.trend-down { color: #b48030; }
.trend-stable { color: #7ac4f0; }

.popup-envelope {
  margin-bottom: 8px;
}

.envelope-bar {
  position: relative;
  height: 4px;
  background: #0f2030;
  border-radius: 2px;
  margin-bottom: 4px;
}

.envelope-fill {
  height: 100%;
  background: #1a6aaa;
  border-radius: 2px;
}

.envelope-marker {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 10px;
  background: #4fc3f7;
  transform: translateX(-50%);
  border-radius: 1px;
}

.envelope-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #2a5a7a;
  font-family: var(--font-mono);
}

body.surface .envelope-bar { background: #b8d4ec; }
body.surface .envelope-fill { background: #5a9ac4; }
body.surface .envelope-marker { background: #1a5a9c; }
body.surface .envelope-labels { color: #7a9ab4; }

/* =====================
   Layer panel
   ===================== */

#layer-panel {
  position: absolute;
  bottom: 32px;
  left: 16px;
  z-index: 10;
  font-family: var(--font-sans);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

#layer-toggle-btn {
  height: 32px;
  padding: 0 14px;
  background: rgba(15, 32, 48, 0.8);
  border: 1px solid var(--color-ui-border);
  border-radius: 16px;
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

#layer-toggle-btn:hover {
  background: rgba(26, 106, 170, 0.3);
  border-color: var(--color-river);
}

#layer-options {
  background: rgba(4, 8, 16, 0.92);
  border: 1px solid var(--color-ui-border);
  border-radius: 8px;
  padding: 12px 14px;
  backdrop-filter: blur(12px);
  min-width: 200px;
}

#layer-options.hidden { display: none; }

.layer-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
  margin-bottom: 8px;
}

.layer-option {
  padding: 3px 0;
}

.layer-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-secondary);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.layer-label:hover { color: var(--color-text-primary); }

.layer-label input[type="radio"] {
  accent-color: var(--color-river);
  width: 13px;
  height: 13px;
  cursor: pointer;
}

/* Surface overrides */
body.surface #layer-toggle-btn {
  background: rgba(255, 255, 255, 0.8);
  border-color: #b8d4ec;
  color: #0c2a44;
}

body.surface #layer-options {
  background: rgba(255, 255, 255, 0.92);
  border-color: #b8d4ec;
}

body.surface .layer-section-title { color: #7a9ab4; }
body.surface .layer-label { color: #3a6a8a; }
body.surface .layer-label:hover { color: #0c2a44; }

#anomaly-legend {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-ui-border);
}

#anomaly-legend.hidden { display: none; }

.legend-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
  margin-bottom: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--color-text-secondary);
  padding: 2px 0;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}