/* Tomasi – Lightbox Garanzia Legale
   L’immagine sta tutta visibile: max larghezza = schermo,
   se è troppo alta viene ridotta proporzionalmente. */

.tomasi-gl-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.tomasi-gl-overlay {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0.75rem;
	box-sizing: border-box;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.25s ease, visibility 0.25s ease;
}

.tomasi-gl-overlay.is-open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.tomasi-gl-overlay[hidden] {
	display: none !important;
}

.tomasi-gl-overlay.is-open[hidden] {
	display: flex !important;
}

.tomasi-gl-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.72);
	cursor: pointer;
}

.tomasi-gl-dialog {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	width: fit-content;
	max-width: 100%;
	max-height: 100%;
	background: #fff;
	border-radius: 4px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
	overflow: hidden;
	transform: translateY(12px) scale(0.98);
	transition: transform 0.25s ease;
}

.tomasi-gl-overlay.is-open .tomasi-gl-dialog {
	transform: translateY(0) scale(1);
}

.tomasi-gl-close {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: #000;
	color: #fff;
	line-height: 0;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
	transition: background 0.15s ease, transform 0.15s ease;
}

.tomasi-gl-close-icon {
	display: block;
	width: 1rem;
	height: 1rem;
	flex-shrink: 0;
}

.tomasi-gl-close:hover,
.tomasi-gl-close:focus-visible {
	background: #111;
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.tomasi-gl-close:active {
	transform: scale(0.96);
}

.tomasi-gl-content {
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	max-width: 100%;
	max-height: 100%;
	padding: 0;
	background: #fff;
}

/* Contiene l’immagine intera nello spazio disponibile (niente scroll) */
.tomasi-gl-image {
	display: block;
	width: auto;
	height: auto;
	max-width: min(100vw - 1.5rem, 720px);
	max-height: calc(100vh - 1.5rem);
	max-height: calc(100dvh - 1.5rem);
	object-fit: contain;
}

html.tomasi-gl-open,
html.tomasi-gl-open body {
	overflow: hidden;
}

html.tomasi-gl-open body {
	touch-action: none;
}

@media (max-width: 767px) {
	.tomasi-gl-overlay {
		padding: 0.5rem;
		padding:
			max(0.5rem, env(safe-area-inset-top, 0px))
			max(0.5rem, env(safe-area-inset-right, 0px))
			max(0.5rem, env(safe-area-inset-bottom, 0px))
			max(0.5rem, env(safe-area-inset-left, 0px));
	}

	.tomasi-gl-dialog {
		width: 100%;
		max-width: 100%;
		border-radius: 2px;
	}

	.tomasi-gl-image {
		width: 100%;
		max-width: 100%;
		height: auto;
		max-height: calc(100vh - 1rem);
		max-height: calc(100dvh - 1rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
	}

	.tomasi-gl-close {
		top: 0.4rem;
		right: 0.4rem;
		width: 2.75rem;
		height: 2.75rem;
	}

	.tomasi-gl-close-icon {
		width: 1rem;
		height: 1rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tomasi-gl-overlay,
	.tomasi-gl-dialog,
	.tomasi-gl-close {
		transition: none;
	}
}
