/**
 * CM Site Animations — Basis-CSS
 * Phase 2: Lenis-Smooth-Scroll (empfohlene Styles).
 * Phasen 3+ ergänzen Reveal-/Text-Opacity-Grundzustände.
 */

/* --- Lenis (empfohlene Styles) --- */
html.lenis,
html.lenis body {
	height: auto;
}

.lenis.lenis-smooth {
	scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
	overscroll-behavior: contain;
}

.lenis.lenis-stopped {
	overflow: hidden;
}

.lenis.lenis-smooth iframe {
	pointer-events: none;
}

/* --- Reveal-Grundzustand (Phase 3) ---
   Nur aktiv, wenn das Head-Flag `cm-anim-js` gesetzt ist (JS an, kein reduced-motion).
   Ohne JS bleibt der Inhalt sichtbar (progressive enhancement, FOUC-sicher). */
html.cm-anim-js .cm-reveal {
	opacity: 0;
	visibility: hidden;
	will-change: transform, opacity;
}

/* --- Text-Opacity-Grundzustand (Phase 4) ---
   Element vor-dimmen, damit kein heller Aufblitz vor dem Split entsteht.
   JS setzt danach Element=1 und dimmt die einzelnen Wörter. */
html.cm-anim-js .cm-text-opacity {
	opacity: 0.18;
}
.cm-text-opacity .word {
	will-change: opacity;
}

/* --- Marquee (Phase 5) --- */
.cm-marquee {
	overflow: hidden;
	width: 100%;
	white-space: nowrap;
}
.cm-marquee__track {
	display: inline-flex;
	flex-wrap: nowrap;
	will-change: transform;
}
.cm-marquee__item {
	flex: 0 0 auto;
	white-space: nowrap;
	padding-right: 0.35em;
}
/* 0.10.1: cm-marquee auf Divi-SEKTIONEN — Rows/Columns/Module deckeln sonst bei
   ihrer max-width (Item wird schmaler gemessen als der Text ist → Textzüge
   übermalen sich). Innerhalb des Laufbands zählt NUR die natürliche Textbreite. */
.cm-marquee__item .et_pb_row,
.cm-marquee__item [class*="et_pb_column"],
.cm-marquee__item .et_pb_module {
	width: auto !important;
	max-width: none !important;
	min-width: 0 !important;
	flex: 0 0 auto !important;
}
/* Bis fertig aufgebaut verstecken (kein Aufblitzen des statischen Texts). */
html.cm-anim-js .cm-marquee:not(.cm-marquee--ready) {
	visibility: hidden;
}

/* --- Custom Cursor (Phase 6) --- */
.cm-cursor {
	position: fixed;
	top: 0;
	left: 0;
	width: 34px;
	height: 34px;
	border: 2px solid #fff;
	border-radius: 50%;
	pointer-events: none;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	mix-blend-mode: difference;
	transition: width 0.25s ease, height 0.25s ease, background-color 0.25s ease, border-color 0.25s ease, opacity 0.25s ease;
}
.cm-cursor.is-hover {
	width: 60px;
	height: 60px;
	background: #fff;
}
.cm-cursor.has-label {
	width: 88px;
	height: 88px;
	mix-blend-mode: normal;
	background: #0e1116;
	border-color: transparent;
}
.cm-cursor.is-hidden {
	opacity: 0;
}
.cm-cursor__label {
	color: #fff;
	font-size: 0.78rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	white-space: nowrap;
	opacity: 0;
	transition: opacity 0.2s ease;
}
.cm-cursor.has-label .cm-cursor__label {
	opacity: 1;
}

/* Nativen Cursor ausblenden, solange der Custom-Cursor läuft — Textfelder ausgenommen. */
html.cm-cursor-active,
html.cm-cursor-active a,
html.cm-cursor-active button,
html.cm-cursor-active .cm-cursor-grow,
html.cm-cursor-active .cm-magnetic {
	cursor: none;
}
html.cm-cursor-active input,
html.cm-cursor-active textarea,
html.cm-cursor-active select,
html.cm-cursor-active [contenteditable="true"] {
	cursor: auto;
}

@media (prefers-reduced-motion: reduce) {
	.cm-cursor { display: none !important; }
	html.cm-cursor-active,
	html.cm-cursor-active * { cursor: auto !important; }
}

/* --- Sticky Background Video (cm-bgvideo) ---
   Eine fixe Bühne hinter dem Inhalt; das aktive Video wird per ScrollTrigger eingeblendet. */
.cm-bgvideo-stage {
	position: fixed;
	inset: 0;
	z-index: 0;
	overflow: hidden;
	pointer-events: none;
}
.cm-bgvideo-stage__item {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	background-size: cover;
	background-position: center;
	opacity: 0;
	visibility: hidden;
	will-change: opacity;
}
/* Inhalt über die fixe Bühne heben (Divi-4/5-Wrapper; JS setzt zusätzlich hart). */
html.cm-bgvideo-on #page-container,
html.cm-bgvideo-on #et-boc,
html.cm-bgvideo-on .et-l--body {
	position: relative;
	z-index: 1;
}
/* Weiße Inhalts-Wrapper transparent, damit die fixe Video-Bühne durchscheint
   (Divi setzt #main-content standardmäßig auf #fff; bei Theme-Builder-Bodies sind
   die Sektionen tief verschachtelt → ganze Wrapper-Kette absichern). */
html.cm-bgvideo-on #main-content,
html.cm-bgvideo-on #et-main-area,
html.cm-bgvideo-on .et-l,
html.cm-bgvideo-on .et-l--body,
html.cm-bgvideo-on .et-l--post,
html.cm-bgvideo-on .et_builder_inner_content,
html.cm-bgvideo-on .et_pb_post_content {
	background-color: transparent !important;
}

/* --- Video-Overlay (cm-video-overlay) ---
   Divi bietet bei Hintergrund-Videos keinen Farb-Overlay (anders als bei Bildern).
   JS liest die Hintergrundfarbe der Sektion und legt sie als Schicht ÜBER das Video
   (in den Divi-Video-Wrapper), unter den Inhalt. Farbe/Deckkraft setzt das JS inline. */
.cm-video-overlay__layer {
	position: absolute;
	inset: 0;
	pointer-events: none;
	z-index: 1;
}

/* Divi-5-Workaround: Ist an der Sektion „Player-Pause zulassen" aktiv, steckt das
   Hintergrund-Video in einem MediaElement-Player. Divi rechnet das <video> zwar
   auf Cover-Größe, lässt den Player-Wrapper aber auf seinen Default-Maßen
   (480×270, inline) stehen — das Video erscheint als kleines Kästchen. Wrapper
   auf volle Wrapper-Fläche zwingen (!important gegen die Inline-Styles). */
.cm-video-overlay .et-pb-background-video .mejs-container,
.cm-video-overlay .et_pb_section_video_bg .mejs-container {
	width: 100% !important;
	height: 100% !important;
}

/* --- Bild-Masken-Reveal (cm-gallery-special-01 / cm-img-mask) ---
   Das Bild „wächst" hinter einer Maske (clip-path, von unten) in den Rahmen und
   settelt aus leichtem Zoom (scale → 1). Rahmen brauchen overflow:hidden, damit
   der Zoom nicht überläuft. Divi-5-Strukturen: Galerie-Bild + Bild-Modul-Wrap. */
[class*="cm-gallery-special-"] .et_pb_gallery_image,
[class*="cm-gallery-special-"] .et_pb_image_wrap,
[class*="cm-gallery-special-"] figure,
.cm-img-mask .et_pb_image_wrap,
.cm-img-mask figure,
img.cm-img-mask {
	overflow: hidden;
}

/* FOUC: Rahmen vor dem JS maskieren — nur mit Head-Flag `cm-anim-js`. Ohne JS / bei
   GSAP-Ausfall (initReveal nimmt das Flag zurück) bleibt alles voll sichtbar. */
html.cm-anim-js [class*="cm-gallery-special-"] .et_pb_gallery_image,
html.cm-anim-js [class*="cm-gallery-special-"] .et_pb_image_wrap,
html.cm-anim-js .cm-img-mask .et_pb_image_wrap,
html.cm-anim-js img.cm-img-mask {
	clip-path: inset(0% 0% 100% 0%);
	will-change: clip-path, transform;
}

/* --- Reduced Motion: Sicherheitsnetz --- */
@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto !important;
	}
	html.cm-anim-js .cm-reveal {
		opacity: 1 !important;
		visibility: visible !important;
	}
	html.cm-anim-js .cm-text-opacity {
		opacity: 1 !important;
	}
	html.cm-anim-js [class*="cm-gallery-special-"] .et_pb_gallery_image,
	html.cm-anim-js [class*="cm-gallery-special-"] .et_pb_image_wrap,
	html.cm-anim-js .cm-img-mask .et_pb_image_wrap,
	html.cm-anim-js img.cm-img-mask {
		clip-path: none !important;
	}
}
