/* ==========================================================================
   DETTAGLIO LAVORO — Gallery moderna (grid desktop, carousel mobile) + Lightbox
   ========================================================================== */

.project-gallery {
	position: relative;
}

/* ==========================================================================
   TRACK — desktop: scroll-snap orizzontale; mobile: grid con tutte le foto
   ========================================================================== */
.project-gallery__track {
	position: relative;              /* offsetParent per i button interni */
	display: flex;
	gap: 14px;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;        /* Firefox */
	-ms-overflow-style: none;     /* IE/Edge legacy */
	padding: 4px 4px 10px;
	scroll-padding-inline: 4px;
}
.project-gallery__track::-webkit-scrollbar {
	display: none;              /* Chrome/Safari */
}

/* ==========================================================================
   ITEM (bottone cliccabile) — altezza uniforme, larghezza auto su misura
   dell'immagine. Contiene l'overlay in position:absolute.
   ========================================================================== */
.project-gallery__item {
	position: relative;
	display: inline-flex;
	flex: 0 0 auto;
	height: 460px;
	width: auto;
	scroll-snap-align: start;
	padding: 0;
	margin: 0;
	border: 0;
	background: transparent;
	cursor: zoom-in;
	overflow: hidden;
	border-radius: 0;
	transition: transform 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

@media (max-width: 1400px) {
	.project-gallery__item { height: 400px; }
}
@media (max-width: 1199px) {
	.project-gallery__item { height: 340px; }
}

.project-gallery__item:focus-visible {
	outline: 2px solid #dc7518;
	outline-offset: 3px;
}

/* Immagine: altezza uguale al contenitore, larghezza proporzionale (no crop) */
.project-gallery__image {
	display: block;
	height: 100%;
	width: auto;
	border: 0;
	padding: 0;
	margin: 0;
	transition: transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Overlay hover con icona expand (ripristinato) */
.project-gallery__overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(180deg, rgba(16, 16, 16, 0) 0%, rgba(16, 16, 16, 0.35) 100%);
	color: #ffffff;
	opacity: 0;
	transition: opacity 280ms cubic-bezier(0.22, 1, 0.36, 1);
	pointer-events: none;
}

.project-gallery__overlay svg {
	padding: 14px;
	background: rgba(220, 117, 24, 0.95);
	border-radius: 50%;
	box-sizing: content-box;
	transform: scale(0.8);
	transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.project-gallery__item:hover .project-gallery__overlay,
.project-gallery__item:focus-visible .project-gallery__overlay {
	opacity: 1;
}
.project-gallery__item:hover .project-gallery__overlay svg,
.project-gallery__item:focus-visible .project-gallery__overlay svg {
	transform: scale(1);
}
.project-gallery__item:hover .project-gallery__image {
	transform: scale(1.04);
}

/* ==========================================================================
   CONTROLLI (counter + frecce) — visibili solo su desktop (il carosello è lì)
   ========================================================================== */
.project-gallery__controls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 16px;
	margin-top: 18px;
}

.project-gallery__arrow {
	border: 0;
	background: transparent;
	padding: 0;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: transform 240ms ease, opacity 240ms ease;
	line-height: 0;
}
.project-gallery__arrow svg {
	display: block;
	width: 44px;
	height: 44px;
	pointer-events: none;
}
.project-gallery__arrow:hover:not(:disabled) {
	transform: translateY(-1px) scale(1.08);
}
.project-gallery__arrow:focus-visible {
	outline: 2px solid #dc7518;
	outline-offset: 4px;
	border-radius: 50%;
}
.project-gallery__arrow:disabled {
	opacity: 0.35;
	cursor: default;
	transform: none;
}

.project-gallery__counter {
	font-size: 13px;
	font-weight: 600;
	color: #5c5c5c;
	min-width: 64px;
	text-align: center;
	letter-spacing: 0.5px;
}

/* ==========================================================================
   RESPONSIVE — mobile: grid con tutte le foto visibili, no crop
   ========================================================================== */
@media (max-width: 767px) {
	.project-gallery__track {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		gap: 10px;
		overflow: visible;
		scroll-snap-type: none;
		padding: 0;
	}

	.project-gallery__item {
		height: auto;
		width: 100%;
		scroll-snap-align: none;
	}

	.project-gallery__image {
		width: 100%;
		height: auto;
	}

	.project-gallery__controls {
		display: none;
	}
}

@media (max-width: 420px) {
	.project-gallery__track {
		grid-template-columns: 1fr;
	}
}

/* ==========================================================================
   LIGHTBOX — overlay fullscreen elegante
   ========================================================================== */
.project-lightbox {
	position: fixed;
	inset: 0;
	z-index: 10000;
	background: rgba(8, 8, 8, 0.92);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	visibility: hidden;
	transition: opacity 320ms cubic-bezier(0.22, 1, 0.36, 1);
	overscroll-behavior: contain;
}

.project-lightbox[hidden] {
	display: none;
}

.project-lightbox.is-open {
	opacity: 1;
	visibility: visible;
}

.project-lightbox__figure {
	position: relative;
	margin: 0;
	max-width: min(94vw, 1600px);
	max-height: 88vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	transform: scale(0.96);
	opacity: 0;
	transition:
		transform 420ms cubic-bezier(0.22, 1, 0.36, 1),
		opacity 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.project-lightbox.is-open .project-lightbox__figure {
	transform: scale(1);
	opacity: 1;
}

.project-lightbox__image {
	display: block;
	max-width: 100%;
	max-height: 80vh;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 4px;
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
	user-select: none;
	-webkit-user-drag: none;
}

.project-lightbox__caption {
	color: rgba(255, 255, 255, 0.72);
	font-size: 13px;
	font-weight: 500;
	text-align: center;
	letter-spacing: 0.3px;
	padding: 0 20px;
}

/* Counter top-center */
.project-lightbox__counter {
	position: absolute;
	top: 20px;
	left: 50%;
	transform: translateX(-50%);
	color: rgba(255, 255, 255, 0.88);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 1px;
	padding: 8px 16px;
	background: rgba(255, 255, 255, 0.08);
	border-radius: 999px;
	backdrop-filter: blur(8px);
}

/* Close */
.project-lightbox__close {
	position: absolute;
	top: 20px;
	right: 20px;
	width: 44px;
	height: 44px;
	border: 0;
	background: rgba(255, 255, 255, 0.1);
	color: #ffffff;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 240ms ease, transform 240ms ease;
	backdrop-filter: blur(8px);
}
.project-lightbox__close:hover,
.project-lightbox__close:focus-visible {
	background: #dc7518;
	outline: none;
	transform: rotate(90deg);
}

/* Frecce laterali */
.project-lightbox__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 52px;
	height: 52px;
	border: 0;
	background: rgba(255, 255, 255, 0.1);
	color: #ffffff;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 240ms ease, transform 240ms ease;
	backdrop-filter: blur(8px);
}
.project-lightbox__nav--prev { left: 24px; }
.project-lightbox__nav--next { right: 24px; }

.project-lightbox__nav:hover,
.project-lightbox__nav:focus-visible {
	background: #dc7518;
	outline: none;
}
.project-lightbox__nav--prev:hover,
.project-lightbox__nav--prev:focus-visible {
	transform: translateY(-50%) translateX(-3px);
}
.project-lightbox__nav--next:hover,
.project-lightbox__nav--next:focus-visible {
	transform: translateY(-50%) translateX(3px);
}

/* Responsive lightbox — mobile */
@media (max-width: 767px) {
	.project-lightbox__nav {
		width: 44px;
		height: 44px;
	}
	.project-lightbox__nav--prev { left: 12px; }
	.project-lightbox__nav--next { right: 12px; }
	.project-lightbox__close {
		width: 40px;
		height: 40px;
		top: 14px;
		right: 14px;
	}
	.project-lightbox__counter {
		top: 14px;
		font-size: 12px;
		padding: 6px 12px;
	}
	.project-lightbox__image {
		max-height: 72vh;
	}
	.project-lightbox__caption {
		font-size: 12px;
	}
}

/* Blocca lo scroll del body quando il lightbox è aperto */
body.project-lightbox-open {
	overflow: hidden;
}

/* Rispetto prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
	.project-gallery__item,
	.project-gallery__thumb img,
	.project-gallery__overlay,
	.project-gallery__overlay svg,
	.project-gallery__arrow,
	.project-lightbox,
	.project-lightbox__figure,
	.project-lightbox__close,
	.project-lightbox__nav {
		transition: none !important;
	}
}
