/* Map (public/assets/map.js). Colours only through the design tokens from app.css. */

.map {
  position: relative;
}

.map-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: hidden;
}

/* ---- areas and markers */

.map-area {
  fill-rule: evenodd;
  stroke: var(--c-surface);
  stroke-width: 0.5px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.map-marker {
  stroke: var(--c-surface);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}

.map-area.is-data,
.map-marker {
  cursor: pointer;
}

.map-area:focus,
.map-marker:focus {
  outline: none;
}

/* step classes: fill for SVG, background for legend swatches */
.map .map-c0 { fill: var(--c-map-0); background-color: var(--c-map-0); }
.map .map-c1 { fill: var(--c-map-1); background-color: var(--c-map-1); }
.map .map-c2 { fill: var(--c-map-2); background-color: var(--c-map-2); }
.map .map-c3 { fill: var(--c-map-3); background-color: var(--c-map-3); }
.map .map-c4 { fill: var(--c-map-4); background-color: var(--c-map-4); }
.map .map-c5 { fill: var(--c-map-5); background-color: var(--c-map-5); }

@media (prefers-reduced-motion: no-preference) {
  .map-area,
  .map-marker {
    transition: fill 0.2s ease;
  }
}

/* ---- overlay outlines (top layer, never intercept the pointer) */

.map-top {
  pointer-events: none;
}

.map-top path,
.map-top circle {
  fill: none;
  fill-rule: evenodd;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

/* selected country */
.map-sel path,
.map-sel circle {
  stroke: var(--c-ink);
  stroke-width: 1.5px;
}

/* hovered / focused country */
.map-act path,
.map-act circle {
  stroke: var(--c-ink);
  stroke-width: 2.5px;
  stroke-opacity: 0.55;
}

.map-svg:focus-within .map-act path,
.map-svg:focus-within .map-act circle {
  stroke-opacity: 1;
}

/* ---- tooltip */

.map-tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  max-width: 16rem;
  padding: 0.375rem 0.625rem;
  border-radius: 4px;
  background: var(--c-ink);
  color: var(--c-surface);
  font-size: 0.875rem;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  white-space: normal;
  overflow-wrap: anywhere;
}

.map-tip[hidden] {
  display: none;
}

/* ---- legend */

.map-legend {
  margin-top: 0.5rem;
  color: var(--c-muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

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

.map-legend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.map-swatch {
  display: inline-block;
  width: 0.875rem;
  height: 0.875rem;
  border: 1px solid var(--c-line);
  border-radius: 2px;
}

@media (forced-colors: active) {
  .map-sel path,
  .map-sel circle,
  .map-act path,
  .map-act circle {
    stroke: CanvasText;
  }
}
