/* Levarix Galerie
 * Desktop/Tablet: Justified Layout (Zeilen in Aufnahmereihenfolge, links→rechts)
 * Handy (≤ 600px): 2-Spalten-Raster, gleich große Kacheln, Reihenfolge bleibt erhalten
 */
.lvx-galerie {
	--lvx-h: var(--lvx-hd, 220px);
	display: flex;
	flex-wrap: wrap;
	gap: var(--lvx-gap, 6px);
	margin: 1.5em 0;
}
@media (max-width: 900px) {
	.lvx-galerie { --lvx-h: calc(var(--lvx-hd, 220px) * 0.8); }
}

.lvx-galerie .lvx-item {
	position: relative;
	display: block;
	flex-basis: calc(var(--lvx-h) * var(--r, 1.5));
	height: var(--lvx-h);
	overflow: hidden;
	border-radius: 6px;
	background: #e9edf0;
	cursor: zoom-in;
	-webkit-tap-highlight-color: transparent;
}
.lvx-galerie .lvx-item img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none;
	object-fit: cover;
	margin: 0;
	transition: transform .45s ease, filter .3s ease;
}
@media (hover: hover) {
	.lvx-galerie .lvx-item:hover img { transform: scale(1.04); filter: brightness(1.05); }
}
.lvx-galerie .lvx-item:active img { filter: brightness(.9); }
.lvx-galerie .lvx-item:focus-visible { outline: 3px solid #4CAF2A; outline-offset: 2px; }

.lvx-galerie .lvx-date {
	position: absolute;
	left: 8px;
	bottom: 8px;
	padding: 2px 8px;
	font-size: 12px;
	line-height: 1.6;
	color: #fff;
	background: rgba(0, 0, 0, .55);
	border-radius: 4px;
	pointer-events: none;
}

/* Platzhalter: letzte Zeile wird nicht auf volle Breite gezogen */
.lvx-galerie .lvx-fill { flex-grow: 999999; flex-basis: 0; height: 0; }

/* ---------------- Handy: 2-Spalten-Raster ---------------- */
@media (max-width: 600px) {
	.lvx-galerie {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		gap: 4px;
		margin: 1em 0;
	}
	.lvx-galerie .lvx-item {
		height: auto;
		aspect-ratio: 1 / 1;
		border-radius: 4px;
		flex: none !important;
	}
	.lvx-galerie .lvx-fill { display: none; }
	.lvx-galerie .lvx-date { left: 4px; bottom: 4px; font-size: 10px; padding: 1px 5px; }
}
/* ganz kleine Geräte bleiben bei 2 Spalten, Querformat-Handy bekommt 3 */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
	.lvx-galerie {
		display: grid;
		grid-template-columns: repeat(3, 1fr);
		gap: 4px;
	}
	.lvx-galerie .lvx-item { height: auto; aspect-ratio: 1 / 1; flex: none !important; }
	.lvx-galerie .lvx-fill { display: none; }
}

/* ---------------- Lightbox ---------------- */
.lvx-lb {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(10, 14, 18, .96);
	-webkit-user-select: none;
	user-select: none;
	overscroll-behavior: contain;
	touch-action: pan-y pinch-zoom;
}
.lvx-lb.open { display: flex; animation: lvx-fade .2s ease; }
@keyframes lvx-fade { from { opacity: 0; } to { opacity: 1; } }

.lvx-lb figure { margin: 0; max-width: 92vw; max-height: 88vh; text-align: center; }
.lvx-lb img {
	display: block;
	max-width: 92vw;
	max-height: 82vh;
	width: auto;
	height: auto;
	margin: 0 auto;
	border-radius: 4px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
	transition: transform .25s ease, opacity .2s ease;
}
.lvx-lb figcaption { color: #ddd; font-size: 14px; margin-top: 10px; min-height: 1em; padding: 0 12px; }

.lvx-lb button {
	position: absolute;
	border: 0;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	cursor: pointer;
	border-radius: 50%;
	width: 48px;
	height: 48px;
	font-size: 30px;
	line-height: 48px;
	padding: 0;
	transition: background .2s;
	-webkit-tap-highlight-color: transparent;
}
.lvx-lb button:hover, .lvx-lb button:focus-visible { background: rgba(255, 255, 255, .25); }
.lvx-lb .lvx-lb-x { top: 16px; right: 16px; }
.lvx-lb .lvx-lb-p { left: 16px; top: 50%; transform: translateY(-50%); }
.lvx-lb .lvx-lb-n { right: 16px; top: 50%; transform: translateY(-50%); }
.lvx-lb .lvx-lb-c { position: absolute; top: 28px; left: 20px; color: #bbb; font-size: 14px; }

/* Lightbox auf dem Handy: Bild randlos, Bedienung unten (Daumenbereich), iPhone-Notch beachten */
@media (max-width: 600px) {
	.lvx-lb figure { max-width: 100vw; }
	.lvx-lb img {
		max-width: 100vw;
		max-height: calc(100vh - 150px);
		max-height: calc(100dvh - 150px);
		border-radius: 0;
		box-shadow: none;
	}
	.lvx-lb figcaption { font-size: 13px; }
	.lvx-lb .lvx-lb-x { top: calc(10px + env(safe-area-inset-top)); right: 10px; }
	.lvx-lb .lvx-lb-c { top: calc(24px + env(safe-area-inset-top)); left: 16px; }
	.lvx-lb .lvx-lb-p,
	.lvx-lb .lvx-lb-n {
		top: auto;
		bottom: calc(16px + env(safe-area-inset-bottom));
		transform: none;
		width: 56px;
		height: 56px;
		line-height: 56px;
	}
	.lvx-lb .lvx-lb-p { left: calc(50% - 72px); }
	.lvx-lb .lvx-lb-n { right: calc(50% - 72px); }
}
