/* ============================================================
   NextGen MIS — Coverage map (.ng-coverage-map)
   ------------------------------------------------------------
   The Leaflet choropleth on the Programme Indicators dashboard.
   Loads after _cards.css (it lives inside .dashboard-chart-card)
   and after leaflet.css (pushed to @stack('styles'), which the
   refinements bundle follows), so every rule here wins on equal
   specificity without !important — except where Leaflet sets its
   own, annotated inline.

   Fill colours are read by coverage-map.js from the --map-* tokens
   (_tokens.css) at draw time and again on ng-theme-change, because
   an SVG path's fill is set per feature in JS. Everything that is
   plain chrome — legend, level switch, attribution, tooltip — is
   styled here and flips with the theme on its own.
   ============================================================ */

.ng-coverage-map__well {
  position: relative;
}

/* The map well. Leaflet needs an explicit height; the card's
   .chart-body min-height is for canvases and is too short for a map. */
.ng-coverage-map__canvas {
  height: 480px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg-sunken);
  border: 1px solid var(--color-border-subtle);
}

/* Dark ground: dim the OSM tiles rather than invert them, so labels on
   the basemap stay readable and the rust ramp keeps its meaning. */
.ng-coverage-map__canvas .leaflet-tile-pane {
  filter: var(--map-tile-filter);
}

/* ---- Level switch (Province / District / LLG) ------------------ */
.ng-coverage-map__levels {
  display: inline-flex;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.ng-coverage-map__level {
  background: var(--color-bg-surface);
  border: 0;
  border-right: 1px solid var(--color-border-default);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: var(--font-weight-semibold);
  padding: 6px 10px;
  cursor: pointer;
  line-height: 1;
}
.ng-coverage-map__level:last-child { border-right: 0; }
.ng-coverage-map__level:hover { background: var(--color-bg-sunken); }
.ng-coverage-map__level[aria-pressed="true"] {
  background: var(--color-bg-sunken);
  color: var(--color-text-strong);
}
.ng-coverage-map__level:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: -2px;
}

/* ---- Legend (inside the map, bottom-left) ---------------------- */
.ng-coverage-map__legend {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  color: var(--color-text-default);
  font-size: var(--font-size-xs);
  line-height: 1.5;
  padding: var(--space-2) var(--space-3);
  min-width: 150px;
}
.ng-coverage-map__legend-title {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}
.ng-coverage-map__legend-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.ng-coverage-map__swatch {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1px solid var(--map-outline-none);
  flex: none;
}
.ng-coverage-map__swatch--none {
  border-style: dashed;
}

/* ---- Status line under the map ---------------------------------- */
.ng-coverage-map__status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-3);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}
.ng-coverage-map__attribution a {
  color: inherit;
  text-decoration: underline;
}

/* ---- Empty / error overlay -------------------------------------- */
.ng-coverage-map__notice {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-6);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  background: color-mix(in srgb, var(--color-bg-surface) 75%, transparent);
  z-index: 500;               /* above Leaflet's tile + overlay panes (400), below its controls (1000) */
  pointer-events: none;
}
/* display:flex above out-specifies the UA [hidden] rule; restate it. */
.ng-coverage-map__notice[hidden] { display: none; }

/* ---- Leaflet chrome on the design-system surface ---------------- */
.ng-coverage-map__canvas .leaflet-control-zoom a,
.ng-coverage-map__canvas .leaflet-control-attribution {
  background: var(--color-bg-surface);
  color: var(--color-text-default);
  border-color: var(--color-border-default);
}
.ng-coverage-map__canvas .leaflet-control-attribution a {
  color: var(--color-text-muted);
}
.ng-coverage-map__canvas .leaflet-bar {
  border: 1px solid var(--color-border-default);
  box-shadow: none;           /* flat, like every other card control */
}
.ng-coverage-map__canvas .leaflet-tooltip {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  color: var(--color-text-default);
  font-size: var(--font-size-xs);
  line-height: 1.5;
  padding: var(--space-2) var(--space-3);
  box-shadow: none;
}
.ng-coverage-map__canvas .leaflet-tooltip::before {
  border-color: transparent;   /* Leaflet's arrow is white; drop it rather than retheme four sides */
}
.ng-coverage-map__tooltip-title {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-strong);
}
.ng-coverage-map__tooltip-note {
  color: var(--color-text-muted);
  font-style: italic;
}
.ng-coverage-map__tooltip-hint {
  color: var(--color-text-faint);
  margin-top: var(--space-1);
}

@media (max-width: 767px) {
  .ng-coverage-map__canvas { height: 360px; }
}
