/* ==========================================================================
   Carte des États-Unis (héro) — trame de points, contours des 3 États mis en
   avant, bulle d'information au survol / au toucher / au clavier.
   Les épaisseurs de trait sont en unités de la carte (viewBox de 955 de large) :
   elles sont renforcées sur mobile, où la carte est affichée plus petite.
   ========================================================================== */

.usmap {
  --dot: #a4a9b3;
  --outline: var(--obsidian);
  --outline-w: 1.9;
  --halo-w: 7;
  position: relative;
  width: 100%;
  max-width: 980px;
  margin: 8px auto 0;
  isolation: isolate;
}

.usmap__svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.usmap pattern circle {
  fill: var(--dot);
}

/* ---------- États mis en avant : contour seul ---------- */

.usmap__state {
  cursor: pointer;
  transition: opacity 0.35s var(--ease);
}

.usmap__halo,
.usmap__shape,
.usmap__glow {
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* Liseré couleur fond qui dégage les points autour du contour */
.usmap__halo {
  fill: none;
  stroke: var(--alabaster);
  stroke-width: var(--halo-w);
}

.usmap__shape {
  fill: rgba(40, 85, 246, 0);
  stroke: var(--outline);
  stroke-width: var(--outline-w);
  transition: fill 0.35s var(--ease), stroke 0.35s var(--ease), stroke-width 0.35s var(--ease);
}

.usmap__glow {
  fill: none;
  stroke: var(--blue);
  stroke-width: 8;
  opacity: 0;
  filter: blur(7px);
  transition: opacity 0.35s var(--ease);
}

.usmap__hit {
  fill: transparent;
}

.usmap__state.is-active .usmap__shape {
  fill: rgba(40, 85, 246, 0.08);
  stroke: var(--blue);
  stroke-width: calc(var(--outline-w) * 1.35);
}

.usmap__state.is-active .usmap__glow {
  opacity: 0.4;
}

.usmap.has-active .usmap__state:not(.is-active) {
  opacity: 0.35;
}

.usmap__link-line {
  stroke: var(--obsidian);
  stroke-width: 1.2;
}

.usmap__de-dot {
  fill: var(--emerald);
  pointer-events: none;
}

/* Tracé des contours à l'apparition de la carte */
.usmap__halo,
.usmap__shape {
  stroke-dasharray: 1 1;
  stroke-dashoffset: 0;
}

.js .usmap.reveal .usmap__halo,
.js .usmap.reveal .usmap__shape {
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.6s cubic-bezier(0.65, 0, 0.35, 1) 0.2s, fill 0.35s var(--ease),
    stroke 0.35s var(--ease), stroke-width 0.35s var(--ease);
}

.js .usmap.reveal.is-visible .usmap__halo,
.js .usmap.reveal.is-visible .usmap__shape {
  stroke-dashoffset: 0;
}

.js .usmap.reveal .usmap__state[data-state="nm"] :is(.usmap__halo, .usmap__shape) { transition-delay: 0.45s, 0s, 0s, 0s; }
.js .usmap.reveal .usmap__state[data-state="de"] :is(.usmap__halo, .usmap__shape) { transition-delay: 0.7s, 0s, 0s, 0s; }

/* ---------- Étiquettes (boutons HTML posés sur la carte) ----------
   Le point vert est posé au centre de l'État, le nom part vers la droite. */

.usmap__pin {
  --dot-x: 13px;
  position: absolute;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px 7px 9px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(10, 10, 12, 0.1);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1;
  color: var(--obsidian);
  white-space: nowrap;
  cursor: pointer;
  transform: translate(calc(var(--dot-x) * -1), -50%);
  transition: transform 0.35s var(--spring), box-shadow 0.3s var(--ease), border-color 0.3s var(--ease),
    opacity 0.5s var(--ease);
}

.usmap__pin--right {
  --dot-x: 0px;
}

.js .usmap.reveal .usmap__pin {
  opacity: 0;
}

.js .usmap.reveal.is-visible .usmap__pin {
  opacity: 1;
  transition-delay: 0s, 0s, 0s, 1.2s;
}

/* Focus clavier avant l'apparition : la carte et l'étiquette focalisée s'affichent tout de suite */
.js .usmap.reveal:focus-within {
  opacity: 1;
  translate: none;
}

.js .usmap.reveal:focus-within .usmap__pin {
  opacity: 1;
  transition-delay: 0s;
}

.usmap__pin:hover,
.usmap__pin[aria-expanded="true"] {
  border-color: var(--blue);
  box-shadow: 0 10px 26px rgba(40, 85, 246, 0.2);
}

.usmap__pin:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.usmap__pulse {
  position: relative;
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 100px;
  background: var(--emerald);
}

.usmap__pulse::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid var(--emerald);
  opacity: 0;
  animation: usmap-pulse 2s var(--ease) 1.4s 2; /* deux pulsations après l’apparition des étiquettes, puis arrêt (WCAG 2.2.2) */
}

.usmap__pin:nth-of-type(2) .usmap__pulse::after { animation-delay: 1.8s; }
.usmap__pin:nth-of-type(3) .usmap__pulse::after { animation-delay: 2.2s; }
.js .usmap.reveal:not(.is-visible) .usmap__pulse::after { animation-play-state: paused; }

@keyframes usmap-pulse {
  0% { transform: scale(0.6); opacity: 0.7; }
  70%, 100% { transform: scale(2.2); opacity: 0; }
}

.usmap__code {
  display: none;
}

/* ---------- Bulle ---------- */

.usmap__tip {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  width: 300px;
  max-width: calc(100% - 16px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border-radius: 18px;
  background: var(--obsidian);
  color: var(--alabaster);
  box-shadow: 0 24px 60px rgba(10, 10, 12, 0.28);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px) scale(0.97);
  transform-origin: var(--tip-origin, 50% 100%);
  transition: opacity 0.22s var(--ease), transform 0.4s var(--spring), visibility 0s linear 0.4s;
}

.usmap__tip.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition: opacity 0.22s var(--ease), transform 0.4s var(--spring), visibility 0s;
}

.usmap__tip::after {
  content: "";
  position: absolute;
  left: var(--arrow-x, 50%);
  width: 14px;
  height: 14px;
  margin-left: -7px;
  background: var(--obsidian);
  border-radius: 3px;
  transform: rotate(45deg);
}

.usmap__tip[data-side="top"]::after { bottom: -6px; }
.usmap__tip[data-side="bottom"]::after { top: -6px; }

.usmap__tip-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.usmap__tip-head .state__code {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 15px;
}

.usmap__tip-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.9px;
  line-height: 1.05;
}

.usmap__tip-head .label--small {
  margin-bottom: 4px;
}

.usmap__tip .checklist {
  gap: 9px;
}

.usmap__tip .checklist li {
  font-size: 13.5px;
  color: var(--mist);
}

.usmap__tip-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--alabaster);
  text-decoration: underline;
  text-decoration-color: rgba(250, 250, 250, 0.35);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s var(--ease);
}

.usmap__tip-link:hover {
  text-decoration-color: var(--alabaster);
}

/* L'indication n'apparaît que si usmap.js a démarré (sinon la carte ne réagit pas) */
.usmap__hint {
  visibility: hidden;
  margin-top: -8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--slate);
  text-align: center;
}

.usmap.is-ready + .usmap__hint {
  visibility: visible;
}

.usmap__hint .when-touch {
  display: none;
}

@media (hover: none) {
  .usmap__hint .when-touch { display: inline; }
  .usmap__hint .when-mouse { display: none; }
}

/* ---------- Tablette et mobile : carte plus petite, traits renforcés ---------- */

@media (max-width: 1199.98px) {
  .usmap {
    --outline-w: 2.4;
    --halo-w: 8;
  }
}

@media (max-width: 809.98px) {
  .usmap {
    --outline-w: 4.2;
    --halo-w: 12;
    margin-top: 0;
  }

  .usmap__link-line {
    stroke-width: 2.5;
  }

  .usmap__pin {
    --dot-x: 10px;
    gap: 5px;
    padding: 5px 8px 5px 7px;
    font-size: 11px;
  }

  .usmap__pin--right {
    --dot-x: 0px;
  }

  .usmap__pulse {
    width: 6px;
    height: 6px;
  }

  /* Nom complet masqué visuellement mais lu par les lecteurs d'écran */
  .usmap__name {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  /* Zone tactile invisible d'environ 45px de haut */
  .usmap__pin::before {
    content: "";
    position: absolute;
    inset: -11px -4px;
  }

  .usmap__code {
    display: inline;
  }

  .usmap__tip {
    width: 270px;
    padding: 16px;
  }

  .usmap__hint {
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .usmap__pulse::after {
    animation: none;
  }
  .usmap__shape,
  .usmap__halo,
  .usmap__tip,
  .usmap__pin,
  .usmap__state,
  .js .usmap.reveal .usmap__halo,
  .js .usmap.reveal .usmap__shape {
    transition: none;
    stroke-dashoffset: 0;
  }
  .js .usmap.reveal .usmap__pin {
    opacity: 1;
  }
}

@media print {
  .usmap__halo,
  .usmap__shape {
    stroke-dashoffset: 0 !important;
  }
  .usmap__pin {
    opacity: 1 !important;
  }
}
