/* Widgets mit 3D-Modell: „Pool füllen beim Scrollen“ und „Farbwahl“.
   Farben, Höhen und Schrift über Elementor (CSS-Variablen) anpassbar. */

.lf-pool-fill,
.lf-pool-colors {
	--lf-stage-height: 520px;
	position: relative;
}

.lf-pool-fill__stage,
.lf-pool-colors__stage {
	position: relative;
	height: var(--lf-stage-height);
}

.lf-pool-fill__stage model-viewer,
.lf-pool-colors__stage model-viewer {
	display: block;
	width: 100%;
	height: 100%;
	background: transparent;
	--poster-color: transparent;
	--progress-bar-color: transparent;
}

/* Modell blendet nach dem Laden weich ein. */
.lf-pool-fill__stage model-viewer,
.lf-pool-colors__stage model-viewer {
	opacity: 0;
	transition: opacity 0.6s ease;
}

.is-ready > model-viewer {
	opacity: 1;
}

/* Weicher Farbwechsel: Standbild der bisherigen Farbe blendet aus. */
.lf-stage-snapshot {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	transition: opacity 0.7s ease;
}

.lf-stage-snapshot.is-fading {
	opacity: 0;
}

.lf-pool-model-missing {
	padding: 24px;
	border: 1px dashed currentColor;
	opacity: 0.7;
	text-align: center;
}

/* ---------- Pool füllen beim Scrollen ---------- */

.lf-pool-fill {
	--lf-title: #00263e;
	--lf-text: #00263e;
	--lf-overlap: 140px;
	--lf-length: 1.5;
}

.lf-pool-fill__sticky {
	display: flex;
	flex-direction: column;
}

/* Scrollytelling: Fensterhöhe plus Strecke, in der der Abschnitt steht. */
.lf-pool-fill.is-pinned {
	height: calc(100vh * (1 + var(--lf-length)));
}

.lf-pool-fill.is-pinned .lf-pool-fill__sticky {
	position: sticky;
	top: 0;
	justify-content: center;
	height: 100vh;
}

.lf-pool-fill.is-pinned .lf-pool-fill__stage {
	max-height: calc(100vh - 120px);
}

.lf-pool-fill__text {
	position: relative;
	z-index: 1;
	width: min(100%, 560px);
	color: var(--lf-text);
}

.lf-pool-fill.is-text-right .lf-pool-fill__text {
	align-self: flex-end;
}

.lf-pool-fill__title {
	margin: 0 0 20px;
	color: var(--lf-title);
}

.lf-pool-fill__body {
	display: flex;
	gap: 14px;
	align-items: flex-start;
}

.lf-pool-fill__body p {
	margin: 0;
	color: var(--lf-text);
}

.lf-pool-fill__icon {
	flex: none;
	width: 36px;
	height: 36px;
	object-fit: contain;
}

/* Modell unter dem Text, leicht überlappend (Mockup: Pool links unten). */
.lf-pool-fill__text + .lf-pool-fill__stage {
	width: min(100%, 78%);
	margin-top: calc(-1 * var(--lf-overlap));
}

.lf-pool-fill.is-text-left .lf-pool-fill__text + .lf-pool-fill__stage {
	align-self: flex-end;
}

@media (max-width: 767px) {
	.lf-pool-fill__text + .lf-pool-fill__stage {
		width: 100%;
	}
}

/* ---------- Farbwahl ---------- */

.lf-pool-colors {
	--lf-title: #fff;
	--lf-text: #fff;
	--lf-swatch: 40px;
	color: var(--lf-text);
}

.lf-pool-colors__head {
	display: flex;
	flex-wrap: wrap;
	gap: 24px 48px;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 32px;
}

.lf-pool-colors__heading {
	margin: 0;
	color: var(--lf-title);
}

.lf-pool-colors__choice {
	display: flex;
	flex-wrap: wrap;
	gap: 16px 24px;
	align-items: center;
}

.lf-pool-colors__text {
	margin: 0;
	color: var(--lf-text);
}

.lf-pool-colors__swatches {
	display: flex;
	gap: 16px;
}

/* Hello-Theme setzt Buttons farbig – hier neutral. */
.lf-pool-colors .lf-pool-colors__swatch,
.lf-pool-colors .lf-pool-colors__swatch:hover,
.lf-pool-colors .lf-pool-colors__swatch:focus {
	display: flex;
	flex-direction: column;
	gap: 8px;
	align-items: center;
	padding: 0;
	border: 0;
	background: none;
	color: var(--lf-text);
	box-shadow: none;
	cursor: pointer;
}

.lf-pool-colors__swatch:focus-visible {
	outline: 2px solid var(--lf-text);
	outline-offset: 4px;
	border-radius: 6px;
}

.lf-pool-colors__dot {
	width: var(--lf-swatch);
	height: var(--lf-swatch);
	border-radius: 50%;
	background: var(--lf-dot) var(--lf-dot-image, none) center / cover;
	box-shadow: 0 0 0 2px transparent;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.lf-pool-colors__swatch:hover .lf-pool-colors__dot {
	transform: scale(1.06);
}

.lf-pool-colors__swatch[aria-checked="true"] .lf-pool-colors__dot {
	box-shadow: 0 0 0 3px var(--lf-text);
}

.lf-pool-colors__name {
	font-size: 0.95em;
}

/* ---------- Pool-Inszenierung ---------- */

.lf-pool-story {
	--lf-bg: #00263e;
	--lf-title: #fff;
	--lf-text: #fff;
	--lf-length: 3;
	--lf-ratio: 1.7778;
	/* Fensterhöhe plus Scrollstrecke, in der der Abschnitt stehen bleibt. */
	height: calc(100vh * (1 + var(--lf-length)));
	background: var(--lf-bg);
	color: var(--lf-text);
}

/* Überschrift oben, darunter die Bühne mittig in der restlichen Höhe. */
.lf-pool-story__sticky {
	position: sticky;
	top: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	height: 100vh;
	padding-top: 18vh;
	padding-bottom: 4vh;
	box-sizing: border-box;
	overflow: hidden;
	/* Für die Hinweise: Breite des Abschnitts als cqw. */
	container-type: inline-size;
}

.lf-pool-story__heading {
	position: absolute;
	top: 6vh;
	left: 0;
	z-index: 2;
	max-width: min(100%, 640px);
	margin: 0;
	color: var(--lf-title);
}

/* Bühne und Foto teilen sich den Rahmen im Seitenverhältnis des Fotos. */
.lf-pool-story__frame {
	position: relative;
	width: min(100%, calc(76vh * var(--lf-ratio)));
	aspect-ratio: var(--lf-ratio);
	margin: 0 auto;
	/* Am Ende auf die ganze Fläche vergrößert (gesetzt per Skript). */
	transform: var(--lf-cover, none);
}

/* Während der Bewegung eigene Ebene: Vergrößern skaliert nur, statt jedes Bild
   neu zu zeichnen. Im Stillstand ohne, damit das Foto scharf gezeichnet wird. */
.lf-pool-story__frame.is-moving {
	will-change: transform;
}

.lf-pool-story__photo {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: fill;
	opacity: 0;
}

.lf-pool-story__stage {
	position: absolute;
	inset: 0;
	will-change: transform;
}

.lf-pool-story__stage model-viewer {
	display: block;
	width: 100%;
	height: 100%;
	background: transparent;
	--poster-color: transparent;
	--progress-bar-color: transparent;
}

/* Hinweise links und rechts neben dem Pool, Höhe relativ zur Bühne. Sie
   nutzen den freien Platz neben dem Rahmen (--lf-gutter) und reichen nur so weit
   hinein, wie ihnen sonst Breite fehlt – höchstens 34 % des Rahmens. */
.lf-pool-story__note {
	--lf-want: min(360px, 34cqw);
	--lf-gutter: calc((100cqw - 100%) / 2);
	--lf-inner: clamp(0px, var(--lf-want) - var(--lf-gutter), 34%);
	position: absolute;
	top: var(--lf-top);
	z-index: 2;
	display: flex;
	gap: 16px;
	align-items: center;
	width: min(var(--lf-want), var(--lf-inner) + var(--lf-gutter));
	transform-origin: center;
	color: var(--lf-text);
	opacity: 0;
	transform: translateY(calc(-50% + 16px));
	transition: opacity 0.5s ease, transform 0.5s ease;
	pointer-events: none;
}

.lf-pool-story__note.is-visible {
	opacity: 1;
	transform: translateY(-50%);
}

.lf-pool-story__note.is-left {
	left: calc(var(--lf-inner) - min(var(--lf-want), var(--lf-inner) + var(--lf-gutter)));
}

.lf-pool-story__note.is-right {
	right: calc(var(--lf-inner) - min(var(--lf-want), var(--lf-inner) + var(--lf-gutter)));
	flex-direction: row-reverse;
}

/* Linie zum Pool hin. */
.lf-pool-story__note::after {
	content: "";
	flex: none;
	width: 56px;
	height: 1px;
	background: currentColor;
}

.lf-pool-story__note-text > :last-child {
	margin-bottom: 0;
}

/* Hochformat: Bühne höher und seitlich überstehend (Pool und Foto bleiben
   deckungsgleich, nur außen beschnitten); Hinweise über die ganze Breite unter
   der Überschrift – meist ist ohnehin nur einer sichtbar. */
@media (max-width: 767px) {
	.lf-pool-story__frame {
		width: calc(40vh * var(--lf-ratio));
		max-width: none;
		margin-left: 50%;
		transform: translateX(-50%) var(--lf-cover, );
	}

	.lf-pool-story__sticky {
		justify-content: flex-end;
		padding-bottom: 8vh;
	}

	/* Über der Bühne, mittig im Fenster (die Bühne ist breiter als das Fenster). */
	.lf-pool-story__note,
	.lf-pool-story__note.is-left,
	.lf-pool-story__note.is-right {
		top: auto;
		right: auto;
		bottom: calc(100% + 16px);
		left: 50%;
		width: calc(100vw - 48px);
		font-size: 0.95em;
		transform: translate(-50%, 16px);
	}

	.lf-pool-story__note.is-visible {
		transform: translate(-50%, 0);
	}

	.lf-pool-story__note::after {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.lf-pool-story__note {
		transition: none;
	}
}

/* ---------- Größenvergleich ---------- */

.lf-pool-sizes {
	--lf-title: #fff;
	--lf-text: #fff;
	--lf-row: 130px;
	--lf-length: 1.5;
	color: var(--lf-text);
}

.lf-pool-sizes.is-pinned {
	height: calc(100vh * (1 + var(--lf-length)));
}

.lf-pool-sizes.is-pinned .lf-pool-sizes__sticky {
	position: sticky;
	top: 0;
	display: flex;
	flex-direction: column;
	/* Höher als das Fenster (Handy quer): nach unten überstehen, nicht nach oben in den Abschnitt davor. */
	justify-content: safe center;
	height: 100vh;
}

.lf-pool-sizes__heading {
	margin: 0 0 40px;
	color: var(--lf-title);
}

.lf-pool-sizes .lf-pool-sizes__rows {
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Pool | Linie | Länge – die Länge steht fest, nur der Pool wächst. */
.lf-pool-sizes__row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) clamp(32px, 10vw, 120px) auto;
	align-items: center;
	height: var(--lf-row);
}

.lf-pool-sizes__stage {
	position: relative;
	height: 100%;
}

.lf-pool-sizes__line {
	height: 1px;
	margin: 0 16px;
	background: currentColor;
}

.lf-pool-sizes__value {
	min-width: 4.6em;
	font-size: 2.2em;
	line-height: 1;
	white-space: nowrap;
}

.lf-pool-sizes__stage model-viewer {
	display: block;
	width: 100%;
	height: 100%;
	background: transparent;
	--poster-color: transparent;
	--progress-bar-color: transparent;
	opacity: 0;
	transition: opacity 0.6s ease;
}

.lf-pool-sizes__stage.is-ready model-viewer {
	opacity: 1;
}

@media (max-width: 767px) {
	.lf-pool-sizes__value {
		font-size: 1.2em;
	}

	.lf-pool-sizes__line {
		margin: 0 8px;
	}
}

/* ---------- Vorgerenderte Ansichten ---------- */

.lf-pool-colors__stage.is-image {
	display: grid;
	/* Feste Zeile/Spalte: sonst richtet sich die Zeile nach dem Bild und
	   max-height in % greift nicht (Bild in Originalgröße, abgeschnitten). */
	grid-template: minmax(0, 1fr) / minmax(0, 1fr);
	place-items: center;
	overflow: hidden;
}

.lf-pool-colors__image {
	grid-area: 1 / 1;
	max-width: calc(100% * var(--lf-scale, 0.85));
	max-height: calc(100% * var(--lf-scale, 0.85));
	opacity: 0;
	transition: opacity 0.7s ease;
}

.lf-pool-colors__image.is-active {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.lf-pool-colors__image {
		transition: none;
	}
}

.lf-pool-sizes__stage.is-image {
	display: flex;
	align-items: center;
	justify-content: flex-end;
}

/* Drei Teile desselben Bilds: Anfang (25 %), gestrecktes Mittelstück, Ende (25 %). */
.lf-pool-sizes__pool {
	display: flex;
	height: var(--lf-height, 0);
}

.lf-pool-sizes__pool > span {
	display: block;
	height: 100%;
	background-image: var(--lf-img);
	background-repeat: no-repeat;
}

.lf-pool-sizes__pool > span:first-child,
.lf-pool-sizes__pool > span:last-child {
	flex: none;
	width: calc(var(--lf-unit, 0px) * 0.25);
	background-size: var(--lf-unit, 0px) 100%;
}

.lf-pool-sizes__pool > span:first-child {
	background-position: 0 0;
}

.lf-pool-sizes__pool > span:last-child {
	background-position: 100% 0;
}

.lf-pool-sizes__pool > span:nth-child(2) {
	flex: none;
	width: var(--lf-middle, 0px);
	/* Mittlere Bildhälfte (25–75 %) auf die Breite des Mittelstücks strecken. */
	background-size: calc(var(--lf-middle, 0px) * 2) 100%;
	background-position: calc(var(--lf-middle, 0px) * -0.5) 0;
}

/* Fall-Illusion: Partikel hinter dem Pool. */
/* Breite und Lage links setzt fall.ts (volle Fensterbreite). */
.lf-pool-story__fall {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

/* Auf dem Desktop darf die Partikelfläche über die Spalte hinausreichen
   (am Handy schneidet der Rahmen die überbreite Bühne ab). */
@media (min-width: 768px) {
	.lf-pool-story__sticky {
		overflow: visible;
	}

	/* Solange das Foto wächst oder hereingleitet: nichts über den Abschnitt hinaus. */
	.lf-pool-story__sticky.is-covering {
		overflow: clip;
	}
}
