/**
 * BDM World Map — styles publics.
 *
 * Identité sobre et institutionnelle. Tout est préfixé en .bdm- et scopé pour
 * ne pas entrer en conflit avec le thème. Les variables permettent d'ajuster
 * rapidement la charte depuis un thème enfant.
 *
 * @package BDM_World_Map
 */

.bdm-map-wrapper {
	--bdm-ink: #1d2433;
	--bdm-muted: #5b6472;
	--bdm-line: #e3e6ec;
	--bdm-surface: #ffffff;
	--bdm-accent: #7b1e3b;
	--bdm-radius: 10px;
	--bdm-shadow: 0 6px 24px rgba(20, 28, 44, 0.12);
	--bdm-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

	position: relative;
	margin: 1.5rem 0;
}

.bdm-map {
	position: relative;
	width: 100%;
	min-height: 320px;
	border-radius: var(--bdm-radius);
	overflow: hidden;
	border: 1px solid var(--bdm-line);
	background: #eef1f5;
	z-index: 0;
}

/* État de chargement / message ------------------------------------------ */

.bdm-map-loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	text-align: center;
	font-family: var(--bdm-font);
	font-size: 0.95rem;
	color: var(--bdm-muted);
	background: rgba(238, 241, 245, 0.92);
	z-index: 500;
}

/* Marqueurs -------------------------------------------------------------- */

.bdm-marker {
	background: transparent;
	border: 0;
}

.bdm-marker svg {
	display: block;
}

.bdm-marker--shadow svg {
	filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

/* Légende / filtres ------------------------------------------------------ */

.bdm-legend {
	font-family: var(--bdm-font);
	background: var(--bdm-surface);
	border: 1px solid var(--bdm-line);
	border-radius: 8px;
	box-shadow: var(--bdm-shadow);
	padding: 0.5rem 0.65rem;
	max-width: 220px;
}

.bdm-legend-item {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	padding: 0.18rem 0;
	font-size: 0.85rem;
	color: var(--bdm-ink);
	cursor: pointer;
	line-height: 1.2;
}

.bdm-legend-item input {
	margin: 0;
	cursor: pointer;
	accent-color: var(--bdm-accent);
}

.bdm-legend-dot {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	flex: 0 0 auto;
}

.bdm-legend-text {
	flex: 1 1 auto;
}

/* Fiche (popup ou modale) ------------------------------------------------ */

.bdm-detail {
	font-family: var(--bdm-font);
	color: var(--bdm-ink);
}

/* Disposition par défaut (popup étroit) : une colonne. */
.bdm-detail__grid {
	display: block;
}

.bdm-detail__aside,
.bdm-detail__main {
	min-width: 0;
}

/* Deux colonnes dans la modale (assez large). */
.bdm-modal__body .bdm-detail__grid {
	display: grid;
	grid-template-columns: minmax(150px, 200px) 1fr;
	gap: 0.75rem 1.35rem;
	align-items: start;
}

/* En tête de la colonne droite, pas de filet superflu. */
.bdm-detail__main > .bdm-popup-description:first-child,
.bdm-detail__main > .bdm-popup-section:first-child {
	border-top: 0;
	padding-top: 0;
	margin-top: 0;
}

/* Conteneur popup Leaflet (mode « popup »). */
.bdm-popup-container .leaflet-popup-content-wrapper {
	border-radius: var(--bdm-radius);
	box-shadow: var(--bdm-shadow);
	padding: 0;
}

.bdm-popup-container .leaflet-popup-content {
	margin: 0;
	width: auto !important;
}

.bdm-popup-container .bdm-detail {
	max-height: 60vh;
	overflow-y: auto;
	padding: 0.95rem 1.05rem 1.05rem;
}

.bdm-popup-header {
	margin-bottom: 0.5rem;
}

.bdm-popup-badge {
	display: inline-block;
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #fff;
	padding: 0.16rem 0.5rem;
	border-radius: 999px;
	margin-bottom: 0.4rem;
}

.bdm-popup-title {
	margin: 0;
	font-size: 1.08rem;
	line-height: 1.25;
	font-weight: 700;
	color: var(--bdm-ink);
}

.bdm-popup-photo {
	margin: 0 0 0.5rem;
	max-width: 200px;
}

.bdm-popup-photo img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 8px;
	border: 1px solid var(--bdm-line);
}

.bdm-popup-info {
	margin: 0.35rem 0;
}

.bdm-popup-line {
	margin: 0.18rem 0;
	font-size: 0.88rem;
	line-height: 1.4;
	color: var(--bdm-ink);
}

.bdm-popup-label {
	font-weight: 600;
	color: var(--bdm-muted);
}

.bdm-popup-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 0.75rem;
	margin: 0.5rem 0;
}

.bdm-popup-links a {
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--bdm-accent);
	text-decoration: none;
}

.bdm-popup-links a:hover,
.bdm-popup-links a:focus {
	text-decoration: underline;
}

.bdm-popup-description {
	margin: 0.5rem 0;
	font-size: 0.88rem;
	line-height: 1.5;
	color: var(--bdm-ink);
	border-top: 1px solid var(--bdm-line);
	padding-top: 0.55rem;
}

.bdm-popup-description p {
	margin: 0 0 0.5rem;
}

.bdm-popup-section {
	margin: 0.6rem 0 0;
	border-top: 1px solid var(--bdm-line);
	padding-top: 0.55rem;
}

.bdm-popup-section h4 {
	margin: 0 0 0.35rem;
	font-size: 0.74rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--bdm-muted);
}

.bdm-popup-section ul {
	margin: 0;
	padding-left: 1.1rem;
}

.bdm-popup-section li {
	margin: 0.2rem 0;
	font-size: 0.86rem;
	line-height: 1.4;
}

.bdm-popup-section a {
	color: var(--bdm-accent);
	text-decoration: none;
}

.bdm-popup-section a:hover {
	text-decoration: underline;
}

/* Modale ----------------------------------------------------------------- */

html.bdm-modal-open {
	overflow: hidden;
}

.bdm-modal {
	--bdm-ink: #1d2433;
	--bdm-muted: #5b6472;
	--bdm-line: #e3e6ec;
	--bdm-surface: #ffffff;
	--bdm-accent: #7b1e3b;
	--bdm-radius: 10px;
	--bdm-shadow: 0 6px 24px rgba(20, 28, 44, 0.12);
	--bdm-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

	position: fixed;
	inset: 0;
	z-index: 10000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	font-family: var(--bdm-font);
}

.bdm-modal[hidden] {
	display: none;
}

.bdm-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(16, 22, 34, 0.55);
	animation: bdm-fade 0.18s ease-out;
}

.bdm-modal__dialog {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 720px;
	max-height: 85vh;
	display: flex;
	flex-direction: column;
	background: var(--bdm-surface);
	border-radius: var(--bdm-radius);
	box-shadow: 0 18px 50px rgba(16, 22, 34, 0.35);
	animation: bdm-pop 0.18s ease-out;
	outline: none;
}

.bdm-modal__close {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	z-index: 2;
	width: 2rem;
	height: 2rem;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.9);
	color: var(--bdm-ink);
	font-size: 1.4rem;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.bdm-modal__close:hover,
.bdm-modal__close:focus-visible {
	background: var(--bdm-accent);
	color: #fff;
	outline: none;
}

.bdm-modal__body {
	overflow-y: auto;
	padding: 1.25rem 1.35rem 1.4rem;
	-webkit-overflow-scrolling: touch;
}

@keyframes bdm-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes bdm-pop {
	from { opacity: 0; transform: translateY(8px) scale(0.98); }
	to { opacity: 1; transform: none; }
}

/* Accessibilité ---------------------------------------------------------- */

.bdm-map a:focus-visible,
.bdm-legend-item:focus-within {
	outline: 2px solid var(--bdm-accent);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.bdm-map *,
	.bdm-modal__backdrop,
	.bdm-modal__dialog {
		transition: none !important;
		animation: none !important;
	}
}

/* Responsive ------------------------------------------------------------- */

@media (max-width: 600px) {
	.bdm-legend {
		max-width: 160px;
		font-size: 0.8rem;
	}

	.bdm-popup-container .bdm-detail {
		max-height: 50vh;
	}

	.bdm-modal {
		padding: 0;
		align-items: flex-end;
	}

	.bdm-modal__dialog {
		max-width: 100%;
		max-height: 92vh;
		border-bottom-left-radius: 0;
		border-bottom-right-radius: 0;
	}

	.bdm-modal__body .bdm-detail__grid {
		display: block;
	}

	.bdm-popup-photo {
		max-width: 160px;
	}
}
