/**
 * Carte des festivités — shortcode [pvd_festival_map].
 *
 * La carte forme un bloc unique : une barre de commandes posée sur le plan, le tout
 * dans un même cadre arrondi. Les habillages de Leaflet (zoom, mentions, infobulles)
 * sont repris pour rester dans la même famille, mais uniquement sous .pvd-festival-map
 * afin de ne pas déteindre sur les autres cartes du site.
 *
 * Les couleurs passent par des variables surchargeables : pour adapter la carte au
 * thème, redéfinissez-les sur .pvd-festival-map depuis Elementor ou le CSS du site.
 *   --pvd-map-accent   couleur de l'onglet actif (défaut : rouge PVD)
 *   --pvd-map-surface  fond du cadre et des boutons au repos
 *   --pvd-map-text     texte des boutons au repos
 *   --pvd-map-border   bordure au repos
 */

.pvd-festival-map {
	--pvd-map-accent: #b91c1c;
	--pvd-map-surface: #fff;
	--pvd-map-text: #2b2b2b;
	--pvd-map-border: rgba(0, 0, 0, .18);
	--pvd-map-radius: 999px;
	--pvd-map-frame: 14px;
	--pvd-map-rule: rgba(0, 0, 0, .09);

	margin: 0 0 1.5em;
	background: var(--pvd-map-surface);
	color: var(--pvd-map-text);
	border-radius: var(--pvd-map-frame);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .07), 0 14px 34px -18px rgba(0, 0, 0, .55);
	overflow: hidden;
}

/*
 * Seule dans son conteneur — le contenu d'un popup, une colonne dédiée — la carte n'a
 * plus rien à espacer en dessous : sa marge basse n'y formerait qu'un bandeau vide.
 */
.pvd-festival-map:last-child {
	margin-bottom: 0;
}

/* --- Barre de commandes --- */

.pvd-festival-map__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .55em 1.5em;
	padding: .85em 1em;
	border-bottom: 1px solid var(--pvd-map-rule);
}

.pvd-festival-map__days {
	display: flex;
	flex-wrap: wrap;
	gap: .5em;
	transition: opacity .15s ease;
}

/* Plus aucune couche datée à l'écran : les onglets n'ont plus de prise sur la carte. */
.pvd-festival-map__days--inactive {
	opacity: .45;
}

.pvd-festival-map__day {
	margin: 0;
	padding: .55em 1.15em;
	border: 1px solid var(--pvd-map-border);
	border-radius: var(--pvd-map-radius);
	background: var(--pvd-map-surface);
	color: var(--pvd-map-text);
	font: inherit;
	line-height: 1.25;
	cursor: pointer;
	transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.pvd-festival-map__day:hover {
	border-color: var(--pvd-map-accent);
	color: var(--pvd-map-accent);
}

.pvd-festival-map__day:focus-visible {
	outline: 2px solid var(--pvd-map-accent);
	outline-offset: 2px;
}

.pvd-festival-map__day[aria-pressed="true"] {
	background: var(--pvd-map-accent);
	border-color: var(--pvd-map-accent);
	color: #fff;
	box-shadow: 0 2px 6px -1px rgba(0, 0, 0, .35);
	transform: translateY(-1px);
}

/* --- Légende / couches --- */

.pvd-festival-map__legend {
	display: flex;
	flex-wrap: wrap;
	gap: .5em;
	font-size: .95em;
}

/* Sur une barre assez large pour tenir sur une ligne, les commandes se répartissent aux
   deux bouts : journées à gauche, couches à droite. Dès que la barre se replie, la
   légende reprend le bord gauche plutôt que de flotter seule à droite. */
@media (min-width: 700px) {
	.pvd-festival-map__legend {
		margin-left: auto;
	}
}

.pvd-festival-map__layer {
	display: inline-flex;
	align-items: center;
	gap: .5em;
	margin: 0;
	padding: .4em .95em;
	border: 1px solid var(--pvd-map-border);
	border-radius: var(--pvd-map-radius);
	background: var(--pvd-map-surface);
	color: var(--pvd-map-text);
	line-height: 1.25;
	cursor: pointer;
	user-select: none;
	transition: border-color .15s ease, opacity .15s ease;
}

.pvd-festival-map__layer:has(input:checked) {
	border-color: var(--pvd-layer-color, var(--pvd-map-accent));
}

.pvd-festival-map__layer:has(input:not(:checked)) {
	opacity: .55;
}

.pvd-festival-map__layer:focus-within {
	outline: 2px solid var(--pvd-layer-color, var(--pvd-map-accent));
	outline-offset: 2px;
}

/*
 * La pastille de couleur EST la case à cocher : pleine quand la couche est affichée,
 * en contour sinon. La coche blanche évite de ne reposer que sur la couleur.
 */
.pvd-festival-map__layer input[type="checkbox"] {
	appearance: none;
	-webkit-appearance: none;
	flex: none;
	width: 1.05em;
	height: 1.05em;
	margin: 0;
	padding: 0;
	border: 2px solid var(--pvd-layer-color, var(--pvd-map-accent));
	border-radius: 50%;
	background: transparent;
	cursor: pointer;
	transition: background-color .15s ease;
}

.pvd-festival-map__layer input[type="checkbox"]:checked {
	background-color: var(--pvd-layer-color, var(--pvd-map-accent));
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M2.6 6.4l2.2 2.2 4.6-4.8'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: .72em;
}

/* --- Légende des pictogrammes --- */

/*
 * Volontairement sans bordure ni fond, à la différence des pastilles de couche voisines :
 * cette liste se lit, elle ne se clique pas, et rien ne doit laisser croire l'inverse.
 */
.pvd-festival-map__keys {
	display: flex;
	flex-wrap: wrap;
	gap: .35em 1.4em;
	margin: 0;
	padding: .7em 1.1em;
	border-bottom: 1px solid var(--pvd-map-rule);
	list-style: none;
	font-size: .92em;
}

.pvd-festival-map__key {
	display: inline-flex;
	align-items: center;
	gap: .45em;
	margin: 0;
}

.pvd-festival-map__key svg {
	flex: none;
	display: block;
}

/* --- Carte --- */

.pvd-festival-map__canvas {
	width: 100%;
	min-height: 240px;
	z-index: 0; /* garde la carte sous les entêtes collants du thème */
}

.pvd-festival-map__empty {
	margin: 0;
	padding: .9em 1.1em;
	border-top: 1px solid var(--pvd-map-rule);
	font-style: italic;
	opacity: .8;
}

/* --- Habillage Leaflet --- */

.pvd-festival-map .leaflet-bar {
	border: 0;
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 2px 10px -2px rgba(0, 0, 0, .45);
}

.pvd-festival-map .leaflet-bar a {
	border-bottom-color: var(--pvd-map-rule);
	color: var(--pvd-map-text);
}

.pvd-festival-map .leaflet-bar a:hover {
	color: var(--pvd-map-accent);
}

.pvd-festival-map .leaflet-control-attribution {
	padding: 1px 8px;
	border-radius: 8px 0 0 0;
	background: rgba(255, 255, 255, .85);
	font-size: 11px;
}

/* --- Infobulles --- */

.pvd-festival-map .leaflet-popup-content-wrapper {
	padding: 2px;
	border-radius: 12px;
	box-shadow: 0 8px 28px -8px rgba(0, 0, 0, .55);
}

.pvd-festival-map .leaflet-popup-content {
	margin: .85em 1.05em;
	line-height: 1.45;
}

.pvd-festival-map__popup {
	display: flex;
	flex-direction: column;
	gap: .2em;
	min-width: 12em;
	color: var(--pvd-map-text);
}

/* Rappel de catégorie, en tête de bulle : il traduit le pictogramme du repère cliqué. */
.pvd-festival-map__popup .pvd-festival-map__tag {
	display: inline-flex;
	align-items: center;
	gap: .4em;
	margin-bottom: .15em;
	font-size: .88em;
	font-weight: 600;
	opacity: 1;
}

.pvd-festival-map__popup .pvd-festival-map__tag svg {
	flex: none;
	display: block;
	width: 17px;
	height: 17px;
}

.pvd-festival-map__popup .pvd-festival-map__title {
	font-size: 1.05em;
	line-height: 1.3;
}

.pvd-festival-map__popup .pvd-festival-map__title a {
	color: inherit;
	text-decoration: none;
}

.pvd-festival-map__popup .pvd-festival-map__title a:hover {
	color: var(--pvd-map-accent);
	text-decoration: underline;
}

.pvd-festival-map__popup span {
	font-size: .95em;
	opacity: .75;
}

/* Le lien de sortie est le seul appel à l'action de la bulle : il se lit comme un
   bouton. La couleur est forcée, les thèmes habillant les liens sans nuance. */
.pvd-festival-map__link {
	align-self: flex-start;
	margin-top: .5em;
	padding: .35em .95em;
	border-radius: var(--pvd-map-radius);
	background: var(--pvd-map-accent);
	color: #fff !important;
	font-size: .9em;
	font-weight: 600;
	text-decoration: none !important;
	transition: filter .15s ease;
}

.pvd-festival-map__link:hover {
	filter: brightness(1.12);
}

@media (max-width: 480px) {
	.pvd-festival-map__bar {
		padding: .75em .8em;
	}

	.pvd-festival-map__day {
		padding: .5em .9em;
		font-size: .92em;
	}

	.pvd-festival-map__layer {
		padding: .35em .75em;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pvd-festival-map__days,
	.pvd-festival-map__day,
	.pvd-festival-map__layer,
	.pvd-festival-map__layer input[type="checkbox"],
	.pvd-festival-map__link {
		transition: none;
	}

	.pvd-festival-map__day[aria-pressed="true"] {
		transform: none;
	}
}
