/* DKfire - interface sombre pensee pour laisser l'imagerie satellite et les
   feux occuper tout l'espace visuel. */

:root {
  --bg: #0a0c10;
  --panel: rgba(16, 19, 25, 0.92);
  --panel-solid: #101319;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #eef1f5;
  --muted: #9aa4b2;
  --flame: #ff6b1a;
  --flame-hot: #ff3b0d;
  --ember: #a8390b;
  --gold: #ffd166;
  --radius: 14px;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
  --panel-w: 372px;
}

* { box-sizing: border-box; }

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

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

/* Le panneau est ancre : la carte occupe strictement le reste de l'ecran,
   sans rien passer dessous. */
#map {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: var(--panel-w);
  /* Teinte du fond clair, visible le temps que les tuiles arrivent. */
  background: #eceff1;
}

/* Ravive le fond de carte, servi delave par CARTO. Le filtre ne porte que sur
   ce calque de tuiles : ni les feux ni les noms de lieux, qui vivent dans
   d'autres conteneurs, ne sont touches. */
.fond-carte {
  filter: saturate(1.5) contrast(1.02);
}

.fire-grid-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  /* Les cellules sont volontairement carrees et nettes : c'est une grille de
     mesure, pas un degrade decoratif. */
  image-rendering: pixelated;
}

.muted { color: var(--muted); }

.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background:
    radial-gradient(circle at 50% 78%, #ffe08a 0%, #ff8c1a 34%, #ff3b0d 62%, #7a1b04 100%);
  box-shadow: 0 0 18px rgba(255, 107, 26, 0.55);
  animation: pulse 3.4s ease-in-out infinite;
}

.brand-sub {
  margin: 1px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(255, 107, 26, 0.45); }
  50%      { box-shadow: 0 0 26px rgba(255, 107, 26, 0.8); }
}

/* --------------------------------------------------------------- panneau */

.panel {
  position: absolute;
  z-index: 850;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--panel-w);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel-solid);
  border-right: 1px solid var(--line);
  box-shadow: 2px 0 24px rgba(0, 0, 0, 0.45);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h1 { font-size: 19px; line-height: 1.15; }

.panel::-webkit-scrollbar { width: 9px; }
.panel::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.13); border-radius: 9px; }
.panel::-webkit-scrollbar-track { background: transparent; }

.block {
  padding: 16px 16px 18px;
  border-bottom: 1px solid var(--line);
}

.block:last-child { border-bottom: none; }

.block h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-weight: 600;
}

.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }

.badge {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hint {
  margin: 6px 0 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

/* ------------------------------------------------------------ selecteurs */

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

.chip {
  padding: 7px 13px;
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.chip:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }

.chip.is-active {
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 107, 26, 0.28), rgba(255, 59, 13, 0.18));
  border-color: rgba(255, 107, 26, 0.5);
}

/* --------------------------------------------------------------- sources */

/* --------------------------------------------------------------- calques */

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.switch[hidden] { display: none; }

.switch:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.switch input { accent-color: var(--flame); width: 15px; height: 15px; cursor: pointer; }
.switch em { font-style: normal; opacity: 0.6; font-size: 11.5px; }

/* -------------------------------------------------------------- hotspots */

.hotspots { margin: 0; padding: 0; list-style: none; counter-reset: rank; }

.hotspot {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  counter-increment: rank;
  transition: background 0.15s;
}

.hotspot:hover { background: rgba(255, 107, 26, 0.1); }

.hotspot-rank::before {
  content: counter(rank);
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.hotspot:nth-child(1) .hotspot-rank::before { background: rgba(255, 59, 13, 0.35); color: #ffd9c2; }
.hotspot:nth-child(2) .hotspot-rank::before { background: rgba(255, 107, 26, 0.26); color: #ffd9c2; }
.hotspot:nth-child(3) .hotspot-rank::before { background: rgba(255, 145, 60, 0.18); color: #ffd9c2; }

.hotspot-main { display: flex; flex-direction: column; min-width: 0; }

.hotspot-place {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hotspot-meta {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.block-about p { margin: 8px 0 0; font-size: 12px; color: var(--muted); line-height: 1.55; }

/* --------------------------------------------------------------- legende */

.legend {
  position: absolute;
  z-index: 800;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  font-size: 11.5px;
  color: var(--muted);
}

.sw {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
}

.sw:not(:first-child) { margin-left: 9px; }
.sw-core  { background: #960c1a; }
.sw-hot   { background: #d61a12; }
.sw-warm  { background: #fa8518; }
.sw-edge  { background: #fcb03e; }
.sw-ember { background: #fcd36a; }

/* ----------------------------------------------------------------- detail */

.detail {
  position: absolute;
  z-index: 880;
  left: calc(var(--panel-w) + 14px);
  bottom: 14px;
  width: 380px;
  max-width: calc(100vw - 28px);
  padding: 16px 18px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.detail h3 { font-size: 15px; margin-bottom: 12px; font-variant-numeric: tabular-nums; }

.detail-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 26px;
  height: 26px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 7px;
}

.detail-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  margin: 0 0 14px;
}

.stats dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stats dd { margin: 1px 0 0; font-size: 15px; font-variant-numeric: tabular-nums; }

.detections { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.detections th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.detections td { padding: 4px 6px 4px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); font-variant-numeric: tabular-nums; }
.detections tr:last-child td { border-bottom: none; }

/* ------------------------------------------------------------------ toast */

.toast {
  position: absolute;
  z-index: 950;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  box-shadow: var(--shadow);
  font-size: 13px;
}

/* ----------------------------------------------------------- Leaflet skin */

.leaflet-container { background: #eceff1; font: inherit; }

.leaflet-control-attribution {
  background: rgba(10, 12, 16, 0.78) !important;
  color: var(--muted) !important;
  font-size: 10.5px !important;
  padding: 3px 8px !important;
  border-radius: 7px 0 0 0;
  backdrop-filter: blur(8px);
}

.leaflet-control-attribution a { color: #b9c2cf !important; }

.leaflet-bar a {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
  backdrop-filter: blur(12px);
}

.leaflet-bar a:hover { background: #1a1f28 !important; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--panel-solid);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.leaflet-popup-content { margin: 11px 14px; font-size: 12.5px; line-height: 1.5; }
.leaflet-popup-content em { color: var(--muted); font-style: normal; font-size: 11px; }
.leaflet-popup-close-button { color: var(--muted) !important; }

/* --------------------------------------------------------------- mobile */

/* --------------------------------------------------------------- mobile */

@media (max-width: 820px) {
  :root { --panel-w: 0px; }

  /* Sur petit ecran, la carte passe en pleine largeur et le panneau devient
     un bandeau bas, glissable au pouce. */
  #map { left: 0; bottom: 44%; }

  .panel {
    top: 56%;
    right: 0;
    width: auto;
    border-right: none;
    border-top: 1px solid var(--line);
  }

  .panel-head { padding: 14px 16px 12px; }
  .legend { display: none; }
  .detail { left: 14px; right: 14px; bottom: calc(44% + 14px); width: auto; }
}
