/* ============================================================
   Carte SVG Agglo Seine-Eure V2.8 (V4) — Fix critique
   Refonte 2026-05-26 Phase 2.8 — Julien bug fix
   Communes TOUJOURS VISIBLES par défaut.
   Aucune animation cascade. Aucun focus-within dim.
   ============================================================ */

:root {
  --carte-navy: #0F2236;
  --carte-navy-3: #1E3A5F;
  --carte-gold: #F4A340;
  --carte-gold-2: #E0913B;
  --carte-cream: #F5EBD9;
  --carte-cream-2: #FAF3E5;
  --carte-paper: #FFFFFF;
  --carte-seine: #4A90C7;
  --carte-line: rgba(15, 34, 54, 0.10);
  --carte-shadow-md: 0 4px 12px rgba(15, 34, 54, 0.08);
  --carte-shadow-lg: 0 16px 40px rgba(15, 34, 54, 0.12);
  --carte-shadow-gold: 0 4px 12px rgba(244, 163, 64, 0.30);
  --carte-radius: 18px;
}

/* === Container === */
.carte-agglo-container {
  position: relative;
  background: var(--carte-paper);
  border-radius: 24px;
  padding: 30px;
  box-shadow: var(--carte-shadow-lg);
  border: 1px solid var(--carte-line);
  max-width: 1200px;
  margin: 0 auto;
}

.carte-agglo-frame {
  /* v2.8 — aspect-ratio aligné sur ratio bbox 60 communes CASE (1.10:1 Lambert-93) */
  aspect-ratio: 1.1 / 1;
  border-radius: var(--carte-radius);
  background: linear-gradient(135deg, var(--carte-cream-2), var(--carte-paper) 60%);
  border: 1px solid var(--carte-line);
  position: relative;
  overflow: hidden;
}

.carte-agglo-frame svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* === Communes V4 — TOUJOURS VISIBLES par défaut, AUCUNE animation entrée === */
.commune {
  fill: var(--carte-cream);
  stroke: var(--carte-navy);
  stroke-width: 0.5;
  stroke-linejoin: round;
  cursor: pointer;
  opacity: 1;            /* CRITIQUE V4 : opacity 1 explicite */
  display: block;        /* CRITIQUE V4 : display block explicite */
  transition:
    fill 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    stroke-width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    filter 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover state — gold + lift subtil + drop-shadow gold */
.commune:hover {
  fill: var(--carte-gold);
  stroke: var(--carte-navy);
  stroke-width: 1.5;
  filter: drop-shadow(0 4px 12px rgba(244, 163, 64, 0.30));
  transform: translateY(-1px);
}

/* Focus state — outline navigateur supprimé, on ne montre rien spécial au focus souris */
.commune:focus {
  outline: none;
}

/* Focus-visible — accessibilité clavier UNIQUEMENT (Tab) */
.commune:focus-visible {
  fill: var(--carte-gold);
  stroke: var(--carte-navy);
  stroke-width: 1.8;
  outline: 2px solid var(--carte-gold);
  outline-offset: 2px;
  filter: drop-shadow(0 4px 12px rgba(244, 163, 64, 0.30));
}

/* Clicked state — effet 200 ms avant redirection */
.commune.is-clicked {
  fill: var(--carte-gold);
  stroke: var(--carte-navy);
  stroke-width: 1.8;
  filter: drop-shadow(0 6px 16px rgba(244, 163, 64, 0.45));
}

/* Active state — commune page visitée (data-active-slug) */
.commune.is-active {
  fill: var(--carte-gold);
  stroke: var(--carte-navy);
  stroke-width: 1.8;
}

/* === Rivières (Seine uniquement, Eure retirée v2.7) === */
.riviere {
  pointer-events: none;
}

/* === Falaises (gold subtiles v2.7) === */
.falaise {
  pointer-events: none;
}

/* === Tooltip V4 (navy bg + gold accent border-left) — affiche NOM commune seul === */
.carte-tooltip {
  position: fixed;
  z-index: 1000;
  background: var(--carte-navy);
  color: var(--carte-cream);
  padding: 10px 14px;
  border-radius: 6px;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.85rem;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(15, 34, 54, 0.25);
  border-left: 3px solid var(--carte-gold);
  max-width: 240px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.carte-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.carte-tooltip__name {
  display: block;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--carte-gold);
  letter-spacing: 0.01em;
}

/* Tooltip — éléments meta/pop/cta cachés V4 (focus design pur, NOM seul) */
.carte-tooltip__meta,
.carte-tooltip__pop,
.carte-tooltip__cta {
  display: none;
}

/* === Légende V4 (4 items simples) === */
.carte-agglo-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1.5rem;
  font-size: 0.85rem;
  font-family: Inter, system-ui, sans-serif;
  color: rgba(15, 34, 54, 0.7);
}

.carte-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.carte-legend-item::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--carte-cream);
  border: 1px solid var(--carte-navy);
}

.carte-legend-item--hover::before {
  background: var(--carte-gold);
  border: 1px solid var(--carte-navy);
}

.carte-legend-item--falaise::before {
  width: 0;
  height: 0;
  background: transparent;
  border: none;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 11px solid var(--carte-gold);
  border-radius: 0;
}

.carte-legend-item--seine::before {
  height: 4px;
  background: var(--carte-seine);
  border: none;
  border-radius: 2px;
  width: 22px;
}

/* === Responsive === */
@media (max-width: 1024px) {
  .carte-agglo-container {
    padding: 22px;
  }
}

@media (max-width: 768px) {
  .carte-agglo-container {
    padding: 16px;
    border-radius: 18px;
  }
  .carte-agglo-frame {
    border-radius: 12px;
  }
  .commune {
    stroke-width: 0.7;
  }
  .carte-agglo-legend {
    gap: 0.9rem;
    font-size: 0.75rem;
  }
  .carte-tooltip {
    font-size: 0.8rem;
    padding: 8px 12px;
    max-width: 200px;
  }
}

@media (max-width: 480px) {
  .carte-agglo-frame {
    aspect-ratio: 1 / 1;
  }
  .commune {
    stroke-width: 0.9;
  }
  .carte-agglo-legend {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0 0.5rem;
  }
}

/* === Accessibilité : prefers-reduced-motion === */
@media (prefers-reduced-motion: reduce) {
  .commune,
  .carte-tooltip {
    transition: none;
  }
}

/* === Mode print === */
@media print {
  .carte-tooltip {
    display: none;
  }
}
