/**
 * kamér Licht – Scroll-Erlebnis (BAUPLAN-ANIMATIONEN P2): 5 Randmond, 6 Sternenstaub,
 * 7 Goldfaden, 8 Listen. Die Deko setzt effekte-scroll.js ein (aria-hidden).
 * Ohne JS entsteht nichts; mit kl-ruhig (auch Live-Wechsel) Endzustand: Staub ruht,
 * Faden ganz gezeichnet, Listen sichtbar, Randmond aus.
 *
 * @package kamer-licht
 */

/* Kennung für effekte-scroll.js. */
:root {
	--kl-effekte-scroll: 1;
}

/* ==== 1. Grundzustand (ohne Bewegung sichtbar, ruhend) ==== */

/* ---- 6. Sternenstaub: Der Abschnitt bildet den Stapelkontext ---- */
html.kl-js .kl-sterne {
	position: relative;
	isolation: isolate;
}

/* z-index −1: über dem Hintergrund, unter dem Inhalt (0 läge über Text). Der Überstand
   der Ebenen wird abgeschnitten; grid-area/margin/max-width heben Layout-Regeln auf. */
:is(.kl-sterne, .kl-fuss) > .kl-staub {
	position: absolute;
	inset: 0;
	z-index: -1;
	grid-area: auto;
	overflow: hidden;
	width: auto;
	max-width: none;
	margin: 0;
	opacity: 0.5;
	pointer-events: none;
}

/* Überstand: 8vh + 7 % der Abschnittshöhe (Skript begrenzt den Versatz). */
.kl-staub__ebene {
	position: absolute;
	inset: calc(-8vh - 7%) 0;
	background-repeat: repeat;
}

/* Ebene 1: feine Punkte, verschiedene Kacheln (kein Gitter). */
.kl-staub__ebene--1 {
	background-image:
		radial-gradient(circle at 37px 52px, rgb(255 255 255 / 0.8) 0 0.6px, transparent 1.1px),
		radial-gradient(circle at 128px 17px, rgb(255 255 255 / 0.55) 0 0.5px, transparent 1px),
		radial-gradient(circle at 151px 133px, rgb(247 243 236 / 0.7) 0 0.55px, transparent 1.05px),
		radial-gradient(circle at 74px 161px, rgb(255 255 255 / 0.45) 0 0.5px, transparent 1px);
	background-size: 180px 180px, 198px 198px, 222px 222px, 186px 186px;
}

/* Ebene 2: gröbere Punkte, etwas Gold. */
.kl-staub__ebene--2 {
	background-image:
		radial-gradient(circle at 61px 88px, rgb(255 255 255 / 0.75) 0 0.9px, transparent 1.6px),
		radial-gradient(circle at 247px 203px, rgb(230 204 143 / 0.85) 0 1.1px, rgb(230 204 143 / 0.18) 2px, transparent 3.2px),
		radial-gradient(circle at 173px 297px, rgb(255 255 255 / 0.5) 0 0.8px, transparent 1.4px),
		radial-gradient(circle at 301px 41px, rgb(230 204 143 / 0.6) 0 0.9px, transparent 1.6px);
	background-size: 320px 320px, 352px 352px, 336px 336px, 388px 388px;
}

/* Handy: nur eine Ebene. */
@media (max-width: 699.98px) {
	.kl-staub__ebene--2 {
		display: none;
	}
}

/* ---- 7. Goldfaden: mittig im freien linken Rand (main als Bezug), nie über Text ---- */
.kl-faden {
	display: none;
}

.kl-haupt.ist-faden {
	position: relative;
}

@media screen and (min-width: 1100px) {

	.kl-haupt > .kl-faden {
		--kl-faden-luft: max(var(--wp--style--root--padding-left, 2.5rem), (100% - var(--wp--style--global--wide-size, 76rem)) / 2);
		position: absolute;
		top: 0;
		left: calc(min(clamp(1.25rem, 3vw, 2.75rem), var(--kl-faden-luft) / 2) - 12px);
		z-index: 1;
		display: block;
		width: 24px;
		height: 100%;
		max-width: none;
		margin: 0;
		overflow: visible;
		pointer-events: none;
	}
}

/* Farbe: Verlauf #kl-faden-ton (Skript, je Abschnitt): Gold 55 % auf Dunkel, Bronze
   #9A7B3A 85 % auf Hell (Gold wäre dort zu blass, ≈ 1,5:1). */
.kl-faden__spur,
.kl-faden__linie {
	fill: none;
	stroke-width: 1;
}

/* Noch nicht gezeichneter Weg: nur eine Ahnung. */
.kl-faden__spur {
	opacity: 0.25;
}

/* Knoten an jeder H2: Goldring, füllt sich beim Passieren. */
.kl-faden__knoten {
	--kl-faden-ton: #E6CC8F;
}

.kl-faden__knoten--hell {
	--kl-faden-ton: #9A7B3A;
}

.kl-faden__punkt {
	fill: var(--kl-faden-ton);
	fill-opacity: 0;
	stroke: var(--kl-faden-ton);
	stroke-opacity: 0.7;
	stroke-width: 1;
}

.kl-faden__schein {
	fill: var(--kl-faden-ton);
	opacity: 0;
	transform: scale(0.35);
	transform-box: fill-box;
	transform-origin: center;
}

/* Leuchtend: passiert (ist-an) oder Endzustand. */
.kl-faden__knoten.ist-an .kl-faden__punkt,
html.kl-ruhig .kl-faden__punkt {
	fill-opacity: 1;
	stroke-opacity: 1;
}

.kl-faden__knoten.ist-an .kl-faden__schein,
html.kl-ruhig .kl-faden__schein {
	opacity: 0.28;
	transform: none;
}

/* Lichtpunkt an der Fadenspitze, nur während er wächst. */
.kl-faden__spitze {
	opacity: 0;
}

.kl-faden__hof {
	fill: #E6CC8F;
	opacity: 0.22;
}

.kl-faden__kern {
	fill: #F3E3B5;
	stroke: rgb(154 123 58 / 0.7);
	stroke-width: 0.75;
}

html.kl-ruhig .kl-faden__spitze {
	display: none;
}

/* ---- 5. Randmond: aus, bis Abschnitt 3 ihn zeigt ---- */
.kl-randmond {
	display: none;
}

/* ==== 2. Bewegung (Bildschirm, mit JS, ohne „Bewegung reduzieren“) ==== */

@media screen and (prefers-reduced-motion: no-preference) {

	/* ---- 6. Sternenstaub: Versatz vom Skript, will-change nur sichtbar ---- */

	html.kl-js:not(.kl-ruhig) .kl-staub__ebene {
		transform: translateY(var(--kl-staub-y, 0px));
	}

	html.kl-js:not(.kl-ruhig) .kl-staub.ist-an > .kl-staub__ebene {
		will-change: transform;
	}

	/* ---- 7. Goldfaden zeichnet sich mit dem Lesefortschritt ---- */

	html.kl-js:not(.kl-ruhig) .kl-faden__linie {
		stroke-dasharray: var(--kl-faden-l, 0px) var(--kl-faden-l, 0px);
		stroke-dashoffset: var(--kl-faden-rest, 0px);
	}

	html.kl-js:not(.kl-ruhig) .kl-faden__spitze {
		transform: translate(12px, var(--kl-faden-spitze, 0px));
		transition: opacity 0.5s ease;
	}

	html.kl-js:not(.kl-ruhig) .kl-faden.ist-unterwegs .kl-faden__spitze {
		opacity: 1;
	}

	/* Aufleuchten mit leichtem Nachschwingen. */
	html.kl-js:not(.kl-ruhig) .kl-faden__punkt {
		transition: fill-opacity 0.6s ease, stroke-opacity 0.6s ease;
	}

	html.kl-js:not(.kl-ruhig) .kl-faden__schein {
		transition: opacity 0.9s ease, transform 1.1s cubic-bezier(0.34, 1.56, 0.64, 1);
	}

	/* ---- 8. Listen füllen sich Punkt für Punkt (li 10px von links, 90 ms Versatz).
	   kl-reveal-gruppe blendet kamer-bewegung.js ein, hier nur Richtung und Marker.
	   .kl-schlicht-inhalt: Text steht sofort, nur die Marker füllen sich. ---- */

	html.kl-js:not(.kl-ruhig) .kl-liste-mond.ist-wartend:not(.ist-sichtbar, .kl-reveal-gruppe, .kl-schlicht-inhalt *) > li:not(:focus-within) {
		opacity: 0;
		translate: -10px 0;
	}

	html.kl-js:not(.kl-ruhig) .kl-liste-mond.kl-reveal-gruppe:not(.ist-sichtbar) > li:not(:focus-within) {
		translate: -10px 0;
	}

	html.kl-js:not(.kl-ruhig) .kl-liste-mond.ist-wartend:not(.kl-reveal-gruppe) > li {
		transition:
			opacity 0.7s ease calc(var(--kl-i, 0) * 90ms),
			translate 0.9s var(--kl-ease, cubic-bezier(0.22, 1, 0.36, 1)) calc(var(--kl-i, 0) * 90ms);
	}

	html.kl-js:not(.kl-ruhig) .kl-liste-mond.ist-wartend:not(.kl-reveal-gruppe) > li:focus-within {
		transition-delay: 0s;
	}

	/* Marker füllt sich von links, 250 ms nach seinem Punkt. */
	html.kl-js:not(.kl-ruhig) .kl-liste-mond.ist-wartend > li::before {
		clip-path: inset(0 0 0 0);
		transition: clip-path 0.5s var(--kl-ease, cubic-bezier(0.22, 1, 0.36, 1)) calc(var(--kl-i, 0) * 90ms + 250ms);
	}

	html.kl-js:not(.kl-ruhig) .kl-liste-mond.ist-wartend:not(.ist-sichtbar) > li:not(:focus-within)::before {
		clip-path: inset(0 100% 0 0);
	}
}

/* ==== 3. Randmond (nicht 404): vom Kopf bis 1.5rem über dem Fensterrand, rechts
   1.1rem vom Rand im freien Rand neben 76rem Inhalt. Erst ab 83.75em (1340px bei
   16px): darunter ist dieser Rand (≈ 36–60px) zu schmal für 28px Mond + 1.1rem und
   der Mond läge über Text rechter alignwide-Spalten (kl-split, Kontakt) oder an der
   Scrollleiste. Das Skript nutzt dieselbe Abfrage (mqRand). clamp: nie näher als
   0.5rem an den Inhalt (feste Scrollleiste, andere Schriftgröße). ==== */

@media screen and (min-width: 1100px) and (min-width: 83.75em) and (prefers-reduced-motion: no-preference) {

	html.kl-js:not(.kl-ruhig) body:not(.error404) > .kl-randmond {
		--kl-rand-oben: calc(var(--wp-admin--admin-bar--height, 0px) + var(--kl-kopf-hoehe, var(--kl-kopfhoehe, 5rem)));
		--kl-rand-weg: calc(100vh - var(--kl-rand-oben) - 28px - 1.5rem);
		--kl-rand-luft: max(var(--wp--style--root--padding-right, 2.5rem), (100% - var(--wp--style--global--wide-size, 76rem)) / 2);
		position: fixed;
		top: var(--kl-rand-oben);
		right: clamp(4px, var(--kl-rand-luft) - 28px - 0.5rem, 1.1rem);
		z-index: 90;
		display: block;
		width: 28px;
		height: calc(var(--kl-rand-weg) + 28px);
		margin: 0;
		opacity: 0;
		pointer-events: none;
		transition: opacity 0.3s ease;
	}

	@supports (height: 100svh) {
		html.kl-js:not(.kl-ruhig) body:not(.error404) > .kl-randmond {
			--kl-rand-weg: calc(100svh - var(--kl-rand-oben) - 28px - 1.5rem);
		}
	}

	/* Wie oben + .ist-an (Spezifität). */
	html.kl-js:not(.kl-ruhig) body:not(.error404) > .kl-randmond.ist-an {
		opacity: 1;
	}

	/* Goldspur bis zum Mond, wächst per scale. */
	html.kl-js:not(.kl-ruhig) .kl-randmond::before {
		content: "";
		position: absolute;
		top: 0;
		left: calc(50% - 0.5px);
		width: 1px;
		height: var(--kl-rand-weg);
		background: linear-gradient(180deg, rgb(201 163 91 / 0), rgb(201 163 91 / 0.5) 70%, rgb(230 204 143 / 0.85));
		transform-origin: 50% 0;
		scale: 1 var(--kl-rand, 0);
	}

	html.kl-js:not(.kl-ruhig) .kl-randmond__mond {
		position: absolute;
		top: 0;
		left: 0;
		display: block;
		width: 28px;
		height: 28px;
		max-width: none;
		filter: drop-shadow(0 0 4px rgb(230 204 143 / 0.35));
		translate: 0 calc(var(--kl-rand, 0) * var(--kl-rand-weg));
		will-change: translate;
	}

	/* Bei 100 %: kurzer Goldschein (600 ms). */
	html.kl-js:not(.kl-ruhig) .kl-randmond.ist-voll .kl-randmond__mond {
		animation: kl-randmond-glanz 0.6s ease-out;
	}
}

/* ==== 4. Keyframes ==== */

@keyframes kl-randmond-glanz {
	40% { filter: drop-shadow(0 0 10px rgb(230 204 143 / 0.9)); }
}

/* ==== 5. Absicherung: „Bewegung reduzieren“ (zweites Netz) und Druck ==== */

@media (prefers-reduced-motion: reduce) {

	.kl-randmond,
	.kl-faden__spitze {
		display: none !important;
	}

	.kl-staub__ebene {
		transform: none !important;
	}

	.kl-faden__punkt {
		fill-opacity: 1;
		stroke-opacity: 1;
	}

	.kl-faden__schein {
		opacity: 0.28;
		transform: none;
	}

	.kl-liste-mond > li,
	.kl-liste-mond > li::before {
		opacity: 1 !important;
		translate: none !important;
		clip-path: none !important;
		transition: none !important;
	}
}

@media print {

	.kl-randmond,
	.kl-faden,
	.kl-staub {
		display: none !important;
	}
}
