/*!
 * Torn Gallery (CSS)
 * Concept: foto a carta strappata / Polaroid fluttuanti, gallerie annidate, lightbox a dissolvenza.
 * Copyright (c) carnevalionline - https://www.carnevalionline.com
 * Tutti i diritti riservati. All rights reserved.
 */
.tg-root {
	position: relative;
	display: block;
	box-sizing: border-box;
	isolation: isolate;
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}
/* fallback senza JS: a tutta larghezza; il JS rifinisce la misura */
.tg-root.tg-full {
	width: 100vw;
	margin-left: calc(50% - 50vw);
}
/* dentro editor/page builder: niente "a tutta larghezza" forzata */
.tg-root.tg-noflush { width: auto; margin-left: 0; }
/* vista gallerie: un'unica schermata fissa */
.tg-root.tg-fixed {
	height: var(--tg-h, 88vh);
	min-height: 420px;
	overflow: hidden;
}
.tg-root.tg-fixed .tg-stage { position: absolute; inset: 0; }
.tg-root.tg-fixed .tg-field { height: 100%; }
/* vista foto: pagina che scorre, una schermata dopo l'altra */
.tg-root.tg-scroll .tg-stage { position: relative; }
.tg-field {
	position: relative;
	overflow: hidden;
	height: var(--tg-h, 88vh);
	min-height: 420px;
}
.tg-sentinel { height: 1px; width: 100%; }

/* ---- foto ---- */
.tg-root button.tg-item {
	position: absolute;
	left: 0;
	top: 0;
	display: block;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
	cursor: pointer;
	touch-action: pan-y;
	transform-origin: 50% 50%;
	will-change: transform;
	-webkit-touch-callout: none;
	/* ombra che segue il bordo strappato e cade sulle foto coperte */
	filter: drop-shadow(0 9px 12px rgba(0, 0, 0, .42)) drop-shadow(0 2px 3px rgba(0, 0, 0, .38));
}
.tg-root button.tg-item.is-drag { cursor: grabbing; }
.tg-root button.tg-item:focus-visible {
	outline: 2px dashed rgba(255, 255, 255, .9);
	outline-offset: 6px;
}
.tg-inner {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	opacity: 0;
	transition: opacity .7s ease;
}
.tg-inner.is-ready { opacity: 1; }
.tg-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	pointer-events: none;
	-webkit-user-drag: none;
}
.tg-shade {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 46%;
	background: linear-gradient(to top, rgba(0, 0, 0, .62), rgba(0, 0, 0, 0));
	pointer-events: none;
}
.tg-label {
	position: absolute;
	left: 9%;
	right: 9%;
	bottom: 8%;
	color: #fff;
	text-align: left;
	line-height: 1.2;
	text-shadow: 0 1px 8px rgba(0, 0, 0, .7);
	pointer-events: none;
	font-family: inherit;
}
.tg-label strong {
	display: block;
	font-weight: 600;
	font-size: clamp(.78rem, 1.05vw, 1.05rem);
	letter-spacing: .02em;
}
.tg-label em {
	display: block;
	font-style: normal;
	font-size: .78em;
	opacity: .8;
	margin-top: 2px;
}
.tg-item.tg-sm .tg-label,
.tg-item.tg-sm .tg-shade { display: none; }

/* ---- stile Polaroid ---- */
.tg-item.tg-pol .tg-inner {
	background: linear-gradient(160deg, #fdfcf8 0%, #f6f3ea 100%);
	border-radius: 2px;
}
.tg-item.tg-pol .tg-img {
	position: absolute;
	left: var(--p, 8px);
	top: var(--p, 8px);
}
.tg-item.tg-pol .tg-pol-in {
	position: absolute;
	left: var(--p, 8px);
	top: var(--p, 8px);
	right: var(--p, 8px);
	bottom: calc(var(--p, 8px) * 4);
	box-shadow: inset 0 0 8px rgba(0, 0, 0, .4), inset 0 0 0 1px rgba(0, 0, 0, .12);
	pointer-events: none;
}
.tg-item.tg-pol .tg-shade { display: none; }
.tg-item.tg-pol .tg-label {
	left: var(--p, 8px);
	right: var(--p, 8px);
	bottom: 0;
	height: calc(var(--p, 8px) * 4);
	display: flex;
	flex-direction: column;
	justify-content: center;
	color: #2b2b2b;
	text-shadow: none;
	font-family: "Segoe Print", "Bradley Hand", "Marker Felt", "Comic Neue", cursive;
}
.tg-item.tg-pol .tg-label strong { font-weight: 400; font-size: clamp(.72rem, .95vw, .98rem); }
.tg-item.tg-pol .tg-label em { opacity: .6; font-size: .72em; }

/* ---- transizioni tra vista gallerie e vista foto ---- */
.tg-stage.tg-leave .tg-item {
	opacity: 0;
	transition: opacity .35s ease;
}
.tg-field.tg-appear .tg-item,
.tg-stage.tg-enter .tg-item {
	animation: tg-in .9s ease both;
	animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes tg-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

/* ---- barra titolo / indietro (resta visibile mentre si scorre) ---- */
.tg-bar {
	position: sticky;
	top: var(--tg-sticky, 14px);
	z-index: 5000;
	height: 0;
	margin: 0 0 0 14px;
	overflow: visible;
}
.tg-bar[hidden] { display: none; }
.tg-pill {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	max-width: calc(100vw - 40px);
	padding: 6px 16px 6px 6px;
	border-radius: 999px;
	background: rgba(15, 15, 18, .55);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	color: #fff;
	font: 500 .9rem/1 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.tg-bar.tg-solo .tg-pill { padding-left: 16px; }
.tg-root button.tg-back {
	-webkit-appearance: none;
	appearance: none;
	border: 0;
	border-radius: 999px;
	background: rgba(255, 255, 255, .14);
	color: #fff;
	padding: 9px 14px;
	font: inherit;
	cursor: pointer;
	white-space: nowrap;
	transition: background .2s;
}
.tg-root button.tg-back[hidden] { display: none; }
.tg-root button.tg-back:hover,
.tg-root button.tg-back:focus-visible { background: rgba(255, 255, 255, .28); }
.tg-bar-title {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ---- lightbox ---- */
html.tg-lock { overflow: hidden; }
.tg-lb {
	position: fixed;
	inset: 0;
	z-index: 999999;
	opacity: 0;
	transition: opacity .45s ease;
	-webkit-user-select: none;
	user-select: none;
}
.tg-lb.is-open { opacity: 1; }
.tg-lb-bg {
	position: absolute;
	inset: 0;
	background: rgba(8, 8, 10, .94);
}
.tg-lb-stage {
	position: absolute;
	inset: 0;
	touch-action: pan-y;
}
.tg-lb-img {
	position: absolute;
	left: 50%;
	top: 50%;
	max-width: 92vw;
	max-height: 84vh;
	width: auto;
	height: auto;
	opacity: 0;
	z-index: 1;
	transform: translate(-50%, -50%) scale(.96);
	transition: opacity .8s ease, transform 1.1s ease;
	-webkit-user-drag: none;
}
.tg-lb-img.is-on {
	opacity: 1;
	z-index: 2;
	transform: translate(-50%, -50%) scale(1);
}
.tg-lb .tg-lb-btn {
	position: absolute;
	z-index: 5;
	-webkit-appearance: none;
	appearance: none;
	width: 48px;
	height: 48px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .08);
	color: #fff;
	font: 300 30px/48px system-ui, sans-serif;
	text-align: center;
	cursor: pointer;
	transition: background .2s;
}
.tg-lb .tg-lb-btn:hover,
.tg-lb .tg-lb-btn:focus-visible { background: rgba(255, 255, 255, .24); }
.tg-lb .tg-lb-btn[hidden] { display: none; }
.tg-lb-close { top: 16px; right: 16px; }
.tg-lb-prev  { left: 16px;  top: 50%; margin-top: -24px !important; }
.tg-lb-next  { right: 16px; top: 50%; margin-top: -24px !important; }
.tg-lb-cap {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 4;
	padding: 14px 72px 20px;
	text-align: center;
	color: #e6e6e6;
	font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
	pointer-events: none;
}
.tg-lb-count { opacity: .65; margin-right: 10px; letter-spacing: .06em; }

/* lightbox in stile Polaroid: cornice bianca attorno alla foto */
.tg-lb-polaroid .tg-lb-img {
	box-sizing: content-box;
	border: 14px solid #fbfaf6;
	border-bottom-width: 46px;
	max-width: calc(92vw - 28px);
	max-height: calc(84vh - 60px);
	box-shadow: 0 14px 40px rgba(0, 0, 0, .55);
}

@media (max-width: 640px) {
	.tg-lb .tg-lb-prev, .tg-lb .tg-lb-next { width: 40px; height: 40px; line-height: 40px; margin-top: -20px !important; background: rgba(0, 0, 0, .35); }
	.tg-lb-cap { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
	.tg-field.tg-appear .tg-item,
	.tg-stage.tg-enter .tg-item { animation: none; }
	.tg-lb-img { transition-duration: .01s; }
}
