/* Home page: district statistics map */
.stats-map-section {
  position: relative;
  padding: var(--spacing-16) 0;
  background:
    radial-gradient(900px 400px at 8% 0%, rgba(57, 73, 171, .10), transparent 60%),
    radial-gradient(800px 420px at 100% 100%, rgba(0, 137, 123, .10), transparent 60%),
    linear-gradient(180deg, #f6f8fd 0%, #eef2fb 100%);
  overflow: hidden;
}

.stats-map-grid {
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(0, 6fr);
  gap: var(--spacing-8);
  align-items: stretch;
  margin-top: var(--spacing-10);
}

.stats-map-header { text-align: center; }
.stats-map-header .section-title { display: inline-block; }
.stats-map-header .section-subtitle { margin: var(--spacing-3) auto 0; max-width: 560px; }

/* ---- map card ---- */
.stats-map-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--spacing-5);
  background: rgba(255, 255, 255, .9);
  border: 1px solid #e3e8f4;
  border-radius: 20px;
  box-shadow: 0 18px 40px rgba(26, 35, 126, .10);
}
.stats-map-wrap { position: relative; flex: 1; display: grid; place-items: center; }
.tn-map-svg { width: 100%; max-height: 720px; height: auto; display: block; overflow: visible; }

.tn-district {
  fill: var(--c);
  stroke: #fff;
  stroke-width: .9;
  stroke-linejoin: round;
  cursor: pointer;
  outline: none;
  transition: opacity .25s ease, filter .2s ease, stroke .2s ease, stroke-width .2s ease;
}
.tn-district:hover,
.tn-district:focus-visible { filter: brightness(1.12) saturate(1.1); stroke: #1a237e; stroke-width: 1.6; }
.tn-district:focus-visible { stroke-width: 2.2; }
.tn-map-svg.has-selection .tn-district:not(.is-selected) { opacity: .5; }
.tn-map-svg.has-selection .tn-district:not(.is-selected):hover,
.tn-map-svg.has-selection .tn-district:not(.is-selected):focus-visible { opacity: 1; }
.tn-district.is-selected {
  stroke: #1a237e; stroke-width: 2.4;
  filter: drop-shadow(0 4px 8px rgba(26, 35, 126, .45)) saturate(1.15);
}

.tn-label {
  font-family: var(--font-primary);
  font-weight: 600;
  letter-spacing: 0;
  fill: #0f1b4d;
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, .55);
  stroke-width: .7;
  pointer-events: none;
  transition: opacity .25s ease;
}
.tn-label-out { text-anchor: start; stroke: none; }
.tn-leader { fill: none; stroke: #0f1b4d; stroke-width: .7; opacity: .7; }
.tn-leader-dot { fill: #0f1b4d; }
.tn-map-svg.has-selection .tn-label:not(.is-selected) { opacity: .5; }
.tn-label.is-selected { font-weight: 700; fill: #0b1236; }

.tn-tooltip {
  position: absolute; z-index: 5;
  transform: translate(-50%, calc(-100% - 14px));
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 12px; min-width: 120px; text-align: center;
  background: #0d1642; color: #fff; border-radius: 10px;
  box-shadow: 0 10px 24px rgba(13, 22, 66, .3);
  font-size: var(--font-size-xs); pointer-events: none; white-space: nowrap;
}
.tn-tooltip[hidden] { display: none; }
.tn-tooltip strong { font-size: var(--font-size-sm); }
.tn-tooltip span { opacity: .8; }
.tn-tooltip::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px;
  background: #0d1642; transform: translateX(-50%) rotate(45deg);
}

/* ---- stats panel ---- */
.stats-panel {
  display: flex; flex-direction: column; gap: var(--spacing-5);
  padding: var(--spacing-6);
  background: rgba(255, 255, 255, .92);
  border: 1px solid #e3e8f4;
  border-radius: 20px;
  box-shadow: 0 18px 40px rgba(26, 35, 126, .10);
}

.stats-panel-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: var(--spacing-4); flex-wrap: wrap;
  padding-bottom: var(--spacing-5); border-bottom: 1px solid #edf0f8;
}
.stats-eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: var(--font-size-xs); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--color-accent-dark); }
.stats-heading h3 { margin: 4px 0 2px; font-family: var(--font-heading); font-size: var(--font-size-3xl); line-height: 1.1; color: var(--color-primary-dark); }
.stats-heading p { margin: 0; font-size: var(--font-size-sm); color: var(--color-grey-500); }

.stats-filters { display: flex; gap: var(--spacing-3); flex-wrap: wrap; }
.stats-filters label { display: flex; flex-direction: column; gap: 4px; }
.stats-filters span { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--color-grey-500); }
.stats-filters select {
  min-width: 150px; height: 42px; padding: 0 12px;
  border: 1px solid #d8def0; border-radius: 10px;
  background: #f7f9fe; color: var(--color-grey-800); font: inherit; font-size: var(--font-size-sm); cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}
.stats-filters select:focus { outline: none; border-color: var(--color-primary-light); box-shadow: 0 0 0 4px rgba(57, 73, 171, .14); }
.stats-filters select:disabled { opacity: .6; cursor: not-allowed; }

.stats-tiles { flex: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: var(--spacing-4); }
.sm-tile {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px;
  min-height: 132px; padding: var(--spacing-5);
  border-radius: 16px; background: var(--tint); border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent);
  transition: transform .25s ease, box-shadow .25s ease;
}
.sm-tile:hover { transform: translateY(-3px); box-shadow: 0 12px 26px color-mix(in srgb, var(--ink) 16%, transparent); }
.sm-icon {
  position: absolute; top: 16px; right: 16px; width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px; background: #fff; color: var(--ink); font-size: 1.05rem;
  box-shadow: 0 4px 10px color-mix(in srgb, var(--ink) 14%, transparent);
}
.sm-value { font-size: var(--font-size-3xl); font-weight: 700; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.sm-label { font-size: var(--font-size-sm); font-weight: 500; line-height: 1.3; color: var(--color-grey-600); max-width: 85%; }
.sm-tile.is-empty .sm-value { opacity: .5; }

.theme-olive { --tint: #f2f6e6; --ink: #5d7f1f; }
.theme-teal { --tint: #e4f3f6; --ink: #0f7a90; }
.theme-blue { --tint: #e9edfb; --ink: #2f3fb5; }
.theme-violet { --tint: #f0eaf8; --ink: #6e4fa3; }
.theme-orange { --tint: #fdeee2; --ink: #d0601f; }
.theme-green { --tint: #e3f5ea; --ink: #1f8a55; }
.theme-magenta { --tint: #f9e9f5; --ink: #a8309a; }
.theme-crimson { --tint: #fce9e9; --ink: #c03333; }

.stats-note { margin: 0; padding: 10px 14px; border-radius: 10px; background: #fff7e8; border: 1px solid #fde3b4; color: #8a5a00; font-size: var(--font-size-sm); }
.stats-note[hidden] { display: none; }

@media (max-width: 1024px) {
  .stats-map-grid { grid-template-columns: 1fr; }
  .stats-map-card { max-width: 640px; margin: 0 auto; width: 100%; }
}
@media (max-width: 560px) {
  .stats-map-section { padding: var(--spacing-10) 0; }
  .stats-panel { padding: var(--spacing-4); }
  .sm-icon { width: 34px; height: 34px; top: 12px; right: 12px; }
  .stats-tiles { gap: var(--spacing-3); }
  .sm-tile { min-height: 116px; padding: var(--spacing-4); }
  .sm-value { font-size: var(--font-size-2xl); }
  .stats-filters { width: 100%; }
  .stats-filters label { flex: 1; }
  .stats-filters select { min-width: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .tn-district, .tn-label, .sm-tile { transition: none; }
  .sm-tile:hover { transform: none; }
}
