/* feux-dz — theme sombre, bilingue FR/AR.
   Le RTL est gere par des proprietes logiques (inline-start/end) : basculer
   dir="rtl" suffit, aucune regle miroir a maintenir. */

:root {
  --bg: #0b0f16;
  --panel: #121824;
  --panel-2: #182031;
  --line: #26314480;
  --text: #e8edf5;
  --muted: #96a2b4;
  --accent: #ff6a33;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-ar: "Noto Naskh Arabic", "Geeza Pro", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  font-size: 15px; line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

html[lang="ar"] body { font-family: var(--font-ar); }
html[lang="ar"] { letter-spacing: 0; }

a { color: #ffb08c; }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}

.skip {
  position: absolute; inset-inline-start: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #10141c; padding: 8px 14px; font-weight: 600;
}
.skip:focus { inset-inline-start: 8px; top: 8px; }

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand h1 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.brand .sub { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); }

.flame {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  background: radial-gradient(circle at 50% 62%, #ffd24d 0%, #ff8c1a 42%, #ff3b1f 74%, #7a1200 100%);
  box-shadow: 0 0 14px #ff5a2b66;
}

.langswitch { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.langswitch button {
  background: transparent; border: 0; color: var(--muted);
  padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.langswitch button.on { background: var(--panel-2); color: var(--text); font-weight: 600; }

/* ------------------------------------------------------------ disclaimer */

.disclaimer {
  background: #2a1408; border-block: 1px solid #7a3a12;
  padding: 9px 16px; font-size: 13.5px; color: #ffdcc4;
}
.disclaimer strong { color: #ffb37a; }
.disclaimer a { margin-inline-start: 6px; white-space: nowrap; }

/* ---------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: 370px 1fr;
  height: calc(100vh - 118px);
  min-height: 420px;
}
html[dir="rtl"] .layout { grid-template-columns: 370px 1fr; }

.panel {
  overflow-y: auto; padding: 14px;
  background: var(--bg);
  border-inline-end: 1px solid var(--line);
}
html[dir="rtl"] .panel { border-inline-end: 1px solid var(--line); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px; margin-bottom: 12px;
}
.card h2 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase;
           letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
html[lang="ar"] .card h2 { text-transform: none; letter-spacing: 0; font-size: 14px; }
.card h2.mt { margin-top: 14px; }

.note { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }

/* ------------------------------------------------------------- fraicheur */

.age { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.age.ok   { color: var(--ok); }
.age.warn { color: var(--warn); }
.age.bad  { color: var(--bad); }

.gaps {
  margin: 8px 0; padding: 9px 11px; border-radius: 8px;
  background: #2b1414; border: 1px solid #7f2c2c; font-size: 12.5px;
}
.gaps strong { color: #ffb4b4; display: block; margin-bottom: 4px; }
.gaps p { margin: 0 0 6px; color: #e6c3c3; }
.gaps ul { margin: 0; padding-inline-start: 18px; color: #d9b0b0; }

details summary { cursor: pointer; font-size: 13px; color: var(--muted); padding: 4px 0; }
.satlist { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12.5px; }
.satlist li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 4px 0; border-bottom: 1px solid var(--line); color: var(--muted);
}
.satlist li b { color: var(--text); font-weight: 500; }

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

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 auto; background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font: inherit; font-size: 13px; cursor: pointer;
}
.seg button.on { background: var(--accent); color: #14100c; border-color: var(--accent); font-weight: 700; }

/* ---------------------------------------------------------------- classement */

.rank { list-style: none; margin: 10px 0 0; padding: 0; }
.rank li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.rank li.empty { color: var(--muted); font-size: 13px; border: 0; }
.rank-head { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.rk-name { font-weight: 600; }
.rk-val { color: var(--accent); font-variant-numeric: tabular-nums; }
.rk-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.bar { height: 4px; background: var(--panel-2); border-radius: 3px; margin-top: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff8c1a, #ff3b1f); }
html[dir="rtl"] .bar i { margin-inline-start: auto; }

.chip {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; vertical-align: middle;
}
.chip-lastPass    { background: #10331d; color: #6ee7a0; border: 1px solid #1f6b3d; }
.chip-staleRecent { background: #33280f; color: #fbbf24; border: 1px solid #7a5c14; }
.chip-staleOld    { background: #2b2b33; color: #a8adba; border: 1px solid #4a4d59; }
.chip-unseen      { background: #2b2b33; color: #a8adba; border: 1px solid #4a4d59; }

.pop .chip { margin-bottom: 8px; }
.rk-sub.dim { opacity: 0.72; }

details.help { margin: 8px 0 4px; }
details.help summary {
  cursor: pointer; font-size: 12.5px; color: #ffb08c; padding: 3px 0;
}
details.help .note { margin-top: 4px; }

.sources { margin: 0; padding-inline-start: 18px; font-size: 12.5px; color: var(--muted); }
.sources li { margin-bottom: 5px; }
.links { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0 0; font-size: 13px; }

/* ------------------------------------------------------------------ carte */

.mapwrap { position: relative; }
#map { position: absolute; inset: 0; }

.legend {
  position: absolute; inset-block-end: 26px; inset-inline-start: 12px;
  background: #121824e6; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; font-size: 12.5px; backdrop-filter: blur(6px);
}
.legend-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; color: var(--muted); }
.legend-sep { height: 1px; background: var(--line); margin: 6px 0; }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.dot.conf-high { background: #ff3b1f; }
.dot.conf-nominal { background: #ff8c1a; }
.dot.conf-low { background: #ffd24d; }
.dot.conf-unknown { background: #9aa4b2; }
.sizehint {
  width: 22px; height: 11px; flex: none;
  background: radial-gradient(circle at 22% 50%, #ff8c1a 0 2px, transparent 2px),
              radial-gradient(circle at 68% 50%, #ff8c1a 0 5px, transparent 5px);
}

.computed-banner {
  position: absolute; inset-block-start: 12px; inset-inline-start: 12px;
  max-width: 380px; background: #241a2ee6; border: 1px solid #6b4a8a;
  border-radius: var(--radius); padding: 9px 12px; font-size: 12.5px;
  color: #e5d5f5; backdrop-filter: blur(6px);
}
.computed-banner strong { color: #d3a8ff; }

/* ---------------------------------------------------------------- popups */

.maplibregl-popup-content {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; font-family: inherit;
}
.maplibregl-popup.rtl .maplibregl-popup-content { direction: rtl; text-align: right; }
.maplibregl-popup-tip { border-top-color: var(--panel) !important; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 18px; }

.pop h3 { margin: 0 0 8px; font-size: 15px; }
.pop .poptag {
  display: inline-block; margin-bottom: 6px; padding: 2px 7px;
  border-radius: 999px; background: #3a2a4d; color: #d3a8ff;
  font-size: 11px; font-weight: 600;
}
.pr { display: flex; justify-content: space-between; gap: 14px; font-size: 13px; padding: 2.5px 0; }
.pr span { color: var(--muted); }
.pr b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ pied */

.foot {
  padding: 8px 16px; font-size: 11.5px; color: var(--muted);
  background: var(--panel); border-top: 1px solid var(--line);
  display: flex; gap: 8px; flex-wrap: wrap;
}
.foot .sep { opacity: 0.5; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 55vh auto;
    height: auto;
  }
  .mapwrap { order: -1; min-height: 55vh; }
  .panel { border-inline-end: 0; border-top: 1px solid var(--line); }
  .legend { inset-block-end: 12px; font-size: 11.5px; padding: 8px 10px; }
  .computed-banner { max-width: calc(100% - 24px); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

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

.layers { list-style: none; margin: 0; padding: 0; }

.layer { padding: 7px 0; border-bottom: 1px solid var(--line); }
.layer:last-child { border-bottom: 0; }

.layer label {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  font-size: 14.5px;
}
.layer.off label { cursor: not-allowed; opacity: 0.55; }

.layer .ico { width: 20px; text-align: center; flex: none; font-size: 15px; }
.layer .lname { flex: 1 1 auto; font-weight: 600; }
.layer .lcount {
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}

.layer input[type=checkbox] {
  appearance: none; -webkit-appearance: none;
  width: 20px; height: 20px; flex: none; margin: 0;
  border: 1px solid #3a475c; border-radius: 5px; background: var(--panel-2);
  cursor: pointer; position: relative;
}
.layer input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
.layer input[type=checkbox]:checked::after {
  content: ''; position: absolute; inset-inline-start: 6px; top: 2px;
  width: 5px; height: 10px; border: solid #14100c;
  border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.layer input[type=checkbox]:disabled { cursor: not-allowed; opacity: 0.5; }

.layer .lnote {
  margin: 5px 0 0; padding-inline-start: 30px;
  font-size: 12px; color: var(--muted); line-height: 1.42;
}
.layer .lnote.warn { color: var(--warn); }

.lsub { padding-inline-start: 30px; margin-top: 8px; }
.range { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.range input[type=range] { flex: 1 1 auto; accent-color: var(--accent); min-width: 0; }
.range output { font-variant-numeric: tabular-nums; color: var(--text); min-width: 34px; }

.legend-note {
  margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted); max-width: 210px; line-height: 1.35;
}

.popwarn {
  margin: 0 0 8px; font-size: 12.5px; color: #d3a8ff;
}

.passes { margin: 6px 0 8px; font-size: 12px; color: var(--muted); line-height: 1.42; }
.passes .dim { opacity: 0.75; }

.legend-title { font-size: 11px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.dot.band-who      { background: #3fb950; }
.dot.band-moderate { background: #d9b016; }
.dot.band-high     { background: #e8802a; }
.dot.band-veryhigh { background: #d9453a; }
.dot.band-extreme  { background: #8b2fbf; }

.rampbar {
  height: 9px; border-radius: 5px; margin: 4px 0 2px;
  background: linear-gradient(90deg,
    rgba(90,190,120,0.10) 0%, rgba(90,190,120,0.45) 8%,
    rgba(214,200,60,0.7) 18%, rgba(232,140,46,0.85) 34%,
    rgba(219,70,58,0.92) 58%, rgba(150,50,180,0.95) 85%,
    rgba(96,30,130,0.97) 100%);
}
.rampscale {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- recherche */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.search-card { padding: 11px; }
.searchbox { position: relative; }
.searchbox input {
  width: 100%; padding: 9px 30px 9px 11px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 14px;
}
.searchbox input::placeholder { color: var(--muted); }
.searchbox button {
  position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; color: var(--muted);
  font-size: 19px; line-height: 1; cursor: pointer; padding: 0 5px;
}

.results {
  list-style: none; margin: 8px 0 0; padding: 0;
  max-height: 280px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
}
.results .res { padding: 8px 11px; cursor: pointer; border-bottom: 1px solid var(--line); }
.results .res:last-child { border-bottom: 0; }
.results .res:hover, .results .res:focus-visible { background: #1e2738; outline: none; }
.res-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.res-name { font-weight: 600; font-size: 14px; }
.res-kind {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); flex: none;
}
html[lang="ar"] .res-kind { text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.res-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.res-sub b { color: var(--accent); font-weight: 600; }
.res-sub i { opacity: 0.8; }
.res-empty { padding: 10px 11px; font-size: 13px; color: var(--muted); }
