/* Mapa Mapbox + burbujas por país + leyenda. Valores desde tokens.css. */
.map-shell { position: relative; height: 560px; background: var(--map-water-fill); }
.map-shell .map { position: absolute; inset: 0; }
@media (max-width: 768px) { .map-shell { height: 460px; } }

/* Burbujas (marcadores HTML), sin bordes */
.aa-bubble {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; padding: 0; cursor: pointer; border: 0;
  font-family: var(--font-family); font-weight: var(--fw-bold); font-size: var(--fs-small);
  font-variant-numeric: tabular-nums; line-height: 1;
  color: var(--text-on-primary); background: var(--ocha-primary);
  opacity: .88; transition: opacity .12s ease, box-shadow .12s ease;
}
.aa-bubble.is-activaciones { background: var(--ocha-blue-800); }
/* Grupo de países cercanos: tono más oscuro de la rampa azul */
.aa-bubble.is-grupo { background: var(--ocha-blue-700); opacity: .95; }
.aa-bubble.is-grupo.is-activaciones { background: var(--ocha-blue-900); }
.aa-bubble.is-zero { background: var(--ocha-neutral-300); color: var(--text-primary); font-size: 10px; opacity: 1; }
.aa-bubble:hover, .aa-bubble:focus-visible { opacity: 1; outline: none; box-shadow: 0 0 0 3px var(--map-hover-line); }
.aa-bubble.is-selected { opacity: 1; box-shadow: 0 0 0 3px var(--ocha-yellow); }
.map-legend .dot.grupo { background: var(--ocha-blue-700); }
.map-legend .dot.grupo.is-activaciones { background: var(--ocha-blue-900); }

/* Barra "Ver: zona" */
.map-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.map-toolbar .zone-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.map-toolbar button {
  padding: 5px 12px; font-family: var(--font-family); font-size: var(--fs-small); font-weight: var(--fw-bold);
  color: var(--ocha-blue-aa); background: var(--surface); border: 1px solid var(--ocha-blue-aa); border-radius: 999px; cursor: pointer;
}
.map-toolbar button:hover { background: var(--ocha-blue-100); }
.map-toolbar button[aria-pressed="true"] { background: var(--ocha-blue-aa); color: var(--text-on-primary); }

/* Tabla del popup de grupo */
.aa-popup-table { border-collapse: collapse; width: 100%; font-size: var(--fs-small); margin-bottom: 6px; }
.aa-popup-table th { text-align: left; font-size: var(--fs-label); text-transform: uppercase; color: var(--text-muted); padding: 2px 4px; border-bottom: 1px solid var(--border); }
.aa-popup-table td { padding: 2px 4px; font-variant-numeric: tabular-nums; }
.aa-popup-table td + td, .aa-popup-table th + th { text-align: right; }

/* Popup */
.mapboxgl-popup.aa-popup { max-width: 280px !important; font-family: var(--font-family); z-index: 3000; pointer-events: none; } /* siempre por encima de las burbujas (z-index ≤ 1000) */
.aa-popup .mapboxgl-popup-content { padding: 12px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow); border-left: 3px solid var(--ocha-blue); }
.aa-popup h3 { margin: 0 0 6px; font-size: var(--fs-h3); color: var(--ocha-primary-strong); }
.aa-popup dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0 0 8px; font-size: var(--fs-small); }
.aa-popup dt { color: var(--text-muted); }
.aa-popup dd { margin: 0; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.aa-popup ul { list-style: none; margin: 4px 0 8px; padding: 0; display: grid; gap: 3px; font-size: var(--fs-small); }
.aa-popup li { display: flex; align-items: center; gap: 6px; }
.aa-popup li img { width: 20px; height: 20px; flex: none; }
.aa-popup .gap { color: var(--ocha-orange-aa); font-weight: var(--fw-bold); }
.aa-popup .hint { font-size: var(--fs-note); color: var(--text-muted); margin: 0; }

/* Leyenda HTML */
.map-legend {
  position: absolute; bottom: 40px; left: 12px; z-index: 2; max-width: 230px; /* abajo a la izquierda: océano Pacífico */
  background: rgba(255, 255, 255, .96); border-left: 3px solid var(--ocha-blue);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 10px 14px; font-size: var(--fs-small);
}
.map-legend fieldset { border: 0; margin: 6px 0 10px; padding: 0; display: flex; gap: 0; }
.map-legend legend { padding: 0; }
.map-legend .seg input { position: absolute; opacity: 0; pointer-events: none; }
.map-legend .seg label {
  display: inline-block; padding: 4px 10px; border: 1px solid var(--ocha-blue-aa); color: var(--ocha-blue-aa);
  cursor: pointer; font-weight: var(--fw-bold); font-size: var(--fs-small);
}
.map-legend .seg:first-of-type label { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.map-legend .seg:last-of-type label { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 0; }
.map-legend .seg input:checked + label { background: var(--ocha-blue-aa); color: var(--text-on-primary); }
.map-legend .seg input:focus-visible + label { box-shadow: 0 0 0 3px var(--focus-ring); }
.map-legend .sizes { display: flex; align-items: flex-end; gap: 10px; margin: 6px 0; }
.map-legend .sizes .s { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: var(--fs-note); font-variant-numeric: tabular-nums; }
.map-legend .dot { border-radius: 50%; background: var(--ocha-primary); opacity: .88; }
.map-legend .dot.is-activaciones { background: var(--ocha-blue-800); }
.map-legend .dot.zero { background: var(--ocha-neutral-300); opacity: 1; }
.map-legend .row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.map-legend .note { margin: 6px 0 0; }
@media (max-width: 576px) { .map-legend { max-width: 170px; padding: 8px 10px; } }

/* Aviso cuando falta el token o falla el mapa */
.aa-map-notice {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: var(--ocha-neutral-100);
}
.aa-map-notice .box { max-width: 520px; background: var(--surface); border-left: 4px solid var(--ocha-yellow-700); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 16px 20px; font-size: var(--fs-small); }
.aa-map-notice h3 { margin: 0 0 8px; font-size: var(--fs-h3); color: var(--msg-warning-fg); }
.aa-map-notice ol { margin: 8px 0 0; padding-left: 20px; }
.aa-map-notice code { font-family: var(--font-family); font-weight: var(--fw-bold); background: var(--ocha-neutral-100); padding: 0 4px; }

/* Descargo y créditos bajo el mapa */
.map-disclaimer { font-size: var(--fs-note); color: var(--text-muted); font-style: italic; }

/* Leyenda en franja debajo del mapa (.map-legend.strip) */
.map-legend.strip {
  position: static; max-width: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px;
  background: var(--surface); border-left: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none; padding: 8px 12px;
}
.map-legend.strip .label { margin-right: 4px; }
.map-legend.strip .sizes { margin: 0; gap: 8px; align-items: center; }
.map-legend.strip .sizes .s { flex-direction: row; gap: 4px; }
.map-legend.strip .row { margin: 0; }
.map-legend.strip .note { margin: 0; flex-basis: 100%; }
.map-legend.strip fieldset { margin: 0; }

/* Borde blanco de 1 px en las burbujas y en sus muestras de leyenda */
.aa-bubble, .map-legend .dot { border: 1px solid var(--ocha-white); }

/* Burbujas más pequeñas: número en 12 px (10 px en las de valor 0) */
.aa-bubble { font-size: 12px; }
.aa-bubble.is-zero { font-size: 9px; }

/* Roboto Condensed también en controles, escala, créditos y popups de Mapbox (su CSS usa Helvetica) */
.mapboxgl-map, .mapboxgl-ctrl, .mapboxgl-ctrl-attrib, .mapboxgl-ctrl-scale, .mapboxgl-popup-content { font-family: var(--font-family); }
