/*
 * BÄHR Jobs – Karussell als Bühne mit fünf Plätzen.
 *
 *   -2 (Teaser)   -1 (Nachbar)   0 (Mitte, groß)   +1 (Nachbar)   +2 (Teaser)
 *
 * Alle Größen beziehen sich auf die Breite des umgebenden Elements (Container Query Units, cqw), das
 * Karussell skaliert also mit seinem Platz. Farben, Größen und Abstände steuert das Elementor-Widget
 * (die CSS-Variablen unten sind die Standardwerte). Die Plätze (data-pos) setzt der Server und hält
 * carousel.js aktuell; ohne JavaScript bleibt die Bühne als statische Ansicht lesbar.
 */

.baehr-carousel {
	container-type: inline-size;
	position: relative;

	--baehr-cw: 34;          /* Breite der Mittelkarte in cqw. */
	--baehr-s1: 0.7;         /* Größe der Nachbarn relativ zur Mitte. */
	--baehr-s2: 0.5;         /* Größe der Teaser relativ zur Mitte. */
	--baehr-ov: -1.2;        /* Überlappung Mitte/Nachbar in cqw (negativ = Abstand). */
	--baehr-ov2: 6;          /* Überlappung Nachbar/Teaser in cqw (positiv = Teaser schiebt sich hinter den Nachbarn). */
	--baehr-teaser-o: 0.4;   /* Sichtbarkeit der Teaser. */
	--baehr-ratio: 1.5;      /* Bildformat (Breite / Höhe). */

	/* Abgeleitete Mittelpunkte der Nachbarn (x1) und Teaser (x2), gemessen von der Mitte. */
	--baehr-x1: calc((var(--baehr-cw) / 2 + var(--baehr-cw) * var(--baehr-s1) / 2 - var(--baehr-ov)) * 1cqw);
	--baehr-x2: calc(var(--baehr-x1) + (var(--baehr-cw) * var(--baehr-s1) / 2 + var(--baehr-cw) * var(--baehr-s2) / 2 - var(--baehr-ov2)) * 1cqw);
}

.baehr-carousel--ratio-3-2  { --baehr-ratio: 1.5; }
.baehr-carousel--ratio-4-3  { --baehr-ratio: 1.3333; }
.baehr-carousel--ratio-16-9 { --baehr-ratio: 1.7778; }
.baehr-carousel--ratio-1-1  { --baehr-ratio: 1; }
.baehr-carousel--ratio-3-4  { --baehr-ratio: 0.75; }

/* Bühne: alle Karten liegen im selben Rasterfeld übereinander; die Höhe bestimmt die Mittelkarte. */
.baehr-carousel__stage {
	display: grid;
	align-items: center;
	justify-items: center;
	position: relative;
	padding-block: 56px;
	overflow-x: clip;
	touch-action: pan-y;
	/* Die Ränder blenden die angeteaserten Karten weich aus. */
	-webkit-mask-image: linear-gradient(90deg, transparent 0, #000 7cqw, #000 calc(100% - 7cqw), transparent 100%);
	mask-image: linear-gradient(90deg, transparent 0, #000 7cqw, #000 calc(100% - 7cqw), transparent 100%);
}

.baehr-carousel__slide {
	grid-area: 1 / 1;
	width: calc(var(--baehr-cw) * 1cqw);
	/* Skaliert wird um die Bildmitte, damit alle Bilder auf einer Höhe sitzen. */
	transform-origin: 50% calc(var(--baehr-cw) * 1cqw / var(--baehr-ratio) / 2);
	transform: translateX(var(--x, 0)) scale(var(--s, 1));
	opacity: var(--o, 1);
	transition: transform 0.75s cubic-bezier(0.22, 0.8, 0.2, 1), opacity 0.55s ease;
	will-change: transform, opacity;
}

.baehr-carousel__slide[data-pos="0"]  { --x: 0; --s: 1; --o: 1; z-index: 5; }
.baehr-carousel__slide[data-pos="-1"] { --x: calc(var(--baehr-x1) * -1); --s: var(--baehr-s1); --o: 1; z-index: 4; }
.baehr-carousel__slide[data-pos="1"]  { --x: var(--baehr-x1); --s: var(--baehr-s1); --o: 1; z-index: 4; }
.baehr-carousel__slide[data-pos="-2"] { --x: calc(var(--baehr-x2) * -1); --s: var(--baehr-s2); --o: var(--baehr-teaser-o); z-index: 3; }
.baehr-carousel__slide[data-pos="2"]  { --x: var(--baehr-x2); --s: var(--baehr-s2); --o: var(--baehr-teaser-o); z-index: 3; }
.baehr-carousel__slide[data-pos="-3"] { --x: calc(var(--baehr-x2) * -1 - 14cqw); --s: calc(var(--baehr-s2) * 0.8); --o: 0; z-index: 2; pointer-events: none; }
.baehr-carousel__slide[data-pos="3"]  { --x: calc(var(--baehr-x2) + 14cqw); --s: calc(var(--baehr-s2) * 0.8); --o: 0; z-index: 2; pointer-events: none; }

/* Eine Karte, die einmal um den Ring herum wandert, soll nicht quer über die Bühne fliegen, sondern erscheint ausgeblendet am neuen Platz. */
.baehr-carousel__slide.is-jump {
	transition: none !important;
	opacity: 0 !important;
}

.baehr-carousel__link {
	display: flex;
	flex-direction: column;
	align-items: center;
	color: inherit;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
}

.baehr-carousel__link:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 8px;
	box-shadow: 0 0 0 11px #1c1c1c;
}

/* Bild --------------------------------------------------------------------------------------------- */
.baehr-carousel__media {
	display: block;
	position: relative;
	align-self: stretch;
	overflow: hidden;
	aspect-ratio: var(--baehr-ratio);
	background-color: #1c1c1c;
	box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
	transition: box-shadow 0.6s ease;
}

.baehr-carousel__slide[data-pos="0"] .baehr-carousel__media {
	box-shadow: 0 34px 70px rgba(0, 0, 0, 0.4);
}

.baehr-carousel__slide[data-pos="-2"] .baehr-carousel__media,
.baehr-carousel__slide[data-pos="2"] .baehr-carousel__media {
	box-shadow: none;
}

/* Absolut, weil height:100% in einem Rahmen mit aspect-ratio nicht zuverlässig greift. Die höhere
   Spezifität schlägt Elementors Grund-CSS (img { height: auto; max-width: 100% }). */
.baehr-carousel .baehr-carousel__media .baehr-carousel__img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	max-width: none;
	height: 100%;
	margin: 0;
	object-fit: cover;
	object-position: center center;
	transition: filter 0.6s ease, transform 1.2s cubic-bezier(0.22, 0.8, 0.2, 1);
}

.baehr-carousel--focus-upper .baehr-carousel__media .baehr-carousel__img  { object-position: center 30%; }
.baehr-carousel--focus-top .baehr-carousel__media .baehr-carousel__img    { object-position: center top; }
.baehr-carousel--focus-bottom .baehr-carousel__media .baehr-carousel__img { object-position: center bottom; }
.baehr-carousel--focus-left .baehr-carousel__media .baehr-carousel__img   { object-position: left center; }
.baehr-carousel--focus-right .baehr-carousel__media .baehr-carousel__img  { object-position: right center; }

/* Die Mittelkarte „atmet“ ganz leicht, damit sie lebendig wirkt. */
.baehr-carousel__slide[data-pos="0"] .baehr-carousel__img {
	transform: scale(1.04);
}

.baehr-carousel--gray .baehr-carousel__slide:not([data-pos="0"]) .baehr-carousel__img {
	filter: grayscale(1) contrast(1.05);
}

.baehr-carousel--gray .baehr-carousel__slide[data-pos="-1"]:hover .baehr-carousel__img,
.baehr-carousel--gray .baehr-carousel__slide[data-pos="1"]:hover .baehr-carousel__img {
	filter: grayscale(0.15);
}

/* Titel: Jede Textzeile bekommt ihren eigenen Kasten, er überlappt die untere Bildkante. ------------ */
.baehr-carousel__label {
	position: relative;
	display: block;
	margin: -1.05em -9% 0;
	text-align: center;
	text-wrap: balance; /* Umbruch nur zwischen Wörtern, Zeilen gleichmäßig lang; keine Silbentrennung. */
}

.baehr-carousel__label-text,
.baehr-carousel__sub-text {
	display: inline;
	padding: 0.18em 0.6em;
	box-decoration-break: clone;
	-webkit-box-decoration-break: clone;
	background-color: #1c1c1c;
	color: #fff;
	font-size: clamp(20px, 2.4cqw, 34px);
	font-weight: 800;
	line-height: 1.7;
	text-transform: uppercase;
	overflow-wrap: break-word;
	transition: background-color 0.5s ease, color 0.5s ease;
}

/* Lange Wörter und „Wort (m/w/d)“ bleiben zusammen; schmale Karten lockern das unten auf. */
.baehr-carousel__word,
.baehr-carousel__word-tail {
	white-space: nowrap;
}

.baehr-carousel__slide[data-pos="0"] .baehr-carousel__label-text {
	background-color: #fff;
	color: #1c1c1c;
}

.baehr-carousel__sub {
	display: block;
	margin-top: 0.5em;
}

.baehr-carousel__sub-text {
	font-size: clamp(12px, 1.1cqw, 16px);
	font-weight: 700;
	line-height: 2;
}

/* Die angeteaserten Außenkarten zeigen nur das Bild – angeschnittene Textfetzen würden unruhig wirken. */
.baehr-carousel__slide[data-pos="-2"] .baehr-carousel__label,
.baehr-carousel__slide[data-pos="2"] .baehr-carousel__label,
.baehr-carousel__slide[data-pos="-3"] .baehr-carousel__label,
.baehr-carousel__slide[data-pos="3"] .baehr-carousel__label {
	opacity: 0;
}

.baehr-carousel__label {
	transition: opacity 0.4s ease;
}

/* Standort-Zeile und Button: nur auf der Mittelkarte sichtbar (die Plätze bleiben belegt, damit alle Karten gleich hoch sind). */
.baehr-carousel__meta,
.baehr-carousel__cta {
	opacity: 0;
	visibility: hidden;
	transform: translateY(14px);
	transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s linear 0.3s;
}

.baehr-carousel__slide[data-pos="0"] .baehr-carousel__meta,
.baehr-carousel__slide[data-pos="0"] .baehr-carousel__cta {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity 0.6s ease 0.3s, transform 0.7s cubic-bezier(0.22, 0.8, 0.2, 1) 0.3s, visibility 0s;
}

.baehr-carousel__slide[data-pos="0"] .baehr-carousel__cta {
	transition-delay: 0.42s, 0.42s, 0s;
}

.baehr-carousel__meta {
	display: block;
	margin-top: 1.1em;
	color: #1c1c1c;
	font-size: clamp(12px, 1.05cqw, 15px);
	font-weight: 700;
	letter-spacing: 1.5px;
	line-height: 1.4;
	text-transform: uppercase;
}

.baehr-carousel__cta {
	display: inline-flex;
	align-items: center;
	gap: 0.7em;
	margin-top: 1.25em;
	padding: 1em 1.7em;
	background-color: #1c1c1c;
	color: #fff;
	font-size: clamp(13px, 1.15cqw, 16px);
	font-weight: 800;
	letter-spacing: 1px;
	line-height: 1.2;
	text-transform: uppercase;
}

.baehr-carousel__cta svg {
	flex: none;
	transition: transform 0.3s ease;
}

.baehr-carousel__link:hover .baehr-carousel__cta,
.baehr-carousel__link:focus-visible .baehr-carousel__cta {
	background-color: #fff;
	color: #1c1c1c;
}

.baehr-carousel__link:hover .baehr-carousel__cta svg,
.baehr-carousel__link:focus-visible .baehr-carousel__cta svg {
	transform: translateX(5px);
}

/* Bedienelemente: Pfeile, Zähler mit Fortschrittslinie ------------------------------------------------ */
.baehr-carousel__controls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: clamp(14px, 2.4cqw, 34px);
	margin-top: 4px;
}

.baehr-carousel__controls[hidden],
.baehr-carousel [hidden] {
	display: none !important; /* Autoren-CSS (display:flex u. a.) überstimmt sonst das hidden-Attribut. */
}

.baehr-carousel__nav {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 56px;
	height: 56px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background-color: #1c1c1c;
	color: #fff;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.baehr-carousel__nav:hover,
.baehr-carousel__nav:focus-visible {
	background-color: #fff;
	color: #1c1c1c;
}

.baehr-carousel__nav:active {
	transform: scale(0.94);
}

.baehr-carousel__nav:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
	box-shadow: 0 0 0 5px #1c1c1c;
}

.baehr-carousel__counter {
	display: flex;
	align-items: center;
	gap: 16px;
	color: #1c1c1c;
	font-size: 26px;
	font-variant-numeric: tabular-nums;
	font-weight: 800;
	letter-spacing: 0.06em;
	line-height: 1;
}

.baehr-carousel__counter-total {
	opacity: 0.55;
}

.baehr-carousel__progress {
	position: relative;
	display: block;
	width: clamp(90px, 15cqw, 240px);
	height: 3px;
	overflow: hidden;
	background-color: rgba(28, 28, 28, 0.28);
	background-color: color-mix(in srgb, currentColor 28%, transparent);
}

.baehr-carousel__progress-bar {
	position: absolute;
	inset: 0;
	background-color: currentColor;
	transform: scaleX(var(--baehr-progress, 0.2));
	transform-origin: left center;
	transition: transform 0.75s cubic-bezier(0.22, 0.8, 0.2, 1);
}

/* Nach der letzten Stelle beginnt die Linie sichtbar von vorn. */
.baehr-carousel__progress-bar.is-restart {
	animation: baehr-restart 0.9s cubic-bezier(0.22, 0.8, 0.2, 1);
}

.baehr-carousel__counter-current.is-tick {
	animation: baehr-tick 0.5s cubic-bezier(0.22, 0.8, 0.2, 1);
}

@keyframes baehr-restart {
	from { transform: scaleX(0); }
}

@keyframes baehr-tick {
	from { opacity: 0; transform: translateY(0.5em); }
}

/* Nur für Screenreader (Ansage der aktuellen Stelle). */
.baehr-carousel__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Leerer Zustand ---------------------------------------------------------------------------------- */
.baehr-carousel-empty {
	padding-block: 56px;
	text-align: center;
}

.baehr-carousel-empty p {
	margin: 0;
}

.baehr-carousel-empty .baehr-carousel__label-text {
	line-height: 2.1;
}

/* Responsive Grundwerte. Die Elementor-Einstellungen (Tab „Stil → Bühne“) überstimmen sie pro Gerät. */
@media (max-width: 1024px) {
	.baehr-carousel {
		--baehr-cw: 50;
		--baehr-ov: -1;
	}

	.baehr-carousel__stage {
		padding-block: 40px;
	}

	.baehr-carousel__label-text {
		font-size: clamp(20px, 3.4cqw, 28px);
	}

	.baehr-carousel__sub-text,
	.baehr-carousel__meta {
		font-size: clamp(12px, 1.8cqw, 15px);
	}

	.baehr-carousel__cta {
		font-size: clamp(13px, 2cqw, 16px);
	}
}

@media (max-width: 767px) {
	.baehr-carousel {
		--baehr-cw: 76;
		--baehr-s1: 0.8;
		--baehr-s2: 0.6;
		--baehr-ov: 14;
		--baehr-ov2: 10;
	}

	.baehr-carousel__stage {
		padding-block: 28px;
	}

	.baehr-carousel__label-text {
		font-size: clamp(18px, 5.6cqw, 24px);
	}

	.baehr-carousel__sub-text,
	.baehr-carousel__meta {
		font-size: clamp(11px, 3.2cqw, 14px);
	}

	.baehr-carousel__cta {
		font-size: clamp(13px, 3.6cqw, 16px);
	}
}

/* Mittlere Container (Tablet): Die Nachbarn werden vom Rand angeschnitten; abgeschnittene Titelfetzen wären Rauschen. */
@container (max-width: 900px) {
	/*
	 * Lange Wörter: Die Box wandert als Ganzes in die nächste Zeile und wird nur dann per Silbentrennung
	 * umbrochen, wenn das Wort allein breiter als die Karte ist. Mit line-height: normal und demselben
	 * Innenabstand deckt ihr Hintergrund genau die Fläche des Textkastens ab.
	 */
	.baehr-carousel__word {
		display: inline-block;
		max-width: 100%;
		white-space: normal;
		text-wrap: wrap; /* Kein Ausgleichen innerhalb der Box: Das würde Wörter trennen, nur um Zeilen anzugleichen. */
		padding-block: 0.18em;
		line-height: normal;
		background-color: inherit;
		-webkit-hyphens: auto;
		hyphens: auto;
	}

	.baehr-carousel__slide[data-pos="-1"] .baehr-carousel__label,
	.baehr-carousel__slide[data-pos="1"] .baehr-carousel__label {
		opacity: 0;
	}
}

/* Schmale Container (Handy, Seitenspalte): Teaser ausblenden, Nachbarn schauen nur seitlich hervor. */
@container (max-width: 720px) {
	.baehr-carousel__slide[data-pos="-2"],
	.baehr-carousel__slide[data-pos="2"] {
		--o: 0;
	}

	.baehr-carousel__stage {
		-webkit-mask-image: linear-gradient(90deg, transparent 0, #000 4cqw, #000 calc(100% - 4cqw), transparent 100%);
		mask-image: linear-gradient(90deg, transparent 0, #000 4cqw, #000 calc(100% - 4cqw), transparent 100%);
	}

	.baehr-carousel__label {
		margin-inline: -4%;
	}

	.baehr-carousel__nav {
		width: 48px;
		height: 48px;
	}

	.baehr-carousel__counter {
		font-size: 17px;
		gap: 12px;
	}

	.baehr-carousel__progress {
		width: clamp(60px, 22cqw, 140px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.baehr-carousel__slide,
	.baehr-carousel__media,
	.baehr-carousel .baehr-carousel__media .baehr-carousel__img,
	.baehr-carousel__label-text,
	.baehr-carousel__meta,
	.baehr-carousel__cta,
	.baehr-carousel__progress-bar,
	.baehr-carousel__nav {
		transition: none !important;
		animation: none !important;
	}
}
