/* home page map (4_test-map.php): the styles of the Leaflet map of test-map.php, moved out of the page */
#map { position: relative; z-index: 0; height: calc(100dvh - 360px); min-height: 420px; width: 100%; background: var(--tblr-bg-surface-secondary); }
.pm-map-wrap { border-radius: .75rem; overflow: hidden; border: 1px solid var(--tblr-border-color); }
.leaflet-popup-content { font-size: 14px; line-height: 1.5; margin-right: 20px; }
.country-label { font-weight: bold; color: #1d5fa7; }
.pm-country-tooltip { position: absolute; z-index: 1100; pointer-events: none; max-width: calc(100% - 16px); padding: 5px 8px; border: 1px solid #b8c8d8; border-radius: 4px; background: rgba(255,255,255,.97); box-shadow: 0 1px 4px rgba(0,0,0,.25); font-size: 12px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend {
	display: block;
	width: max-content;
	max-height: calc(var(--pm-map-height, 480px) - 20px);
	overflow-y: auto;
	background: var(--tblr-bg-surface); color: var(--tblr-body-color);
	padding: 8px 12px;
	border-radius: 4px;
	box-shadow: 0 1px 4px rgba(0,0,0,0.3);
	font-size: 12px;
	line-height: 18px;
}
.legend i {
	width: 18px;
	height: 18px;
	float: left;
	margin-right: 6px;
	opacity: 1;
}
.legend-compact { display: none; }

.country-badge {
	position: absolute;
	display: inline-flex;
	align-items: center;
	gap: 3px;
	pointer-events: auto;
	cursor: pointer;
	text-decoration: none !important;
	background: rgba(255, 255, 255, 0.95);
	border: 1px solid #1d5fa7;
	border-radius: 3px;
	padding: 1px 5px;
	font-size: 11px;
	color: #08306b;
	white-space: nowrap;
	box-shadow: 0 1px 2px rgba(0,0,0,0.25);
	line-height: 1.2;
	transition: background-color 0.15s ease, color 0.15s ease;
}
.pm-country-callouts { position: absolute; inset: 0; z-index: 450; pointer-events: none; transform-origin: 0 0; }
.pm-country-callouts.pm-callout-zoom { transition: transform .25s cubic-bezier(0, 0, .25, 1); }
.pm-country-callouts > svg { position: absolute; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.pm-callout-line { fill: none; stroke: #1d5fa7; stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; }
.pm-callout-dot { fill: #1d5fa7; stroke: #fff; stroke-width: 1.5; transform-box: fill-box; transform-origin: center; }
.pm-callout-hit { fill: transparent; pointer-events: all; cursor: pointer; }
.pm-callout-active .pm-callout-dot { stroke-width: 2.5; }
.pm-callout-enter .pm-callout-dot { animation: pm-callout-point .16s ease-out var(--pm-callout-delay, 0ms) both; }
.pm-callout-enter .pm-callout-line { animation: pm-callout-leader .28s ease-out calc(var(--pm-callout-delay, 0ms) + 160ms) both; }
.country-badge.pm-callout-enter { animation: pm-callout-label .22s ease-out calc(var(--pm-callout-delay, 0ms) + 440ms) both; }
@keyframes pm-callout-point { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } }
@keyframes pm-callout-leader { from { stroke-dasharray: var(--pm-leader-length); stroke-dashoffset: var(--pm-leader-length); } to { stroke-dasharray: var(--pm-leader-length); stroke-dashoffset: 0; } }
@keyframes pm-callout-label { from { opacity: 0; clip-path: inset(0 var(--pm-hide-right) 0 var(--pm-hide-left)); } 99% { opacity: 1; clip-path: inset(0); } to { opacity: 1; clip-path: none; } }
@media (prefers-reduced-motion: reduce) {
	.pm-callout-enter .pm-callout-dot, .pm-callout-enter .pm-callout-line, .country-badge.pm-callout-enter { animation: none; }
}

#map.pm-popup-open .legend { display: none; }
#map .leaflet-popup-content-wrapper, #map .leaflet-popup-tip { background: var(--tblr-bg-surface, #fff); color: var(--tblr-body-color, #333); }
[data-bs-theme="dark"] #map .popup-title { color: #b5d3f7; }
[data-bs-theme="dark"] #map .pm-map-missing, [data-bs-theme="dark"] #map .popup-photo-loading, [data-bs-theme="dark"] #map .leaflet-popup-close-button { color: #bbc9d6; }

/* Popup content */
.pm-popup-left .leaflet-popup-tip-container { left: 100%; top: var(--pm-popup-tip-y); width: 20px; height: 40px; margin: 0; transform: translateY(-50%); }
.pm-popup-left .leaflet-popup-tip { margin: 11px 0 0 -9px; }
.country-popup {
	font-size: 13px;
	line-height: 1.5;
	min-width: 0;
	text-align: center;
}
.country-popup .popup-flag {
	width: 20px;
	height: 14px;
	display: block;
	flex-shrink: 0;
	transform: translateY(-1px);
}
.country-popup .popup-title {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	font-weight: bold;
	color: #08306b;
	font-size: 14px;
}
.country-popup .popup-count {
	color: #2171b5;
	margin: 6px 0;
}
.country-popup .popup-link {
	display: inline-block;
	margin-top: 4px;
	padding: 4px 10px;
	background: #1d5fa7;
	color: #fff !important;
	border-radius: 3px;
	text-decoration: none !important;
	font-size: 12px;
}
.country-popup .popup-link:hover {
	background: #08306b;
}

/* Badge highlight on hover */
.country-badge.badge-highlight {
	background: #1d5fa7 !important;
	color: #fff !important;
	border-color: #08306b !important;
	z-index: 1000;
}

.country-popup .popup-photo {
	margin: 8px 0;
	min-height: 20px;
}
.country-popup .popup-photo img {
	width: 100%;
	height: auto;
	border-radius: 3px;
	display: block;
}
.country-popup .popup-photo-loading {
	color: #888;
	font-size: 11px;
	text-align: center;
	padding: 10px 0;
}

/* Also for SVG paths inside the map */
#map svg path:focus {
	outline: none;
}
.leaflet-interactive:focus,
#map svg path:focus,
.leaflet-container:focus {
	outline: none;
}

.map-reset-btn {
	background: #fff;
	border-radius: 4px;
}
.map-reset-btn a {
	display: block;
	width: 30px;
	height: 30px;
	line-height: 30px;
	text-align: center;
	text-decoration: none;
	color: #333;
	font-size: 16px;
	background: #fff;
	cursor: pointer;
}
.map-reset-btn a:hover {
	background: #f4f4f4;
	color: #1d5fa7;
}
.map-reset-btn a:active {
	background: #e0e0e0;
}
.map-reset-btn a i {
	line-height: inherit;
	vertical-align: middle;
}

/* phones: the map takes the whole width of the screen (no side gaps, no frame) */
@media (max-width: 767.98px) {
	#map { min-height: 320px; }
	.pm-map-wrap { border-radius: 0; border-left: 0; border-right: 0; }
	.legend { padding: 6px 8px; font-size: 10.5px; line-height: 14px; background: color-mix(in srgb, var(--tblr-bg-surface) 88%, transparent); }
	.legend i { width: 14px; height: 14px; margin-right: 5px; }
	.legend-full { display: none; }
	.legend-compact { display: inline; }
}

/* the badges with the number of the photos: the box always fits its content (Tabler sets img { max-width: 100% }, which made the shrink-to-fit box of the absolutely positioned tooltip narrower than the flag + number) */
.country-badge { width: max-content; max-width: none; box-sizing: content-box; }
.country-badge img { max-width: none; display: block; transform: translateY(-1px); }
.country-badge img, .country-popup .popup-flag { filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.country-badge b { white-space: nowrap; line-height: 1; }

.pm-territory-status { margin: 10px 0; padding: 4px 8px; border-radius: 4px; background: var(--tblr-bg-surface-secondary, #edf2f7); color: var(--tblr-body-color, #333); font-size: 12px; }
.pm-territory-objects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pm-territory-objects > div { min-width: 0; padding: 8px 4px; border: 1px solid var(--tblr-border-color, #d8e0e8); border-radius: 4px; }
.pm-territory-heading { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 36px; font-size: 12px; line-height: 16px; }
.pm-territory-objects .popup-link { padding: 4px 6px; font-size: 11px; white-space: nowrap; }
@media (max-width: 399.98px) {
	.pm-territory-status { margin: 6px 0; }
	.pm-territory-objects > div { padding: 6px 4px; }
}
.pm-map-missing { margin-top: 8px; font-size: 11px; color: var(--tblr-secondary); }
.pm-map-error { position: absolute; z-index: 1000; left: 50%; top: 20px; transform: translateX(-50%); max-width: 320px; padding: 12px; border-radius: 6px; background: var(--tblr-bg-surface, #fff); box-shadow: 0 2px 8px #0003; text-align: center; }

.pm-map-toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 0 8px 8px; }
.pm-map-toolbar .form-select { width: auto; max-width: 100%; }
.leaflet-control-scale-line { background: color-mix(in srgb, var(--tblr-bg-surface, #fff) 72%, transparent); color: var(--tblr-body-color, #333); border-color: var(--tblr-body-color, #333); font: 10px/1.2 sans-serif; box-shadow: none; text-shadow: none; }

.pm-population-source { display: block; padding: 0 8px 8px; color: var(--tblr-secondary); font-size: 11px; }
.legend b { display: inline-block; max-width: 170px; white-space: normal; }
