/* ==========================================================================
   Perabite — "Gli aeroporti del circuito"
   Vista griglia + vista mappa Italia con aree Nielsen.
   ========================================================================== */

.apm {
	--apm-fg: #081D2B;
	--apm-fg2: #3F5261;
	--apm-fg3: #5C7385;
	--apm-surface: #FFFFFF;
	--apm-eyebrow: #1A9DD9;
	--apm-accent: #35A7E0;

	/* Card */
	--apm-card-bg: #FFFFFF;
	--apm-card-radius: 12px;
	--apm-card-gap: 20px;
	--apm-card-min: 280px;
	--apm-media-ratio: 16 / 10;
	--apm-media-empty: rgba(127, 167, 197, 0.14);

	/* Accordion */
	--apm-area-bg: #FFFFFF;
	--apm-area-border: rgba(53, 167, 224, 0.35);
	--apm-area-radius: 24px;
	--apm-area-gap: 12px;
	--apm-area-name: #0C2536;

	/* Mappa */
	--apm-map-land: #D8E2E9;
	--apm-map-land2: #E9EFF3;
	--apm-map-land3: #FFFFFF;
	--apm-map-stroke: #FFFFFF;
	--apm-map-dim: 0.45;
	--apm-map-top: -120px;
	--apm-map-left: clamp(300px, 58vw, 700px);
	--apm-areas-width: min(58%, 580px);
	--apm-pin-base: 1;
	--apm-pin-scale: 1;

	/* Tooltip */
	--apm-tip-bg: #0C2536;
	--apm-tip-fg: #FFFFFF;
	--apm-tip-fg2: #BFD6E4;

	color: var(--apm-fg);
	box-sizing: border-box;
}

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

.apm-icon {
	flex: none;
	display: block;
}

/* --------------------------------------------------------------------------
   Intestazione e toggle
   -------------------------------------------------------------------------- */

.apm__head {
	position: relative;
	z-index: 2;
	margin-bottom: 40px;
}

.apm__eyebrow {
	margin: 0 0 8px;
	font-size: 12px;
	font-weight: 500;
	line-height: 1.3;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--apm-eyebrow);
}

.apm__headrow {
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
	gap: 24px;
	flex-wrap: wrap;
}

.apm__title {
	margin: 0;
	font-size: clamp(28px, 3.2vw, 40px);
	font-weight: 600;
	letter-spacing: -0.01em;
	line-height: 1.15;
	color: inherit;
}

.apm__toggle {
	display: flex;
	gap: 2px;
	padding: 4px;
	/* semi-opaco: il selettore resta leggibile anche sopra la mappa */
	background: rgba(255, 255, 255, 0.72);
	box-shadow: inset 0 0 0 1px rgba(8, 29, 43, 0.08);
	border-radius: 999px;
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}

.apm__tgl {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 16px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	font-family: inherit;
	font-size: 14px;
	font-weight: 500;
	line-height: 1;
	color: var(--apm-fg3);
	cursor: pointer;
	transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
	-webkit-appearance: none;
	appearance: none;
}

.apm__tgl[aria-checked="true"] {
	background: var(--apm-surface);
	color: var(--apm-fg);
	box-shadow: 0 1px 2px rgba(8, 29, 43, 0.12);
}

.apm__tgl:focus-visible {
	outline: 2px solid var(--apm-accent);
	outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Commutazione delle viste
   -------------------------------------------------------------------------- */

.apm[data-view="grid"] .apm__view--map,
.apm[data-view="map"] .apm__view--grid {
	display: none;
}

/* --------------------------------------------------------------------------
   Vista griglia
   -------------------------------------------------------------------------- */

.apm-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(var(--apm-card-min), 1fr));
	gap: var(--apm-card-gap);
}

.apm-card {
	display: flex;
	flex-direction: column;
	background: var(--apm-card-bg);
	border-radius: var(--apm-card-radius);
	overflow: hidden;
	color: inherit;
}

.apm-card__media {
	aspect-ratio: var(--apm-media-ratio);
	background-color: var(--apm-media-empty);
	background-position: center;
	background-size: cover;
	background-repeat: no-repeat;
}

.apm-card__media--empty {
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--apm-fg3);
}

.apm-card__media--empty .apm-icon {
	width: 28px;
	height: 28px;
}

.apm-card__body {
	padding: 18px 22px;
}

.apm-card__name {
	margin: 0 0 2px;
	font-size: 20px;
	font-weight: 600;
	letter-spacing: -0.01em;
	line-height: 1.25;
	color: inherit;
}

.apm-card__city {
	margin: 0 0 6px;
	font-size: 14px;
	line-height: 1.4;
	color: var(--apm-fg2);
}

.apm-card__formats {
	margin: 0;
	font-size: 12px;
	line-height: 1.4;
	color: var(--apm-fg3);
}

/* --------------------------------------------------------------------------
   Vista mappa
   -------------------------------------------------------------------------- */

.apm-maplayout {
	position: relative;
}

/* Senza accordion la colonna di sinistra non fa piu' altezza: gliela diamo noi,
   altrimenti la mappa (assoluta) resterebbe invisibile. */
.apm-maplayout--noareas {
	min-height: 520px;
}

.apm-areas[hidden] {
	display: none;
}

.apm-mapbg {
	position: absolute;
	top: var(--apm-map-top);
	bottom: 0;
	left: 45%;
	right: 0;
	overflow: hidden;
	-webkit-mask-image: linear-gradient(to bottom, #000 0, #000 72%, transparent 100%);
	mask-image: linear-gradient(to bottom, #000 0, #000 72%, transparent 100%);
}

/* Mappa a tutta larghezza fino al bordo destro della finestra. */
.apm--bleed .apm-mapbg {
	left: calc(50% - 50vw + var(--apm-map-left));
	right: calc(50% - 50vw);
}

/* Senza accordion la mappa prende tutta la larghezza invece di lasciare un vuoto. */
.apm-maplayout--noareas .apm-mapbg,
.apm--bleed .apm-maplayout--noareas .apm-mapbg {
	left: 0;
}

.apm-mapbg__inner {
	position: absolute;
	inset: 0;
}

.apm-map__svg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.apm-land {
	stroke: var(--apm-map-stroke);
	stroke-width: 0.3;
	vector-effect: non-scaling-stroke;
	pointer-events: none;
}

.apm-land.is-land {
	fill: var(--apm-map-land);
}

.apm-land.is-land2 {
	fill: var(--apm-map-land2);
}

.apm-land.is-land3 {
	fill: var(--apm-map-land3);
}

.apm-country {
	fill: var(--apm-map-land);
	stroke: var(--apm-map-stroke);
	stroke-width: 0.3;
	vector-effect: non-scaling-stroke;
	pointer-events: none;
}

.apm-region {
	fill: var(--apm-area-color, var(--apm-map-land));
	fill-opacity: 1;
	stroke: var(--apm-map-stroke);
	stroke-width: 0.3;
	vector-effect: non-scaling-stroke;
	cursor: pointer;
	transition: fill-opacity 200ms ease;
}

.apm-maplayout.has-focus .apm-region:not(.is-on) {
	fill-opacity: var(--apm-map-dim);
}

/*
 * Pin: riempimento bianco e anello nel colore dell'area. Nel prototipo il pin
 * ha il colore dell'area e finisce invisibile sopra la regione dello stesso
 * colore; invertendo i due resta leggibile ovunque. In hover si inverte di nuovo.
 */
.apm-pin {
	fill: var(--apm-pin-fill, #FFFFFF);
	stroke: var(--apm-area-color, var(--apm-accent));
	stroke-width: 0.9;
	cursor: pointer;
	transform-box: fill-box;
	transform-origin: center;
	transform: scale(calc(var(--apm-pin-base, 1) * var(--apm-pin-scale, 1)));
	transition: transform 150ms ease, opacity 200ms ease;
}

.apm-maplayout.has-focus .apm-pin:not(.is-on) {
	opacity: var(--apm-map-dim);
}

.apm-pin.is-hover,
.apm-pin:focus-visible {
	--apm-pin-scale: 1.45;
	--apm-pin-fill: var(--apm-area-color, var(--apm-accent));
	stroke: #FFFFFF;
	outline: none;
}

/* Tooltip */
.apm-tip {
	position: absolute;
	z-index: 5;
	display: flex;
	flex-direction: column;
	gap: 2px;
	max-width: 240px;
	padding: 8px 12px;
	background: var(--apm-tip-bg);
	border-radius: 10px;
	box-shadow: 0 6px 20px rgba(8, 29, 43, 0.22);
	pointer-events: none;
	transform: translate(-50%, calc(-100% - 10px));
}

.apm-tip[hidden] {
	display: none;
}

.apm-tip__name {
	font-size: 14px;
	font-weight: 600;
	letter-spacing: -0.01em;
	line-height: 1.25;
	color: var(--apm-tip-fg);
	white-space: nowrap;
}

.apm-tip__city {
	font-size: 13px;
	line-height: 1.25;
	color: var(--apm-tip-fg2);
	white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Accordion delle aree
   -------------------------------------------------------------------------- */

.apm-areas {
	position: relative;
	z-index: 1;
	width: var(--apm-areas-width);
	padding: 32px 0 60px;
}

.apm-area {
	background: var(--apm-area-bg);
	border: 1px solid var(--apm-area-border);
	border-radius: var(--apm-area-radius);
	padding: 0 24px;
	overflow: hidden;
	margin-bottom: var(--apm-area-gap);
	transition: border-color 200ms ease;
}

.apm-area.is-open {
	border-color: var(--apm-area-color, var(--apm-accent));
}

.apm-area__heading {
	margin: 0;
	font-size: inherit;
	line-height: inherit;
}

.apm-area__toggle {
	display: flex;
	align-items: center;
	gap: 16px;
	width: 100%;
	padding: 22px 0;
	border: 0;
	background: transparent;
	font-family: inherit;
	text-align: left;
	color: var(--apm-area-name);
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.apm-area__toggle:focus-visible {
	outline: 2px solid var(--apm-area-color, var(--apm-accent));
	outline-offset: 4px;
	border-radius: 4px;
}

.apm-area__sign {
	position: relative;
	flex: none;
	width: 24px;
	height: 24px;
	display: block;
}

.apm-area__sign-h,
.apm-area__sign-v {
	position: absolute;
	top: 50%;
	left: 50%;
	background: var(--apm-accent);
	border-radius: 2px;
	transform: translate(-50%, -50%);
	transition: opacity 200ms ease, transform 200ms ease;
}

.apm-area__sign-h {
	width: 15px;
	height: 2px;
}

.apm-area__sign-v {
	width: 2px;
	height: 15px;
}

.apm-area.is-open .apm-area__sign-v {
	opacity: 0;
	transform: translate(-50%, -50%) rotate(90deg);
}

.apm-area__labels {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.apm-area__name {
	font-size: 20px;
	font-weight: 600;
	line-height: 1.2;
}

.apm-area__regions {
	font-size: 12px;
	font-weight: 400;
	line-height: 1.35;
	color: var(--apm-fg3);
	text-wrap: pretty;
}

.apm-area__dot {
	flex: none;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--apm-area-color, var(--apm-accent));
	transition: transform 200ms ease;
}

.apm-area.is-open .apm-area__dot {
	transform: scale(1.2);
}

.apm-area__panel {
	max-height: 0;
	opacity: 0;
	overflow: hidden;
	transition: max-height 250ms ease, opacity 250ms ease;
}

.apm-area.is-open .apm-area__panel {
	opacity: 1;
}

.apm-area__list {
	list-style: none;
	margin: 0;
	padding: 0 0 16px 40px;
}

.apm-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 10px;
	margin: 0 -10px;
	border-radius: 8px;
	font-size: 15px;
	line-height: 1.4;
	cursor: default;
	transition: background-color 150ms ease;
}

.apm-item:hover,
.apm-item.is-hover {
	background: rgba(8, 29, 43, 0.05);
}

.apm-item__name {
	flex: 1 1 auto;
	min-width: 0;
}

.apm-item__city {
	display: flex;
	align-items: center;
	gap: 6px;
	flex: none;
	width: 34%;
	min-width: 110px;
	font-size: 13px;
	color: var(--apm-fg3);
}

.apm-item__city .apm-icon {
	width: 14px;
	height: 14px;
	color: var(--apm-accent);
}

.apm-item__city > span {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Stato vuoto (solo per chi puo' modificare)
   -------------------------------------------------------------------------- */

/* Diagnostica per chi modifica */
.apm-debug {
	margin-top: 24px;
	padding: 14px 18px;
	border: 1px dashed var(--apm-accent);
	border-radius: 12px;
	background: rgba(53, 167, 224, 0.06);
	font-size: 13px;
	line-height: 1.5;
	color: var(--apm-fg2);
}

.apm-debug__title {
	margin: 0 0 6px;
	font-weight: 600;
	color: var(--apm-fg);
}

.apm-debug ul {
	margin: 0;
	padding-left: 18px;
}

.apm-debug code {
	padding: 1px 5px;
	border-radius: 4px;
	background: rgba(8, 29, 43, 0.07);
	font-size: 12px;
}

.apm--empty {
	padding: 24px;
	border: 1px dashed var(--apm-area-border);
	border-radius: var(--apm-area-radius);
	color: var(--apm-fg3);
}

.apm--empty p {
	margin: 0;
}

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

@media (max-width: 1024px) {
	.apm {
		--apm-areas-width: 100%;
		--apm-map-top: 0px;
	}

	.apm-mapbg,
	.apm--bleed .apm-mapbg {
		position: relative;
		inset: auto;
		left: auto;
		right: auto;
		height: 420px;
		margin-bottom: 8px;
		-webkit-mask-image: none;
		mask-image: none;
	}

	.apm-areas {
		padding-top: 0;
	}
}

@media (max-width: 600px) {
	.apm-mapbg,
	.apm--bleed .apm-mapbg {
		height: 320px;
	}

	.apm-area {
		padding: 0 18px;
	}

	.apm-area__list {
		padding-left: 0;
	}

	.apm-item {
		flex-wrap: wrap;
		gap: 4px 12px;
	}

	.apm-item__city {
		width: auto;
	}
}

@media (prefers-reduced-motion: reduce) {
	.apm *,
	.apm *::before,
	.apm *::after {
		transition-duration: 0.01ms !important;
	}
}
