/* ==========================================================================
   CARTE INTERACTIVE MAPLIBRE — País → Estado → Ciudad
   ========================================================================== */

@font-face {
	font-family: 'Iosevka Charon';
	font-style: normal;
	font-weight: 700;
	font-display: swap;
	src: url('fonts/iosevka-charon-latin-700-normal.woff2') format('woff2');
}

   .bad-map-embed #bad-maplibre-wrap {
	position: relative;
	width: 100%;
	height: 100vh;
	height: 100dvh; /* s'ajuste aux barres du navigateur mobile, quel que soit le fabricant */
}

/* La barre d'administration WordPress (visible uniquement en étant connecté,
   jamais pour un visiteur) ajoute une hauteur fixe en haut de l'écran — sans
   ce correctif, la carte déborde d'autant en bas, hors du champ visible. */
body.admin-bar .bad-map-embed #bad-maplibre-wrap {
	height: calc(100vh - 32px);
	height: calc(100dvh - 32px);
}

@media (max-width: 782px) {
	body.admin-bar .bad-map-embed #bad-maplibre-wrap {
		height: calc(100vh - 46px);
		height: calc(100dvh - 46px);
	}
}

#bad-maplibre {
	position: absolute;
	inset: 0;
}

.maplibregl-popup {
	display: none !important;
}

/* --- Titre et sous-titre de la vue (remplis par map.js) --- */
#bad-map-title {
	position: absolute;
	top: 1.5rem;
	left: 1.5rem;
	z-index: 9;
	max-width: calc(100% - 13rem); /* laisse la place au sélecteur de langue */
	pointer-events: none;
	color: #fff;
	font-family: 'Iosevka Charon', var(--bad-display, var(--bad-body, sans-serif));
	font-weight: 700;
	text-transform: uppercase;
}

#bad-map-title[hidden],
#bad-map-title p[hidden] {
	display: none;
}

#bad-map-title p {
	margin: 0;
}

#bad-map-title-main {
	font-size: 24px;
	line-height: 1.1;
}

#bad-map-title-sub {
	margin-top: 0.5rem;
	font-size: 16px;
	line-height: 1.3;
}

@media (max-width: 782px) {
	#bad-map-title-main {
		font-size: 24px;
	}
}

/* Smartphone : titre et sous-titre sur une seule ligne verticale */
@media (max-width: 899px) {
	#bad-map-title {
		top: 20px;
		left: 12px;
		max-width: none;
		max-height: calc(100% - 20px - 11rem); /* ne descend pas sur les boutons */
		writing-mode: vertical-rl;
		transform: rotate(180deg);
	}

	#bad-map-title p {
		display: inline;
	}

	#bad-map-title-main,
	#bad-map-title-sub {
		font-size: 14px;
		line-height: 1.2;
	}

	#bad-map-title-sub {
		margin-top: 0;
	}

	#bad-map-title-sub::before {
		content: ' - ';
	}
}

/* --- Barre inférieure unifiée : zoom — Itinerarios — Index --- */
#bad-map-bottom-bar {
	position: absolute;
	left: 1.25rem;
	right: 1.25rem;
	bottom: 1.25rem;
	bottom: calc(1.25rem + env(safe-area-inset-bottom)); /* encoche / barre d'accueil iPhone */
	z-index: 10;
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 0.75rem;
}

/* --- Colonne de droite : Información (mobile) au-dessus d'Index ---
   Style des boutons : style.css, section 10. --- */
#bad-map-actions {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 8px;
	flex-shrink: 0;
}

/* Mobile : les deux boutons passent en icône seule (carrés de 44 px). */
@media (max-width: 899px) {
	#bad-map-actions .bad-map__menu {
		width: 44px;
		padding: 0;
		gap: 0;
	}

	#bad-map-actions .bad-map__menu-label {
		display: none;
	}
}

/* --- Boutons de zoom --- */
#bad-map-zoom {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	flex-shrink: 0;
}

#bad-map-zoom button {
	width: 44px;
	height: 44px;
	border: 2px solid var(--bad-ink, #1E1E1E);
	border-radius: 6px;
	background: rgba(247, 247, 247, 0.8);
	color: var(--bad-ink, #1E1E1E);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

#bad-map-zoom button:hover:not(:disabled),
#bad-map-zoom button:focus-visible:not(:disabled) {
	background: var(--bad-blue, #443EC2);
	border-color: var(--bad-paper, #F3F3F3);
	color: #fff;
}

#bad-map-zoom button:disabled {
	opacity: 0.35;
	cursor: default;
}

/* Boussole : visible seulement sur un appareil tactile (voir map.js) ; cercle
   de 44 px, le point noir suit le nord. */
#bad-map-zoom #bad-map-compass {
	display: none;
	position: relative;
	padding: 0;
	border-radius: 50%;
}

@media (any-pointer: coarse) {
	#bad-map-zoom #bad-map-compass {
		display: block;
	}
}

.bad-map-compass__needle {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.bad-map-compass__needle::before {
	content: '';
	position: absolute;
	top: 2px;
	left: 50%;
	width: 12px;
	height: 12px;
	margin-left: -6px;
	border-radius: 50%;
	background: currentColor;
}

/* --- Panneau « Itinerarios » : en-tête avec interrupteur (la légende vient ensuite) --- */
#bad-map-rutas {
	align-self: flex-end;
	width: fit-content;
	max-width: 100%;
	z-index: 10;
}

#bad-map-rutas:has(#bad-map-toggle-rutas:checked) {
	width: 315px;
}

#bad-map-toggle-rutas-label {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	box-sizing: border-box;
	padding: 8px 16px;
	background: rgba(247, 247, 247, 0.8);
	border: 2px solid var(--bad-ink, #1E1E1E);
	border-radius: 24px;
	font-family: var(--bad-display, var(--bad-body, sans-serif));
	font-size: 14px;
	font-weight: 700;
	text-transform: uppercase;
	color: #1a1a1a;
	cursor: pointer;
	user-select: none;
	white-space: nowrap;
}

#bad-map-rutas:has(#bad-map-toggle-rutas:checked) #bad-map-toggle-rutas-label {
	border-bottom: 0;
	border-bottom-left-radius: 0;
	border-bottom-right-radius: 0;
}

#bad-map-toggle-rutas-label input[type="checkbox"] {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.bad-map-toggle-switch {
	display: inline-flex;
}

.bad-map-toggle-track {
	position: relative;
	display: block;
	box-sizing: border-box;
	width: 52px;
	height: 32px;
	background: var(--bad-paper, #F3F3F3);
	border: 2px solid var(--bad-ink, #1E1E1E);
	border-radius: 100px;
	transition: background 0.2s ease;
}

.bad-map-toggle-thumb {
	position: absolute;
	top: 50%;
	left: 6px;
	width: 16px;
	height: 16px;
	background: var(--bad-ink, #1E1E1E);
	border-radius: 50%;
	transform: translateY(-50%);
	transition: left 0.2s ease, width 0.2s ease, height 0.2s ease, background 0.2s ease;
}

#bad-map-toggle-rutas:checked ~ .bad-map-toggle-track {
	background: var(--bad-blue, #443EC2);
	border-color: var(--bad-blue, #443EC2);
}

#bad-map-toggle-rutas:checked ~ .bad-map-toggle-track .bad-map-toggle-thumb {
	left: 22px;
	width: 24px;
	height: 24px;
	background: #fff;
}

#bad-map-toggle-rutas:focus-visible ~ .bad-map-toggle-track {
	outline: 2px solid var(--bad-blue, #443EC2);
	outline-offset: 2px;
}

@media (max-width: 782px) {
	#bad-map-rutas:has(#bad-map-toggle-rutas:checked) {
		width: 257px;
	}
}

/* --- Légende des itinéraires (lignes remplies par map.js) --- */
#bad-map-legend {
	display: flex;
	flex-direction: column;
	gap: 16px;
	box-sizing: border-box;
	margin: 0;
	padding: 12px 8px;
	list-style: none;
	background: rgba(247, 247, 247, 0.8);
	border: 2px solid var(--bad-ink, #1E1E1E);
	border-radius: 0 0 24px 24px;
}

#bad-map-legend[hidden] {
	display: none;
}

.bad-map-legend__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	width: 100%;
	padding: 4px 8px;
	background: none;
	border: 0;
	border-radius: 8px;
	font-family: var(--bad-display, var(--bad-body, sans-serif));
	font-size: 14px;
	font-weight: 700;
	line-height: normal;
	text-align: left;
	text-transform: uppercase;
	color: #1a1a1a;
	cursor: pointer;
}

.bad-map-legend__row:hover {
	background: #d9d9d9;
}

.bad-map-legend__row:focus-visible {
	outline: 2px solid var(--bad-blue, #443EC2);
	outline-offset: 1px;
}

.bad-map-legend__id {
	display: flex;
	align-items: center;
	gap: 16px;
}

.bad-map-legend__line {
	flex: none;
	width: 20px;
	height: 5px;
	border-radius: 2px;
}

.bad-map-legend__icon {
	flex: none;
	display: flex;
	width: 24px;
	height: 24px;
}


/* --- Indicateur de chargement (n'apparaît que si le chargement dépasse 300 ms) --- */
#bad-map-loading {
	position: absolute;
	left: 50%;
	bottom: 6rem;
	transform: translateX(-50%);
	z-index: 8;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5rem;
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

#bad-map-loading.is-visible {
	opacity: 1;
}

#bad-map-loading span {
	font-family: var(--bad-body, sans-serif);
	font-size: 13px;
	color: var(--bad-ink, #1E1E1E);
}

#bad-map-loading-bar {
	width: 140px;
	height: 4px;
	border-radius: 999px;
	background: var(--bad-paper, #F3F3F3);
	overflow: hidden;
}

#bad-map-loading-fill {
	height: 100%;
	width: 0%;
	background: var(--bad-blue, #443EC2);
	border-radius: 999px;
	transition: width 0.15s ease;
}

/* --- Overlay du lieu : rempli en Ajax, la carte reste intacte en dessous --- */
#bad-map-overlay {
	position: fixed;
	inset: 0;
	z-index: 2000;
	background: rgba(20, 18, 30, 0.55);
	overflow: hidden;
}

#bad-map-overlay[hidden] {
	display: none;
}

#bad-map-overlay-scroll {
	position: absolute;
	inset: 0;
	overflow-y: auto;
	padding: clamp(1rem, 4vw, 3rem) 1rem;
}

#bad-map-overlay-inner {
	max-width: 1100px;
	margin: 0 auto;
	background: #fff;
	border-radius: 8px;
	min-height: 200px;
}

#bad-map-overlay-inner .bad-lugar {
	margin: 0;
	max-width: none;
}

.bad-map-overlay__loading {
	padding: 3rem;
	text-align: center;
	font-family: var(--bad-display, sans-serif);
	color: var(--bad-ink, #1E1E1E);
}
