@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&display=swap");

:root {
  --bg: #0e1114;
  --panel: rgba(18, 22, 26, 0.94);
  --panel-border: rgba(196, 165, 116, 0.22);
  --text: #ebe6de;
  --muted: #9a9388;
  --accent: #c4a574;
  --accent-hot: #f0d5a8;
  --danger: #d45d4a;
  --ok: #6f9e7b;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}
#map {
  position: absolute; inset: 0;
  background: #1a1f24;
}

.panel {
  position: absolute;
  z-index: 1000;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  font-size: 13px;
  line-height: 1.45;
}

.brand-bar {
  top: 12px; left: 50%;
  transform: translateX(-50%);
  padding: 10px 14px 8px;
  text-align: center;
  min-width: min(480px, calc(100vw - 620px));
  max-width: min(860px, calc(100vw - 620px));
  pointer-events: none;
  z-index: 1001;
}
#top-nav {
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  z-index: 1100;
  pointer-events: auto;
}
.nav-about {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: 6px;
  background: var(--accent);
  color: #1a140c;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid var(--accent-hot);
  box-shadow: 0 0 0 1px rgba(240, 213, 168, 0.15);
}
.nav-about:hover {
  background: var(--accent-hot);
  color: #1a140c;
}
.nav-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.nav-link:hover { color: var(--accent-hot); }
.lang-toggle {
  display: inline-flex;
  border: 1px solid #2c343c;
  border-radius: 6px;
  overflow: hidden;
}
.lang-btn {
  background: #1c2228;
  color: var(--muted);
  border: none;
  padding: 4px 8px;
  font: inherit;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
}
.lang-btn.active {
  background: var(--accent);
  color: #1a140c;
  font-weight: 600;
}
.brand-mark {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.brand-title {
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
}
.brand-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.brand-mobility,
.brand-disclaimer {
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.35;
}
.brand-disclaimer {
  opacity: 0.85;
  font-style: italic;
}
.focus-btn {
  flex: 1;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--muted);
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}
.focus-btn.active {
  background: rgba(196, 165, 116, 0.18);
  color: var(--accent-hot);
  border-color: rgba(196, 165, 116, 0.45);
}
.brand-refresh {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.brand-epi {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #2a323a;
  position: relative;
}
.epi-toggle {
  display: none;
  appearance: none;
  border: 1px solid #3a4450;
  background: #1c2228;
  color: var(--accent-hot);
  border-radius: 999px;
  width: 28px;
  height: 22px;
  padding: 0;
  font: inherit;
  cursor: pointer;
  margin: 6px auto 0;
  align-items: center;
  justify-content: center;
}
.epi-toggle:hover {
  border-color: var(--accent);
  color: #fff;
}
.epi-chevron {
  display: block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 6px solid currentColor; /* pointe vers le haut = replier */
}
.brand-epi.is-collapsed .epi-chevron {
  border-bottom: none;
  border-top: 6px solid currentColor; /* pointe vers le bas = déplier */
}
.epi-body { display: block; }
.brand-epi.is-collapsed .epi-body { display: none; }
.epi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px 6px;
  justify-items: stretch;
}
.epi-chip {
  background: #171c21;
  border-radius: 4px;
  padding: 5px 7px;
  text-align: center;
  line-height: 1.2;
  min-width: 0;
}
.epi-chip span {
  display: block;
  color: #c9c2b6;
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.01em;
  white-space: normal;
  line-height: 1.25;
}
.epi-chip strong {
  display: block;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-hot);
  margin-top: 2px;
}
.epi-asof {
  margin: 5px 0 0;
  font-size: 11px;
  color: var(--muted);
}

#controls {
  top: 12px;
  left: 12px;
  bottom: 22px;
  width: min(310px, calc(100vw - 24px));
  max-height: none;
  padding: 12px 14px;
  overflow: hidden;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0;
  font-size: 14px;
  color: var(--text);
}
.controls-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}
.controls-hint {
  margin-top: 8px;
  margin-bottom: 0;
  font-size: 12px;
  color: #b8b0a4;
  line-height: 1.4;
}
.controls-legend {
  flex: 0 0 auto;
  margin-top: 10px;
  padding-top: 10px;
  padding-bottom: 2px;
  border-top: 1px solid #2a323a;
  overflow: visible;
}
#controls .panel-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--accent-hot);
  font-weight: 500;
  margin-bottom: 8px;
}
#controls .field-label {
  color: #d4cdc2;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
}
#controls .seg-btn {
  color: #cfc7bb;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 6px;
}
#controls .seg-btn.active {
  color: #1a140c;
  font-weight: 600;
}
#controls .check {
  color: #e4ddd3;
  font-size: 13px;
  line-height: 1.45;
  margin: 8px 0;
}
#controls .metrics span {
  color: #c9c2b6;
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.01em;
}
#controls .metrics strong {
  font-size: 16px;
  color: var(--accent-hot);
}
#controls .legend-ends,
#controls .key {
  color: #d4cdc2;
  font-size: 12px;
}
#info {
  top: 148px;
  right: 12px;
  bottom: 22px;
  width: min(320px, calc(100vw - 24px));
  max-height: none;
  padding: 12px 14px 14px;
  overflow: auto;
  z-index: 1000;
}

.panel-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 12px;
}
.seg.focus-seg {
  grid-template-columns: 1fr 1fr 1fr;
}
.seg-btn {
  background: #1c2228;
  color: var(--muted);
  border: 1px solid #2c343c;
  border-radius: 6px;
  padding: 8px 6px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.seg-btn.active {
  color: #1a140c;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.search-wrap { position: relative; margin-bottom: 10px; }
#zone-search {
  width: 100%;
  background: #1c2228;
  color: var(--text);
  border: 1px solid #2c343c;
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
}
#zone-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(196, 165, 116, 0.35);
}
#search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px);
  background: #151a1f;
  border: 1px solid #2c343c;
  border-radius: 6px;
  max-height: 220px;
  overflow: auto;
  z-index: 1100;
}
.search-opt {
  display: block; width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid #222931;
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
  font: inherit;
}
.search-opt:hover { background: #222931; color: var(--accent-hot); }

.check {
  display: flex; align-items: flex-start; gap: 8px;
  color: var(--muted);
  margin: 7px 0;
  cursor: pointer;
  font-size: 12.5px;
  line-height: 1.4;
}
.check input { margin-top: 2px; accent-color: var(--accent); }

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #2a323a;
}
.metrics div {
  background: #171c21;
  border-radius: 6px;
  padding: 8px;
}
.metrics span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.metrics strong {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}
.tab {
  background: #1c2228;
  border: 1px solid #2c343c;
  color: var(--muted);
  border-radius: 6px;
  padding: 7px 4px;
  cursor: pointer;
  font: inherit;
}
.tab.active {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent-hot);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

#info h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
}
.muted { color: var(--muted); margin: 0 0 12px; }
.hint { color: var(--muted); font-size: 11px; margin-top: 14px; }

.kv {
  margin: 0;
  display: grid;
  gap: 8px;
}
.kv > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #222931;
}
.kv dt { color: var(--muted); }
.kv dd {
  margin: 0;
  font-family: var(--mono);
  font-weight: 500;
}

.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rank-list li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #222931;
  cursor: pointer;
}
.rank-list li:hover { color: var(--accent-hot); }
.rank-list .idx {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 11px;
}
.rank-list .val {
  font-family: var(--mono);
  font-size: 12px;
}
.rank-list .badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 999px;
  border: 1px solid #3a4450;
  color: var(--muted);
}
.rank-list .badge.hot {
  border-color: rgba(212, 93, 74, 0.5);
  color: #f0a090;
}

.legend-bar {
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2a3340 0%, #8a6a3d 35%, #c45a3a 70%, #f0d5a8 100%);
  margin: 6px 0 4px;
}
.legend-ends {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}
.legend-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 8px;
  overflow: visible;
}
.key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  overflow: visible;
}
.swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.25);
  flex-shrink: 0;
  box-sizing: border-box;
}
.swatch.invaded { background: #3a4149; }
.swatch.poe {
  background: transparent;
  box-shadow: inset 0 0 0 2px #e8c48a;
}
.swatch.arc {
  background: linear-gradient(
    to bottom,
    transparent 0,
    transparent 4px,
    #7eb6ff 4px,
    #7eb6ff 8px,
    transparent 8px,
    transparent 12px
  );
  border: 1px solid rgba(126, 182, 255, 0.35);
  box-shadow: none;
  height: 12px;
}

.empty {
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  padding: 18px 20px;
  max-width: 420px;
  text-align: center;
}
.empty code {
  display: block;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent-hot);
  background: #171c21;
  padding: 8px;
  border-radius: 6px;
}

/* Leaflet tweaks */
.leaflet-container { background: #1a1f24; font: inherit; }
.leaflet-bottom.leaflet-right {
  right: 344px !important;
  bottom: 24px !important;
  z-index: 1200;
}
.leaflet-control-zoom {
  border: 1px solid rgba(196, 165, 116, 0.35) !important;
  box-shadow: var(--shadow) !important;
}
.leaflet-control-zoom a {
  background: rgba(18, 22, 26, 0.95) !important;
  color: var(--accent-hot) !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
  font-size: 16px !important;
}
.leaflet-control-zoom a:hover {
  background: #222931 !important;
  color: #fff !important;
}
.leaflet-control-attribution {
  background: rgba(14,17,20,0.75) !important;
  color: #888 !important;
  font-size: 10px !important;
  margin-right: 344px !important;
}
.leaflet-control-attribution a { color: var(--accent) !important; }

/* About page */
.about-page {
  min-height: 100%;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(196, 165, 116, 0.12), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(126, 182, 255, 0.08), transparent 45%),
    var(--bg);
}
.about-shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.about-header,
.about-content {
  position: relative;
  width: 100%;
}
.about-header {
  padding: 16px 18px;
  margin-bottom: 14px;
}
.about-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.about-header .brand-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.about-header h1 {
  margin: 10px 0 0;
  font-size: 22px;
  font-weight: 600;
}
.about-content {
  padding: 8px 20px 24px;
}
.about-content section {
  padding: 16px 0;
  border-bottom: 1px solid #222931;
}
.about-content section:last-child { border-bottom: none; }
.about-content h2 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--accent);
  font-family: var(--mono);
  letter-spacing: 0.04em;
  font-weight: 500;
}
.about-content p {
  margin: 0;
  color: var(--text);
  line-height: 1.65;
  font-size: 14px;
}
.about-contact {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1.8;
}
.about-contact a {
  color: var(--accent-hot);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 13px;
}
.about-contact a:hover { text-decoration: underline; }

.about-team {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 4px;
}
.team-card {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(196, 165, 116, 0.18);
  border-radius: 8px;
}
.team-photo {
  width: 84px;
  height: 84px;
  object-fit: cover;
  object-position: center top;
  border-radius: 50%;
  border: 1px solid rgba(196, 165, 116, 0.35);
  background: #1a1f24;
}
.team-body h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.team-role {
  margin: 0 0 8px !important;
  font-size: 12.5px !important;
  line-height: 1.45 !important;
  color: var(--accent-hot) !important;
}
.team-affils,
.team-emails {
  list-style: none;
  margin: 0;
  padding: 0;
}
.team-affils {
  margin-bottom: 8px;
}
.team-affils li {
  position: relative;
  padding-left: 10px;
  margin-bottom: 3px;
  font-size: 12px;
  line-height: 1.4;
  color: #c9c2b6;
}
.team-affils li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(196, 165, 116, 0.7);
}
.team-affils a {
  color: #d8c4a0;
  text-decoration: none;
  border-bottom: 1px solid rgba(196, 165, 116, 0.35);
}
.team-affils a:hover {
  color: var(--accent-hot);
  border-bottom-color: var(--accent-hot);
}
.team-emails li {
  margin-bottom: 2px;
  color: var(--accent-hot);
  font-family: var(--mono);
  font-size: 11.5px;
  word-break: break-all;
}

@media (max-width: 720px) {
  .about-team {
    grid-template-columns: 1fr;
  }
}

.error-shell { max-width: 640px; }
.error-content {
  text-align: center;
  padding: 28px 24px 32px !important;
}
.error-code {
  margin: 0;
  font-family: var(--mono);
  font-size: 56px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--accent);
  line-height: 1;
}
.error-content h1 {
  margin: 10px 0 12px;
  font-size: 24px;
  font-weight: 600;
}
.error-lead {
  margin: 0 0 14px;
  font-size: 15px;
  color: #e4ddd3;
  line-height: 1.55;
}
.error-path {
  margin: 0 0 14px;
  font-size: 13px;
}
.error-path code {
  font-family: var(--mono);
  color: var(--accent-hot);
  word-break: break-all;
}
.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin-top: 22px;
}
.error-secondary {
  font-size: 13px !important;
  padding: 7px 4px;
}

@media (max-width: 860px) {
  .brand-bar {
    top: 8px;
    left: 8px;
    right: 8px;
    transform: none;
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 8px 10px 6px;
    padding-right: 10px;
    z-index: 1002;
    pointer-events: auto;
  }
  .brand-title {
    font-size: 13px;
    line-height: 1.3;
    padding-right: 0;
  }
  .brand-sub { font-size: 11px; }
  .brand-refresh {
    display: none;
  }
  .brand-epi {
    margin-top: 6px;
    padding-top: 6px;
  }
  .epi-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .epi-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
  }
  .epi-chip {
    padding: 4px 3px;
  }
  .epi-chip span {
    font-size: 9px;
    line-height: 1.15;
  }
  .epi-chip strong {
    font-size: 11px;
  }
  .epi-asof { font-size: 10px; }

  #top-nav {
    top: 8px;
    right: 8px;
    left: auto;
    padding: 5px 6px;
    gap: 6px;
    z-index: 1105;
  }
  .nav-about {
    padding: 5px 9px;
    font-size: 11px;
  }
  .lang-btn {
    padding: 3px 6px;
    font-size: 10px;
  }

  /* Map free — panels become bottom sheets */
  #controls,
  #info {
    display: none;
    top: auto !important;
    left: 8px !important;
    right: 8px !important;
    bottom: 64px !important;
    width: auto !important;
    max-height: min(58vh, 480px) !important;
    z-index: 1100;
    border-radius: 12px 12px 10px 10px;
  }
  #controls.is-open,
  #info.is-open {
    display: flex;
  }
  #info.is-open {
    display: block;
    overflow: auto;
  }

  #mobile-dock {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    top: auto;
    padding: 6px;
    z-index: 1200;
  }
  .dock-btn {
    appearance: none;
    border: 1px solid #2c343c;
    background: #1c2228;
    color: #cfc7bb;
    border-radius: 8px;
    padding: 10px 6px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }
  .dock-btn.active {
    background: var(--accent);
    border-color: var(--accent-hot);
    color: #1a140c;
  }

  .leaflet-bottom.leaflet-right {
    right: 12px !important;
    bottom: 72px !important;
  }
  .leaflet-control-attribution {
    margin-right: 0 !important;
    max-width: 55vw;
  }

  .empty {
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    transform: translateY(-50%);
  }
}

@media (max-width: 480px) {
  .brand-bar {
    top: 52px; /* sous la nav À propos / langue */
  }
  #top-nav {
    left: 8px;
    right: 8px;
    justify-content: space-between;
  }
  .epi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .brand-title {
    font-size: 12.5px;
  }
}

#mobile-dock { display: none; }
@media (max-width: 860px) {
  #mobile-dock { display: grid; }
}
