/* KW Biohof – Fotogalerie-Widget.
 *
 * Frei gewählte Bilder als Raster, zwei Anordnungen: Mauerwerk (CSS columns,
 * natürliche Höhe) und einheitliches Raster (grid, festes Seitenverhältnis).
 * Klick auf ein Bild öffnet die geteilte Lightbox. Tokens fallen auf die
 * Marken-Werte zurück, solange im Style-Tab nichts gesetzt ist. Kein !important. */

.biohof-gallery {
	--biohof-gallery-gap: var(--biohof-space-sm);
	--biohof-gallery-ratio: 1 / 1;
	--biohof-gallery-img-pos: center center;
	--biohof-gallery-radius: var(--biohof-radius-md);
	--biohof-gallery-zoom: 1;
	/* Zeilen-Deckel fürs Kachel-Overlay – der volle Text steht in der Lightbox. */
	--biohof-gallery-title-lines: 2;
	--biohof-gallery-text-lines: 3;

	display: flex;
	flex-direction: column;
	gap: var(--biohof-space-lg);
}

.biohof-gallery--empty {
	color: var(--biohof-color-text-muted);
	padding: var(--biohof-space-md);
	border: 1px dashed var(--biohof-color-border);
	border-radius: var(--biohof-radius-md);
}

/* Überschrift: geteilte Komponente (assets/css/core/heading.css). */

/* ── Steuerzeile: Typ-Umschalter + Pferd-Filter in EINER Zeile, zentriert ────
   Ohne Scripting wären beide funktionslos → weg; beide Typen sind dann sichtbar
   ([hidden] greift nur mit Scripting, siehe unten). Kein Aufblitzen. */

.biohof-gallery__controls {
	display: none;
}

@media (scripting: enabled) {
	.biohof-gallery__controls {
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		align-items: center;
		align-self: center;
		gap: var(--biohof-space-xs) var(--biohof-space-md);
	}
}

.biohof-gallery__switcher {
	display: inline-flex;
	gap: var(--biohof-space-2xs);
}

/* Die Reiter tragen .biohof-button (nimmt die Elementor-Defense aus, damit der
   aktive Reiter seine Farbe behält). Der .biohof-gallery-Prefix (0,2,0) schlägt
   zusätzlich das Theme-reset.css (#c36 bei :hover/:focus) – kein !important.
   44px Touch-Target bleibt; schlanke Optik über dünne Umrandung statt Kasten.
   Der „Mehr laden"-Knopf teilt diese Optik. Rand in text-muted statt border:
   border lag bei 1,5:1 gegen die Seite (WCAG 1.4.11 verlangt 3:1 für die
   Komponenten-Abgrenzung); text-muted ist per ContrastTest gegen bg gesichert. */
.biohof-gallery .biohof-gallery__switch,
.biohof-gallery .biohof-gallery__more-btn {
	appearance: none;
	min-block-size: 44px;
	padding: 0.3rem 1rem;
	font: inherit;
	font-size: var(--biohof-fs-300);
	font-weight: var(--biohof-weight-medium);
	color: var(--biohof-color-text);
	background-color: transparent;
	border: 1px solid var(--biohof-color-text-muted);
	border-radius: var(--biohof-radius-pill);
	cursor: pointer;
	transition: color var(--biohof-duration) var(--biohof-ease), background-color var(--biohof-duration) var(--biohof-ease), border-color var(--biohof-duration) var(--biohof-ease);
}

.biohof-gallery .biohof-gallery__switch[aria-pressed="true"] {
	color: var(--biohof-color-on-primary);
	background-color: var(--biohof-color-primary);
	border-color: var(--biohof-color-primary);
}

@media (hover: hover) {
	.biohof-gallery .biohof-gallery__switch:hover,
	.biohof-gallery .biohof-gallery__more-btn:hover {
		color: var(--biohof-color-primary);
		border-color: var(--biohof-color-primary);
	}

	.biohof-gallery .biohof-gallery__switch[aria-pressed="true"]:hover {
		color: var(--biohof-color-on-primary);
		border-color: var(--biohof-color-primary);
	}
}

.biohof-gallery .biohof-gallery__switch:focus-visible,
.biohof-gallery .biohof-gallery__more-btn:focus-visible {
	outline: 3px solid var(--biohof-color-focus);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.biohof-gallery__switch,
	.biohof-gallery__more-btn {
		transition: none;
	}
}

/* ── Pferd-Filter – dezentes Auswahlfeld: nur Text + feine Unterstreichung ───
   Bewusst KEINE Pill (raubte als eigene Zeile zu viel Platz, Rico 2026-06-07):
   randlos, sitzt in der Steuerzeile neben dem Umschalter. Die Unterstreichung
   nutzt text-muted (border-Token bestünde WCAG 1.4.11 nicht, siehe oben).
   Das native Pfeil-Dreieck ist abgeschaltet; den Chevron zeichnet der Wrapper
   in currentColor – er färbt beim Hover mit. */

.biohof-gallery__filter {
	position: relative;
	display: inline-flex;
	color: var(--biohof-color-text);
}

/* Attribut schlägt das display oben (im Dienstleistungs-Reiter versteckt). */
.biohof-gallery__filter[hidden] {
	display: none;
}

.biohof-gallery__filter::after {
	content: '';
	position: absolute;
	inset-inline-end: 0.35rem;
	inset-block-start: 50%;
	inline-size: 0.45em;
	block-size: 0.45em;
	border-inline-end: 2px solid currentColor;
	border-block-end: 2px solid currentColor;
	transform: translateY(-70%) rotate(45deg);
	pointer-events: none;
}

.biohof-gallery .biohof-gallery__filter-select {
	appearance: none;
	min-block-size: 44px;
	padding-block: 0.3rem;
	padding-inline: 0.15rem 1.5rem;
	font: inherit;
	font-size: var(--biohof-fs-300);
	font-weight: var(--biohof-weight-medium);
	color: inherit;
	background-color: transparent;
	border: 0;
	border-block-end: 1px solid var(--biohof-color-text-muted);
	border-radius: 0;
	cursor: pointer;
	transition: color var(--biohof-duration) var(--biohof-ease), border-color var(--biohof-duration) var(--biohof-ease);
}

@media (prefers-reduced-motion: reduce) {
	.biohof-gallery .biohof-gallery__filter-select {
		transition: none;
	}
}

.biohof-gallery .biohof-gallery__filter-select:focus-visible {
	outline: 3px solid var(--biohof-color-focus);
	outline-offset: 2px;
}

@media (hover: hover) {
	.biohof-gallery__filter:hover {
		color: var(--biohof-color-primary);
	}

	.biohof-gallery .biohof-gallery__filter-select:hover {
		border-color: var(--biohof-color-primary);
	}
}

/* ── „Mehr laden" ────────────────────────────────────────────────────────────
   Ohne Scripting zeigt die Galerie alle Bilder und der Knopf bleibt weg –
   @media (scripting: enabled) greift schon beim ersten Paint (kein Aufblitzen). */

.biohof-gallery__more {
	text-align: center;
}

.biohof-gallery .biohof-gallery__more-btn {
	display: none;
}

@media (scripting: enabled) {
	.biohof-gallery .biohof-gallery__more-btn {
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}

	/* Attribut schlägt das display oben (gleicher Block, später + Attribut). */
	.biohof-gallery .biohof-gallery__more-btn[hidden] {
		display: none;
	}

	/* Kacheln über dem Limit: erst der Knopf deckt sie auf. */
	.biohof-gallery__grid .biohof-gallery__item--more {
		display: none;
	}
}

/* Kachel des inaktiven Typs – schlägt das display:block oben. Nur mit
   Scripting: ohne JS gibt es keinen Umschalter, beide Typen bleiben sichtbar. */
@media (scripting: enabled) {
	.biohof-gallery__item[hidden] {
		display: none;
	}
}

/* ── Raster-Container ────────────────────────────────────────────────────── */

.biohof-gallery__grid {
	--biohof-gallery-cols: 3;
}

/* Mauerwerk: natürliche Bildhöhen, spaltenweise gefüllt. */
.biohof-gallery--masonry .biohof-gallery__grid {
	columns: var(--biohof-gallery-cols);
	column-gap: var(--biohof-gallery-gap);
}

.biohof-gallery--masonry .biohof-gallery__item {
	inline-size: 100%;
	margin-block-end: var(--biohof-gallery-gap);
	break-inside: avoid;
}

/* Einheitliches Raster: gleiche Kachelgröße, Bilder auf das Format zugeschnitten. */
.biohof-gallery--grid .biohof-gallery__grid {
	display: grid;
	grid-template-columns: repeat(var(--biohof-gallery-cols), minmax(0, 1fr));
	gap: var(--biohof-gallery-gap);
}

.biohof-gallery--grid .biohof-gallery__img {
	block-size: 100%;
	aspect-ratio: var(--biohof-gallery-ratio);
	object-fit: cover;
	object-position: var(--biohof-gallery-img-pos);
}

/* Leerer Reiter: Hinweis über die volle Rasterbreite, ruhig und gedämpft. */
.biohof-gallery__empty-tab {
	margin: 0;
	padding: var(--biohof-space-lg);
	color: var(--biohof-color-text-muted);
	text-align: center;
}

.biohof-gallery--masonry .biohof-gallery__empty-tab {
	column-span: all;
}

.biohof-gallery--grid .biohof-gallery__empty-tab {
	grid-column: 1 / -1;
}

/* ── Kachel ──────────────────────────────────────────────────────────────── */

.biohof-gallery__item {
	display: block;
	position: relative;
	overflow: hidden;
	border-radius: var(--biohof-gallery-radius);
	background: var(--biohof-color-surface-soft);
}

.biohof-gallery__item--button {
	appearance: none;
	padding: 0;
	border: 0;
	inline-size: 100%;
	cursor: pointer;
	/* Browser-Default für <button> ist nowrap – die Kachel-Texte sollen umbrechen. */
	white-space: normal;
}

.biohof-gallery__img {
	display: block;
	inline-size: 100%;
	block-size: auto;
	transition: transform var(--biohof-duration) var(--biohof-ease);
}

/* ── Vergrößern-Hinweis (Lupe) ───────────────────────────────────────────── */

.biohof-gallery__zoom {
	position: absolute;
	inset-block-start: var(--biohof-space-xs);
	inset-inline-end: var(--biohof-space-xs);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.4rem;
	color: var(--biohof-color-on-primary);
	background: color-mix(in srgb, var(--biohof-color-primary) 88%, transparent);
	border-radius: var(--biohof-radius-pill);
	opacity: 0;
	transform: translateY(-0.3rem);
	transition: opacity var(--biohof-duration) var(--biohof-ease), transform var(--biohof-duration) var(--biohof-ease);
}

.biohof-gallery__zoom svg {
	inline-size: 1.1rem;
	block-size: 1.1rem;
}

/* ── Titel + Beschreibung als Overlay – beim Überfahren/Fokus ─────────────── */

.biohof-gallery__caption {
	position: absolute;
	inset-inline: 0;
	inset-block-end: 0;
	display: flex;
	flex-direction: column;
	gap: 0.1rem;
	padding: 1.6rem 0.85rem 0.7rem;
	text-align: start;
	color: color-mix(in srgb, white 96%, transparent);
	background: linear-gradient(to top, color-mix(in srgb, black 80%, transparent), transparent);
	opacity: 0;
	transform: translateY(0.4rem);
	transition: opacity var(--biohof-duration) var(--biohof-ease), transform var(--biohof-duration) var(--biohof-ease);
	pointer-events: none;
}

/* Lange Texte: mehrzeilig mit „…"-Deckel statt aus der Kachel zu laufen.
   Vollständig stehen Titel + Beschreibung immer in der Lightbox. */
.biohof-gallery__caption-title {
	font-weight: var(--biohof-weight-semibold);
	font-size: var(--biohof-fs-400);
	line-height: var(--biohof-line-snug);
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: var(--biohof-gallery-title-lines);
	line-clamp: var(--biohof-gallery-title-lines);
	overflow: hidden;
}

.biohof-gallery__caption-text {
	font-size: var(--biohof-fs-300);
	line-height: var(--biohof-line-snug);
	color: color-mix(in srgb, white 82%, transparent);
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: var(--biohof-gallery-text-lines);
	line-clamp: var(--biohof-gallery-text-lines);
	overflow: hidden;
}

@media (hover: hover) {
	.biohof-gallery__item:hover .biohof-gallery__caption,
	.biohof-gallery__item--button:focus-visible .biohof-gallery__caption {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Ohne Hover-Fähigkeit (Touch): Bildunterschrift dauerhaft zeigen. */
@media (hover: none) {
	.biohof-gallery__caption {
		opacity: 1;
		transform: none;
	}
}

@media (hover: hover) {
	.biohof-gallery__item--button:hover .biohof-gallery__img {
		transform: scale(var(--biohof-gallery-zoom));
	}

	.biohof-gallery__item--button:hover .biohof-gallery__zoom,
	.biohof-gallery__item--button:focus-visible .biohof-gallery__zoom {
		opacity: 1;
		transform: translateY(0);
	}
}

.biohof-gallery__item--button:focus-visible {
	outline: 3px solid var(--biohof-color-focus);
	outline-offset: -3px;
}

@media (prefers-reduced-motion: reduce) {
	.biohof-gallery__img,
	.biohof-gallery__zoom,
	.biohof-gallery__caption {
		transition: none;
	}

	.biohof-gallery__item--button:hover .biohof-gallery__img {
		transform: none;
	}
}
