/* ===== Mini Montpellier 3D — style sombre ===== */

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0b0c0e;
  font-family: "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
}

/* ---- Colonne de gauche : horloge puis panneaux (empilés) ---- */
#side {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: calc(100vw - 28px);
}

/* ---- Panneau horloge, même esprit que mini-tokyo-3d ---- */
#clock {
  padding: 10px 16px;
  background: rgba(16, 18, 21, 0.85);
  border-radius: 10px;
  color: #e8eaed;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

#clock-date {
  font-size: 14px;
  opacity: 0.85;
}

#clock-time {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

/* ---- Indicateur temps réel / simulation ---- */
#rt-status {
  margin-top: 4px;
  font-size: 11.5px;
  color: #9aa0a6;
}

#rt-status:empty {
  display: none;
}

#rt-status code {
  font-size: 11px;
  color: #c9ccd1;
}

.rt-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: 1px;
  background: #9aa0a6;
}

.rt-live .rt-dot {
  background: #34c759;
  box-shadow: 0 0 6px #34c759;
  animation: rt-pulse 2s ease-in-out infinite;
}

.rt-error .rt-dot {
  background: #ff453a;
}

@keyframes rt-pulse {
  50% { opacity: 0.35; }
}

/* ---- Choix des lignes affichées ---- */
#filters {
  max-width: min(320px, calc(100vw - 28px));
  color: #e8eaed;
  font-size: 13px;
}

.toolbar {
  display: flex;
  gap: 6px;
}

.filters-toggle.has-alerts {
  background: rgba(200, 30, 40, 0.95);
  color: #ffffff;
}

.filters-toggle.has-alerts:hover {
  background: rgba(225, 45, 55, 0.98);
}

.filters-toggle.has-alerts::before {
  content: '⚠ ';
}

.filters-chip.has-alert {
  position: relative;
}

.filters-chip.has-alert::after {
  content: '⚠';
  position: absolute;
  top: -7px;
  right: -5px;
  font-size: 10px;
  color: #ffc23a;
  text-shadow: 0 0 3px #000;
}

.alert-chip {
  display: inline-block;
  margin-right: 4px;
  cursor: default;
}

.alert {
  padding: 8px 0;
}

.alert + .alert {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.alert h3 {
  margin: 6px 0 3px;
  font-size: 13px;
}

.alert p {
  margin: 4px 0;
  color: #c9ccd1;
  line-height: 1.4;
}

.alert a {
  color: #8ab4f8;
  font-size: 12px;
}

.alert-tags {
  color: #ffc23a;
  font-size: 11.5px;
}

.alerts-empty {
  margin: 2px 0;
  color: #9aa0a6;
}

.alerts-updated {
  margin-top: 8px;
  color: #6f757d;
  font-size: 11px;
}

.popup-alert {
  margin-top: 7px;
  padding: 5px 7px;
  border-left: 3px solid #ffc23a;
  background: rgba(255, 194, 58, 0.08);
  color: #ffd27a;
  font-size: 12px;
}

.spark {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 34px;
  margin: 6px 0 2px;
}

.spark span {
  flex: 1;
  min-width: 3px;
  border-radius: 1px;
  background: #8e5cf7;
}

/* ---- Météo (dans le panneau horloge) ---- */
#weather {
  margin-top: 3px;
  font-size: 12.5px;
  color: #c9ccd1;
}

#weather:empty {
  display: none;
}

#weather .wx-main {
  font-weight: 700;
  color: #e8eaed;
}

#weather .wx-sub {
  font-size: 11px;
  color: #9aa0a6;
}

/* ---- Qualité de l'air (panneau horloge et popups) ---- */
#air {
  margin-top: 3px;
  font-size: 12px;
  color: #c9ccd1;
}

#air:empty {
  display: none;
}

#air .air-main {
  font-weight: 700;
  color: #e8eaed;
}

#air .air-sub {
  font-size: 11px;
  color: #9aa0a6;
}

#air .air-episode {
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 700;
  color: #ff8a5b;
}

.air-badge {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  vertical-align: 0;
}

.air-dim {
  font-weight: 400;
  color: #9aa0a6;
}

/* Le panneau horloge ignore la souris ; la météo, elle, est cliquable */
#weather.wx-clickable {
  pointer-events: auto;
  cursor: pointer;
}

#weather .wx-caret {
  font-size: 10px;
  color: #9aa0a6;
  display: inline-block;
  transition: transform 0.15s;
}

#weather.wx-open .wx-caret {
  transform: rotate(180deg);
}

#weather .wx-forecast {
  display: none;
  gap: 4px;
  margin-top: 6px;
}

#weather.wx-open .wx-forecast {
  display: flex;
}

#weather .wx-hour {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 34px;
  padding: 3px 2px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 11px;
  line-height: 1.35;
}

#weather .wx-ico {
  font-size: 14px;
}

#weather .wx-rain {
  min-height: 14px;
  font-size: 10px;
  color: #6fb6ff;
}

.departures {
  margin-top: 6px;
  border-collapse: collapse;
  font-size: 12px;
}

.departures td {
  padding: 3px 0;
  vertical-align: middle;
}

.departures td + td {
  padding-left: 8px;
}

.departures .dep-times {
  color: #e8eaed;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dep-sched {
  font-style: italic;
  color: #9aa0a6;
}

.dep-late {
  color: #ff9f6b;
}

.filters-toggle {
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: rgba(16, 18, 21, 0.85);
  color: #e8eaed;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.filters-toggle::after {
  content: ' ▾';
  opacity: 0.7;
}

.filters-toggle[aria-expanded="true"]::after {
  content: ' ▴';
}

.filters-panel {
  margin-top: 6px;
  padding: 10px 12px;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
  border-radius: 10px;
  background: rgba(16, 18, 21, 0.9);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.filters-group + .filters-group {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.filters-mode {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  cursor: pointer;
}

.filters-actions button {
  padding: 2px 6px;
  border: 0;
  background: none;
  color: #9aa0a6;
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}

.filters-actions button:hover {
  color: #e8eaed;
}

.filters-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.filters-chip {
  min-width: 30px;
  padding: 3px 6px;
  border: 1px solid var(--chip-bg);
  border-radius: 5px;
  background: var(--chip-bg);
  color: var(--chip-fg);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.filters-chip.is-hidden {
  background: transparent;
  color: #6f757d;
  border-color: #3a3f47;
}

.filters-group.is-off .filters-chips {
  opacity: 0.35;
}

/* ---- Légende (bas gauche, au-dessus du titre) ---- */
/* Légende masquée tant qu'un panneau de la barre (Lignes, Info trafic) est
   ouvert : ils occupent la même colonne à gauche */
body:has(#filters .side-panel:not([hidden])) #legend {
  display: none;
}

#legend {
  position: absolute;
  left: 14px;
  bottom: 68px;
  z-index: 9;
  max-width: min(260px, calc(100vw - 28px));
  color: #e8eaed;
  font-size: 11.5px;
}

.legend-toggle {
  padding: 5px 11px;
  border: 0;
  border-radius: 7px;
  background: rgba(16, 18, 21, 0.85);
  color: #e8eaed;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.legend-body {
  margin-top: 5px;
  padding: 8px 10px;
  max-height: 42vh;
  overflow-y: auto;
  border-radius: 9px;
  background: rgba(16, 18, 21, 0.88);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.legend-body section + section {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.legend-body h4 {
  margin: 0 0 3px;
  font-size: 11.5px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 16px;
  color: #c9ccd1;
}

.legend-note {
  color: #8a9099;
  font-style: italic;
}

/* ---- Titre ---- */
#title {
  position: absolute;
  bottom: 32px;
  left: 14px;
  z-index: 10;
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

#title span {
  color: #f5a623;
}

/* ---- Contrôles MapLibre, re-colorés pour le thème sombre ---- */
.maplibregl-ctrl-group {
  background: rgba(16, 18, 21, 0.9) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) !important;
}

.maplibregl-ctrl-group button {
  background: transparent !important;
  filter: invert(1);
}

.maplibregl-ctrl-attrib {
  background: rgba(16, 18, 21, 0.7) !important;
  color: #9aa0a6 !important;
}

.maplibregl-ctrl-attrib a {
  color: #9aa0a6 !important;
}

/* ---- Popups tramway ---- */
.tram-popup .maplibregl-popup-content {
  background: rgba(16, 18, 21, 0.95);
  color: #e8eaed;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

.tram-popup .maplibregl-popup-tip {
  border-top-color: rgba(16, 18, 21, 0.95);
}

.popup-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.popup-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 6px;
}

.popup-body b {
  color: #ffffff;
}

.popup-meta {
  margin-top: 3px;
  font-size: 11.5px;
  color: #9aa0a6;
}

.popup-specs {
  margin-top: 7px;
  border-collapse: collapse;
  font-size: 12px;
}

.popup-specs th,
.popup-specs td {
  padding: 2px 0;
  vertical-align: top;
  text-align: left;
}

.popup-specs th {
  padding-right: 10px;
  color: #9aa0a6;
  font-weight: 400;
  white-space: nowrap;
}

.popup-specs td {
  color: #e8eaed;
}

.popup-note {
  font-size: 11px;
  color: #9aa0a6;
}


/* ---- Aide ---- */
.help-toggle {
  order: 99;
}

.help-toggle::after,
.help-toggle[aria-expanded="true"]::after {
  content: none;
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(0, 0, 0, 0.6);
}

.help-overlay[hidden] {
  display: none;
}

.help-dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  max-height: 85vh;
  border-radius: 10px;
  background: rgba(16, 18, 21, 0.97);
  color: #e8eaed;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
  outline: none;
}

.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 8px;
}

.help-head h2 {
  margin: 0;
  font-size: 18px;
}

.help-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9aa0a6;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.help-close:hover {
  color: #e8eaed;
  background: rgba(255, 255, 255, 0.08);
}

.help-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.help-tab {
  padding: 8px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #9aa0a6;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.help-tab:hover {
  color: #e8eaed;
}

.help-tab.active {
  color: #f5a623;
  border-bottom-color: #f5a623;
}

.help-body {
  padding: 8px 16px 16px;
  overflow-y: auto;
}

.help-body h3 {
  margin: 14px 0 4px;
  font-size: 15px;
  color: #f5a623;
}

.help-body p {
  margin: 4px 0;
}

.help-body ul {
  margin: 4px 0;
  padding-left: 20px;
}

.help-body a {
  color: #f5a623;
}

.help-late {
  color: #ff9f6b;
}

.help-intro {
  color: #9aa0a6;
}

.help-sources {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.help-source {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.help-source h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

.help-field + .help-field {
  margin-top: 3px;
}

.help-label {
  display: block;
  color: #9aa0a6;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.help-credits {
  margin-top: 14px;
  color: #9aa0a6;
  font-size: 12px;
}

@media (max-width: 600px) {
  .help-overlay {
    padding: 8px;
  }

  .help-dialog {
    max-height: 92vh;
  }

  .help-tab {
    padding: 8px 10px;
  }

  .help-sources {
    grid-template-columns: 1fr;
  }
}
