/* ==========================================================================
   CHAMP Demo — Map Styles
   Overrides svgMap defaults to match WRI/Climate Watch design language
   ========================================================================== */

/* ---------- Map Section ---------- */
.map-section {
  padding: 24px 0 48px;
  background: var(--color-bg-light);
}

/* ---------- Controls ---------- */
.map-controls {
  max-width: var(--max-width);
  margin: 0 auto 16px;
  padding: 0 var(--grid-gap);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 14px;
  border: 2px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-white);
  font-family: var(--font-primary);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.filter-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-white);
}

.filter-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ---------- Legend ---------- */
.legend {
  display: flex;
  gap: 16px;
  align-items: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-light);
}

.legend-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ---------- Map Container ---------- */
.map-container {
  width: 100%;
}

/* ---------- svgMap Overrides ---------- */

/* Map wrapper */
.svgMap-map-wrapper {
  background: var(--color-bg-light) !important;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

/* Country paths — default (not participating) */
.svgMap-map-wrapper .svgMap-country {
  fill: var(--color-not-participating) !important;
  stroke: #fff !important;
  stroke-width: 0.5 !important;
  transition: fill 0.2s, opacity 0.3s !important;
  cursor: pointer !important;
}

/* Endorsed countries */
.svgMap-map-wrapper .svgMap-country.champ-endorsed {
  fill: var(--color-endorsed) !important;
}

/* Endorsed hover */
.svgMap-map-wrapper .svgMap-country.champ-endorsed:hover {
  fill: var(--color-primary-light) !important;
  stroke: var(--color-accent) !important;
  stroke-width: 1.5 !important;
}

/* Non-endorsed hover */
.svgMap-map-wrapper .svgMap-country:hover {
  fill: #c5c9cc !important;
}

/* Filtered out */
.svgMap-map-wrapper .svgMap-country.champ-filtered-out {
  opacity: 0.15 !important;
  pointer-events: none !important;
}

/* Prospective country status colors */
.svgMap-map-wrapper .svgMap-country.champ-status-commitment_pending {
  fill: var(--color-accent) !important;
}

.svgMap-map-wrapper .svgMap-country.champ-status-in_dialogue {
  fill: #4a8c8d !important;
}

.svgMap-map-wrapper .svgMap-country.champ-status-expression_of_interest {
  fill: var(--color-prospective) !important;
}

.svgMap-map-wrapper .svgMap-country.champ-prospective:hover {
  stroke: var(--color-accent) !important;
  stroke-width: 1.5 !important;
  filter: brightness(1.1);
}

/* Hover highlight from list (bidirectional sync) — high specificity to override all style modes */
.svgMap-map-wrapper .svgMap-country.champ-hover,
.svgMap-map-wrapper .svgMap-country.champ-endorsed.champ-hover,
.svgMap-map-wrapper .svgMap-country.champ-prospective.champ-hover {
  fill: var(--color-primary-light) !important;
  stroke: var(--color-accent) !important;
  stroke-width: 1.5 !important;
  filter: none !important;
}

/* Selected/active country — high specificity to override all style modes */
.svgMap-map-wrapper .svgMap-country.champ-selected,
.svgMap-map-wrapper .svgMap-country.champ-endorsed.champ-selected,
.svgMap-map-wrapper .svgMap-country.champ-prospective.champ-selected {
  fill: var(--color-accent) !important;
  stroke: var(--color-primary-dark) !important;
  stroke-width: 2 !important;
  filter: none !important;
}

/* Tooltip overrides */
.svgMap-tooltip {
  background: var(--color-primary-dark) !important;
  color: var(--color-white) !important;
  font-family: var(--font-primary) !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
  padding: 8px 14px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
  border: none !important;
}

.svgMap-tooltip .svgMap-tooltip-content-container {
  font-family: var(--font-primary) !important;
}

.svgMap-tooltip .svgMap-tooltip-title {
  font-weight: 700 !important;
  font-size: 14px !important;
}

/* Hide svgMap's default data display in tooltip */
.svgMap-tooltip .svgMap-tooltip-content {
  font-size: 12px !important;
  font-weight: 400 !important;
  color: rgba(255, 255, 255, 0.8) !important;
}

/* Zoom controls */
.svgMap-map-controls-wrapper {
  bottom: 16px !important;
  right: 16px !important;
}

.svgMap-map-controls-wrapper .svgMap-control-button {
  background: var(--color-white) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: 6px !important;
  width: 36px !important;
  height: 36px !important;
  box-shadow: var(--shadow-card) !important;
  cursor: pointer !important;
}

.svgMap-map-controls-wrapper .svgMap-control-button:hover {
  background: var(--color-bg-light) !important;
}

/* ---------- Demo Banner ---------- */
.demo-banner {
  max-width: var(--max-width);
  margin: 0 auto 12px;
  padding: 8px 16px;
  background: rgba(17, 55, 80, 0.06);
  border: 1px dashed var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--color-text-light);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: var(--grid-gap);
  margin-right: var(--grid-gap);
}

.demo-badge {
  background: var(--color-accent);
  color: var(--color-primary-dark);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 1px;
  flex-shrink: 0;
}

/* ---------- Style Switcher ---------- */
.style-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
}

.style-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: help;
  border-bottom: 1px dotted var(--color-text-light);
}

.style-btn {
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-white);
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-light);
  cursor: pointer;
  transition: all 0.15s;
}

.style-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.style-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-white);
}

/* ---------- Map Display Styles ---------- */

/* Region mode -- override endorsed fills with region colors */
.map-style-region .svgMap-country.champ-endorsed[data-region="africa"] {
  fill: #2D6A4F !important;
}
.map-style-region .svgMap-country.champ-endorsed[data-region="europe"],
.map-style-region .svgMap-country.champ-endorsed[data-region="central_east_asia"] {
  fill: #0845CB !important;
}
.map-style-region .svgMap-country.champ-endorsed[data-region="latin_america"] {
  fill: #13C881 !important;
}
.map-style-region .svgMap-country.champ-endorsed[data-region="north_america"] {
  fill: #A73F14 !important;
}
.map-style-region .svgMap-country.champ-endorsed[data-region="east_southeast_asia_oceania"],
.map-style-region .svgMap-country.champ-endorsed[data-region="south_west_asia"] {
  fill: #25597C !important;
}

/* Flags mode -- country flags as SVG pattern fills (applied via JS) */
.map-style-flags .svgMap-country {
  stroke: rgba(0, 0, 0, 0.35) !important;
  stroke-width: 0.8 !important;
}

.map-style-flags .svgMap-country:not(.champ-endorsed):not(.champ-prospective) {
  fill: #f0f0ef !important;
}

/* Pledges mode -- fills applied via JS inline styles, base styles here */
.map-style-pledges .svgMap-country:not(.champ-endorsed):not(.champ-prospective) {
  fill: #f0f0ef !important;
}

/* Minimal mode -- clean two-tone */
.map-style-minimal .svgMap-country.champ-endorsed {
  fill: var(--color-endorsed) !important;
}
.map-style-minimal .svgMap-country.champ-prospective {
  fill: var(--color-not-participating) !important;
}
.map-style-minimal .svgMap-country:not(.champ-endorsed):not(.champ-prospective) {
  fill: #f5f5f5 !important;
}

/* Hide status colors in non-status modes */
.map-style-region .svgMap-country.champ-prospective,
.map-style-flags .svgMap-country.champ-prospective,
.map-style-pledges .svgMap-country.champ-prospective,
.map-style-minimal .svgMap-country.champ-prospective {
  fill: var(--color-not-participating) !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .map-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-group {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .filter-btn {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .legend {
    width: 100%;
    justify-content: flex-start;
  }
}
