/* =========================================================
   TVD Galerie – Variante B: Aufmacher (16:9) + 2 Spalten
   Greift nur, wenn das Script die Klasse .tvd-gallery gesetzt
   hat. Ohne JavaScript bleibt die bisherige Theme-Darstellung.
   ========================================================= */

/* ---------- Raster ---------- */
.ngg-galleryoverview.tvd-gallery {
	display: grid !important;
	grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
	gap: 14px !important;
}

/* Aufmacher und einzelnes letztes Bild über die volle Breite */
.tvd-gallery > .tvd-lead,
.tvd-gallery > .tvd-wide {
	grid-column: 1 / -1;
}
.tvd-gallery > .tvd-lead .ngg-gallery-thumbnail img,
.tvd-gallery > .tvd-wide .ngg-gallery-thumbnail img {
	aspect-ratio: 16 / 9 !important;
}
.tvd-gallery > .tvd-lead .ngg-gallery-thumbnail img {
	object-position: 50% 40%;
}

/* Hochformate: Ausschnitt nach oben, damit Köpfe sichtbar bleiben */
.tvd-gallery > .tvd-portrait .ngg-gallery-thumbnail img {
	object-position: 50% 18% !important;
}

/* Kachel: Verlauf, Bildnummer, Lupe */
.tvd-gallery .ngg-gallery-thumbnail a {
	position: relative;
	overflow: hidden;
	border-radius: var(--radius, 14px);
	background: rgba(42, 15, 34, .12);
}
.tvd-gallery .ngg-gallery-thumbnail a:focus-visible {
	outline: 3px solid var(--plum, #6e1f4d);
	outline-offset: 3px;
}
.tvd-gallery .ngg-gallery-thumbnail a::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(to top, rgba(0, 0, 0, .6), transparent 45%);
	opacity: 0;
	transition: opacity .3s;
	pointer-events: none;
}
.tvd-gallery .tvd-num,
.tvd-gallery .tvd-zoom {
	position: absolute;
	z-index: 1;
	opacity: 0;
	transition: opacity .3s, transform .3s;
	pointer-events: none;
}
.tvd-gallery .tvd-num {
	left: 12px;
	bottom: 10px;
	color: #fff;
	font-size: 13px;
	font-weight: 700;
}
.tvd-gallery .tvd-zoom {
	right: 12px;
	bottom: 12px;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .95);
	color: #2a0f22;
	display: grid;
	place-items: center;
	transform: translateY(6px);
}
.tvd-gallery .ngg-gallery-thumbnail a:hover::after,
.tvd-gallery .ngg-gallery-thumbnail a:focus-visible::after,
.tvd-gallery .ngg-gallery-thumbnail a:hover .tvd-num,
.tvd-gallery .ngg-gallery-thumbnail a:focus-visible .tvd-num,
.tvd-gallery .ngg-gallery-thumbnail a:hover .tvd-zoom,
.tvd-gallery .ngg-gallery-thumbnail a:focus-visible .tvd-zoom {
	opacity: 1;
	transform: none;
}

/* „[Zeige eine Slideshow]“ übernimmt jetzt das Pop-up */
.tvd-gallery > .slideshowlink {
	display: none !important;
}

@media (max-width: 520px) {
	.ngg-galleryoverview.tvd-gallery { gap: 8px !important; }
	.tvd-gallery .tvd-zoom { display: none; }
}

/* ---------- Vollbild-Pop-up ---------- */
.tvd-lb {
	position: fixed;
	inset: 0;
	z-index: 2147483000; /* über Cookie-Banner & Header */
	display: none;
	grid-template-rows: auto minmax(0, 1fr) auto auto;
	background: rgba(13, 5, 9, .96);
	color: #fff;
	font-family: inherit;
	opacity: 0;
	transition: opacity .25s;
}
.tvd-lb.is-open { display: grid; }
.tvd-lb [hidden] { display: none !important; }
.tvd-lb.is-visible { opacity: 1; }

.tvd-lb__top {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px 16px;
	padding-top: max(12px, env(safe-area-inset-top));
}
.tvd-lb__count { font-weight: 700; letter-spacing: .04em; font-size: 15px; }

.tvd-lb__btn {
	appearance: none;
	border: 0;
	margin: 0;
	padding: 0;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	display: grid;
	place-items: center;
	cursor: pointer;
	transition: background .2s;
}
.tvd-lb__btn:hover,
.tvd-lb__btn:focus-visible { background: rgba(255, 255, 255, .25); }
.tvd-lb__btn:focus-visible { outline: 2px solid #efda37; outline-offset: 2px; }

.tvd-lb__stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
	padding: 0 68px;
	touch-action: pan-y;
}
.tvd-lb__img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 6px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
	transition: opacity .2s, transform .25s;
	user-select: none;
	-webkit-user-drag: none;
}
.tvd-lb__img.is-loading { opacity: 0; transform: scale(.98); }

.tvd-lb__prev,
.tvd-lb__next { position: absolute; top: 50%; transform: translateY(-50%); }
.tvd-lb__prev { left: 12px; }
.tvd-lb__next { right: 12px; }

.tvd-lb__cap {
	text-align: center;
	padding: 12px 16px 4px;
	font-size: 15px;
	line-height: 1.4;
	opacity: .9;
	min-height: 1.4em;
}

.tvd-lb__thumbs {
	position: relative;
	display: flex;
	gap: 6px;
	overflow-x: auto;
	padding: 8px 16px 16px;
	padding-bottom: max(16px, env(safe-area-inset-bottom));
	justify-content: safe center;
	scrollbar-width: thin;
}
.tvd-lb__thumbs button {
	flex: 0 0 auto;
	width: 64px;
	height: 44px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 6px;
	overflow: hidden;
	opacity: .5;
	cursor: pointer;
	background: #333;
}
.tvd-lb__thumbs button[aria-current="true"] { border-color: #efda37; opacity: 1; }
.tvd-lb__thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }

@media (max-width: 640px) {
	.tvd-lb__stage { padding: 0 8px; }
	.tvd-lb__prev,
	.tvd-lb__next { top: auto; bottom: -58px; transform: none; }
	.tvd-lb__cap { padding-left: 68px; padding-right: 68px; min-height: 52px; }
	.tvd-lb__thumbs { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.tvd-lb, .tvd-lb__img,
	.tvd-gallery .ngg-gallery-thumbnail a::after,
	.tvd-gallery .tvd-num, .tvd-gallery .tvd-zoom { transition: none !important; }
}
