/* Galleria da riordinare. Un mosaico di 16 foto in cui le prime quattro (la "vetrina") sono più grandi:
   si afferra una foto, le altre si scansano (GSAP Flip) e la forma delle tessere segue la posizione.
   La foto in grande si apre in una proiezione a tutto schermo. Colori e font da base.css. */

/* ───────── Struttura ───────── */
.app {
	display: grid;
	grid-template-columns: minmax(15rem, 18rem) minmax(0, 1fr);
	gap: clamp(1.5rem, 3.5vw, 3.5rem);
	align-items: start;
	max-width: 100rem;
	margin: 0 auto;
	padding: 1.25rem clamp(1rem, 3vw, 2.5rem) 2rem;
}

/* ───────── Pannello ───────── */
.pannello {
	position: sticky;
	top: 1.25rem;
	padding-top: 1.25rem;
}
.kicker {
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--muted);
}
.pannello h1 {
	margin-top: 0.6rem;
	font-size: clamp(2rem, 3.2vw, 2.9rem);
	line-height: 1;
	letter-spacing: -0.02em;
	text-wrap: balance;
}
.lead {
	margin-top: 1rem;
	color: rgb(255 255 255 / 0.82);
	line-height: 1.6;
	text-wrap: pretty;
}

.comandi {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 1.5rem;
}
.btn {
	padding: 0.65rem 1.15rem;
	border: 1px solid var(--line);
	border-radius: 99px;
	background: transparent;
	color: var(--text);
	font: 600 0.9rem var(--font-text);
	cursor: pointer;
	transition: scale 0.15s var(--ease-out), background-color 0.2s var(--ease-out), opacity 0.2s var(--ease-out);
}
.btn:active:not(:disabled) {
	scale: 0.97;
}
.btn:disabled {
	opacity: 0.4;
	cursor: default;
}
.btn--primario {
	border-color: transparent;
	background: var(--accent-strong);
	color: #fff;
}
.btn--testo {
	border-color: transparent;
	color: var(--muted);
}
@media (hover: hover) and (pointer: fine) {
	.btn:hover:not(:disabled) {
		background: var(--surface);
	}
	.btn--primario:hover:not(:disabled) {
		background: #b8231a;
	}
}

.stato {
	display: flex;
	align-items: center;
	gap: 0.55rem;
	margin-top: 1rem;
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--muted);
}
.stato::before {
	content: '';
	flex: none;
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
	background: var(--muted);
	transition: background-color 0.2s var(--ease-out);
}
.stato[data-stato='modificato'] {
	color: var(--text);
}
.stato[data-stato='modificato']::before {
	background: var(--accent);
}
.stato[data-stato='salvato']::before {
	background: #3ddc84;
}

.aiuto {
	display: grid;
	gap: 0.5rem;
	margin-top: 1.75rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--line);
	font-size: 0.82rem;
	line-height: 1.55;
	color: var(--muted);
}
/* Sul tocco la riga della tastiera non serve. */
@media (pointer: coarse) {
	.aiuto__riga + .aiuto__riga {
		display: none;
	}
}
.aiuto__presa {
	display: inline-block;
	vertical-align: -0.15em;
	color: var(--text);
}
kbd {
	padding: 0.05rem 0.4rem;
	border: 1px solid var(--line);
	border-radius: 0.3rem;
	background: var(--surface);
	color: var(--text);
	font: 600 0.78rem var(--font-text);
}
.nota {
	margin-top: 1rem;
	font-size: 0.82rem;
	line-height: 1.55;
	color: var(--muted);
	text-wrap: pretty;
}

/* ───────── Mosaico ───────── */
/* La larghezza è limitata anche dall'altezza: 5 righe di tessere (1,5 : 1) stanno sempre in una schermata. */
.mosaico-wrap {
	container-type: inline-size;
	justify-self: center;
	width: min(100%, calc((100svh - 7rem) * 1.2));
}
.mosaico {
	--gap: clamp(0.4rem, 1.1cqw, 0.75rem);
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	grid-auto-rows: calc((100cqw - 3 * var(--gap)) / 6); /* tessera 1×1 = 3 : 2 */
	gap: var(--gap);
	margin: 0;
	padding: 0;
	list-style: none;
}
/* Telefono: due colonne. Le due forme larghe (posizioni 1 e 4) occupano tutta la riga. */
@container (max-width: 34rem) {
	.mosaico {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		grid-auto-rows: calc((100cqw - var(--gap)) / 3);
	}
}
/* La forma segue la posizione: vetrina = 2×2, 1×1, 1×1 e 2×1. */
.cella:nth-child(1) {
	grid-column: span 2;
	grid-row: span 2;
}
.cella:nth-child(4) {
	grid-column: span 2;
}

.cella {
	position: relative;
	min-width: 0;
	container-type: size; /* il testo della tessera si misura sulla tessera (cqw), non sulla finestra */
}

/* Tessera: un vero bottone con la foto dentro. */
.tessera {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	padding: 0;
	border: 0;
	border-radius: 0.6rem;
	overflow: hidden;
	isolation: isolate;
	background: var(--surface);
	color: #fff;
	font: inherit;
	text-align: start;
	cursor: pointer;
	-webkit-touch-callout: none;
	transition: scale 0.15s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
.tessera:active {
	scale: 0.985;
}
.tessera__foto {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: var(--fx, 50%) var(--fy, 50%);
	-webkit-user-drag: none;
	user-select: none;
	transition: scale 1.2s var(--ease-out);
}
/* Velo in basso: il nome si legge su ogni foto, anche sulla neve. Va esplicitamente SOPRA la foto
   (z-index): un ::before è il primo figlio e, senza, l'immagine posizionata dopo lo coprirebbe. */
.tessera::before {
	content: '';
	position: absolute;
	inset: auto 0 0;
	z-index: 1;
	height: 70%;
	background: linear-gradient(transparent, rgb(0 0 0 / 0.78));
	pointer-events: none;
}
/* Al passaggio il fondo si scurisce ancora: lo strato più scuro entra in dissolvenza (solo opacità). */
.tessera::after {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 1;
	background: linear-gradient(transparent 20%, rgb(0 0 0 / 0.88));
	opacity: 0;
	transition: opacity 0.4s var(--ease-out);
	pointer-events: none;
}

/* Etichette in alto a sinistra. */
.tessera__alto {
	position: absolute;
	top: 0.55rem;
	left: 0.55rem;
	z-index: 2;
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem;
	max-width: calc(100% - 3.6rem);
}
.chip {
	display: inline-flex;
	align-items: center;
	padding: 0.18rem 0.55rem;
	border-radius: 99px;
	background: rgb(0 0 0 / 0.58);
	color: #fff;
	font-size: 0.64rem;
	font-weight: 700;
	letter-spacing: 0.07em;
	line-height: 1.3;
	text-transform: uppercase;
	font-variant-numeric: tabular-nums;
}
.chip--vetrina {
	display: none;
	background: var(--accent-strong);
}
.cella:nth-child(-n + 4) .chip--vetrina {
	display: inline-flex;
}
.chip--nuova {
	display: none;
	background: #fff;
	color: #000;
}
.cella[data-nuova] .chip--nuova {
	display: inline-flex;
}

/* Maniglia: sempre visibile (sul tocco è l'unico punto da cui si trascina). */
.tessera__presa {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	z-index: 3;
	display: grid;
	place-items: center;
	width: 2.4rem;
	height: 2.4rem;
	border-radius: 50%;
	background: rgb(0 0 0 / 0.55);
	color: #fff;
	opacity: 0.8;
	cursor: grab;
	touch-action: none;
	transition: opacity 0.2s var(--ease-out), background-color 0.2s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
	.tessera__presa {
		width: 2rem;
		height: 2rem;
		opacity: 0.65;
	}
}

/* Testi in basso: il blocco intero scende di una riga e al passaggio risale, mostrando il fotografo. */
.tessera__testi {
	--dett: 1.55rem;
	position: absolute;
	inset: auto 0.85rem 0.8rem;
	z-index: 2;
	translate: 0 var(--dett);
	transition: translate 0.45s var(--ease-out);
}
.tessera__nome {
	display: block;
	font-family: var(--font-display);
	font-weight: 600;
	font-size: clamp(0.82rem, 6.2cqw, 1.6rem);
	line-height: 1.12;
	letter-spacing: -0.01em;
	text-shadow: 0 1px 12px rgb(0 0 0 / 0.5);
	text-wrap: balance;
}
.tessera__dett {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	height: var(--dett);
	padding-top: 0.3rem;
	font-size: 0.74rem;
	font-weight: 600;
	color: rgb(255 255 255 / 0.9);
	opacity: 0;
	transition: opacity 0.3s var(--ease-out);
}
.tessera__dett span {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.tessera__dett svg {
	flex: none;
	color: var(--accent);
	transition: translate 0.45s var(--ease-out);
}

/* Anello (focus da tastiera e tessera sollevata): sta in uno strato SOPRA la foto. Un outline sul bottone
   verrebbe dipinto sotto l'immagine che contiene e non si vedrebbe. */
.cella::after {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 5;
	border-radius: 0.6rem;
	box-shadow: inset 0 0 0 3px var(--accent);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.15s var(--ease-out);
}
.cella:has(.tessera:focus-visible)::after,
.cella.is-sollevata::after {
	opacity: 1;
}
.tessera:focus-visible {
	outline: none;
}
@supports not selector(:has(*)) {
	.tessera:focus-visible {
		outline: 3px solid var(--accent);
		outline-offset: -3px;
	}
}
/* Tastiera: stesso racconto del mouse. */
.tessera:focus-visible::after {
	opacity: 1;
}
.tessera:focus-visible .tessera__testi {
	translate: 0 0;
}
.tessera:focus-visible .tessera__dett {
	opacity: 1;
}
/* Mouse: zoom lento della foto, risalita dei testi, freccia che scivola. Non mentre si trascina. */
@media (hover: hover) and (pointer: fine) {
	.mosaico:not(.is-trascinando) .tessera:hover .tessera__foto {
		scale: 1.07;
	}
	.mosaico:not(.is-trascinando) .tessera:hover::after {
		opacity: 1;
	}
	.mosaico:not(.is-trascinando) .tessera:hover .tessera__testi {
		translate: 0 0;
	}
	.mosaico:not(.is-trascinando) .tessera:hover .tessera__dett {
		opacity: 1;
	}
	.mosaico:not(.is-trascinando) .tessera:hover .tessera__dett svg {
		translate: 0.3rem 0;
	}
	.mosaico:not(.is-trascinando) .tessera:hover .tessera__presa {
		opacity: 1;
	}
}

/* Sollevata da tastiera. */
.cella.is-sollevata .tessera {
	box-shadow: 0 1rem 2.5rem rgb(0 0 0 / 0.55);
	scale: 1.015;
}

/* Il posto che la foto afferrata sta per occupare: cornice tratteggiata col numero della posizione. */
.cella.is-segnaposto .tessera {
	visibility: hidden;
}
.cella.is-segnaposto::before {
	content: attr(data-pos);
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	border: 2px dashed var(--accent);
	border-radius: 0.6rem;
	background: rgb(255 59 48 / 0.07);
	color: var(--accent);
	font-family: var(--font-display);
	font-weight: 700;
	font-size: clamp(1.4rem, 28cqh, 4.5rem);
	font-variant-numeric: tabular-nums;
}

/* La copia che segue il puntatore. */
.fantasma {
	position: fixed;
	left: 0;
	top: 0;
	z-index: 50;
	margin: 0;
	container-type: size;
	border-radius: 0.6rem;
	overflow: hidden;
	box-shadow: 0 0 0 2px var(--accent), 0 1.5rem 3.5rem rgb(0 0 0 / 0.6);
	pointer-events: none;
}
/* In mano basta il nome: la riga del fotografo è per il passaggio del mouse. */
.fantasma .tessera__dett {
	display: none;
}
.fantasma .tessera__testi {
	translate: none;
}
html.sta-trascinando,
html.sta-trascinando * {
	cursor: grabbing !important;
	user-select: none;
	-webkit-user-select: none;
}

/* ───────── Proiezione ───────── */
.proiezione {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	overflow: hidden;
	background: #000;
	color: var(--text);
}
html:has(.proiezione[open]) {
	overflow: hidden; /* con la proiezione aperta la pagina dietro non scorre */
}
.proiezione {
	touch-action: pan-y; /* lo swipe orizzontale lo gestisce lo script */
}
.proiezione:focus {
	outline: none; /* il focus iniziale sta sul dialog, non sul pulsante Chiudi: niente anello per chi usa il mouse */
}
.proiezione::backdrop {
	background: #000;
}
/* Luce ambiente: la stessa foto, grande e molto sfocata, cambia colore a ogni animale. */
.p-ambiente {
	position: absolute;
	inset: -12%;
	overflow: hidden;
}
.p-ambiente img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	filter: blur(56px) saturate(1.35) brightness(0.55);
}
.p-scena {
	position: absolute;
	inset: 4.5rem 5.5rem 7rem;
	margin: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}
.p-scena img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	border-radius: 0.5rem;
	box-shadow: 0 2rem 5rem rgb(0 0 0 / 0.5);
}

.p-chiudi,
.p-freccia {
	position: absolute;
	z-index: 3;
	border: 1px solid rgb(255 255 255 / 0.22);
	background: rgb(0 0 0 / 0.45);
	color: #fff;
	cursor: pointer;
	transition: scale 0.15s var(--ease-out), background-color 0.2s var(--ease-out);
}
.p-chiudi:active,
.p-freccia:active {
	scale: 0.95;
}
@media (hover: hover) and (pointer: fine) {
	.p-chiudi:hover,
	.p-freccia:hover {
		background: rgb(0 0 0 / 0.75);
	}
}
.p-chiudi {
	top: 1rem;
	right: 1rem;
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.6rem 1.05rem;
	border-radius: 99px;
	font: 600 0.85rem var(--font-text);
}
.p-freccia {
	top: 50%;
	display: grid;
	place-items: center;
	width: 3rem;
	height: 3rem;
	padding: 0;
	border-radius: 50%;
	translate: 0 -50%;
}
.p-freccia--prec {
	left: 1.25rem;
}
.p-freccia--succ {
	right: 1.25rem;
}
.p-freccia:active {
	scale: 0.95;
}

.p-barra {
	position: absolute;
	inset: auto 0 0;
	z-index: 2;
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 1.5rem;
	padding: 3rem clamp(1.25rem, 4vw, 3rem) 1.5rem;
	background: linear-gradient(transparent, rgb(0 0 0 / 0.72));
	pointer-events: none;
}
.p-barra a {
	pointer-events: auto;
}
.p-vetrina {
	display: inline-block;
	margin-bottom: 0.55rem;
	padding: 0.18rem 0.6rem;
	border-radius: 99px;
	background: var(--accent-strong);
	font-size: 0.66rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}
.p-vetrina[hidden] {
	display: none;
}
.p-testi h2 {
	font-size: clamp(1.6rem, 3.4vw, 2.6rem);
	line-height: 1.05;
	letter-spacing: -0.02em;
}
.p-luogo {
	margin-top: 0.4rem;
	font-size: 0.9rem;
	color: rgb(255 255 255 / 0.85);
}
.p-luogo:empty {
	display: none;
}
.p-credito {
	margin-top: 0.3rem;
	font-size: 0.82rem;
	color: rgb(255 255 255 / 0.7);
}
.p-credito a {
	color: #fff;
	text-underline-offset: 0.2em;
}
.p-pos {
	flex: none;
	font-size: 0.85rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	font-variant-numeric: tabular-nums;
	color: rgb(255 255 255 / 0.85);
}

/* ───────── Schermi stretti ───────── */
@media (max-width: 56rem) {
	.app {
		grid-template-columns: minmax(0, 1fr);
		gap: 1.5rem;
	}
	.pannello {
		position: static;
		padding-top: 0.25rem;
	}
	.pannello h1 {
		font-size: clamp(1.8rem, 7vw, 2.4rem);
	}
	.lead {
		margin-top: 0.75rem;
	}
	.comandi {
		margin-top: 1.1rem;
	}
	.aiuto {
		margin-top: 1.1rem;
		padding-top: 1rem;
	}
	.mosaico-wrap {
		width: 100%;
	}
	.p-scena {
		inset: 4rem 1rem 7.5rem;
	}
	/* Frecce in basso a destra: non coprono la foto. */
	.p-freccia {
		top: auto;
		bottom: 1.25rem;
		translate: none;
	}
	.p-freccia--prec {
		left: auto;
		right: 4.75rem;
	}
	.p-freccia--succ {
		right: 1rem;
	}
	.p-barra {
		padding-right: 9rem;
	}
	.p-pos {
		display: none;
	}
}
