/* Interactive Map Runtime Styles v1.1.0 — layout léger, légende flottante */

.im-root {
  --im-primary: #2563eb;
  --im-secondary: #64748b;
  --im-background: #f8fafc;
  --im-text: #1e293b;
  --im-accent: #f59e0b;
  --im-legend-background: rgba(255, 255, 255, 0.92);
  --im-popup-background: #ffffff;
  --im-font-family: system-ui, -apple-system, sans-serif;
  --im-title-size: 1.25rem;
  --im-body-size: 0.875rem;
  --im-border: rgb(148 163 184 / 0.25);
  --im-shadow: 0 8px 32px rgb(15 23 42 / 0.12), 0 2px 8px rgb(15 23 42 / 0.06);
  --im-float-shadow: 0 4px 20px rgb(15 23 42 / 0.1);
  --im-radius: 16px;
  --im-legend-width: min(280px, calc(100vw - 2rem));

  font-family: var(--im-font-family);
  font-size: var(--im-body-size);
  color: var(--im-text);
  background: var(--im-background);
  border-radius: var(--im-radius);
  overflow: hidden;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.im-root *, .im-root *::before, .im-root *::after {
  box-sizing: border-box;
}

.im-sr-live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── Layout plein écran : carte seule, légende en overlay ─── */
.im-layout {
  display: block;
  position: relative;
  min-height: min(70dvh, 560px);
  height: 100%;
}

.im-map-area {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: inherit;
  padding: 0;
  overflow: hidden;
  background: linear-gradient(145deg, #f1f5f9 0%, #e2e8f0 100%);
}

/* Pinch / pan runtime */
.im-map-canvas.im-gestures-on {
  touch-action: none;
  cursor: grab;
}
.im-map-canvas.im-gestures-on.is-panning {
  cursor: grabbing;
}
.im-map-canvas.im-gestures-on .im-svg-wrapper {
  will-change: transform;
  transition: none;
}

.im-map-canvas {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
}

.im-svg-wrapper {
  width: 100%;
  height: 100%;
  max-height: none;
  overflow: hidden;
  filter: drop-shadow(0 2px 12px rgb(15 23 42 / 0.08));
}

.im-map-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.im-map-svg [data-im-element],
.im-map-svg [data-element-id] {
  cursor: pointer;
}

.im-map-svg .im-element-icon:hover,
.im-map-svg .im-element-text:hover,
.im-map-svg [data-element-id]:hover {
  opacity: 0.9;
}

/* Survol : on met à l'échelle l'IMAGE interne (centrée en 0,0) et non le <g>
   qui porte le translate() de position — sinon l'élément « saute » vers l'origine. */
.im-map-svg .im-element-icon image,
.im-map-svg .im-element-zone image {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.14s ease;
}
.im-map-svg .im-element-icon:hover image {
  transform: scale(1.15);
}

/* Tracés raster (g enfant exporté : chemin + nom) */
.im-map-svg .im-element-trace-raster image {
  transition: filter 0.14s ease, opacity 0.14s ease;
}
.im-map-svg .im-element-trace-raster:hover image,
.im-map-svg .im-element-trace-raster.is-trace-hovered image {
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.38)) brightness(1.1);
}

/* Tracés vectoriels legacy */
.im-map-svg .im-element-trace path[data-trace-stroke] {
  transition: stroke 0.14s ease, stroke-width 0.14s ease, filter 0.14s ease, opacity 0.14s ease;
}
.im-map-svg .im-element-trace:hover path[data-trace-stroke],
.im-map-svg .im-element-trace.is-trace-hovered path[data-trace-stroke] {
  stroke: #8b2e1a;
  stroke-width: 4.5;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}
.im-map-svg .im-trace-label image {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.14s ease, opacity 0.14s ease;
}
.im-map-svg .im-trace-label:hover image,
.im-map-svg .im-trace-label.is-trace-hovered image {
  transform: scale(1.12);
  opacity: 0.95;
}

/* Élément « révélé au survol » (hors zones de navigation parent) */
.im-map-svg .im-hover-reveal {
  pointer-events: all;
}
.im-map-svg .im-hover-reveal:not(.im-zone-nav) image {
  opacity: 0;
  pointer-events: all;
  transition: opacity 0.2s ease;
}
.im-map-svg .im-hover-reveal:not(.im-zone-nav):hover image {
  opacity: 1;
}

/* Zones de navigation parent : silhouette calée sur la carte, libellé uniquement au survol */
.im-map-svg .im-zone-nav {
  pointer-events: none;
}
.im-map-svg .im-zone-nav .im-zone-shape {
  pointer-events: all;
}
.im-map-svg .im-zone-nav .im-zone-shape path {
  fill: #b8442b;
  fill-opacity: 0;
  stroke: #b8442b;
  stroke-width: 4;
  stroke-opacity: 0;
  transition: fill-opacity 0.2s ease, stroke-opacity 0.2s ease;
  pointer-events: all;
  cursor: pointer;
}
.im-map-svg .im-zone-nav.is-zone-hovered .im-zone-shape path,
.im-map-svg .im-zone-nav:focus-within .im-zone-shape path {
  fill-opacity: 0.14;
  stroke-opacity: 0.85;
}
.im-map-svg .im-zone-hover-ui {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.im-map-svg .im-zone-nav.is-zone-hovered .im-zone-hover-ui,
.im-map-svg .im-zone-nav:focus-within .im-zone-hover-ui {
  opacity: 1;
}
.im-map-svg .im-zone-hover-pill {
  fill: #b8442b;
  stroke: #fff;
  stroke-width: 2.5;
}
.im-map-svg .im-zone-hover-label {
  fill: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 700;
  paint-order: stroke fill;
}

/* Fond beige territoire partagé (entre carte de base et tracés) */
/* Fond beige semi-transparent partagé : entre carte de base et calques de tracés */
.im-map-svg > .im-trace-backdrop {
  pointer-events: none;
}
.im-trace-backdrop.im-layer-enter {
  animation: im-layer-fade-in 0.42s ease-out forwards;
}

/* Pulse sur les éléments cliquables : application directe de l'animation
   demandée sur le groupe SVG cliquable. */
.im-root.im-click-pulse .im-map-svg .im-element-pulse {
  cursor: pointer;
  animation: pulse 2.5s infinite;
}
@keyframes pulse {
  0%, 100% {
    filter: drop-shadow(0px 0px 8px rgba(0,0,0,0));
  }
  50% {
    filter: drop-shadow(0px 0px 8px rgba(0,0,0,0.5));
  }
}

/* Overlays de calques (tracés) : pas de capture de clic, ne masquent pas les calques sous-jacents */
.im-map-svg .im-layer-background {
  pointer-events: none;
}
.im-layer-background.im-layer-enter {
  animation: im-layer-fade-in 0.42s ease-out forwards;
}
@keyframes im-layer-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Animations d'apparition / disparition en cascade (éléments) */
.im-el-enter-fade  { animation: im-el-fade-in 0.38s ease-out both; }
.im-el-enter-slide { animation: im-el-slide-in 0.38s ease-out both; }
.im-el-enter-zoom  { animation: im-el-zoom-in 0.35s ease-out both; }
.im-el-exit-fade   { animation: im-el-fade-out 0.32s ease-in both; }
.im-el-exit-slide  { animation: im-el-slide-out 0.32s ease-in both; }
.im-el-exit-zoom   { animation: im-el-zoom-out 0.32s ease-in both; }
@keyframes im-el-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes im-el-slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes im-el-zoom-in {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes im-el-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes im-el-slide-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}
@keyframes im-el-zoom-out {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.88); }
}

.im-map-svg .im-selected {
  outline: 2px dashed var(--im-primary);
  outline-offset: 2px;
}

/* ─── Toolbar navigation — bulle discrète en haut à gauche ─── */
.im-toolbar {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem;
  background: rgb(255 255 255 / 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 999px;
  border: 1px solid rgb(255 255 255 / 0.7);
  box-shadow: var(--im-float-shadow);
  min-height: auto;
}

.im-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.65rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--im-text);
  font-size: 0.8125rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.im-back-btn:hover {
  background: var(--im-primary);
  color: #fff;
}

.im-back-btn:focus-visible {
  outline: 2px solid var(--im-primary);
  outline-offset: 2px;
}

.im-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  font-size: 0.75rem;
  color: var(--im-secondary);
}

.im-breadcrumb-item.im-current {
  color: var(--im-text);
  font-weight: 600;
}

.im-breadcrumb-item:not(.im-current):hover {
  color: var(--im-primary);
  text-decoration: underline;
  cursor: pointer;
}

.im-breadcrumb-sep {
  color: var(--im-secondary);
  opacity: 0.5;
  margin: 0 0.2rem;
}

/* ─── Volet légende flottant (bulle à droite) ─── */
.im-legend-float {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  bottom: 0.65rem;
  width: var(--im-legend-width);
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.65rem 0.55rem 0.55rem;
  background: var(--im-legend-background);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--im-legend-radius, var(--im-radius));
  border: 1px solid rgb(255 255 255 / 0.65);
  box-shadow: var(--im-legend-shadow, var(--im-shadow));
  overflow: hidden;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.22s ease,
              visibility 0.22s ease;
}

.im-root.im-legend-hidden .im-legend-float {
  transform: translateX(calc(100% + 1rem));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Barre supérieure du volet (en-tête + fermer) */
.im-legend-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.35rem;
  flex-shrink: 0;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--im-border);
  margin-bottom: 0.15rem;
}

.im-legend-close {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgb(15 23 42 / 0.06);
  color: var(--im-secondary);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.im-legend-close:hover {
  background: rgb(15 23 42 / 0.1);
  color: var(--im-text);
}

/* FAB réouverture — uniquement quand volet masqué */
.im-legend-open-fab {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 25;
  display: none;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--im-text);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--im-shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.im-legend-open-fab[hidden] {
  display: none !important;
}

.im-legend-open-fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgb(15 23 42 / 0.14);
}

.im-root.im-legend-hidden .im-legend-open-fab {
  display: inline-flex;
}

/* ─── Option : volet légende côté gauche ─── */
@media (min-width: 641px) {
  .im-root.im-legend-left .im-legend-float {
    left: 0.65rem;
    right: auto;
    top: 3.4rem; /* laisse la place au fil d'Ariane (haut-gauche) */
  }
  .im-root.im-legend-left.im-legend-hidden .im-legend-float {
    transform: translateX(calc(-100% - 1rem));
  }
  .im-root.im-legend-left .im-legend-open-fab {
    left: 0.65rem;
    right: auto;
    top: 3.4rem;
  }
}

/* En-tête optionnel (texte / image) */
.im-legend-header {
  flex: 1;
  min-width: 0;
  padding: 0;
  border-bottom: none;
  margin-bottom: 0;
}

.im-legend-header[hidden] {
  display: none;
}

.im-legend-header-text {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #374151;
  font-weight: 500;
}

.im-legend-header-img {
  display: block;
  max-width: 100%;
  max-height: 72px;
  object-fit: contain;
  margin: 0 auto;
  border-radius: 8px;
}

.im-legend-controls {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 0.15rem;
}

.im-legend-group {
  border: none;
  margin: 0 0 0.35rem;
  padding: 0;
}

/* ─── Sections repliables de la légende ─── */
.im-legend-section {
  margin: 0 0 0.2rem;
}

.im-legend-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4rem 0.55rem;
  margin: 0.15rem 0 0.15rem;
  background: transparent;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  color: #1a3d2e;
  transition: background 0.15s, color 0.15s;
}

.im-legend-section-header:hover {
  background: rgb(15 23 42 / 0.05);
  color: var(--im-text);
}

.im-legend-section-title {
  text-align: left;
}

.im-legend-section-chevron {
  flex-shrink: 0;
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transform: rotate(90deg);
  transition: transform 0.18s ease;
  opacity: 0.7;
}

.im-legend-section.is-collapsed .im-legend-section-chevron {
  transform: rotate(0deg);
}

.im-legend-section-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.im-legend-section.is-collapsed .im-legend-section-body {
  display: none;
}

.im-legend-section-actions {
  display: flex;
  gap: 0.35rem;
  padding: 0 0.5rem 0.4rem;
  flex-wrap: wrap;
}

.im-legend-bulk-btn {
  flex: 1 1 calc(50% - 0.2rem);
  min-width: 5.5rem;
  padding: 0.32rem 0.55rem;
  border: 1px solid rgb(15 23 42 / 0.1);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.75);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--im-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.im-legend-bulk-btn:hover {
  background: rgb(47 125 79 / 0.09);
  color: var(--im-primary);
  border-color: rgb(47 125 79 / 0.28);
}

.im-legend-bulk-btn:focus-visible {
  outline: 2px solid var(--im-primary);
  outline-offset: 2px;
}

/* Lignes légende — sans checkbox visible, effet « creux » si actif */
.im-legend-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.25rem;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  font-size: var(--im-body-size);
  color: var(--im-text);
  background: transparent;
  box-shadow: none;
  border: 1px solid transparent;
  transition: background 0.18s, box-shadow 0.18s, transform 0.12s, border-color 0.18s;
}

.im-legend-item:hover {
  background: rgb(255 255 255 / 0.55);
}

.im-legend-item.is-active {
  background: rgb(15 23 42 / 0.04);
  border-color: rgb(15 23 42 / 0.06);
  box-shadow: inset 0 2px 5px rgb(15 23 42 / 0.1),
              inset 0 1px 0 rgb(255 255 255 / 0.5);
  transform: translateY(1px);
}

.im-legend-item.is-active .im-legend-label {
  font-weight: 600;
  color: var(--im-primary);
}

.im-legend-input-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.im-legend-icon {
  flex-shrink: 0;
  object-fit: contain;
  opacity: 0.85;
}

.im-legend-item.is-active .im-legend-icon {
  opacity: 1;
}

.im-legend-label {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

/* Rétrocompat anciennes classes */
.im-legend-area { /* alias */ }
.im-legend-title { display: none !important; }

.im-legend-item--focus,
.im-legend-item:focus-within {
  outline: 2px solid var(--im-primary);
  outline-offset: 2px;
}

/* Animations */
.im-anim-fade.im-anim-enter { animation: im-fade-in 0.4s ease forwards; }
.im-anim-slide.im-anim-enter { animation: im-slide-in 0.4s ease forwards; }
.im-anim-zoom.im-anim-enter { animation: im-zoom-in 0.35s ease forwards; }

@keyframes im-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes im-slide-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes im-zoom-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .im-root.im-click-pulse .im-map-svg .im-element-pulse,
  .im-root.im-click-pulse .im-map-svg .im-element-pulse image {
    animation: none;
  }
  .im-layer-background.im-layer-enter,
  .im-trace-backdrop.im-layer-enter,
  .im-el-enter-fade,
  .im-el-enter-slide,
  .im-el-enter-zoom,
  .im-el-exit-fade,
  .im-el-exit-slide,
  .im-el-exit-zoom {
    animation: none !important;
  }
}

/* Popups */
.im-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / 0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: im-fade-in 0.2s ease;
}

.im-popup {
  background: var(--im-popup-background);
  border-radius: var(--im-radius);
  box-shadow: var(--im-shadow);
  max-width: min(480px, 100%);
  max-height: 85dvh;
  overflow-y: auto;
  padding: 1.6rem 1.7rem 1.5rem;
  position: relative;
}

.im-popup-handle {
  display: none;
  width: 2.5rem;
  height: 4px;
  margin: 0 auto 1rem;
  border-radius: 999px;
  background: rgb(148 163 184 / 0.65);
}

/* Fallback blur coûteux / appareils modestes */
.im-no-blur .im-legend-float,
.im-no-blur .im-toolbar,
.im-no-blur .im-legend-open-fab {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: #fff;
}

@media (prefers-reduced-transparency: reduce) {
  .im-legend-float,
  .im-toolbar,
  .im-legend-open-fab {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: #fff;
  }
}

.im-popup-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 999px;
  background: rgb(15 23 42 / 0.06);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--im-secondary);
}

.im-popup-close:hover {
  background: rgb(15 23 42 / 0.1);
}

.im-popup-title {
  margin: 0 0 0.3rem;
  padding-right: 2rem; /* laisse la place au bouton fermer */
  font-size: var(--im-title-size);
  font-weight: 700;
  line-height: 1.25;
}

.im-popup-subtitle {
  margin: 0 0 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--im-primary);
}

.im-popup-description {
  margin: 0 0 1rem;
  font-size: var(--im-body-size);
  line-height: 1.55;
  color: var(--im-text);
}

.im-popup-coords {
  margin: 0 0 0.85rem;
  font-size: 0.8rem;
  color: var(--im-secondary);
}

.im-popup-links {
  margin-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.im-popup-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.05rem;
  background: var(--im-primary);
  color: #fff;
  border-radius: 999px;
  text-decoration: none;
  font-size: var(--im-body-size);
  font-weight: 600;
  transition: opacity 0.15s, transform 0.15s;
}

.im-popup-links a:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

/* Champ attendu mais absent des sources : « info manquante » */
.im-popup-link-missing {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.9rem;
  border: 1px dashed rgba(180, 68, 43, 0.5);
  color: #b4442b;
  background: rgba(180, 68, 43, 0.06);
  border-radius: 999px;
  font-size: 0.82rem;
  font-style: italic;
  font-weight: 500;
}

.im-popup-phone {
  margin: 0.85rem 0 0;
  font-size: var(--im-body-size);
  color: var(--im-text);
}
.im-popup-phone a {
  color: var(--im-primary);
  font-weight: 600;
  text-decoration: none;
}

.im-popup-content {
  font-size: var(--im-body-size);
  line-height: 1.6;
}

.im-popup-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.im-popup-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.im-popup-action-btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--im-primary);
  color: #fff;
  border-radius: 999px;
  text-decoration: none;
  font-size: var(--im-body-size);
  font-weight: 500;
  transition: opacity 0.15s;
}

.im-popup-action-btn:hover {
  opacity: 0.9;
}

/* ─── Responsive : tablette ─── */
@media (max-width: 900px) {
  .im-root {
    --im-legend-width: min(260px, calc(100vw - 1.5rem));
  }

  .im-map-canvas {
    padding: 0.5rem;
  }

  .im-legend-toggle {
    right: calc(var(--im-legend-width) + 0.35rem);
  }
}

/* ─── Tablette paysage : rail latéral fixe (pas overlay) ─── */
@media (min-width: 768px) and (orientation: landscape) and (max-height: 520px) {
  .im-map-area {
    display: flex;
    flex-direction: row;
    align-items: stretch;
  }

  .im-toolbar {
    position: absolute;
    top: 0.45rem;
    left: 0.45rem;
    z-index: 20;
  }

  .im-map-canvas {
    flex: 1;
    min-width: 0;
    min-height: 0;
    padding: 0.45rem;
  }

  .im-legend-float {
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    width: 240px;
    max-width: 34vw;
    max-height: none;
    flex-shrink: 0;
    margin: 0.45rem 0.45rem 0.45rem 0;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .im-root.im-legend-hidden .im-legend-float {
    display: none;
  }

  .im-legend-open-fab {
    top: 0.45rem;
    right: 0.45rem;
  }
}

/* ─── Responsive : mobile — bottom sheet ─── */
@media (max-width: 640px) {
  .im-root {
    --im-legend-width: 100%;
    border-radius: 12px;
    min-height: min(65dvh, 480px);
  }

  .im-layout {
    min-height: min(65dvh, 480px);
  }

  .im-map-canvas {
    padding: 0.35rem;
    min-height: 240px;
  }

  .im-toolbar {
    top: 0.45rem;
    left: 0.45rem;
    max-width: calc(100% - 5.5rem);
    padding: 0.3rem 0.5rem;
  }

  .im-legend-float {
    top: auto;
    left: 0.45rem;
    right: 0.45rem;
    bottom: 0.45rem;
    width: auto;
    max-height: 42vh;
    border-radius: 14px 14px var(--im-radius) var(--im-radius);
  }

  .im-root.im-legend-hidden .im-legend-float {
    transform: translateY(calc(100% + 1rem));
  }

  .im-legend-open-fab {
    top: auto;
    bottom: 0.55rem;
    right: 0.55rem;
  }

  /* Popups plein écran mobile (sheet) */
  .im-popup-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .im-popup {
    width: 100%;
    max-width: 100%;
    max-height: min(92dvh, 100%);
    border-radius: 16px 16px 0 0;
    padding: 0.75rem 1.25rem 1.5rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }

  .im-popup-handle {
    display: block;
  }

  .im-popup-close {
    top: 0.65rem;
  }

  .im-legend-item {
    padding: 0.65rem 0.75rem;
    min-height: 44px;
  }
}

@media (max-width: 380px) {
  .im-legend-open-label {
    display: none;
  }

  .im-breadcrumb {
    display: none;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .im-anim-fade.im-anim-enter,
  .im-anim-slide.im-anim-enter,
  .im-anim-zoom.im-anim-enter {
    animation: none;
  }

  .im-popup-overlay,
  .im-popup,
  .im-legend-float,
  .im-legend-toggle {
    transition: none;
  }
}

/* Safe areas (encoches iPhone) */
@supports (padding: env(safe-area-inset-bottom)) {
  @media (max-width: 640px) {
    .im-legend-float {
      bottom: calc(0.45rem + env(safe-area-inset-bottom));
    }

    .im-legend-open-fab {
      bottom: calc(0.55rem + env(safe-area-inset-bottom));
    }
  }
}

/* Badge zoom (pinch / molette) */
.im-zoom-badge {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 12;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--im-text);
  background: rgb(255 255 255 / 0.92);
  border: 1px solid var(--im-border);
  box-shadow: var(--im-float-shadow);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.25s ease;
}
.im-zoom-badge[hidden] {
  display: none;
}

/* Carte plein bord mobile */
@media (max-width: 640px) {
  .im-map-canvas {
    padding: 0;
  }
  .im-map-area {
    background: var(--im-background);
  }
}

/* Schémas clair / sombre projet */
.im-root.im-color-dark {
  --im-background: #0f172a;
  --im-text: #e2e8f0;
  --im-border: rgb(148 163 184 / 0.2);
  --im-legend-background: rgba(30, 41, 59, 0.94);
}
.im-root.im-color-dark .im-map-area {
  background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
}
.im-root.im-color-dark .im-legend-item:hover {
  background: rgb(255 255 255 / 0.06);
}
.im-root.im-color-dark .im-legend-item.is-active {
  background: rgb(0 0 0 / 0.25);
  border-color: rgb(255 255 255 / 0.08);
  box-shadow: inset 0 2px 5px rgb(0 0 0 / 0.35);
}
.im-root.im-color-dark .im-legend-float {
  border-color: rgb(255 255 255 / 0.1);
}
.im-root.im-color-dark .im-zoom-badge {
  background: rgb(30 41 59 / 0.92);
  color: #e2e8f0;
}

@media (prefers-color-scheme: dark) {
  .im-root.im-color-auto {
    --im-background: #0f172a;
    --im-text: #e2e8f0;
    --im-border: rgb(148 163 184 / 0.2);
    --im-legend-background: rgba(30, 41, 59, 0.94);
  }
  .im-root.im-color-auto .im-map-area {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
  }
  .im-root.im-color-auto .im-legend-item:hover {
    background: rgb(255 255 255 / 0.06);
  }
  .im-root.im-color-auto .im-legend-item.is-active {
    background: rgb(0 0 0 / 0.25);
    border-color: rgb(255 255 255 / 0.08);
    box-shadow: inset 0 2px 5px rgb(0 0 0 / 0.35);
  }
  .im-root.im-color-auto .im-legend-float {
    border-color: rgb(255 255 255 / 0.1);
  }
  .im-root.im-color-auto .im-zoom-badge {
    background: rgb(30 41 59 / 0.92);
    color: #e2e8f0;
  }
}

/* Mode kiosk / présentation */
.im-root.im-kiosk-mode {
  border-radius: 0;
  min-height: 100dvh;
}
.im-root.im-kiosk-mode .im-layout {
  min-height: 100dvh;
}
.im-root.im-kiosk-mode .im-toolbar {
  display: none;
}
.im-root.im-kiosk-mode .im-legend-item {
  min-height: 48px;
  padding: 0.75rem 0.85rem;
}
.im-root.im-kiosk-mode .im-legend-open-fab {
  font-size: 1rem;
  padding: 0.75rem 1.1rem;
}
