/* Palette : voir la méthode data-viz interne — bleu séquentiel pour les
   magnitudes, encre neutre pour le texte, jamais de couleur seule pour
   porter un sens (toujours accompagnée d'un libellé). */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page-plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --seq-100: #cde2fb;
  --seq-250: #86b6ef;
  --seq-400: #3987e5;
  --seq-550: #1c5cab;
  --seq-700: #0d366b;
  --brand: #1c5cab;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page-plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --seq-100: #184f95;
    --seq-250: #1c5cab;
    --seq-400: #3987e5;
    --seq-550: #86b6ef;
    --seq-700: #cde2fb;
    --brand: #6da7ec;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
}

a { color: var(--brand); }

.site-header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.site-header__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.site-header__title h1 {
  margin: 0;
  font-size: 1.4rem;
}

.site-header__title p {
  margin: 2px 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.site-header__meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot--ok { background: #0ca30c; }
.dot--pending { background: #898781; }
.dot--error { background: #d03b3b; }

.tabs {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: 0 16px;
}

.tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 14px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.tab[aria-selected="true"] {
  color: var(--text-primary);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.panel[hidden] { display: none; }

.map-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.map-controls label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

#metric-select {
  font-size: 0.95rem;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--gridline);
  background: var(--surface-1);
  color: var(--text-primary);
}

.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.legend__ramp {
  width: 120px;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(to right, var(--seq-100), var(--seq-250), var(--seq-400), var(--seq-550), var(--seq-700));
  border: 1px solid var(--border);
}

.avalanche-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-1);
  border: 1px solid var(--border);
}

.avalanche-badge__swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

#map {
  height: 65vh;
  min-height: 420px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-1);
}

.hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 8px;
}

.station-popup h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}
.station-popup .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  padding: 2px 0;
  border-bottom: 1px dashed var(--gridline);
}
.station-popup .row:last-child { border-bottom: none; }
.station-popup .timestamp {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 6px;
}

.ranking-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.ranking-tabs, .order-toggle {
  display: flex;
  gap: 4px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.ranking-tab, .order-btn {
  border: none;
  background: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.ranking-tab.is-active, .order-btn.is-active {
  background: var(--brand);
  color: #fff;
}

#ranking-search {
  margin-left: auto;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--gridline);
  background: var(--surface-1);
  color: var(--text-primary);
  min-width: 200px;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

.ranking-table th, .ranking-table td {
  text-align: left;
  padding: 8px 12px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--gridline);
}

.ranking-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.ranking-table tbody tr:hover {
  background: color-mix(in srgb, var(--brand) 6%, transparent);
}

.ranking-table td:first-child { color: var(--text-muted); width: 48px; }

.about {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  line-height: 1.6;
}
.about h2 { margin-top: 0; }

.site-footer {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px 24px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  .site-header__inner { flex-direction: column; align-items: flex-start; }
  .ranking-controls { flex-direction: column; align-items: stretch; }
  #ranking-search { margin-left: 0; }
  .ranking-table { font-size: 0.8rem; }
}
