/* Europe Member Map – front end. Colours come from the Map Settings page as CSS variables. */
.emm-map, .emm-list {
	--emm-ink: #14213d;
	--emm-muted: #4a5468;
	--emm-line: #e2e6ed;
	--emm-radius: 14px;
	color: var(--emm-ink);
	box-sizing: border-box;
}
.emm-map *, .emm-map *::before, .emm-map *::after,
.emm-list *, .emm-list *::before, .emm-list *::after { box-sizing: border-box; }
.emm-map [hidden], .emm-list [hidden] { display: none !important; }

/* ---------- Map: header and toolbar ---------- */
.emm-map { container-type: inline-size; margin: 0; padding: 0; }
.emm-head { margin-bottom: 16px; }
.emm-map .emm-title { margin: 0 0 8px; color: var(--emm-selected); }
.emm-map .emm-intro, .emm-map .emm-stats { margin: 0 0 4px; color: var(--emm-muted); }
.emm-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-bottom: 16px; }

.emm-search { position: relative; flex: 0 1 360px; min-width: 220px; }
.emm-search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #5b6475; pointer-events: none; }
.emm-map input[type=search], .emm-list input[type=search] {
	width: 100%; height: 44px; margin: 0; padding: 0 14px 0 42px;
	border: 1px solid #cbd3e0; border-radius: 8px; background: #fff;
	font: inherit; font-size: 15px; color: var(--emm-ink); box-shadow: none;
}
.emm-map input[type=search]:focus, .emm-list input[type=search]:focus { outline: 2px solid var(--emm-accent); outline-offset: 1px; border-color: var(--emm-accent); }
.emm-search-results {
	position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0;
	margin: 0; padding: 6px; list-style: none; background: #fff;
	border: 1px solid var(--emm-line); border-radius: 10px; box-shadow: 0 12px 32px rgba(15, 45, 92, .16);
	max-height: 320px; overflow-y: auto;
}
.emm-search-hit { display: flex; align-items: center; gap: 10px; margin: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.emm-search-hit:hover, .emm-search-hit[aria-selected=true] { background: #f0f4fa; }
.emm-search-hit img { width: 24px; height: 18px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px var(--emm-line); flex-shrink: 0; }
.emm-search-hit span { display: flex; flex-direction: column; line-height: 1.3; }
.emm-search-hit strong { font-weight: 600; }
.emm-search-hit small { color: var(--emm-muted); font-size: 12px; }
.emm-search-empty { margin: 0; padding: 8px 10px; color: var(--emm-muted); }

.emm-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--emm-muted); }
.emm-legend li { display: flex; align-items: center; gap: 8px; margin: 0; }
.emm-swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.emm-swatch--member { background: var(--emm-member); }
.emm-swatch--shaded { background: linear-gradient(135deg, var(--emm-member) 50%, var(--emm-member-1) 50%); }
.emm-swatch--other { background: var(--emm-other); }
.emm-swatch--selected { background: var(--emm-selected); }

/* ---------- Map: stage and SVG ---------- */
.emm-stage {
	position: relative; overflow: hidden; width: 100%; aspect-ratio: var(--emm-aspect, 16 / 9);
	background: var(--emm-sea); border-radius: var(--emm-radius-map, 0);
	-webkit-user-select: none; user-select: none;
}
/* Fixed height from Map Settings or the shortcode. */
.emm-fixed-height .emm-stage { aspect-ratio: auto; height: var(--emm-height); }
@container (max-width: 640px) {
	.emm-stage { aspect-ratio: 1 / 1; }
	.emm-fixed-height-mobile .emm-stage { aspect-ratio: auto; height: var(--emm-height-mobile); }
}
.emm-svg { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.emm-zoomed .emm-svg { cursor: grab; }
.emm-dragging .emm-svg { cursor: grabbing !important; }

.emm-bg path { fill: var(--emm-other); stroke: var(--emm-border); stroke-width: .7; stroke-linejoin: round; vector-effect: non-scaling-stroke; opacity: .75; }
.emm-country { fill: var(--emm-other); stroke: var(--emm-border); stroke-width: .7; stroke-linejoin: round; vector-effect: non-scaling-stroke; transition: fill .15s ease; }
.emm-country.emm-member { fill: var(--emm-member); }
.emm-country.emm-member.emm-shade-1 { fill: var(--emm-member-1); }
.emm-country.emm-member.emm-shade-2 { fill: var(--emm-member-2); }
.emm-country.emm-member.emm-shade-3 { fill: var(--emm-member-3); }
/* No focus frame when a country is clicked (themes and page builders often add one to :focus).
   Keyboard users still see the focused country highlighted, like on hover. */
.emm-map .emm-stage, .emm-map .emm-svg, .emm-map .emm-svg *,
.emm-map .emm-stage:focus, .emm-map .emm-svg:focus, .emm-map .emm-svg *:focus,
.emm-map .emm-svg *:focus-visible { outline: none !important; box-shadow: none !important; }
.emm-map .emm-svg, .emm-map .emm-svg * { -webkit-tap-highlight-color: transparent; }
.emm-country.is-selected { fill: var(--emm-selected); }

.emm-hl { pointer-events: none; stroke: var(--emm-border); stroke-width: 1.2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.emm-hl--hover { fill: var(--emm-hover); filter: drop-shadow(0 3px 4px rgba(15, 45, 92, .35)); }
.emm-hl--hover.emm-hl--other { fill: #c9d0db; filter: none; }
.emm-hl--selected { fill: var(--emm-selected); filter: drop-shadow(0 2px 3px rgba(15, 45, 92, .3)); }
.emm-country.emm-member:focus-visible + .emm-hl, .emm-hl--hover { animation: emm-lift .15s ease; }
@keyframes emm-lift { from { opacity: .4; } to { opacity: 1; } }

/* ---------- Fonts (Map Settings → Fact box fonts) ---------- */
.emm-popup, .emm-tooltip { font-family: var(--emm-font-text, inherit); }
.emm-map .emm-popup-country, .emm-popup-name { font-family: var(--emm-font-heading, inherit); }

/* ---------- Tooltip ---------- */
.emm-tooltip {
	position: absolute; z-index: 5; transform: translateY(-100%); pointer-events: none;
	padding: 7px 12px; border-radius: 6px; background: var(--emm-ink); color: #fff;
	font-size: 13px; font-weight: 500; line-height: 1.3; white-space: nowrap;
	box-shadow: 0 4px 12px rgba(15, 45, 92, .25);
}

/* ---------- Fact box ---------- */
.emm-popup {
	position: absolute; z-index: 10; width: 344px; max-width: calc(100% - 24px);
	background: #fff; border-radius: var(--emm-radius); overflow: hidden;
	box-shadow: 0 18px 48px rgba(15, 45, 92, .22), 0 2px 6px rgba(15, 45, 92, .08);
	animation: emm-pop .18s ease;
}
@keyframes emm-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (max-width: 559px) {
	.emm-popup.is-below.is-multi .emm-popup-body { grid-template-columns: minmax(0, 1fr); }
	.emm-popup.is-below.is-multi .emm-popup-card + .emm-popup-card { border-top: 1px solid var(--emm-line); }
}
.emm-popup.is-below {
	position: relative; left: auto; top: auto; width: auto; max-width: none; margin-top: 12px;
	border: 1px solid var(--emm-line); box-shadow: 0 8px 24px rgba(15, 45, 92, .12);
}
@media (min-width: 560px) {

}
.emm-popup-head { display: flex; align-items: center; gap: 12px; padding: 12px 6px 12px 20px; background: var(--emm-selected); color: #fff; }
.emm-popup-flag { width: 36px; height: 27px; object-fit: cover; border-radius: 3px; flex-shrink: 0; box-shadow: 0 0 0 1px rgba(255, 255, 255, .25); }
.emm-map .emm-popup-country { flex: 1; margin: 0; padding: 0; font-size: 20px; font-weight: 700; line-height: 1.2; color: #fff; }
.emm-map .emm-popup button {
	display: inline-flex; align-items: center; justify-content: center;
	width: 44px; height: 44px; min-width: 0; margin: 0; padding: 0;
	border: 0; border-radius: 8px; background: transparent; color: inherit; box-shadow: none; cursor: pointer;
}
.emm-map .emm-popup-close { color: #fff; }
.emm-map .emm-popup button:hover { background: rgba(127, 140, 160, .15); }
.emm-map .emm-popup button:focus-visible { outline: 2px solid var(--emm-accent); outline-offset: -2px; }
.emm-map .emm-popup-close:focus-visible { outline-color: #fff; }

.emm-popup { display: flex; flex-direction: column; }
.emm-popup-head { flex-shrink: 0; }
.emm-popup-body { padding: 0 20px; display: flex; flex-direction: column; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.emm-popup-card { display: flex; flex-direction: column; gap: 16px; padding: 20px 0; }
.emm-popup-card + .emm-popup-card { border-top: 1px solid var(--emm-line); }
/* Several organisations in one country: side by side, so they are all visible at once. */
.emm-popup.is-multi:not(.is-below) { width: min(760px, calc(100% - 24px)); }
.emm-popup.is-multi .emm-popup-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 32px; }
.emm-popup.is-multi .emm-popup-card + .emm-popup-card { border-top: 0; }
.emm-popup.is-multi .emm-popup-card:nth-child(n+3) { border-top: 1px solid var(--emm-line); }
.emm-popup-org { display: flex; align-items: center; gap: 14px; }
.emm-popup-logo {
	width: 120px; height: 120px; flex-shrink: 0; border-radius: 16px; border: 1px solid var(--emm-line);
	background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden;
	font-size: 15px; font-weight: 700; color: #5b6475;
}
.emm-popup-logo img { max-width: 100%; max-height: 100%; object-fit: contain; padding: 6px; }
.emm-popup { width: 400px; }
.emm-popup-org { align-items: center; }
.emm-popup-names { min-width: 0; }
.emm-map .emm-popup-name { margin: 4px 0 0; padding: 0; }
.emm-popup-parent { margin-top: 6px; font-size: 14px; line-height: 1.35; color: var(--emm-ink); }
.emm-popup-parent-label { color: var(--emm-muted); }
.emm-popup-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--emm-muted); }
.emm-popup-name { margin-top: 4px; font-size: 17px; font-weight: 700; line-height: 1.25; color: var(--emm-selected); }
.emm-popup-rows { display: flex; flex-direction: column; gap: 12px; margin: 0; font-size: 14px; }
.emm-popup-row { display: flex; align-items: center; gap: 12px; }
.emm-popup-row > svg { color: #5b6475; flex-shrink: 0; }
.emm-popup-row > div { min-width: 0; }
.emm-popup-row dt { margin: 0; font-size: 12px; font-weight: 400; color: var(--emm-muted); }
.emm-popup-row dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.emm-map .emm-popup a { color: var(--emm-accent); }
.emm-popup-foot { display: flex; align-items: center; gap: 8px; }
.emm-map a.emm-popup-button {
	display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px;
	border-radius: 8px; background: var(--emm-accent); color: #fff; font-size: 14px; font-weight: 600; text-decoration: none;
}
.emm-map a.emm-popup-button:hover { filter: brightness(1.1); color: #fff; }
.emm-popup-pager { display: flex; align-items: center; gap: 2px; margin-left: auto; font-size: 13px; color: var(--emm-muted); white-space: nowrap; }

/* ---------- Zoom ---------- */
.emm-zoom {
	position: absolute; right: 16px; bottom: 16px; z-index: 12;
	display: flex; flex-direction: column; border-radius: 10px; overflow: hidden;
	background: #fff; box-shadow: 0 4px 14px rgba(15, 45, 92, .15);
}
.emm-map .emm-zoom button {
	width: 44px; height: 44px; min-width: 0; margin: 0; padding: 0; border: 0; border-radius: 0;
	border-bottom: 1px solid var(--emm-line); background: #fff; color: var(--emm-ink); box-shadow: none;
	font: 400 22px/1 system-ui, sans-serif; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.emm-map .emm-zoom button:last-child { border-bottom: 0; }
.emm-map .emm-zoom button:hover { background: #f0f4fa; }
.emm-map .emm-zoom button:focus-visible { outline: 2px solid var(--emm-accent); outline-offset: -2px; }
.emm-narrow .emm-zoom { right: 10px; bottom: 10px; }

/* ---------- Member list ---------- */
/* Cards per row come from Map Settings (or the shortcode/block) as --emm-cols, --emm-cols-tablet and --emm-cols-mobile.
   That number is the maximum: if the list sits in a narrow column, fewer cards fit and the grid uses fewer per row
   rather than squeezing them (a card is never narrower than --emm-card-min). */
.emm-list {
	margin: 0; padding: 0; font-family: var(--emm-font-text, inherit);
	--emm-c: var(--emm-cols, 3);
	--emm-card-min: calc(var(--emm-card-logo, 100px) + 170px);
}
.emm-list--vertical { --emm-card-min: max(180px, calc(var(--emm-card-logo, 100px) + 60px)); }
@media (max-width: 1024px) { .emm-list { --emm-c: var(--emm-cols-tablet, 2); } }
@media (max-width: 640px) { .emm-list { --emm-c: var(--emm-cols-mobile, 1); --emm-card-min: 0px; } }
.emm-list-cards {
	display: grid; gap: var(--emm-card-gap, 16px);
	grid-template-columns: repeat(auto-fill, minmax(max(min(var(--emm-card-min), 100%), calc((100% - (var(--emm-c) - 1) * var(--emm-card-gap, 16px)) / var(--emm-c))), 1fr));
}

.emm-card {
	display: flex; gap: 16px; min-width: 0; padding: 18px;
	background: var(--emm-card-bg, #fff); border: 1px solid var(--emm-card-border, var(--emm-line));
	border-radius: var(--emm-card-radius, 12px);
}
.emm-list--vertical .emm-card { flex-direction: column; align-items: center; text-align: center; }
.emm-card-logo {
	width: var(--emm-card-logo, 100px); height: var(--emm-card-logo, 100px); flex-shrink: 0;
	border-radius: 12px; border: 1px solid var(--emm-line); background: #fff;
	display: flex; align-items: center; justify-content: center; overflow: hidden;
	font-size: 14px; font-weight: 700; color: #5b6475;
}
.emm-card-logo img { max-width: 100%; max-height: 100%; object-fit: contain; padding: 6px; }
.emm-card-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 14px; line-height: 1.45; font-family: var(--emm-font-text, inherit); }
.emm-card-body p { margin: 0; overflow-wrap: break-word; }
.emm-card-country { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; font-size: 13px; font-weight: 600; color: var(--emm-muted); }
.emm-list--vertical .emm-card-country { justify-content: center; }
.emm-card-flag { width: 30px; height: 22px; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px var(--emm-line); flex-shrink: 0; }
.emm-list .emm-card-name { margin: 0 0 2px; padding: 0; font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--emm-ink); font-family: var(--emm-font-heading, inherit); }
.emm-list .emm-card a { color: var(--emm-accent); }
.emm-muted { color: var(--emm-muted); }
.emm-list-empty { color: var(--emm-muted); }

@media (prefers-reduced-motion: reduce) {
	.emm-popup, .emm-hl--hover, .emm-country { animation: none !important; transition: none !important; }
}
