/*
 * Mappa Buonissima — stili front-end.
 * Palette: menta #9af8d2, vermiglio #f8401c, nero per il testo minuto.
 * Raleway per i titoli, DM Sans per il resto: entrambi già caricati dal tema.
 */

.bt-mappa {
	--bt-mint: #9af8d2;
	--bt-red: #f8401c;
	--bt-ink: #000;
	--bt-paper: #fff;
	--bt-line: rgba(0, 0, 0, .14);
	--bt-muted: #5a5a5a;
	--bt-radius: 12px;

	position: relative;
	width: 100%;
	font-family: "DM Sans", system-ui, sans-serif;
	font-size: 16px;
	color: var(--bt-ink);
}

.bt-mappa *,
.bt-mappa *::before,
.bt-mappa *::after {
	box-sizing: border-box;
}

/*
 * L'attributo hidden va imposto qui: le regole di classe dichiarano
 * display:flex o grid e vincerebbero sul foglio di stile del browser,
 * lasciando visibili pannelli che dovrebbero sparire.
 */
.bt-mappa [hidden] {
	display: none !important;
}

/* Il consenso già dato viene marcato prima del disegno della pagina. */
.bt-mappa[data-consent="yes"] .bt-mappa__consent {
	display: none !important;
}

/* --- Segnaposto di consenso --------------------------------------- */

.bt-mappa__consent {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: .5rem;
	height: var(--bt-mappa-h, 640px);
	padding: 2rem 1.5rem;
	border-radius: var(--bt-radius);
	text-align: center;
	background: var(--bt-mint);
}

.bt-mappa__consent-title {
	margin: 0;
	font-family: Raleway, system-ui, sans-serif;
	font-weight: 700;
	font-size: clamp(1.5rem, 4vw, 2.25rem);
	line-height: 1.1;
	color: var(--bt-red);
}

.bt-mappa__consent-body {
	max-width: 46ch;
	margin: 0;
	font-size: .9375rem;
	line-height: 1.5;
}

.bt-mappa__button {
	margin-top: .5rem;
	padding: .7rem 1.4rem;
	border: 2px solid var(--bt-red);
	border-radius: 999px;
	background: var(--bt-red);
	color: var(--bt-mint);
	font-family: Raleway, system-ui, sans-serif;
	font-weight: 700;
	font-size: 1rem;
	cursor: pointer;
}

.bt-mappa__button:hover,
.bt-mappa__button:focus-visible {
	background: transparent;
	color: var(--bt-red);
}

.bt-mappa__button:focus-visible,
.bt-mappa__chip:focus-visible,
.bt-mappa__item:focus-visible {
	outline: 2px solid var(--bt-ink);
	outline-offset: 2px;
}

/* --- Ricerca e filtri ---------------------------------------------- */

.bt-mappa__controls {
	display: flex;
	flex-direction: column;
	gap: .5rem;
	margin-bottom: .75rem;
}

.bt-mappa__search {
	position: relative;
	max-width: 360px;
}

.bt-mappa__search-icon {
	position: absolute;
	top: 50%;
	left: .75rem;
	width: 16px;
	height: 16px;
	transform: translateY(-50%);
	fill: var(--bt-muted);
	pointer-events: none;
}

.bt-mappa__search input {
	width: 100%;
	height: 36px;
	margin: 0;
	padding: 0 .75rem 0 2.2rem;
	border: 1px solid var(--bt-line);
	border-radius: 8px;
	background: var(--bt-paper);
	font-family: inherit;
	font-size: .875rem;
	line-height: 34px;
	color: var(--bt-ink);
	-webkit-appearance: none;
	appearance: none;
}

.bt-mappa__search input::placeholder {
	color: var(--bt-muted);
}

.bt-mappa__search input:focus {
	border-color: var(--bt-ink);
	outline: none;
}

.bt-mappa__chips {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .3rem;
}

/*
 * Pillole basse e larghe: con un testo breve, un'altezza generosa e un
 * raggio pieno le trasformerebbe in cerchi.
 */
.bt-mappa__chip {
	flex: 0 0 auto;
	height: 30px;
	padding: 0 .7rem;
	border: 1px solid var(--bt-line);
	border-radius: 8px;
	background: var(--bt-paper);
	color: var(--bt-ink);
	font-family: inherit;
	font-size: .8125rem;
	font-weight: 500;
	line-height: 28px;
	white-space: nowrap;
	cursor: pointer;
}

.bt-mappa__chip:hover {
	border-color: var(--bt-ink);
}

.bt-mappa__chip--type.is-active {
	background: var(--bt-ink);
	border-color: var(--bt-ink);
	color: var(--bt-paper);
}

.bt-mappa__chip--event.is-active {
	background: var(--bt-mint);
	border-color: transparent;
	color: var(--bt-ink);
	font-weight: 600;
}

.bt-mappa__chip--event span {
	margin-left: .15rem;
	font-size: 1.1em;
	line-height: 1;
}

.bt-mappa__divider {
	flex: 0 0 1px;
	width: 1px;
	height: 20px;
	margin: 0 .3rem;
	background: rgba(0, 0, 0, .35);
}

/* --- Impianto ------------------------------------------------------ */

.bt-mappa__layout {
	display: grid;
	gap: .875rem;
	grid-template-columns: 290px minmax(0, 1fr);
	align-items: stretch;
}

.bt-mappa__panel {
	display: flex;
	flex-direction: column;
	min-width: 0;
	min-height: 0;
	height: var(--bt-mappa-h, 640px);
}

.bt-mappa__count {
	margin: 0 0 .4rem;
	font-size: .75rem;
	letter-spacing: .02em;
	text-transform: uppercase;
	color: var(--bt-muted);
}

.bt-mappa__list {
	display: flex;
	flex-direction: column;
	gap: .25rem;
	min-width: 0;
	overflow-x: hidden;
	overflow-y: auto;
	padding-right: .25rem;
	scrollbar-width: thin;
}

.bt-mappa__canvas {
	height: var(--bt-mappa-h, 640px);
	border-radius: var(--bt-radius);
	overflow: hidden;
	background: #eee;
}

.bt-mappa .leaflet-container {
	background: #eee;
	font-family: inherit;
}

.bt-mappa__canvas.is-loading::after {
	content: attr(data-loading);
	display: grid;
	place-items: center;
	height: 100%;
	font-size: .9375rem;
	color: var(--bt-muted);
}

.bt-mappa__error,
.bt-mappa__empty {
	padding: 1rem;
	text-align: center;
	font-size: .875rem;
	color: var(--bt-muted);
}

/* --- Voce dell'elenco ----------------------------------------------
 * Solo nome ed etichette: in un elenco lungo l'indirizzo non aiuta a
 * scegliere e la miniatura è troppo piccola per mostrare qualcosa.
 */

.bt-mappa__item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .5rem;
	width: 100%;
	min-width: 0;
	padding: .45rem .6rem;
	border: 0;
	border-bottom: 1px solid var(--bt-line);
	border-radius: 0;
	background: transparent;
	text-align: left;
	font-family: inherit;
	cursor: pointer;
}

.bt-mappa__item:hover {
	background: rgba(0, 0, 0, .04);
}

.bt-mappa__item.is-current {
	background: var(--bt-ink);
}

/* Evento senza luoghi: visibile ma non scegliibile. */
.bt-mappa__item.is-empty {
	opacity: .45;
	cursor: default;
}

.bt-mappa__item.is-empty:hover {
	background: transparent;
}

.bt-mappa__item.is-current .bt-mappa__item-name {
	color: var(--bt-paper);
}

.bt-mappa__item-name {
	flex: 1 1 auto;
	min-width: 0;
	font-family: Raleway, system-ui, sans-serif;
	font-weight: 700;
	font-size: .875rem;
	line-height: 1.25;
	color: var(--bt-ink);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bt-mappa__item .bt-tags {
	flex: 0 1 auto;
	min-width: 0;
	margin: 0;
	/* Con due etichette la seconda riga va comunque a filo destro. */
	justify-content: flex-end;
}

.bt-mappa__item .bt-tag {
	overflow: hidden;
	max-width: 140px;
	text-overflow: ellipsis;
}

.bt-mappa__hint {
	margin: 0 0 .4rem;
	padding: 0 .6rem;
	font-size: .75rem;
	line-height: 1.3;
	color: var(--bt-muted);
}

/* --- Etichette degli eventi ---------------------------------------- */

.bt-tags {
	display: flex;
	flex-wrap: wrap;
	gap: .2rem;
}

.bt-tag {
	display: inline-block;
	padding: .05rem .4rem;
	border-radius: 4px;
	background: var(--bt-mint);
	font-family: "DM Sans", system-ui, sans-serif;
	font-size: .6875rem;
	font-weight: 500;
	line-height: 1.5;
	color: var(--bt-ink);
	white-space: nowrap;
}

/* --- Segnaposti -----------------------------------------------------
 * Nessun colore: un anello bianco e un'ombra li staccano da qualunque
 * sfondo di mappa. La forma distingue i due tipi — quadrato smussato
 * per gli eventi, goccia per i locali.
 */

.leaflet-marker-icon.bt-pin-wrap {
	background: none;
	border: 0;
}

/*
 * Ruotando il quadrato la punta esce dal riquadro in basso, quindi la
 * goccia ha bisogno di più altezza del quadrato. Le misure devono
 * corrispondere a iconSize e iconAnchor impostati nel JavaScript.
 */
.bt-pin {
	position: relative;
	display: block;
}

.bt-pin--evento {
	width: 46px;
	height: 50px;
}

.bt-pin--locale {
	width: 50px;
	height: 62px;
}

.bt-pin__shape {
	position: absolute;
	top: 0;
	left: 0;
	width: 40px;
	height: 40px;
	overflow: hidden;
	border: 3px solid #fff;
	background: #2b2b2b;
	box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}

.bt-pin--evento .bt-pin__shape {
	border-radius: 10px;
}

/*
 * La goccia nasce da un cerchio con un angolo vivo in basso a sinistra,
 * ruotato di 45° in senso antiorario: è la rotazione che porta la punta
 * verso il basso. In senso orario finirebbe a sinistra.
 */
.bt-pin--locale .bt-pin__shape {
	top: 2px;
	left: 2px;
	border-radius: 50% 50% 50% 2px;
	transform: rotate(-45deg);
}

.bt-pin__media {
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	background-position: center;
	background-size: cover;
	background-repeat: no-repeat;
	font-family: Raleway, system-ui, sans-serif;
	font-weight: 700;
	font-size: 1rem;
	color: #fff;
}

/* Il contenuto va controruotato, altrimenti la foto resta storta. */
.bt-pin--locale .bt-pin__media {
	transform: rotate(45deg) scale(1.42);
}

.bt-pin.is-current .bt-pin__shape {
	border-color: var(--bt-red, #f8401c);
}

.bt-pin__label {
	position: absolute;
	top: 100%;
	left: 50%;
	display: none;
	max-width: 130px;
	padding: .08rem .4rem;
	transform: translateX(-50%);
	border-radius: 4px;
	background: rgba(255, 255, 255, .95);
	box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
	font-size: .6875rem;
	line-height: 1.35;
	color: #000;
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	pointer-events: none;
}

.bt-mappa__canvas.is-zoomed .bt-pin__label {
	display: block;
}

.bt-mappa-cluster {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	border: 3px solid #fff;
	border-radius: 50%;
	background: #2b2b2b;
	color: #fff;
	font-family: Raleway, system-ui, sans-serif;
	font-weight: 700;
	font-size: .875rem;
	box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}

/* Attribuzione: obbligatoria, ma può essere discreta. */
.bt-mappa .leaflet-control-attribution {
	padding: 1px 6px;
	background: rgba(255, 255, 255, .75);
	font-size: 10px;
	line-height: 1.4;
}

.bt-mappa .leaflet-control-attribution a {
	color: #444;
	text-decoration: none;
}

/* --- Card sulla mappa ---------------------------------------------- */

.bt-mappa .leaflet-popup-content-wrapper {
	padding: 0;
	overflow: hidden;
	border-radius: var(--bt-radius);
	background: #fff;
	box-shadow: 0 8px 26px rgba(0, 0, 0, .2);
}

.bt-mappa .leaflet-popup-content {
	margin: 0;
	width: 296px !important;
	font-family: inherit;
	line-height: 1.25;
	color: #000;
}

.bt-mappa .leaflet-popup-tip {
	background: #fff;
	box-shadow: none;
}

.bt-mappa .leaflet-popup-close-button {
	top: 8px !important;
	right: 8px !important;
	width: 30px !important;
	height: 30px !important;
	padding: 0 !important;
	border-radius: 50%;
	background: #fff !important;
	box-shadow: 0 1px 5px rgba(0, 0, 0, .3);
	color: #000 !important;
	/* Peso leggero e corpo generoso: la croce si legge senza ingrossare il bollino. */
	font: 300 26px/28px Raleway, system-ui, sans-serif !important;
	text-align: center;
}

.bt-mappa .leaflet-popup-close-button:hover {
	background: #000 !important;
	color: #fff !important;
}

/*
 * Impaginazione orizzontale: foto a sinistra e testo a destra.
 * In verticale la foto rubava metà dell'altezza disponibile e la
 * scheda diventava alta quanto mezzo schermo.
 */
.bt-card {
	display: flex;
	align-items: stretch;
	gap: 0;
	line-height: 1.2;
	text-decoration: none;
	color: inherit;
}

/* Foto rettangolare e bassa: il soggetto si riconosce comunque e la
   card resta corta. Le etichette ci stanno sopra, non rubano una riga. */
/*
 * La colonna della foto prende l'altezza dal testo accanto, tramite
 * flexbox. Un'immagine con altezza al 100% dentro un contenitore la cui
 * altezza viene calcolata dopo viene disegnata a zero al primo passaggio:
 * da qui la card "spaccata" al primo clic. Posizionandola in assoluto
 * sui quattro lati, l'immagine riempie il riquadro qualunque sia il
 * momento in cui la sua altezza diventa nota. L'!important serve perché
 * il tema dichiara height:auto su tutte le immagini.
 */
.bt-card__media {
	position: relative;
	flex: 0 0 96px;
	width: 96px;
	min-height: 96px;
	overflow: hidden;
	background: var(--bt-mint);
}

.bt-card__photo {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none;
	margin: 0;
	object-fit: cover;
}

.bt-card__media .bt-tags {
	display: none;
}

.bt-card__body {
	flex: 1 1 auto;
	min-width: 0;
	padding: .5rem .65rem .55rem;
}

.bt-card__body > .bt-tags {
	margin-bottom: 3px;
}

.bt-card__place {
	display: flex;
	align-items: center;
	gap: .25rem;
	margin: 0;
	font-family: Raleway, system-ui, sans-serif;
	font-weight: 700;
	font-size: .9375rem;
	line-height: 1.1;
	color: var(--bt-red);
}

.bt-card__arrow {
	flex: 0 0 auto;
	width: .65em;
	height: .65em;
	fill: currentColor;
}

.bt-card__address,
.bt-card__when,
.bt-card__title {
	margin: 3px 0 0;
	font-size: .75rem;
	line-height: 1.2;
}

.bt-card__address {
	color: var(--bt-muted);
}

.bt-card__when {
	font-size: .78rem;
	color: #000;
}

.bt-card__title {
	display: flex;
	align-items: center;
	gap: .25rem;
	font-family: Raleway, system-ui, sans-serif;
	font-weight: 700;
	font-size: .8125rem;
	color: #000;
}

.bt-card__item {
	display: block;
	margin-top: .35rem;
	padding-top: .35rem;
	border-top: 1px solid var(--bt-line);
	text-decoration: none;
	color: inherit;
}

.bt-card__item:first-of-type {
	margin-top: .25rem;
	padding-top: 0;
	border-top: 0;
}

a.bt-card:hover .bt-card__place,
.bt-card__item:hover .bt-card__title {
	text-decoration: underline;
	text-underline-offset: 2px;
}


/* --- Contenitore della mappa, pannello e velo di attivazione -------- */

.bt-mappa__map {
	position: relative;
	min-width: 0;
}

/*
 * Scheda a comparsa dal basso, usata al posto del fumetto quando lo
 * schermo è troppo stretto perché un fumetto ancorato allo spillo
 * risulti leggibile.
 */
.bt-mappa__sheet {
	position: absolute;
	right: 8px;
	bottom: 8px;
	left: 8px;
	z-index: 1200;
	max-height: 60%;
	overflow-y: auto;
	border-radius: var(--bt-radius);
	background: var(--bt-paper);
	box-shadow: 0 4px 20px rgba(0, 0, 0, .28);
}

.bt-mappa__sheet-close {
	position: absolute;
	top: 6px;
	right: 6px;
	z-index: 2;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 5px rgba(0, 0, 0, .3);
	font: 300 26px/26px Raleway, system-ui, sans-serif;
	color: #000;
	cursor: pointer;
}

.bt-mappa__sheet .bt-card__media {
	border-radius: var(--bt-radius) 0 0 var(--bt-radius);
}

.bt-mappa__sheet .bt-card__body {
	padding: .6rem .85rem .9rem;
}

.bt-mappa__sheet .bt-card__place {
	font-size: 1rem;
	padding-right: 30px;
}

.bt-mappa__sheet .bt-card__address,
.bt-mappa__sheet .bt-card__when {
	font-size: .8125rem;
}

/* Velo di attivazione: sparisce al primo tocco. */
.bt-mappa__gate {
	position: absolute;
	inset: 0;
	z-index: 1100;
	display: grid;
	place-items: center;
	background: rgba(255, 255, 255, .12);
	cursor: pointer;
}

.bt-mappa__gate span {
	padding: .4rem .8rem;
	border-radius: 999px;
	background: rgba(0, 0, 0, .78);
	font-size: .8125rem;
	color: #fff;
}

/* --- Pulsante "mostra tutti" --------------------------------------- */

.bt-mappa__more {
	margin-top: .4rem;
	padding: .45rem .8rem;
	border: 1px solid var(--bt-line);
	border-radius: 8px;
	background: var(--bt-paper);
	font-family: inherit;
	font-size: .8125rem;
	font-weight: 500;
	color: var(--bt-ink);
	cursor: pointer;
}

.bt-mappa__more:hover {
	border-color: var(--bt-ink);
}

/* --- Mobile: prima la mappa, l'elenco sotto ------------------------ */

@media (max-width: 900px) {
	.bt-mappa__layout {
		display: flex;
		flex-direction: column;
		gap: .75rem;
	}

	.bt-mappa__canvas,
	.bt-mappa__consent {
		height: var(--bt-mappa-h-mobile, 420px);
	}

	.bt-mappa__panel {
		order: 2;
		height: auto;
	}

	/* Sotto la mappa l'elenco cresce con la pagina: uno scorrimento
	   dentro un altro scorrimento è ingestibile col dito. */
	.bt-mappa__list {
		max-height: none;
		overflow: visible;
		padding-right: 0;
	}

	.bt-mappa__search {
		max-width: none;
	}

	/* I filtri scorrono in orizzontale invece di impilarsi su tre righe. */
	.bt-mappa__chips {
		flex-wrap: nowrap;
		overflow-x: auto;
		padding-bottom: .25rem;
		scrollbar-width: none;
	}

	.bt-mappa__chips::-webkit-scrollbar {
		display: none;
	}

	.bt-mappa__sheet .bt-card__media {
		flex: 0 0 104px;
		width: 104px;
		min-height: 104px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bt-mappa * {
		transition: none !important;
		animation: none !important;
	}
}
