/* Light-Style Bildergalerien – Frontend */

.lsbg {
	--cols: 3;
	--cols-m: 2;
	--gap: 6px;
	--radius: 0px;
	--aspect: 3/2;
	position: relative;
	box-sizing: border-box;
	margin-block: 1.5em;
	container-type: inline-size;
}
.lsbg *, .lsbg *::before, .lsbg *::after { box-sizing: border-box; }
.lsbg.alignleft, .lsbg.alignright { width: 50%; max-width: 50%; }
.lsbg.aligncenter { margin-inline: auto; }

.lsbg__inner { --c: var(--cols); }
@container (max-width: 600px) {
	.lsbg__inner { --c: var(--cols-m); }
}

.lsbg__item {
	position: relative;
	margin: 0 !important;
	padding: 0;
	min-width: 0;
}
.lsbg__link {
	display: block;
	position: relative;
	width: 100%;
	overflow: hidden;
	border-radius: var(--radius);
	background: rgba(127, 127, 127, .12);
	aspect-ratio: var(--box, var(--ar));
	color: inherit;
	text-decoration: none;
	-webkit-tap-highlight-color: transparent;
}
.lsbg__link[data-lsbg-full] { cursor: zoom-in; }
.lsbg__link:focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }
.lsbg__img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	border: 0;
	border-radius: 0 !important;
	object-fit: cover;
	transition: transform .6s cubic-bezier(.2, .7, .2, 1), filter .4s;
}
@media (hover: hover) {
	.lsbg:not(.lsbg--slideshow) .lsbg__item:hover .lsbg__img { transform: scale(1.035); }
}

/* --- Mosaik: Hoch- & Querformat in gleich hohen, bündigen Zeilen --- */
.lsbg--mosaic .lsbg__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: var(--gap);
	--rh: calc(100cqw / var(--c) / 1.6);
}
.lsbg--mosaic .lsbg__item { flex: var(--ar) 1 calc(var(--ar) * var(--rh)); }
.lsbg--mosaic .lsbg__inner::after { content: ""; flex: 1000 1 0px; }

/* --- Mauerwerk --- */
.lsbg--masonry .lsbg__inner { column-count: var(--c); column-gap: var(--gap); }
.lsbg--masonry .lsbg__item { break-inside: avoid; page-break-inside: avoid; margin-bottom: var(--gap) !important; display: block; }

/* --- Raster / Quadrate / Kreise / Hervorgehoben --- */
.lsbg--grid .lsbg__inner,
.lsbg--square .lsbg__inner,
.lsbg--circle .lsbg__inner,
.lsbg--featured .lsbg__inner {
	display: grid;
	grid-template-columns: repeat(var(--c), minmax(0, 1fr));
	gap: var(--gap);
}
.lsbg--grid { --box: var(--aspect); }
.lsbg--square, .lsbg--circle, .lsbg--featured { --box: 1; }
.lsbg--circle .lsbg__link { border-radius: 50%; }
.lsbg--circle .lsbg__caption { text-align: center; }
.lsbg--featured .lsbg__inner { grid-auto-flow: dense; }
.lsbg--featured .lsbg__item:first-child { grid-column: span 2; grid-row: span 2; }
.lsbg--featured .lsbg__item:first-child .lsbg__link { position: absolute; inset: 0; height: auto; aspect-ratio: auto; }
.lsbg--featured .lsbg__item:only-child { grid-row: auto; }
.lsbg--featured .lsbg__item:only-child .lsbg__link { position: relative; aspect-ratio: 1; }

/* --- Karussell --- */
.lsbg--carousel .lsbg__inner {
	display: flex;
	gap: var(--gap);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	--h: min(calc(100cqw / var(--c) / 1.1), 80vh);
}
.lsbg--carousel .lsbg__inner::-webkit-scrollbar { display: none; }
.lsbg--carousel .lsbg__item { flex: 0 0 auto; scroll-snap-align: start; }
.lsbg--carousel .lsbg__link { height: var(--h); width: auto; }

/* --- Diashow --- */
.lsbg--slideshow .lsbg__inner {
	position: relative;
	aspect-ratio: var(--aspect);
	overflow: hidden;
	border-radius: var(--radius);
	background: var(--lsbg-slide-bg, #111);
	touch-action: pan-y;
}
.lsbg--slideshow .lsbg__item {
	position: absolute;
	inset: 0;
	opacity: 0;
	visibility: hidden;
	transition: opacity .9s ease, visibility .9s, transform .7s cubic-bezier(.4, 0, .2, 1);
}
.lsbg--slideshow .lsbg__item.is-active { opacity: 1; visibility: visible; }
.lsbg--fx-slide .lsbg__item { opacity: 1; visibility: visible; }
.lsbg--slideshow .lsbg__link { height: 100%; aspect-ratio: auto; border-radius: 0; background: none; }
.lsbg--slideshow .lsbg__img { object-fit: contain; }

/* --- Navigation (Diashow / Karussell) --- */
.lsbg__nav {
	position: absolute;
	top: 50%;
	z-index: 3;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	margin-top: -22px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, .45);
	color: #fff;
	cursor: pointer;
	opacity: .85;
	transition: opacity .2s, background .2s;
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
}
.lsbg__nav:hover, .lsbg__nav:focus-visible { opacity: 1; background: rgba(0, 0, 0, .7); }
.lsbg__nav[disabled] { opacity: 0; pointer-events: none; }
.lsbg__nav--prev { left: 12px; }
.lsbg__nav--next { right: 12px; }
.lsbg--carousel .lsbg__nav { top: calc(var(--h) / 2); }
@media (hover: hover) {
	.lsbg--slideshow .lsbg__nav { opacity: 0; }
	.lsbg--slideshow:hover .lsbg__nav, .lsbg--slideshow:focus-within .lsbg__nav { opacity: .85; }
}
.lsbg__dots {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px;
	padding-top: 12px;
}
.lsbg__dot {
	width: 9px;
	height: 9px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: currentColor;
	opacity: .25;
	cursor: pointer;
	transition: opacity .2s, transform .2s;
}
.lsbg__dot.is-active { opacity: .85; transform: scale(1.25); }

/* --- Bildunterschriften --- */
.lsbg__caption { font-size: .85em; line-height: 1.4; }
.lsbg--cap-below .lsbg__caption { padding: .45em .15em .2em; opacity: .8; }
.lsbg--cap-hover .lsbg__caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 2;
	padding: 2em .9em .7em;
	border-radius: 0 0 var(--radius) var(--radius);
	background: linear-gradient(transparent, rgba(0, 0, 0, .7));
	color: #fff;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity .3s, transform .3s;
	pointer-events: none;
}
.lsbg--masonry.lsbg--cap-hover .lsbg__caption { bottom: var(--gap); }
.lsbg--cap-hover .lsbg__item:hover .lsbg__caption,
.lsbg--cap-hover .lsbg__item:focus-within .lsbg__caption { opacity: 1; transform: none; }
.lsbg--slideshow.lsbg--cap-hover .lsbg__caption { opacity: 1; transform: none; text-align: center; }
@media (hover: none) {
	.lsbg--cap-hover .lsbg__caption { opacity: 1; transform: none; }
}

/* --- Fallback für Jetpack-Markup ohne auffindbare Bild-IDs --- */
.lsbg-jp-fallback .tiled-gallery__row { display: flex; gap: 4px; }
.lsbg-jp-fallback .tiled-gallery__col { flex: 1 1 0; display: flex; flex-direction: column; gap: 4px; }
.lsbg-jp-fallback .tiled-gallery__item { margin: 0; }
.lsbg-jp-fallback img { display: block; width: 100%; height: auto; }

/* ================================================================== *
 * Vollbild-Karussell
 * ================================================================== */
html.lsbg-lock, html.lsbg-lock body { overflow: hidden !important; }

.lsbg-lb {
	--lb-bg: rgba(8, 8, 10, .97);
	--lb-fg: #f2f2f2;
	--lb-muted: rgba(242, 242, 242, .65);
	--lb-btn: rgba(255, 255, 255, .08);
	--lb-btn-h: rgba(255, 255, 255, .18);
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	flex-direction: column;
	background: var(--lb-bg);
	color: var(--lb-fg);
	font-family: inherit;
	opacity: 0;
	transition: opacity .25s ease;
	-webkit-user-select: none;
	user-select: none;
}
.lsbg-lb[hidden] { display: none; }
.lsbg-lb.is-open { opacity: 1; }
.lsbg-lb--light {
	--lb-bg: rgba(250, 250, 248, .98);
	--lb-fg: #1a1a1a;
	--lb-muted: rgba(26, 26, 26, .6);
	--lb-btn: rgba(0, 0, 0, .06);
	--lb-btn-h: rgba(0, 0, 0, .14);
}
.lsbg-lb button {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--lb-btn);
	color: inherit;
	cursor: pointer;
	transition: background .2s;
}
.lsbg-lb button:hover, .lsbg-lb button:focus-visible { background: var(--lb-btn-h); }
.lsbg-lb button:focus-visible, .lsbg-lb a:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.lsbg-lb svg { width: 22px; height: 22px; }

.lsbg-lb__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 14px;
	flex: 0 0 auto;
}
.lsbg-lb__count { font-size: 14px; letter-spacing: .05em; color: var(--lb-muted); font-variant-numeric: tabular-nums; }
.lsbg-lb__tools { display: flex; gap: 8px; align-items: center; }
.lsbg-lb__tools a {
	display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
	background: var(--lb-btn); color: inherit;
}
.lsbg-lb__tools a:hover { background: var(--lb-btn-h); }

.lsbg-lb__stage {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	touch-action: none;
}
.lsbg-lb__img {
	display: block;
	max-width: calc(100% - 140px);
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	transition: opacity .3s ease, transform .3s ease;
	cursor: zoom-in;
	-webkit-user-drag: none;
}
.lsbg-lb__img.is-loading { opacity: 0; }
.lsbg-lb__stage.is-zoomed .lsbg-lb__img { transform: scale(2.2); cursor: zoom-out; transition: opacity .3s ease; }
.lsbg-lb__spinner {
	position: absolute;
	width: 36px; height: 36px;
	border: 3px solid var(--lb-btn-h);
	border-top-color: var(--lb-fg);
	border-radius: 50%;
	animation: lsbg-spin .8s linear infinite;
	opacity: 0;
	transition: opacity .2s;
	pointer-events: none;
}
.lsbg-lb__stage.is-busy .lsbg-lb__spinner { opacity: 1; }
@keyframes lsbg-spin { to { transform: rotate(360deg); } }

.lsbg-lb__prev, .lsbg-lb__next { position: absolute; top: 50%; margin-top: -22px; z-index: 2; }
.lsbg-lb__prev { left: 16px; }
.lsbg-lb__next { right: 16px; }

.lsbg-lb__bottom { flex: 0 0 auto; padding: 8px 14px 14px; text-align: center; }
.lsbg-lb__caption { font-size: 15px; line-height: 1.45; max-width: 820px; margin: 0 auto; }
.lsbg-lb__exif { font-size: 12px; color: var(--lb-muted); margin-top: 4px; letter-spacing: .03em; }
.lsbg-lb__caption:empty, .lsbg-lb__exif:empty { display: none; }
.lsbg-lb__thumbs {
	display: flex;
	gap: 6px;
	justify-content: safe center;
	overflow-x: auto;
	margin-top: 10px;
	padding: 4px 2px;
	scrollbar-width: thin;
}
.lsbg-lb__thumbs:empty { display: none; }
.lsbg-lb .lsbg-lb__thumb {
	flex: 0 0 auto;
	width: 56px;
	height: 56px;
	border-radius: 6px;
	overflow: hidden;
	opacity: .45;
	background: var(--lb-btn);
	transition: opacity .2s, box-shadow .2s;
}
.lsbg-lb .lsbg-lb__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lsbg-lb .lsbg-lb__thumb:hover { opacity: .8; }
.lsbg-lb .lsbg-lb__thumb.is-active { opacity: 1; box-shadow: 0 0 0 2px var(--lb-fg); }

@media (max-width: 700px) {
	.lsbg-lb__img { max-width: 100%; }
	.lsbg-lb__prev, .lsbg-lb__next { top: auto; bottom: 8px; margin: 0; background: transparent; }
	.lsbg-lb__stage { padding-bottom: 52px; }
	.lsbg-lb .lsbg-lb__thumb { width: 44px; height: 44px; }
	.lsbg-lb__zoom { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
	.lsbg__img, .lsbg--slideshow .lsbg__item, .lsbg-lb, .lsbg-lb__img { transition: none !important; }
}
