/* ============================================================
   Arnaud Berthier — Conseil & Développement
   Feuille de style globale.
   Design : minimalisme architecte, blanc dominant, typographie
   forte (Space Grotesk pour les titres, Inter pour le texte),
   accents = les 5 couleurs de catégories. La page carte est
   traitée comme une expérience : splash, hero, grain, halos.
   ============================================================ */

:root {
  --ink: #141414;
  --ink-soft: #6f6f6c;
  --paper: #ffffff;
  --line: #e9e9e6;
  --accent: #d64545; /* rouge du portfolio */
  --glass: rgba(255, 255, 255, 0.82);
  --shadow: 0 10px 36px rgba(20, 20, 20, 0.1);
  --shadow-soft: 0 2px 14px rgba(20, 20, 20, 0.07);
  --radius: 12px;
  --header-h: 64px;
  --font: "Inter", -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: "Space Grotesk", "Inter", "Helvetica Neue", sans-serif;
  /* Filet signature : les 5 catégories. */
  --signature: linear-gradient(90deg,
    #3a9d5d 0 20%, #d64545 20% 40%, #e0b428 40% 60%,
    #ef8a2b 60% 80%, #3672e0 80% 100%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  /* Pas de flash gris au tap sur mobile. */
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }

/* Supprime le délai de double-tap sur les éléments interactifs (mobile). */
a, button { touch-action: manipulation; }

/* En-tête compact sur mobile. */
@media (max-width: 640px) {
  :root { --header-h: 56px; }
}

::selection { background: rgba(214, 69, 69, 0.16); }

/* Fondu de sortie quand on quitte la carte vers une page projet. */
body.leaving { animation: page-out 0.32s ease forwards; }

@keyframes page-out {
  to { opacity: 0; }
}

/* ------------------------------------------------------------
   Splash d'introduction
   ------------------------------------------------------------ */

.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--paper);
  transition: opacity 0.7s ease, visibility 0.7s;
}

.splash.gone {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0;
  animation: rise-in 0.8s ease 0.1s forwards;
}

.splash-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(34px, 7vw, 64px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
  /* Révélation par balayage. */
  clip-path: inset(0 100% 0 0);
  animation: wipe-in 1s cubic-bezier(0.7, 0, 0.2, 1) 0.35s forwards;
}

@keyframes wipe-in {
  to { clip-path: inset(0 0 0 0); }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* Cinq points aux couleurs des catégories, pulsés en séquence. */
.splash-dots {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.splash-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: dot-beat 1.2s ease-in-out infinite;
}

.splash-dots span:nth-child(1) { background: #3a9d5d; animation-delay: 0s; }
.splash-dots span:nth-child(2) { background: #d64545; animation-delay: 0.12s; }
.splash-dots span:nth-child(3) { background: #e0b428; animation-delay: 0.24s; }
.splash-dots span:nth-child(4) { background: #ef8a2b; animation-delay: 0.36s; }
.splash-dots span:nth-child(5) { background: #3672e0; animation-delay: 0.48s; }

@keyframes dot-beat {
  0%, 100% { transform: scale(1); opacity: 0.55; }
  35% { transform: scale(1.45); opacity: 1; }
}

/* ------------------------------------------------------------
   En-tête
   ------------------------------------------------------------ */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  /* Safe-areas : encoche iPhone en paysage. */
  padding: 0 max(26px, env(safe-area-inset-right)) 0 max(26px, env(safe-area-inset-left));
  background: var(--glass);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
}

/* Filet signature 5 couleurs sous l'en-tête. */
.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--signature);
}

.site-header.solid { position: sticky; background: var(--paper); }

.site-title {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.site-title strong {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.01em;
}

.site-title span {
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-soft);
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-nav { display: flex; gap: 22px; flex-shrink: 0; }

.site-nav a {
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  /* Zone tactile confortable sans changer le rendu. */
  padding: 12px 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--ink);
  border-color: var(--accent);
}

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

.page-map { overflow: hidden; }

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

/* Grain photographique + vignettage doux, au-dessus de la carte,
   sous l'interface. Purement décoratif. */
.map-veil {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background:
    radial-gradient(130% 100% at 50% 42%, transparent 58%, rgba(20, 20, 20, 0.14) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}

/* Hero : accroche au chargement */
.hero {
  position: fixed;
  left: 26px;
  bottom: 350px; /* au-dessus de la légende */
  z-index: 12;
  max-width: 560px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hero.in { opacity: 1; transform: none; }

.hero.gone {
  opacity: 0;
  transform: translateY(-14px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.hero-kicker {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(34px, 5.2vw, 62px);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.025em;
  /* Léger halo blanc pour rester lisible sur la carte. */
  text-shadow:
    0 0 22px rgba(255, 255, 255, 0.9),
    0 0 60px rgba(255, 255, 255, 0.7);
}

/* « Léman » en dégradé lac → rive : la touche de couleur du hero. */
.hero-lac {
  background: linear-gradient(95deg, #3672e0 10%, #3a9d5d 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

.hero-sub {
  margin: 14px 0 0;
  font-size: 14.5px;
  font-weight: 400;
  color: #3c3c3a;
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.9);
}

.hero-cta {
  pointer-events: auto;
  margin-top: 20px;
  padding: 12px 22px;
  border: 0;
  border-radius: 99px;
  background: var(--ink);
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.25s cubic-bezier(0.2, 1.2, 0.4, 1), background 0.2s;
}

.hero-cta:hover { transform: translateY(-2px) scale(1.03); background: #000; }

/* --------------------------------------------------------
   Marqueurs : halo pulsé + point. Le conteneur est positionné
   par MapLibre ; .marker gère apparition, survol, filtres.
   -------------------------------------------------------- */

.marker {
  position: relative;
  width: 18px;
  height: 18px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-16px) scale(0.3);
  transition:
    opacity 0.55s ease,
    transform 0.6s cubic-bezier(0.2, 1.5, 0.4, 1);
}

/* Zone de toucher élargie, invisible (44px mini). */
.marker::after {
  content: "";
  position: absolute;
  inset: -13px;
  border-radius: 50%;
}

/* Écrans tactiles : points un peu plus gros. */
@media (pointer: coarse) {
  .marker { width: 21px; height: 21px; }
}

.marker.visible { opacity: 1; transform: none; }

.marker-dot {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--c);
  border: 2.5px solid #fff;
  /* Lueur colorée de la catégorie + ancrage au sol. */
  box-shadow:
    0 3px 12px color-mix(in srgb, var(--c) 55%, transparent),
    0 1px 4px rgba(20, 20, 20, 0.3);
  transition: transform 0.25s cubic-bezier(0.2, 1.4, 0.4, 1);
}

/* Halo pulsé en continu. */
.marker-halo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--c);
  opacity: 0;
  animation: halo 2.8s ease-out infinite;
}

@keyframes halo {
  0% { transform: scale(0.9); opacity: 0.5; }
  70% { transform: scale(2.6); opacity: 0; }
  100% { transform: scale(2.6); opacity: 0; }
}

.marker:hover .marker-dot,
.marker.highlight .marker-dot {
  transform: scale(1.5);
}

.marker.highlight .marker-halo { animation-duration: 1.6s; }

/* Survol d'un point : les autres s'estompent. */
#map.dim .marker:not(.is-hover) { opacity: 0.28; }

/* Survol d'une catégorie dans la légende : sa famille ressort. */
#map.dim-cat .marker:not(.cat-hi) { opacity: 0.15; }
#map.dim-cat .marker.cat-hi .marker-dot { transform: scale(1.3); }

.marker.filtered-out {
  opacity: 0 !important;
  transform: scale(0.3);
  pointer-events: none;
}

/* --------------------------------------------------------
   Popup de survol
   -------------------------------------------------------- */

.maplibregl-popup.project-popup { z-index: 15; }

.project-popup .maplibregl-popup-content {
  font-family: var(--font);
  padding: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  width: 230px;
  animation: pop-in 0.28s cubic-bezier(0.2, 1.3, 0.4, 1);
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

.popup-media { position: relative; }

.popup-thumb {
  display: block;
  width: 100%;
  height: 108px;
  object-fit: cover;
  background: #f2f2f0;
}

.popup-chip {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--c);
  color: #fff;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.popup-body { padding: 12px 14px 13px; }

.popup-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.25;
}

.popup-commune {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: var(--ink-soft);
  letter-spacing: 0.03em;
}

.popup-cta {
  margin: 9px 0 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}

.popup-cta span { display: inline-block; transition: transform 0.2s; }

.popup-card { cursor: pointer; }

/* Bouton de fermeture de l'aperçu (affiché sur tactile). */
.project-popup .maplibregl-popup-close-button {
  width: 32px;
  height: 32px;
  top: 4px;
  right: 4px;
  font-size: 20px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.55);
  border-radius: 50%;
}

.project-popup .maplibregl-popup-close-button:hover { background: rgba(0, 0, 0, 0.18); }

/* --------------------------------------------------------
   Légende / filtres
   -------------------------------------------------------- */

.legend {
  position: fixed;
  left: 20px;
  bottom: 30px;
  z-index: 18;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px 18px 14px;
  max-width: 272px;
}

.legend-title {
  margin: 0 0 10px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--ink-soft);
}

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

.legend-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 6px;
  margin: 0;
  border: 0;
  background: none;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: opacity 0.2s, background 0.2s, transform 0.2s;
}

.legend-list button:hover {
  background: rgba(20, 20, 20, 0.05);
  transform: translateX(2px);
}

.legend-list button.off { opacity: 0.3; }

.legend-list button.off .legend-dot { background: #c9c9c5; box-shadow: none; }

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent);
  transition: background 0.2s, box-shadow 0.2s;
}

.legend-label { flex: 1; }

/* Libellé court, utilisé uniquement par la légende mobile. */
.legend-short { display: none; }

.legend-count {
  font-size: 10.5px;
  font-weight: 600;
  color: color-mix(in srgb, var(--c) 70%, #141414);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border-radius: 99px;
  padding: 2px 7px;
}

.off-map-links {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.off-map-links:empty { display: none; }

.off-map-links a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.off-map-links a:hover { border-color: var(--ink); }

/* --------------------------------------------------------
   Bouton mode découverte
   -------------------------------------------------------- */

.discovery-toggle {
  position: fixed;
  top: calc(var(--header-h) + 18px);
  right: 20px;
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 20px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 99px;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: var(--shadow);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.25s, color 0.25s, transform 0.25s cubic-bezier(0.2, 1.2, 0.4, 1);
}

.discovery-toggle:hover { transform: translateY(-2px); }

.discovery-toggle:hover,
.discovery-toggle.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* Pastille animée du bouton : reprend le filet signature. */
.dt-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--signature);
  animation: dt-spin 3.2s linear infinite;
}

@keyframes dt-spin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------
   Panneau mode découverte
   -------------------------------------------------------- */

.discovery-panel {
  position: fixed;
  top: var(--header-h);
  right: 0;
  bottom: 0;
  z-index: 17;
  width: min(440px, 88vw);
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  /* Le scroll du panneau ne doit pas entraîner la page (mobile). */
  overscroll-behavior: contain;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(20, 20, 20, 0.08);
  animation: panel-in 0.5s cubic-bezier(0.2, 0.9, 0.2, 1);
}

@keyframes panel-in {
  from { transform: translateX(60px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.discovery-hint {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 26px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.discovery-counter {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.discovery-progress {
  flex: 1;
  height: 2px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}

#discovery-progress-bar {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
  transition: width 0.5s cubic-bezier(0.2, 0.9, 0.2, 1), background 0.5s;
}

.discovery-card {
  min-height: calc(100vh - var(--header-h) - 43px);
  /* dvh : tient compte des barres d'interface des navigateurs mobiles. */
  min-height: calc(100dvh - var(--header-h) - 43px);
  scroll-snap-align: start;
  padding: 46px 28px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 13px;
  border-bottom: 1px solid var(--line);
  opacity: 0.28;
  transform: translateY(6px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.discovery-card.current { opacity: 1; transform: none; }

/* Révélation en cascade du contenu de la fiche active. */
.discovery-card .st {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.55s ease var(--d, 0s),
    transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) var(--d, 0s);
}

.discovery-card.current .st {
  opacity: 1;
  transform: none;
}

.card-index {
  font-family: var(--font-display);
  font-size: 46px;
  font-weight: 700;
  line-height: 1;
  color: transparent;
  /* Numéro en contour teinté de la couleur de la catégorie. */
  -webkit-text-stroke: 1.2px color-mix(in srgb, var(--c, #d8d8d4) 55%, #e2e2de);
  letter-spacing: 0.02em;
}

.card-media { will-change: transform; }

.card-media {
  overflow: hidden;
  border-radius: var(--radius);
}

.card-media img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #f2f2f0;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.discovery-card.current .card-media img { transform: scale(1.04); }

.discovery-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
}

.discovery-card .commune {
  margin: 0;
  font-size: 12.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.discovery-card p.desc {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.65;
  color: #3d3d3b;
  font-weight: 300;
}

.discovery-card .project-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--c);
  border-bottom: 1.5px solid currentColor;
  padding-bottom: 3px;
}

.discovery-card .project-link span { transition: transform 0.25s; }

.discovery-card .project-link:hover span { transform: translateX(4px); }

/* Flèches de navigation du panneau. */
.discovery-arrows {
  position: sticky;
  bottom: 18px;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 22px;
  pointer-events: none;
}

.discovery-arrows button {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}

.discovery-arrows button:hover {
  background: var(--ink);
  color: #fff;
  transform: translateY(-2px);
}

.discovery-close-mobile {
  display: none;
  border: 0;
  background: none;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 2px 6px;
}

/* Rail de navigation du mode découverte : un point par projet,
   à gauche du panneau (desktop uniquement). */
.discovery-rail {
  position: fixed;
  top: 50%;
  right: calc(min(440px, 88vw) + 16px);
  transform: translateY(-50%);
  z-index: 18;
  display: none;
  flex-direction: column;
  gap: 7px;
  padding: 10px 7px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 99px;
  box-shadow: var(--shadow-soft);
}

body.discovery-on .discovery-rail { display: flex; }

.discovery-rail button {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--c);
  opacity: 0.35;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}

.discovery-rail button:hover { opacity: 0.8; transform: scale(1.3); }

.discovery-rail button.on {
  opacity: 1;
  transform: scale(1.45);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent);
}

/* Badge de catégorie (partagé carte / page projet) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  padding: 5px 13px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #fff;
  background: var(--c, var(--ink));
}

/* Contrôles MapLibre : ronds, verre dépoli. */
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-group {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: var(--glass);
  backdrop-filter: blur(10px);
}

.maplibregl-ctrl-group button { background: transparent; }

/* ------------------------------------------------------------
   Page projet
   ------------------------------------------------------------ */

.page-project,
.page-static {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  animation: page-in 0.45s ease both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.project-main { flex: 1; }

.project-hero {
  position: relative;
  height: min(54vh, 500px);
  background: #f2f2f0;
  overflow: hidden;
}

.project-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  animation: hero-zoom 1.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes hero-zoom {
  from { transform: scale(1.06); }
  to { transform: scale(1); }
}

.project-head {
  max-width: 860px;
  margin: 0 auto;
  padding: 42px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.project-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(30px, 4.8vw, 46px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.project-head .commune {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.project-body {
  max-width: 860px;
  margin: 0 auto;
  padding: 8px 24px 24px;
}

.project-body p {
  font-size: 15.5px;
  line-height: 1.75;
  color: #2e2e2c;
  font-weight: 300;
}

.coords-note {
  font-size: 12px;
  color: var(--ink-soft);
  font-style: italic;
}

.project-gallery {
  max-width: 860px;
  margin: 0 auto;
  padding: 8px 24px 56px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.project-gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  background: #f2f2f0;
}

.error-message {
  max-width: 860px;
  margin: 0 auto;
  padding: 80px 24px;
  text-align: center;
  color: var(--ink-soft);
}

.loading {
  padding: 80px 24px;
  text-align: center;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------
   Pages statiques (À propos, Contact)
   ------------------------------------------------------------ */

.static-main {
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  padding: 64px 24px;
}

.static-main h1 {
  font-family: var(--font-display);
  font-size: clamp(30px, 4.8vw, 44px);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
}

.static-main .lead {
  font-size: 18px;
  font-weight: 400;
  line-height: 1.6;
}

.static-main p {
  font-size: 15.5px;
  line-height: 1.75;
  font-weight: 300;
  color: #2e2e2c;
}

.contact-list {
  list-style: none;
  margin: 32px 0 0;
  padding: 0;
}

.contact-list li {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  font-weight: 300;
}

.contact-list li span {
  width: 110px;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  padding-top: 3px;
}

/* ------------------------------------------------------------
   Pied de page
   ------------------------------------------------------------ */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px 24px;
}

.back-link {
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink);
}

.back-link:hover { color: var(--accent); }

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */

@media (max-width: 640px) {
  .site-title span { display: none; }

  .hero {
    left: 18px;
    right: 18px;
    bottom: auto;
    top: calc(var(--header-h) + 30px);
    max-width: none;
  }

  .hero h1 { font-size: clamp(30px, 9vw, 40px); }

  .hero-sub { margin-top: 10px; }

  .hero-cta { margin-top: 16px; }

  /* Légende compacte : barre de pastilles horizontales défilables. */
  .legend {
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(12px + env(safe-area-inset-bottom));
    max-width: none;
    padding: 6px 8px;
    border-radius: 99px;
  }

  .legend-title { display: none; }

  .off-map-links { display: none; }

  .legend-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .legend-list::-webkit-scrollbar { display: none; }

  .legend-list button {
    flex: 0 0 auto;
    width: auto;
    min-height: 40px;
    padding: 9px 14px;
    border-radius: 99px;
    background: color-mix(in srgb, var(--c) 10%, #ffffff);
    font-size: 11.5px;
  }

  .legend-list button:hover { transform: none; }

  .legend-label { display: none; }

  .legend-short { display: inline; }

  .legend-dot { width: 9px; height: 9px; box-shadow: none; }

  .legend-count { padding: 1px 6px; font-size: 10px; }

  /* Le bouton découverte se pose au-dessus de la barre de légende. */
  .discovery-toggle {
    top: auto;
    bottom: calc(72px + env(safe-area-inset-bottom));
    right: max(10px, env(safe-area-inset-right));
    padding: 12px 18px;
    font-size: 12px;
  }

  /* Contrôles MapLibre (zoom, boussole, attribution) au-dessus du bouton. */
  .maplibregl-ctrl-bottom-right {
    bottom: calc(122px + env(safe-area-inset-bottom));
    right: env(safe-area-inset-right);
  }

  .discovery-panel {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 48vh;
    height: 48dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    animation: panel-up 0.5s cubic-bezier(0.2, 0.9, 0.2, 1);
  }

  .discovery-card {
    min-height: calc(48vh - 43px);
    min-height: calc(48dvh - 43px);
    padding: 22px 20px;
    gap: 9px;
  }

  .discovery-card .card-media { display: none; }

  .card-index { font-size: 32px; }

  .discovery-card h2 { font-size: 19px; }

  .discovery-card p.desc {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .discovery-arrows { bottom: calc(12px + env(safe-area-inset-bottom)); }

  .discovery-arrows button { width: 44px; height: 44px; }

  .discovery-close-mobile { font-size: 20px; padding: 10px 14px; margin: -8px -8px -8px 0; }

  /* Pas de rail sur mobile ; légende et bouton laissent la place au panneau. */
  body.discovery-on .discovery-rail { display: none; }

  body.discovery-on .legend,
  body.discovery-on .discovery-toggle { display: none; }

  body.discovery-on .discovery-close-mobile { display: block; }

  /* ---- Pages projet ---- */
  .project-hero {
    height: min(38vh, 340px);
    height: min(38dvh, 340px);
  }

  .project-head { padding: 26px 18px 4px; gap: 10px; }

  .project-body { padding: 6px 18px 16px; }

  .project-body p { font-size: 15px; }

  .project-gallery {
    padding: 4px 18px 40px;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  /* ---- Pages statiques ---- */
  .static-main { padding: 40px 18px; }

  .contact-list li { flex-direction: column; gap: 5px; }

  .contact-list li span { width: auto; padding-top: 0; }

  /* ---- Pied de page ---- */
  .site-footer {
    padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  }

  .back-link { display: inline-block; padding: 8px 0; }
}

/* Téléphone en paysage : on libère l'écran pour la carte. */
@media (max-height: 480px) {
  :root { --header-h: 48px; }

  .hero { display: none; }

  .discovery-toggle { top: calc(var(--header-h) + 10px); padding: 8px 14px; }

  .legend {
    left: max(16px, env(safe-area-inset-left));
    bottom: max(14px, env(safe-area-inset-bottom));
    padding: 10px 12px 8px;
    max-height: calc(100vh - var(--header-h) - 28px);
    max-height: calc(100dvh - var(--header-h) - 28px);
    overflow-y: auto;
  }

  .legend-list button { padding: 3px 4px; font-size: 11.5px; }

  .legend-title { margin-bottom: 5px; }

  .off-map-links { display: none; }
}

@keyframes panel-up {
  from { transform: translateY(60px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* Écrans peu hauts : hero compacté pour ne pas toucher l'en-tête. */
@media (max-height: 800px) and (min-width: 641px) {
  .hero h1 { font-size: clamp(28px, 4vw, 44px); }
  .hero-sub { margin-top: 10px; }
  .hero-cta { margin-top: 14px; padding: 10px 18px; }
}

/* ------------------------------------------------------------
   Accessibilité : mouvement réduit
   ------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .marker-halo,
  .splash-dots span,
  .dt-dot { animation: none; }

  .splash-name {
    clip-path: none;
    animation: none;
  }

  .splash-kicker { animation: none; opacity: 1; }

  .hero,
  .discovery-card,
  .card-media img { transition: none; }
}
