/**
 * EACH — National plans map ([each_country_map]).
 *
 * Country colours are driven by the `plan_status` term slug: the JS adds
 * `is-{slug}` on each SVG path, legend swatches use the same classes.
 * To recolour a status, change its variable below — nothing else.
 * Uses the theme tokens (--mc-*) from css/scss/custom/_vars.scss.
 */

.each-map {
	/* Status palette — one hue, intensity = progress. */
	--each-map-has-plan:        var(--mc-color-1);
	--each-map-in-preparation:  color-mix(in srgb, var(--mc-color-1) 45%, #fff);
	--each-map-no-plan:         #8f9596;
	--each-map-to-be-confirmed: #cdd1cf;
	--each-map-outside:         #f0f0ec;
	--each-map-border:          #fff;
	--each-map-ocean:           #fff;

	position: relative;
}

/* Canvas ------------------------------------------------------------------ */

.each-map__canvas,
.each-map__canvas.leaflet-container {
	width: 100%;
	height: var(--each-map-height, 560px);
	background: var(--each-map-ocean);
	border: var(--mc-border-width) var(--mc-border-style) var(--line);
	font-family: inherit;
}

/* Countries (SVG paths — CSS beats Leaflet's presentation attributes) ----- */

.each-map__country {
	fill-opacity: 1;
	stroke: var(--each-map-border);
	stroke-width: 1;
	transition: fill 0.2s ease;
}

.each-map__country.is-outside {
	fill: var(--each-map-outside);
	stroke-width: 0.75;
}

.each-map__country.is-has-plan        { fill: var(--each-map-has-plan); }
.each-map__country.is-in-preparation  { fill: var(--each-map-in-preparation); }
.each-map__country.is-no-plan         { fill: var(--each-map-no-plan); }
.each-map__country.is-to-be-confirmed { fill: var(--each-map-to-be-confirmed); }

.each-map__country.is-hover,
.each-map__country.is-selected {
	stroke: var(--mc-color-dark);
	stroke-width: 1.5;
}

/* Swatches (legend + popup) ----------------------------------------------- */

.each-map__swatch {
	flex: none;
	display: inline-block;
	width: 0.75em;
	height: 0.75em;
	border-radius: 2px;
	background: var(--each-map-to-be-confirmed);
}

.each-map__swatch.is-has-plan        { background: var(--each-map-has-plan); }
.each-map__swatch.is-in-preparation  { background: var(--each-map-in-preparation); }
.each-map__swatch.is-no-plan         { background: var(--each-map-no-plan); }
.each-map__swatch.is-to-be-confirmed { background: var(--each-map-to-be-confirmed); }

/* Legend ------------------------------------------------------------------ */

.each-map__legend {
	display: flex;
	flex-wrap: wrap;
	gap: var(--mc-space-2xs) var(--mc-space-md);
	margin: var(--mc-space-sm) 0 0;
	padding: 0;
	list-style: none;
	font-size: var(--mc-font-size-xs);
}

.each-map__legend-item {
	display: inline-flex;
	align-items: center;
	gap: var(--mc-space-3xs);
	margin: 0;
	padding: 0;
}

.each-map__legend-count {
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}

.each-map__legend-count::before { content: "("; }
.each-map__legend-count::after  { content: ")"; }

/* Accessible list --------------------------------------------------------- */

.each-map__list {
	margin-top: var(--mc-space-sm);
	font-size: var(--mc-font-size-xs);
}

.each-map__list summary {
	display: inline-block;
	color: var(--mc-color-1);
	font-weight: var(--mc-font-weight-bold);
	cursor: pointer;
}

.each-map__list summary:hover {
	text-decoration: underline;
}

.each-map__list summary:focus-visible {
	outline: 2px solid var(--mc-color-1);
	outline-offset: 3px;
}

.each-map__list-groups {
	display: grid;
	gap: var(--mc-space-xs);
	margin-top: var(--mc-space-xs);
}

.each-map__list-groups h4 {
	margin: 0 0 var(--mc-space-3xs);
	padding: 0;
	font-size: var(--mc-font-size-xs);
	font-weight: var(--mc-font-weight-bold);
}

.each-map__list-groups p {
	margin: 0;
	padding: 0;
	color: var(--muted);
}

/* Tooltip & popup --------------------------------------------------------- */

.each-map__tooltip {
	padding: 0.35em 0.6em;
	border: 0;
	border-radius: 4px;
	background: var(--mc-color-dark);
	color: var(--mc-color-light);
	font-size: var(--mc-font-size-xxs);
	font-weight: var(--mc-font-weight-bold);
	box-shadow: none;
}

.each-map__tooltip::before {
	display: none;
}

.each-map__popup-wrap .leaflet-popup-content-wrapper {
	border-radius: 6px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

.each-map__popup-wrap .leaflet-popup-content {
	margin: var(--mc-space-sm);
	font-family: inherit;
	line-height: 1.45;
}

.each-map__popup {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--mc-space-3xs);
	font-size: var(--mc-font-size-xs);
}

.each-map__popup-title {
	font-size: var(--mc-font-size-sm);
	font-weight: var(--mc-font-weight-bold);
}

.each-map__popup-status {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	font-weight: var(--mc-font-weight-bold);
}

.each-map__popup-plan {
	color: var(--mc-color-dark);
}

/* Doubled class: beats Leaflet's `.leaflet-popup-content p { margin: 17px 0 }`. */
.each-map__popup .each-map__popup-summary {
	margin: 0;
	padding: 0;
	color: var(--muted);
}

.each-map .each-map__popup-link {
	margin-top: var(--mc-space-3xs);
	color: var(--mc-color-1);
	font-weight: var(--mc-font-weight-bold);
	text-decoration: none;
}

.each-map .each-map__popup-link:hover {
	text-decoration: underline;
}

.each-map__popup-checked {
	color: var(--muted);
	font-size: var(--mc-font-size-xxs);
}

.each-map__error {
	display: grid;
	place-items: center;
	height: 100%;
	margin: 0;
	color: var(--muted);
}

/* Responsive & motion ----------------------------------------------------- */

@media (max-width: 45rem) {
	.each-map__canvas,
	.each-map__canvas.leaflet-container {
		height: min(var(--each-map-height, 560px), 90vw);
		min-height: 300px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.each-map__country {
		transition: none;
	}
}
