/* =====================================================================
   Schleebach Holding – Motion-System (B1, Finishing 2026-10-27)
   Spezifikation: docs/finishing-2026-10-27/analyse/A2-motion.md
   Signatur: Linien zeichnen sich, Inhalte steigen auf (12–24 px, ease-out).
   Nur opacity/transform/clip-path. Kein Parallax, keine Dauerschleifen.

   Zustände
     html.sh-m               Head-Snippet (inc/motion.php): JS läuft, Verstecken erlaubt.
                             Nie gesetzt bei reduced motion, ohne IntersectionObserver
                             oder wenn das Snippet verspätet läuft (readyState !== loading).
     .is-in                  motion.js, einmalig: Ziel ist enthüllt.
     .is-settled             motion.js nach der Reveal-Transition: ab dann gelten wieder
                             die eigenen Hover-Transitions des Elements.
     .sh-header.is-scrolled  Seite ist mehr als 9 px gescrollt (IO-Sentinel).
     --m-i / --m-stagger     inline von motion.js: Stagger-Index je Elternelement und
                             Observer-Batch; erster Batch (Startviewport) 50 ms.

   API für Komponenten (struktur.css, kontakt.css, portrait.css)
     .sh-reveal              Einzelziel (opacity 0→1, translateY --m-rise → 0).
     .sh-reveal-group > *    Kinder gestaffelt; --m-stagger am Container setzen (Standard 90 ms).
     .sh-seq                 Container bekommt nur .is-in; die Komponente definiert ihre
                             Sequenz selbst und versteckt ausschließlich unter
                             @media screen and (prefers-reduced-motion: no-preference) { html.sh-m .x:not(.is-in) … }
     Verschachtelte Ziele erscheinen mit dem äußersten Ziel (kein doppeltes Blenden).
     Bilder in Zielen (.sh-figure, .sh-split__media) setzen sich von scale(1.04) auf 1.

   Sicherheitsnetze: Snippet-Timer 2,5 s (entfernt html.sh-m, wenn motion.js nicht läuft),
   CSS-Animation sh-m-safety 4 s (zeigt alles, wenn JS nach dem Setzen der Klasse stirbt;
   motion.js pausiert sie über --m-safety). Druck: alle Verstecken-Regeln stehen unter
   @media screen. Reduced motion: Klasse wird nicht gesetzt, globaler Reset in theme.css.
   ===================================================================== */

/* ---------- Tokens ---------- */
:root {
	--m-ease-out: cubic-bezier(0.22, 1, 0.36, 1);   /* Reveals, Hero: schnell los, weich ankommen */
	--m-ease-hover: cubic-bezier(0.4, 0, 0.2, 1);   /* Hover/Fokus, beide Richtungen */
	--m-ease-line: cubic-bezier(0.65, 0, 0.35, 1);  /* Linien zeichnen (ease-in-out) */
	--m-hover: 220ms;    /* Buttons, Links, Karten */
	--m-reveal: 560ms;   /* Scroll-Reveal */
	--m-hero: 650ms;     /* Hero-Elemente beim Laden */
	--m-line: 700ms;     /* Linien in Diagrammen */
	--m-rise: 18px;      /* Versatz Reveal */
	--m-rise-sm: 12px;   /* Versatz Hero, Formularfelder */
	--m-stagger: 90ms;   /* Standard-Stagger */
	--m-safety: running; /* motion.js setzt paused, sobald der Observer steht */
}

/* ---------- Stagger und Versatz je Gruppe (Container, vererbt an die Ziele) ---------- */
.sh-section-head, .sh-b-cols__head, .sh-footer__grid { --m-stagger: 70ms; }
.sh-idea > .wp-block-column, .sh-text-col, .sh-b-cols__body, .sh-split__inner, .sh-contact-band,
.sh-person__text, .sh-brand-section .wp-block-column, .sh-section--compact .wp-block-column { --m-stagger: 80ms; }
.sh-cards { --m-stagger: 100ms; }
.sh-steps { --m-stagger: 110ms; }
/* Formularfelder werden nicht einzeln versteckt (A7 §5.4: Autofill, Fehlerfokus, ?anfrage=); Reveal nur auf der Tafel (B3: .sh-kontakt-form.sh-reveal) */
/* Schritt 04 („Perspektive“) kommt bewusst nach 01–03: mehr Versatz, zusätzliche Verzögerung */
.sh-steps > .wp-block-column:last-child { --m-rise: 24px; --m-extra: 200ms; }
.sh-steps__note { --m-extra: 240ms; }
/* Tim: Eyebrow sofort, der Rest ab 200 ms */
.sh-person__text > :not(:first-child) { --m-extra: 200ms; }

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

	/* ---------- Hero beim Laden: selbstauflösende Keyframes (Startzustand nur im from), Bild nie ----------
	   A7 P1: mobil ist oft H1 oder der erste Absatz das LCP-Element. Deshalb steigen die Texte nur auf
	   (transform, kein Opacity-Start) mit höchstens 80 ms Verzögerung; nur Eyebrow und Buttons blenden ein. */
	html.sh-m :is(.sh-hero__content, .sh-hero-split__text) > * { animation: sh-m-hero-rise var(--m-hero) var(--m-ease-out) both; }
	html.sh-m :is(.sh-hero__content, .sh-hero-split__text) > :nth-child(3) { animation-delay: 60ms; }
	html.sh-m :is(.sh-hero__content, .sh-hero-split__text) > :nth-child(n + 4) { animation-delay: 80ms; }
	html.sh-m :is(.sh-hero__content, .sh-hero-split__text) > :first-child { animation-name: sh-m-hero; }
	html.sh-m :is(.sh-hero__content, .sh-hero-split__text) > .wp-block-buttons { animation-name: sh-m-hero; animation-delay: 240ms; }
	html.sh-m :is(.sh-hero__content, .sh-hero-split__text) .is-style-eyebrow::before {
		transform-origin: left center; animation: sh-m-line 500ms var(--m-ease-line) both;
	}
	html.sh-m .sh-hero__bend { animation: sh-m-bend 900ms var(--m-ease-line) 200ms both; }
	html.sh-m .sh-hero .sh-caption--on-dark { animation: sh-m-fade 500ms var(--m-ease-out) 600ms both; }

	/* ---------- Scroll-Reveal ----------
	   SEL = Reveal-Ziele. Die Liste steht byte-identisch in motion.js (Variable SEL);
	   bei Änderungen beide Stellen pflegen (validate-theme.sh vergleicht sie). */
	/* SEL */
	html.sh-m :where(.sh-reveal, .sh-reveal-group > *, .sh-section-head > *, .sh-b-cols__head > *, .sh-idea > .wp-block-column > *, .sh-brand-section .wp-block-column > *, .sh-section--compact .wp-block-column > *, .sh-text-col > *, .sh-b-cols__body > *, .sh-split__inner > *, .sh-contact-band > *, .sh-section--navy > .is-style-lead, .sh-section--navy > .wp-block-buttons, .sh-cards > .wp-block-column, .sh-values > .wp-block-column, .sh-steps > .wp-block-column, .sh-steps__note, .sh-b-notice, .sh-legal-line, .sh-section .sh-figure, .sh-split__media, .sh-person > .wp-block-column:first-child, .sh-person__text > *, .sh-footer__grid > *) {
		--m-delay: calc(var(--m-i, 0) * var(--m-stagger) + var(--m-extra, 0ms));
	}
	/* SEL */
	html.sh-m :where(.sh-reveal, .sh-reveal-group > *, .sh-section-head > *, .sh-b-cols__head > *, .sh-idea > .wp-block-column > *, .sh-brand-section .wp-block-column > *, .sh-section--compact .wp-block-column > *, .sh-text-col > *, .sh-b-cols__body > *, .sh-split__inner > *, .sh-contact-band > *, .sh-section--navy > .is-style-lead, .sh-section--navy > .wp-block-buttons, .sh-cards > .wp-block-column, .sh-values > .wp-block-column, .sh-steps > .wp-block-column, .sh-steps__note, .sh-b-notice, .sh-legal-line, .sh-section .sh-figure, .sh-split__media, .sh-person > .wp-block-column:first-child, .sh-person__text > *, .sh-footer__grid > *):not(.is-settled) {
		transition: opacity var(--m-reveal) var(--m-ease-out), transform var(--m-reveal) var(--m-ease-out);
		transition-delay: var(--m-delay);
	}
	/* SEL */
	html.sh-m :where(.sh-reveal, .sh-reveal-group > *, .sh-section-head > *, .sh-b-cols__head > *, .sh-idea > .wp-block-column > *, .sh-brand-section .wp-block-column > *, .sh-section--compact .wp-block-column > *, .sh-text-col > *, .sh-b-cols__body > *, .sh-split__inner > *, .sh-contact-band > *, .sh-section--navy > .is-style-lead, .sh-section--navy > .wp-block-buttons, .sh-cards > .wp-block-column, .sh-values > .wp-block-column, .sh-steps > .wp-block-column, .sh-steps__note, .sh-b-notice, .sh-legal-line, .sh-section .sh-figure, .sh-split__media, .sh-person > .wp-block-column:first-child, .sh-person__text > *, .sh-footer__grid > *):not(.is-in) {
		opacity: 0; transform: translateY(var(--m-rise));
		animation: sh-m-safety 1ms linear 4s forwards; animation-play-state: var(--m-safety);
	}

	/* Linien (Eyebrow, Legende, Schritt-Marke) zeichnen sich 120 ms nach dem Elternelement */
	html.sh-m :is(.is-style-eyebrow, .sh-caption, .sh-step__tag)::before {
		transform-origin: left center;
		transition: transform 450ms var(--m-ease-line);
		transition-delay: calc(var(--m-delay, 0ms) + 120ms);
	}
	/* SEL */
	html.sh-m :where(.sh-reveal, .sh-reveal-group > *, .sh-section-head > *, .sh-b-cols__head > *, .sh-idea > .wp-block-column > *, .sh-brand-section .wp-block-column > *, .sh-section--compact .wp-block-column > *, .sh-text-col > *, .sh-b-cols__body > *, .sh-split__inner > *, .sh-contact-band > *, .sh-section--navy > .is-style-lead, .sh-section--navy > .wp-block-buttons, .sh-cards > .wp-block-column, .sh-values > .wp-block-column, .sh-steps > .wp-block-column, .sh-steps__note, .sh-b-notice, .sh-legal-line, .sh-section .sh-figure, .sh-split__media, .sh-person > .wp-block-column:first-child, .sh-person__text > *, .sh-footer__grid > *):not(.is-in) :is(.is-style-eyebrow, .sh-caption, .sh-step__tag)::before,
	/* SEL */
	html.sh-m :where(.sh-reveal, .sh-reveal-group > *, .sh-section-head > *, .sh-b-cols__head > *, .sh-idea > .wp-block-column > *, .sh-brand-section .wp-block-column > *, .sh-section--compact .wp-block-column > *, .sh-text-col > *, .sh-b-cols__body > *, .sh-split__inner > *, .sh-contact-band > *, .sh-section--navy > .is-style-lead, .sh-section--navy > .wp-block-buttons, .sh-cards > .wp-block-column, .sh-values > .wp-block-column, .sh-steps > .wp-block-column, .sh-steps__note, .sh-b-notice, .sh-legal-line, .sh-section .sh-figure, .sh-split__media, .sh-person > .wp-block-column:first-child, .sh-person__text > *, .sh-footer__grid > *):is(.is-style-eyebrow, .sh-caption, .sh-step__tag):not(.is-in)::before {
		transform: scaleX(0);
		animation: sh-m-safety 1ms linear 4s forwards; animation-play-state: var(--m-safety);
	}

	/* Bilder in Zielen: setzen sich von 1.04 auf 1 (picture schneidet ab, Layout bleibt) */
	html.sh-m :is(.sh-figure, .sh-split__media) > picture { overflow: hidden; }
	html.sh-m :is(.sh-figure, .sh-split__media) > picture > img {
		transition: transform 900ms var(--m-ease-out); transition-delay: var(--m-delay, 0ms);
	}
	/* SEL */
	html.sh-m :where(.sh-reveal, .sh-reveal-group > *, .sh-section-head > *, .sh-b-cols__head > *, .sh-idea > .wp-block-column > *, .sh-brand-section .wp-block-column > *, .sh-section--compact .wp-block-column > *, .sh-text-col > *, .sh-b-cols__body > *, .sh-split__inner > *, .sh-contact-band > *, .sh-section--navy > .is-style-lead, .sh-section--navy > .wp-block-buttons, .sh-cards > .wp-block-column, .sh-values > .wp-block-column, .sh-steps > .wp-block-column, .sh-steps__note, .sh-b-notice, .sh-legal-line, .sh-section .sh-figure, .sh-split__media, .sh-person > .wp-block-column:first-child, .sh-person__text > *, .sh-footer__grid > *):is(.sh-figure, .sh-split__media):not(.is-in) > picture > img {
		transform: scale(1.04);
		animation: sh-m-safety 1ms linear 4s forwards; animation-play-state: var(--m-safety);
	}

	/* Werte: Römische Ziffer folgt 100 ms nach der Spalte */
	html.sh-m .sh-values .sh-value__num {
		transition: opacity var(--m-reveal) var(--m-ease-out); transition-delay: calc(var(--m-delay, 0ms) + 100ms);
	}
	html.sh-m .sh-values > .wp-block-column:not(.is-in) .sh-value__num {
		opacity: 0; animation: sh-m-safety 1ms linear 4s forwards; animation-play-state: var(--m-safety);
	}

	/* Schritte 01–04: die gestrichelten Linien von 04 zeichnen sich (Oberkante scaleX, ab 64 rem Trennlinie scaleY).
	   Ohne Markupänderung: die Rahmen aus theme.css werden unter html.sh-m transparent, Pseudo-Elemente zeichnen. */
	html.sh-m .sh-step--future { position: relative; border-top-color: transparent; }
	html.sh-m .sh-step--future::before {
		content: ""; position: absolute; left: 0; right: 0; top: -1px; border-top: 1px dashed var(--color-olive);
		transform-origin: left center; transition: transform 600ms var(--m-ease-line); transition-delay: calc(var(--m-delay, 0ms) + 120ms);
	}
	html.sh-m .sh-steps > .wp-block-column:not(.is-in) > .sh-step--future::before {
		transform: scaleX(0); animation: sh-m-safety 1ms linear 4s forwards; animation-play-state: var(--m-safety);
	}
	@media (min-width: 64rem) {
		html.sh-m .sh-step--future { border-left-color: transparent; }
		html.sh-m .sh-step--future::after {
			content: ""; position: absolute; top: 0; bottom: 0; left: -1px; border-left: 1px dashed var(--color-olive);
			transform-origin: center top; transition: transform 500ms var(--m-ease-line); transition-delay: calc(var(--m-delay, 0ms) + 120ms);
		}
		html.sh-m .sh-steps > .wp-block-column:not(.is-in) > .sh-step--future::after {
			transform: scaleY(0); animation: sh-m-safety 1ms linear 4s forwards; animation-play-state: var(--m-safety);
		}
	}

	/* Tim: Portrait-Spalte wird von oben nach unten freigelegt (clip-path), kein Versatz, kein Blenden.
	   motion.js setzt nach der Transition clip-path:none, damit kein Clipping/Stacking-Context bleibt. */
	html.sh-m .sh-person > .wp-block-column:first-child:not(.is-settled) {
		transition: clip-path 800ms var(--m-ease-line); transition-delay: var(--m-delay);
	}
	html.sh-m .sh-person > .wp-block-column:first-child:not(.is-in) { opacity: 1; transform: none; clip-path: inset(0 0 100% 0); }
	html.sh-m .sh-person > .wp-block-column:first-child.is-in { clip-path: inset(0); }

	/* Formular: Fehlermeldungen und Bestätigung erscheinen weich (WPForms fügt sie per JS ein) */
	.sh-contact-form :is(label.wpforms-error, em.wpforms-error, .wpforms-error-container, .wpforms-error-alert) {
		animation: sh-m-note 220ms var(--m-ease-out) both;
	}
	.sh-contact-form .wpforms-confirmation-container-full { animation: sh-m-hero 500ms var(--m-ease-out) both; }

	/* Mobilmenü: Öffnen blendet ein (nur CSS, @starting-style); Schließen und ältere Browser springen wie bisher.
	   Nur bei aria-expanded="true", damit das Setzen von [hidden] beim Laden nie animiert. */
	@media (max-width: 56rem) {
		.sh-nav-toggle[aria-expanded="true"] ~ .sh-nav { transition: opacity 240ms var(--m-ease-out), transform 240ms var(--m-ease-out); }
		.sh-nav-toggle[aria-expanded="true"] ~ .sh-nav :is(.sh-nav__list > li, .sh-nav__cta) { transition: opacity 240ms var(--m-ease-out), transform 240ms var(--m-ease-out); }
		.sh-nav-toggle[aria-expanded="true"] ~ .sh-nav .sh-nav__list > li:nth-child(2) { transition-delay: 50ms; }
		.sh-nav-toggle[aria-expanded="true"] ~ .sh-nav .sh-nav__list > li:nth-child(3) { transition-delay: 100ms; }
		.sh-nav-toggle[aria-expanded="true"] ~ .sh-nav .sh-nav__list > li:nth-child(n + 4) { transition-delay: 150ms; }
		.sh-nav-toggle[aria-expanded="true"] ~ .sh-nav .sh-nav__cta { transition-delay: 150ms; }
		@starting-style {
			.sh-nav-toggle[aria-expanded="true"] ~ .sh-nav { opacity: 0; transform: translateY(-8px); }
			.sh-nav-toggle[aria-expanded="true"] ~ .sh-nav :is(.sh-nav__list > li, .sh-nav__cta) { opacity: 0; transform: translateY(-6px); }
		}
	}

	@keyframes sh-m-hero { from { opacity: 0; transform: translateY(var(--m-rise-sm)); } }
	@keyframes sh-m-hero-rise { from { transform: translateY(var(--m-rise-sm)); } }
	@keyframes sh-m-line { from { transform: scaleX(0); } }
	@keyframes sh-m-bend { from { transform: rotate(45deg) scaleY(0); } }
	@keyframes sh-m-fade { from { opacity: 0; } }
	@keyframes sh-m-note { from { opacity: 0; transform: translateY(-4px); } }
	@keyframes sh-m-safety { to { opacity: 1; transform: none; clip-path: none; } }
}

/* ---------- Header: Zustand beim Scrollen (Höhe bleibt konstant, kein CLS) ---------- */
.sh-header { transition: background-color var(--m-hover) var(--m-ease-hover); }
.sh-header::after {
	content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
	box-shadow: 0 12px 28px -18px rgba(32, 47, 70, .35); opacity: 0;
	transition: opacity var(--m-hover) var(--m-ease-hover);
}
.sh-header.is-scrolled { background: color-mix(in srgb, var(--color-paper-light) 97%, transparent); }
.sh-header.is-scrolled::after { opacity: 1; }
.sh-brand .sh-crest { transform-origin: left center; transition: transform var(--m-hover) var(--m-ease-hover); }
.sh-header.is-scrolled .sh-brand .sh-crest { transform: scale(.88); }

/* ---------- Markenkarten: Lift, Schatten, Rahmen (Buttons/Pfeile: theme.css) ---------- */
.wp-block-group.is-style-card {
	transition:
		transform var(--m-hover) var(--m-ease-hover),
		border-color var(--m-hover) var(--m-ease-hover);
}
.wp-block-group.is-style-card::after {
	content: ""; position: absolute; inset: -1px; pointer-events: none;
	box-shadow: 0 18px 32px -20px rgba(32, 47, 70, .35); opacity: 0;
	transition: opacity var(--m-hover) var(--m-ease-hover);
}
.is-style-card .sh-card__index { transition: color var(--m-hover) var(--m-ease-hover); }
.wp-block-group.is-style-card:focus-within {
	transform: translateY(-3px);
	border-right-color: var(--color-olive); border-bottom-color: var(--color-olive); border-left-color: var(--color-olive);
}
.wp-block-group.is-style-card:focus-within::after { opacity: 1; }
@media (hover: hover) {
	.wp-block-group.is-style-card:hover {
		transform: translateY(-3px);
		border-right-color: var(--color-olive); border-bottom-color: var(--color-olive); border-left-color: var(--color-olive);
	}
	.wp-block-group.is-style-card:hover::after { opacity: 1; }
	.is-style-card:hover .sh-card__index { color: var(--color-olive-text); }
	/* Bilder in Markenabschnitten: leichter Zoom im Ausschnitt (A2 rät bei nicht klickbaren Bildern ab – bei Kundenwunsch entfernen) */
	.sh-brand-section .sh-figure > picture { overflow: hidden; }
	.sh-brand-section .sh-figure > picture > img { transition: transform 900ms var(--m-ease-out); }
	.sh-brand-section .sh-figure:hover > picture > img { transform: scale(1.03); }
}
