/* KW Biohof – Core-Baustein: barrierefreie Bild-Lightbox (<dialog>).
 *
 * Wiederverwendbar (Galerie + Fotogalerie). Liegt im Top-Layer am <body>,
 * außerhalb von .biohof UND .elementor-widget – die zentrale elementor-defense
 * erreicht sie also nicht. Zwei Konsequenzen, hier lokal gelöst:
 *
 * 1. THEME-PINK: Hello-Elementor `assets/css/reset.css` färbt nackte <button>
 *    pink (`button:focus, button:hover { background:#c36 }`, Spezifität 0,1,1).
 *    Da die Defense nicht greift, sichern wir die Bedienelemente selbst – mit
 *    DERSELBEN Technik wie die Defense: Spezifität über `.biohof-lightbox …`
 *    (0,2,0) statt !important, deterministisch unabhängig von der Ladereihenfolge.
 * 2. DUNKLER SCHLEIER: in BEIDEN Farbschemata dunkel → eigenständiges helles
 *    Overlay-Theme (white-basierte Tokens, mode-unabhängig) statt der mode-
 *    flippenden --biohof-color-*-Tokens (sonst dunkler Text auf dunklem Grund). */

.biohof-lightbox {
	/* Helles Overlay-Theme auf dunklem Schleier (mode-unabhängig). */
	--biohof-lb-fg: color-mix(in srgb, white 94%, transparent);
	--biohof-lb-fg-muted: color-mix(in srgb, white 74%, transparent);
	--biohof-lb-control-bg: color-mix(in srgb, white 16%, transparent);
	--biohof-lb-control-bg-hover: color-mix(in srgb, white 30%, transparent);
	--biohof-lb-control-border: color-mix(in srgb, white 40%, transparent);

	max-inline-size: 100vw;
	max-block-size: 100dvh;
	inline-size: 100%;
	block-size: 100%;
	margin: 0;
	padding: clamp(0.75rem, 0.4rem + 1.6vw, 2rem);
	border: 0;
	background: transparent;
	color: var(--biohof-lb-fg);
	font-family: var(--biohof-font-body);
	overflow: hidden;
}

/* Schleier: in beiden Farbschemata dunkel (aus passenden Tokens gemischt). */
.biohof-lightbox::backdrop {
	background: color-mix(in srgb, var(--biohof-color-text-strong) 82%, transparent);
}

@media (prefers-color-scheme: dark) {
	.biohof-lightbox::backdrop {
		background: color-mix(in srgb, var(--biohof-color-bg) 90%, transparent);
	}
}

.biohof-lightbox__inner {
	display: flex;
	flex-direction: column;
	gap: clamp(0.5rem, 0.3rem + 1vw, 1rem);
	block-size: 100%;
	inline-size: 100%;
}

.biohof-lightbox__stage {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: clamp(0.25rem, 0.1rem + 1vw, 1rem);
	flex: 1 1 auto;
	min-block-size: 0;
}

.biohof-lightbox__figure {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: var(--biohof-space-xs);
	margin: 0;
	flex: 1 1 auto;
	align-self: stretch;
	min-inline-size: 0;
	min-block-size: 0;
}

/* Bühne der zwei gestapelten Bild-Ebenen – definite Fläche (Flex), damit die
   contain-Bilder eine Bezugsgröße haben (keine Magic-Number-Höhe mehr nötig). */
.biohof-lightbox__frame {
	display: grid;
	place-items: center;
	flex: 1 1 auto;
	inline-size: 100%;
	min-block-size: 0;
}

/* Echtes Crossfade: zwei gestapelte Ebenen, die aktive ist sichtbar, die
   vorherige blendet aus. Beide kurz gleichzeitig sichtbar = weiches Überblenden.
   reduced-motion = sofort (--biohof-duration ist dann 0ms, siehe tokens.css). */
.biohof-lightbox__img {
	grid-area: 1 / 1;
	max-inline-size: 100%;
	max-block-size: 100%;
	inline-size: auto;
	block-size: auto;
	border-radius: var(--biohof-radius-sm);
	box-shadow: var(--biohof-shadow-lg);
	opacity: 0;
	pointer-events: none;
	transition: opacity calc(var(--biohof-duration) * 1.5) var(--biohof-ease);
}

.biohof-lightbox__img.is-active {
	opacity: 1;
}

.biohof-lightbox__meta {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.15rem;
	max-inline-size: 60ch;
	text-align: center;
}

.biohof-lightbox__title {
	font-family: var(--biohof-font-heading);
	font-size: var(--biohof-fs-500);
	font-weight: var(--biohof-weight-semibold);
	line-height: var(--biohof-line-snug);
	color: var(--biohof-lb-fg);
}

.biohof-lightbox__caption {
	font-size: var(--biohof-fs-300);
	color: var(--biohof-lb-fg-muted);
}

.biohof-lightbox__meta[hidden],
.biohof-lightbox__title[hidden],
.biohof-lightbox__caption[hidden] {
	display: none;
}

.biohof-lightbox__counter {
	margin: 0;
	text-align: center;
	font-size: var(--biohof-fs-300);
	color: var(--biohof-lb-fg-muted);
}

/* ── Bedienelemente (verstärkte Spezifität gegen Theme-Pink) ─────────────── */

.biohof-lightbox .biohof-lightbox__close,
.biohof-lightbox .biohof-lightbox__nav {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-inline-size: 44px;
	min-block-size: 44px;
	padding: 0;
	border: 1px solid var(--biohof-lb-control-border);
	border-radius: var(--biohof-radius-pill);
	background: var(--biohof-lb-control-bg);
	color: var(--biohof-lb-fg);
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
	transition: background-color var(--biohof-duration) var(--biohof-ease), transform var(--biohof-duration) var(--biohof-ease);
}

.biohof-lightbox__close {
	position: absolute;
	inset-block-start: clamp(0.75rem, 0.4rem + 1.6vw, 2rem);
	inset-inline-end: clamp(0.75rem, 0.4rem + 1.6vw, 2rem);
}

.biohof-lightbox__nav[hidden] {
	display: none;
}

@media (hover: hover) {
	.biohof-lightbox .biohof-lightbox__close:hover,
	.biohof-lightbox .biohof-lightbox__nav:hover {
		background: var(--biohof-lb-control-bg-hover);
		color: var(--biohof-lb-fg);
		transform: scale(1.06);
	}
}

.biohof-lightbox .biohof-lightbox__close:focus-visible,
.biohof-lightbox .biohof-lightbox__nav:focus-visible,
.biohof-lightbox .biohof-lightbox__thumb:focus-visible {
	outline: 3px solid var(--biohof-color-focus);
	outline-offset: 2px;
}

/* ── Thumbnail-Leiste ───────────────────────────────────────────────────── */

.biohof-lightbox__strip {
	display: flex;
	gap: var(--biohof-space-2xs);
	justify-content: flex-start;
	overflow-x: auto;
	padding-block: var(--biohof-space-2xs);
	scrollbar-width: thin;
}

.biohof-lightbox__strip[hidden] {
	display: none;
}

.biohof-lightbox .biohof-lightbox__thumb {
	flex: 0 0 auto;
	inline-size: 64px;
	block-size: 48px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: var(--biohof-radius-sm);
	background: none;
	cursor: pointer;
	opacity: 0.6;
	transition: opacity var(--biohof-duration) var(--biohof-ease), border-color var(--biohof-duration) var(--biohof-ease);
}

.biohof-lightbox .biohof-lightbox__thumb.is-current {
	opacity: 1;
	border-color: var(--biohof-color-primary);
}

@media (hover: hover) {
	.biohof-lightbox .biohof-lightbox__thumb:hover {
		opacity: 1;
	}
}

.biohof-lightbox__thumb-img {
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
	border-radius: calc(var(--biohof-radius-sm) - 2px);
	display: block;
}

@media (prefers-reduced-motion: reduce) {
	.biohof-lightbox .biohof-lightbox__close,
	.biohof-lightbox .biohof-lightbox__nav,
	.biohof-lightbox .biohof-lightbox__thumb {
		transition: none;
	}
}
