:root {
  --bg: #1a1f1c;
  --bg-elev: #242b27;
  --bg-soft: #2e3732;
  --text: #e8efe9;
  --muted: #9aab9f;
  --accent: #c4a35a;
  --accent-dim: #8f763c;
  --danger: #c45c4a;
  --ok: #6f9e78;
  --line: #3a4540;
  --font-display: "Source Serif 4", "Palatino Linotype", Palatino, serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, #2c3830 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #3a3224 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #dfc07a; }

.wrap {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(26, 31, 28, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 1.6vw, 1.15rem);
  letter-spacing: 0.02em;
  color: var(--text);
  line-height: 1.25;
  max-width: min(52vw, 34rem);
}

.brand span { color: var(--accent); }

.nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.95rem;
}

.nav a { color: var(--muted); }
.nav a:hover, .nav a.is-active { color: var(--text); }

/* Liens externes SpeleBase / ARIS GrottoCenter (style capture ARIS) */
.external-nav-banner {
  background: #0e1116;
  border-bottom: 2px solid #2b3442;
  padding: 0.55rem 0;
  position: relative;
  z-index: 9;
}

.external-nav-banner-inner {
  display: flex;
  justify-content: center;
}

.external-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1.25rem;
  margin-bottom: 0;
  justify-content: center;
  width: 100%;
}

.external-nav-sep {
  color: #8a7348;
  font-weight: 400;
  font-size: 1.1rem;
  line-height: 1;
  user-select: none;
  padding: 0 0.15rem;
}

.external-nav a + a {
  margin-left: 0.25rem;
}

.btn-external {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.15rem;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: #f0d090 !important;
  background: #121a26;
  border: 1px solid #c4a35a;
  border-radius: 4px;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  transition: color 0.15s, background 0.15s, border-color 0.15s, transform 0.15s;
}

.btn-external:hover {
  color: #fff4d0 !important;
  background: #1a2433;
  border-color: #dfc07a;
  transform: translateY(-1px);
}

.user-chip {
  color: var(--muted);
  font-size: 0.85rem;
}

main.wrap { padding: 2rem 0 3.5rem; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.75rem;
}

h1 { font-size: clamp(1.8rem, 3vw, 2.4rem); }
h2 { font-size: 1.35rem; }

.lead {
  color: var(--muted);
  max-width: 42rem;
  margin: 0 0 1.5rem;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem 1.35rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 1.5rem 0;
}

.stat {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.stat strong {
  display: block;
  font-size: 1.6rem;
  font-family: var(--font-display);
  color: var(--accent);
}

.stat span { color: var(--muted); font-size: 0.9rem; }

.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.25rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--accent-dim);
  background: var(--accent);
  color: #1a1f1c;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}

.btn:hover { filter: brightness(1.05); color: #1a1f1c; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.btn-ghost:hover { border-color: var(--muted); color: var(--text); }

.flash {
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
}

.flash-error { background: rgba(196, 92, 74, 0.15); border-color: var(--danger); color: #f0c2ba; }
.flash-success { background: rgba(111, 158, 120, 0.15); border-color: var(--ok); color: #c6e0cb; }
.flash-info { background: rgba(196, 163, 90, 0.12); border-color: var(--accent-dim); }

.form {
  display: grid;
  gap: 0.9rem;
  max-width: 420px;
}

.form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.form input, .form select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 0.6rem 0.7rem;
  font: inherit;
}

.form input:focus, .form select:focus {
  outline: 2px solid rgba(196, 163, 90, 0.35);
  border-color: var(--accent-dim);
}

.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: end;
}

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

table.data th, table.data td {
  text-align: left;
  padding: 0.65rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

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

table.data tr:hover td { background: rgba(255,255,255,0.02); }

.meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.pager {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  color: var(--muted);
}

.fiche-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
}

/* Fiche cavité : fond sombre → tout le texte en clair */
section:has(.fiche-grid) .meta,
section:has(.fiche-grid) .lead,
section:has(.fiche-grid) h1,
section:has(.fiche-grid) h2,
section:has(.fiche-grid) h3 {
  color: var(--text);
}

.fiche-grid .kv dt,
.fiche-grid .kv dd {
  color: var(--text);
}

.kv {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.35rem 0.75rem;
  font-size: 0.95rem;
}

.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.prose {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  max-height: 28rem;
  overflow: auto;
}

/* Fiche : Description + Description GrottoCenter — même rendu (GrottoCenter legacy) */
.prose.prose-fiche {
  background: #4a3728;
  border: 1px solid #3a2a1f;
  border-radius: 16px;
  color: #e9eef7;
}

.prose-fiche,
.prose-fiche .fiche,
.prose-fiche .gc-fiche-content {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.45;
  color: #e9eef7;
}

/* Description WebDev : styles inline (texte noir, fond blanc/jaune) → thème fiche GC */
.prose :where(p, div, span, font, td, th, li, h1, h2, h3, h4, h5, h6, b, strong, i, em, u, label) {
  color: var(--text) !important;
  background: transparent !important;
  background-color: transparent !important;
}

.prose-fiche :where(p, div, span, font, td, th, li, h1, h2, h3, h4, h5, h6, b, strong, i, em, u, label) {
  color: #e9eef7 !important;
  font-family: Consolas, "Courier New", monospace !important;
  font-size: 13px !important;
  line-height: 1.45 !important;
  background: transparent !important;
  background-color: transparent !important;
}

.prose-fiche table {
  border-color: #6d4c41 !important;
}

.prose-fiche :where(td, th) {
  background: rgba(0, 0, 0, 0.12) !important;
  border-color: #6d4c41 !important;
}

.prose-fiche a {
  color: var(--accent) !important;
}

.prose-fiche a:hover {
  color: #dfc07a !important;
}

.prose a {
  color: var(--accent) !important;
}

.prose a:hover {
  color: #dfc07a !important;
}

.prose img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0.5rem 0;
}

.prose table {
  border-color: var(--line) !important;
  width: 100%;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.25rem 0 2rem;
}

/* ——— Carte (priorité produit) ——— */
body.map-layout {
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}
body.map-layout .site-header { position: relative; }
body.map-layout .map-wrap { width: min(100% - 1.5rem, 1600px); }
.map-page {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  height: calc(100vh - 64px - 52px);
  gap: 0;
}
.map-sidebar {
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--line);
  overflow: auto;
  z-index: 2;
}
.map-filter-form {
  display: grid;
  gap: 0.7rem;
  margin: 1rem 0;
}
.quick-filters {
  margin: 0.85rem 0 0.25rem;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}
.quick-filters.panel {
  margin-bottom: 1rem;
}
.quick-filters-title {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.55rem;
}
.quick-filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.btn-quick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  color: #1a1f1c;
  cursor: pointer;
}
.btn-quick-maj {
  background: #3b82c4;
  border-color: #2f6aa3;
  color: #fff;
}
.btn-quick-kml {
  background: #3f9a5f;
  border-color: #2f7a4a;
  color: #fff;
}
.btn-quick-grandes {
  background: #4cae6a;
  border-color: #3a8f55;
  color: #fff;
}
.btn-quick:hover {
  filter: brightness(1.08);
  color: #fff;
}
.btn-quick.is-active {
  outline: 2px solid #f4e27a;
  outline-offset: 1px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25) inset;
}
.quick-filters-active {
  margin: 0.55rem 0 0;
}
.quick-filters-active a {
  color: var(--accent);
}
.map-filter-form label {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.map-filter-form input,
.map-filter-form select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  font: inherit;
}
.map-stage {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 0;
}
.map-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.map-title {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}
.map-info {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  max-width: 52rem;
}
.map-toolbar-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.map-frame {
  position: relative;
  min-height: 0;
  height: 100%;
}
.map-canvas {
  width: 100%;
  height: 100%;
  min-height: 320px;
  background: #111;
}
.map-loading {
  position: absolute;
  z-index: 500;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(26, 31, 28, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.map-loading.is-hidden { display: none; }
.map-legend {
  display: grid;
  gap: 0.35rem;
  margin: 1rem 0 0.5rem;
}
.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4f8cff;
  margin-right: 0.35rem;
  vertical-align: middle;
}
.legend-dot.kml { background: #e8a838; }
.cave-marker { background: transparent; border: 0; }
.cave-dot {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4f8cff;
  border: 1.5px solid #0e1210;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15);
}
.cave-marker.is-siphon .cave-dot { background: #4aa3c8; }
.cave-marker.has-kml .cave-dot {
  box-shadow: 0 0 0 2px #e8a838;
}
.leaflet-container { font: inherit; background: #111; }
.leaflet-control-layers {
  background: #171b22 !important;
  color: #e9eef7 !important;
  border: 1px solid #2b3442 !important;
  border-radius: 10px !important;
  max-width: 280px;
}
.leaflet-control-layers label { color: #e9eef7 !important; }
.leaflet-popup-content-wrapper {
  background: #242b27;
  color: #e8efe9;
  border-radius: 8px;
  border: 1px solid #3a4540;
}
.leaflet-popup-tip { background: #242b27; }
.leaflet-popup-content a { color: #c4a35a; }
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(196, 163, 90, 0.35) !important;
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: #c4a35a !important;
  color: #1a1f1c !important;
}

@media (max-width: 900px) {
  .map-page { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: calc(100vh - 110px - 52px); }
  .map-sidebar { max-height: 36vh; border-right: none; border-bottom: 1px solid var(--line); }
  .map-toolbar { flex-direction: column; }
}

@media (max-width: 800px) {
  .stats { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .fiche-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
}

.home-hero h1 { margin-bottom: 0.35rem; }
.slogan {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
  max-width: 36rem;
  margin: 0 0 0.85rem;
}
.home-sub { margin-top: 0; }
.map-credit {
  margin-top: 1.35rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  line-height: 1.45;
}
