/* FTCD Core - Gallerie. Colori dal tema se presenti (--primary, --secondary). */
.ftcd-gallery,
.ftcd-gallery-list,
.ftcd-gallery-embed,
.ftcd-lb {
	--ftcd-g-primary: var(--primary, #223146);
	--ftcd-g-accent: var(--secondary, #b20e10);
	--ftcd-g-gap: clamp(6px, 1.2vw, 16px);
	--ftcd-g-radius: 10px;
}

/* Griglia */
.ftcd-gallery { margin: 1.25rem 0 0; }
.ftcd-gallery__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--ftcd-g-gap);
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
}
.ftcd-gallery--full .ftcd-gallery__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .ftcd-gallery--full .ftcd-gallery__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .ftcd-gallery--full .ftcd-gallery__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1600px) { .ftcd-gallery--full .ftcd-gallery__grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 768px) { .ftcd-gallery--preview .ftcd-gallery__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.ftcd-gallery__item { margin: 0 !important; padding: 0 !important; min-width: 0; }
.ftcd-gallery__link {
	position: relative;
	display: block;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: var(--ftcd-g-radius);
	background: #e9edf2;
	outline-offset: 3px;
	-webkit-tap-highlight-color: transparent;
}
.ftcd-gallery__img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	object-fit: cover;
	transition: transform .4s ease, filter .4s ease;
}
@media (hover: hover) {
	.ftcd-gallery__link:hover .ftcd-gallery__img { transform: scale(1.04); }
}
.ftcd-gallery__link:focus-visible { outline: 3px solid var(--ftcd-g-accent); }
.ftcd-gallery__more {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(34, 49, 70, .62);
	color: #fff;
	font-size: clamp(1.4rem, 3vw, 2.2rem);
	font-weight: 600;
}

/* Pulsanti e azioni */
.ftcd-gallery-actions { display: flex; flex-wrap: wrap; gap: 10px 14px; margin: 1.25rem 0 0 !important; }
.ftcd-gallery-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 12px 26px;
	border: 2px solid var(--ftcd-g-accent);
	border-radius: 999px;
	background: var(--ftcd-g-accent);
	color: #fff !important;
	font-weight: 600;
	font-size: 1rem;
	line-height: 1.2;
	text-decoration: none !important;
	text-align: center;
	transition: background .25s, color .25s, border-color .25s;
}
.ftcd-gallery-btn:hover,
.ftcd-gallery-btn:focus-visible { background: var(--ftcd-g-primary); border-color: var(--ftcd-g-primary); }
.ftcd-gallery-btn--ghost { background: transparent; color: var(--ftcd-g-accent) !important; }
.ftcd-gallery-btn--ghost:hover,
.ftcd-gallery-btn--ghost:focus-visible { color: #fff !important; }
@media (max-width: 479px) { .ftcd-gallery-actions .ftcd-gallery-btn { flex: 1 1 100%; } }

/* Elenco eventi (pagina Galleria) */
.ftcd-gallery-list { display: grid; gap: clamp(2.5rem, 6vw, 4.5rem); scroll-margin-top: 130px; }
.ftcd-gallery-item__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1.5rem; }
.ftcd-gallery-item__title { margin: 0 !important; font-size: clamp(1.35rem, 2.6vw, 2rem) !important; line-height: 1.25 !important; }
.ftcd-gallery-item__title a { color: var(--ftcd-g-primary); text-decoration: none; }
.ftcd-gallery-item__title a:hover { color: var(--ftcd-g-accent); }
.ftcd-gallery-item__meta { margin: 0 !important; font-size: .95rem !important; line-height: 1.4 !important; color: #5a6472 !important; }

.ftcd-gallery-filter ul,
.ftcd-gallery-pagination ul { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 !important; padding: 0 !important; list-style: none !important; }
.ftcd-gallery-filter li,
.ftcd-gallery-pagination li { margin: 0 !important; }
.ftcd-gallery-filter a,
.ftcd-gallery-pagination a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	min-width: 44px;
	justify-content: center;
	padding: 8px 18px;
	border: 1px solid #c9d1db;
	border-radius: 999px;
	color: var(--ftcd-g-primary);
	text-decoration: none;
	font-size: 1rem;
}
.ftcd-gallery-filter a[aria-current],
.ftcd-gallery-pagination a[aria-current] { background: var(--ftcd-g-primary); border-color: var(--ftcd-g-primary); color: #fff; }
.ftcd-gallery-filter a:hover,
.ftcd-gallery-pagination a:hover { border-color: var(--ftcd-g-primary); }
@media (max-width: 639px) {
	.ftcd-gallery-filter ul { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px !important; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
	.ftcd-gallery-filter li { flex: 0 0 auto; scroll-snap-align: start; }
}
.ftcd-gallery-pagination ul { justify-content: center; }

/* Galleria dentro l'articolo */
.ftcd-gallery-embed { margin: clamp(2rem, 5vw, 3rem) 0 0; }
.ftcd-gallery-embed__title { margin: 0 !important; font-size: clamp(1.4rem, 2.6vw, 1.9rem) !important; line-height: 1.3 !important; }

.ftcd-gallery-list .screen-reader-text,
.ftcd-gallery-embed .screen-reader-text,
.ftcd-lb .screen-reader-text {
	position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Lightbox */
html.ftcd-lb-open { overflow: hidden; }
.ftcd-lb {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: grid;
	grid-template-rows: auto 1fr auto;
	background: #0c121c;
	color: #fff;
	opacity: 0;
	transition: opacity .2s ease;
	padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
	touch-action: pan-y pinch-zoom;
}
.ftcd-lb[hidden] { display: none; }
.ftcd-lb.is-visible { opacity: 1; }
.ftcd-lb__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px clamp(10px, 2vw, 24px); min-height: 60px; }
.ftcd-lb__count { font-size: .95rem; opacity: .85; font-variant-numeric: tabular-nums; }
.ftcd-lb__stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 0 clamp(8px, 6vw, 96px); }
.ftcd-lb__img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	user-select: none;
	-webkit-user-drag: none;
	transition: opacity .2s ease, transform .2s ease;
}
.ftcd-lb__img.is-loading { opacity: 0; }
.ftcd-lb__caption { min-height: 48px; margin: 0 !important; padding: 10px clamp(12px, 4vw, 48px) 16px; text-align: center; font-size: .95rem !important; line-height: 1.45 !important; color: #e8ecf1 !important; }
.ftcd-lb__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	cursor: pointer;
	transition: background .2s;
}
.ftcd-lb__btn:hover,
.ftcd-lb__btn:focus-visible { background: rgba(255, 255, 255, .26); }
.ftcd-lb__btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.ftcd-lb__btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ftcd-lb__nav { position: absolute; top: 50%; transform: translateY(-50%); }
.ftcd-lb__prev { left: clamp(6px, 1.5vw, 24px); }
.ftcd-lb__next { right: clamp(6px, 1.5vw, 24px); }
@media (max-width: 639px) {
	.ftcd-lb__stage { padding: 0; }
	.ftcd-lb__nav { top: auto; bottom: 8px; transform: none; background: rgba(0, 0, 0, .45); }
}
@media (prefers-reduced-motion: reduce) {
	.ftcd-gallery__img, .ftcd-lb, .ftcd-lb__img { transition: none !important; }
}
