/* ─── SAR Bilder-Slider ─────────────────────────────── */

.sar-slider {
	--sar-slider-gap: 4px;
	--sar-slider-slides: 4;

	position: relative;
	margin: 32px 0;
}

.sar-slider__viewport {
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	-ms-overflow-style: none;
	cursor: grab;
	touch-action: pan-y;
}

.sar-slider__viewport::-webkit-scrollbar {
	display: none;
}

.sar-slider__viewport.is-dragging {
	cursor: grabbing;
	scroll-snap-type: none;
	scroll-behavior: auto;
}

.sar-slider__track {
	display: flex;
	gap: var(--sar-slider-gap);
}

.sar-slider__slide {
	flex: 0 0 calc(
		( 100% - ( var(--sar-slider-gap) * ( var(--sar-slider-slides) - 1 ) ) )
		/ var(--sar-slider-slides)
	);
	scroll-snap-align: start;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: #f2f2f2;
}

.sar-slider__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	user-select: none;
	-webkit-user-drag: none;
	pointer-events: none;
}

/* ─── Pfeile ─────────────────────────────────────── */

.sar-slider__arrow {
	position: absolute;
	top: 50%;
	transform: translateY( -50% );
	width: 44px;
	height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: rgba( 26, 58, 92, 0.85 );
	color: #fff;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	z-index: 2;
	transition: background 0.15s, opacity 0.2s;
}

.sar-slider__arrow:hover {
	background: #1a3a5c;
}

.sar-slider__arrow--prev { left: 8px; }
.sar-slider__arrow--next { right: 8px; }

.sar-slider__arrow.is-hidden {
	opacity: 0;
	pointer-events: none;
}

.sar-slider--empty {
	padding: 24px;
	background: #f8f8f8;
	border: 1px dashed #ccc;
	text-align: center;
}

/* ─── Responsive (dynamisch via view.js) ─────────────
   --sar-slider-slides wird zur Laufzeit vom ResizeObserver in view.js
   gesetzt, basierend auf den data-min-image-width und data-max-images
   Attributen am Slider-Wrapper. Anzahl Slides nebeneinander:
     anzahl = min(maxImages, max(1, floor(slider_width / minImageWidth)))
   Damit gibt es keine halben Slides, und die Anzahl skaliert
   stufenlos mit der Container-Breite, statt an feste Breakpoints
   gebunden zu sein.

   Der Initial-Default (4 Slides) gilt nur, bis das view.js gelaufen ist
   und einen passenden Wert gesetzt hat. */

/* ─── Hero-Modus: erstes Bild doppelt so breit ───────
   Bei aktiver Option "firstImageDouble" zaehlt das erste Slide als
   2 Einheiten, alle anderen als je 1 Einheit. Gesamt-Einheiten der
   Sichtbreite = N+1 (statt N). Beispiele:
     N=3 ohne Hero: 33/33/33
     N=3 mit Hero:  50/25/25
     N=4 ohne Hero: 25/25/25/25
     N=4 mit Hero:  40/20/20/20
   Bei N=1 (sehr schmaler Slider) macht die Option nichts Sinnvolles,
   weil dann ohnehin nur ein Slide gleichzeitig sichtbar ist; das
   erste Bild ist halt voll breit, der Rest wird gescrollt. */
.sar-slider--hero .sar-slider__slide {
	flex: 0 0 calc(
		( 100% - ( var(--sar-slider-gap) * ( var(--sar-slider-slides) - 1 ) ) )
		/ ( var(--sar-slider-slides) + 1 )
	);
}

.sar-slider--hero .sar-slider__slide:first-child {
	flex: 0 0 calc(
		2 * (
			( 100% - ( var(--sar-slider-gap) * ( var(--sar-slider-slides) - 1 ) ) )
			/ ( var(--sar-slider-slides) + 1 )
		)
	);
	/* Doppelte Breite bei gleicher Hoehe wie die anderen Slides:
	   Standard-Aspect-Ratio ist 4:3, das Hero bekommt 8:3 — bei
	   doppelter Breite ist die Hoehe damit identisch zum Rest.
	   object-fit: cover (am img) schneidet oben/unten ab. */
	aspect-ratio: 8 / 3;
}

/* ─── Editor-Vorschau ───────────────────────────── */

.sar-slider-editor {
	padding: 20px;
	background: #f9f9f9;
	border: 2px dashed #c3c4c7;
}

.sar-slider-editor__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 12px;
}

.sar-slider-editor__grid {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 100px, 1fr ) );
	gap: 8px;
	margin-bottom: 12px;
}

.sar-slider-editor__thumb {
	aspect-ratio: 4 / 3;
	background: #e5e5e5;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}

.sar-slider-editor__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.sar-slider-editor__empty {
	padding: 24px;
	text-align: center;
	background: #fff;
	border: 1px dashed #ccc;
	margin-bottom: 12px;
}

.sar-slider-editor__actions {
	display: flex;
	gap: 8px;
}

/* ─── Lightbox ───────────────────────────────────── */

.sar-slider--lightbox .sar-slider__slide {
	cursor: pointer;
}

body.sar-lightbox-open {
	overflow: hidden;
}

.sar-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.80);
}

.sar-lightbox.is-open {
	display: flex;
}

.sar-lightbox__figure {
	position: relative;
	margin: 0;
	/* Kein Randabstand für Rand-Pfeile mehr nötig — die Buttons liegen
	   jetzt AUF dem Bild (absolute zur Figure). */
	max-width: calc(100vw - 48px);
	max-height: calc(100vh - 64px);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.sar-lightbox__img {
	max-width: 100%;
	max-height: calc(100vh - 140px);
	object-fit: contain;
	display: block;
	user-select: none;
	-webkit-user-drag: none;
	box-shadow: 0 4px 32px rgba(0, 0, 0, 0.25);
}

/* Titel-Leiste: liegt auf der Unterkante des Bildes,
   volle Bildbreite, Weiß mit 0.9, Text schwarz. */
.sar-lightbox__caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(255, 255, 255, 1);
	opacity: 1;
	color: #111;
	font-size: 14px;
	line-height: 1.5;
	text-align: center;
	padding: 10px 16px;
}

.sar-lightbox__caption.is-hidden {
	display: none;
}

.sar-lightbox__desc {
	display: block;
}

.sar-lightbox__copyright {
	display: block;
	opacity: 0.65;
	font-size: 12px;
}

.sar-lightbox__counter {
	position: absolute;
	top: 16px;
	left: 50%;
	transform: translateX(-50%);
	color: rgba(0, 0, 0, 0.7);
	font-size: 14px;
	pointer-events: none;
}

/* Close + Pfeile liegen AUF dem Bild (absolute zur Figure): weiße,
   halbtransparente Kreise mit Schatten, damit sie auf Fotos jeder
   Helligkeit sichtbar bleiben. */
.sar-lightbox__close,
.sar-lightbox__arrow {
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.85);
	box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
	color: #1a1a1a;
	cursor: pointer;
	transition: background 0.15s ease;
}

.sar-lightbox__close:hover,
.sar-lightbox__arrow:hover {
	background: rgba(255, 255, 255, 1);
	/* Farbe explizit halten: Theme-Button-Hover setzt color auf Weiß,
	   das Icon (stroke: currentColor) verschwand sonst auf dem weißen
	   Kreis. */
	color: #1a1a1a;
}

.sar-lightbox__close:focus-visible,
.sar-lightbox__arrow:focus-visible {
	outline: 2px solid #1a1a1a;
	outline-offset: 2px;
}

.sar-lightbox__close {
	top: 10px;
	right: 10px;
}

.sar-lightbox__arrow {
	top: 50%;
	transform: translateY(-50%);
}

.sar-lightbox__arrow--prev { left: 10px; }
.sar-lightbox__arrow--next { right: 10px; }

.sar-lightbox__arrow.is-hidden {
	display: none;
}

@media (max-width: 767px) {
	.sar-lightbox__figure {
		max-width: 100vw;
		padding: 0 8px;
	}

	.sar-lightbox__img {
		max-height: calc(100vh - 160px);
	}

	.sar-lightbox__close,
	.sar-lightbox__arrow {
		width: 40px;
		height: 40px;
	}

	.sar-lightbox__arrow--prev { left: 8px; }
	.sar-lightbox__arrow--next { right: 8px; }
}
