/* ==========================================================================
   Motion-Schicht
   Grundsatz: Inhalte sind ohne JS und bei reduzierter Bewegung immer sichtbar.
   Startzustände für Reveals gelten nur unter html.js.motion-ok
   (gesetzt im <head>, entfernt von main.js, falls GSAP nicht lädt).
   ========================================================================== */

/* ---------- Hero: Mask-Reveal per CSS, unabhängig von GSAP (LCP bleibt schnell) ---------- */
.motion-ok .hero__title .line { overflow: hidden; padding-top: .12em; margin-top: -.12em; padding-bottom: .04em; margin-bottom: -.04em; }
.motion-ok .hero__title .line > span { display: inline-block; animation: line-up var(--dur-l) var(--ease-heavy) both; }
.motion-ok .hero__title .line:nth-child(2) > span { animation-delay: 90ms; }
.motion-ok .hero__title .line:nth-child(3) > span { animation-delay: 180ms; }
.motion-ok .hero__sub, .motion-ok .hero__cta { animation: fade-up var(--dur-m) var(--ease-out) 420ms both; }
.motion-ok .hero__media-inner { animation: wipe-in 1200ms var(--ease-heavy) 120ms both; }
.motion-ok .hero__title-mark::after { animation: hatch-in 700ms var(--ease-heavy) 900ms both; transform-origin: left; }
@keyframes line-up { from { transform: translateY(105%); } to { transform: none; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes wipe-in { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }
@keyframes hatch-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- Zeilen-Reveal (GSAP, data-reveal="lines") ---------- */
.motion-ok [data-reveal="lines"]:not(.hero__title) .line { display: inline-block; overflow: hidden; vertical-align: top; padding-top: .14em; margin-top: -.14em; padding-bottom: .06em; margin-bottom: -.06em; }
.motion-ok [data-reveal="lines"]:not(.hero__title) .line__inner { display: inline-block; transform: translateY(105%); }
.motion-ok [data-reveal="lines"].is-in .line__inner { transform: none; transition: transform var(--dur-l) var(--ease-heavy); }
.motion-ok [data-reveal="lines"].is-in .line:nth-child(2) .line__inner { transition-delay: 80ms; }
.motion-ok [data-reveal="lines"].is-in .line:nth-child(3) .line__inner { transition-delay: 160ms; }
[data-reveal="lines"] .line { display: inline; }
[data-reveal="lines"]:not(.hero__title) .line::after { content: " "; }
.h-1[data-reveal="lines"] .line, .h-display[data-reveal="lines"] .line, .hero__title .line { display: block; }

.motion-ok [data-reveal="fade"]:not(.hero__sub):not(.hero__cta) { opacity: 0; transform: translateY(12px); }
.motion-ok [data-reveal="fade"].is-in { opacity: 1; transform: none; transition: opacity var(--dur-m) var(--ease-out) 150ms, transform var(--dur-m) var(--ease-out) 150ms; }

.motion-ok [data-reveal="rise"] { opacity: 0; transform: translateY(40px); }
.motion-ok [data-reveal="rise"].is-in { opacity: 1; transform: none; transition: opacity var(--dur-m) var(--ease-out), transform var(--dur-l) var(--ease-heavy); transition-delay: calc(var(--i, 0) * var(--stagger)); }

/* Bruchkanten-Reveal für Leistungsbilder */
.motion-ok [data-reveal="break"] .l-card__media { clip-path: polygon(0 0, 100% 0, 100% 0, 92% 0, 84% 0, 76% 0, 68% 0, 60% 0, 52% 0, 44% 0, 36% 0, 28% 0, 20% 0, 12% 0, 0 0); }
.motion-ok [data-reveal="break"] .l-card__body { opacity: 0; transform: translateY(16px); }
.motion-ok [data-reveal="break"].is-in .l-card__media {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 92% 97%, 84% 100%, 76% 96%, 68% 100%, 60% 97%, 52% 100%, 44% 96%, 36% 100%, 28% 97%, 20% 100%, 12% 96%, 0 100%);
  transition: clip-path 1100ms var(--ease-heavy) calc(var(--i, 0) * var(--stagger));
}
.motion-ok [data-reveal="break"].is-done .l-card__media { clip-path: none; }
.motion-ok [data-reveal="break"].is-in .l-card__body { opacity: 1; transform: none; transition: opacity var(--dur-m) var(--ease-out), transform var(--dur-m) var(--ease-out); transition-delay: calc(var(--i, 0) * var(--stagger) + 350ms); }

/* Maßkette zeichnet sich */
.motion-ok .masskette::before { transform: scaleX(0); }
.motion-ok .masskette.is-in::before { transform: scaleX(1); transition: transform 1200ms var(--ease-heavy); }

/* ---------- Rückbau-Story: Desktop-Bühne ---------- */
@media (min-width: 64rem) {
  .motion-ok .story__stage { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
  .motion-ok .story__drawing { display: grid; gap: var(--space-4); position: sticky; top: calc(var(--header-h) + 4vh); align-self: start; height: calc(100vh - var(--header-h) - 8vh); grid-template-rows: 1fr auto; }
  .motion-ok .story__drawing .qs { height: 100%; max-height: 100%; }
  .motion-ok .story__legend { display: flex; gap: var(--space-6); color: var(--concrete-600); }
  .motion-ok .story__progress { position: absolute; top: 0; right: 0; font-size: var(--step-1); }
  .motion-ok .story__static { display: none; }
  .motion-ok .story__steps { gap: 0; }
  .motion-ok .story__step { min-height: 78vh; align-content: center; opacity: .28; transition: opacity var(--dur-m) var(--ease-out); }
  .motion-ok .story__step.is-active { opacity: 1; }
  .motion-ok .story__step:last-child { min-height: 92vh; }
}
.story__legend, .story__progress { display: none; }
.qs--stage .qs-part { transform-box: fill-box; transform-origin: 50% 100%; }

/* ---------- Mikro-Interaktionen ---------- */
[data-magnetic] { will-change: auto; }
.doc-card { transform: perspective(700px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); }

/* Mobile-Menü: clip-path-Reveal vom Button aus */
.motion-ok .mobile-menu { clip-path: circle(0 at calc(100% - 2.5rem) -2rem); transition: clip-path 700ms var(--ease-heavy); }
.motion-ok .mobile-menu.is-open { clip-path: circle(150% at calc(100% - 2.5rem) -2rem); }
.motion-ok .mobile-menu__list li { opacity: 0; transform: translateY(16px); }
.motion-ok .mobile-menu.is-open .mobile-menu__list li { opacity: 1; transform: none; transition: opacity var(--dur-m) var(--ease-out), transform var(--dur-m) var(--ease-out); transition-delay: calc(200ms + var(--i, 0) * 60ms); }

/* Marquee (CSS-Basis, GSAP moduliert die Geschwindigkeit) */
.motion-ok .marquee__track { animation: marquee 38s linear infinite; }
.marquee:hover .marquee__track, .marquee:focus-within .marquee__track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-100%); } }

/* Seitenwechsel */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 320ms; animation-timing-function: cubic-bezier(.22, 1, .36, 1); }

/* CSS Scroll-Driven Animations: Scroll-Fortschritt ohne JS */
@supports (animation-timeline: scroll()) {
  .motion-ok .scroll-progress__bar { animation: grow-x linear both; animation-timeline: scroll(root); }
  @keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}

/* ---------- Reduzierte Bewegung (System oder Schalter) ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms; animation-iteration-count: 1; transition-duration: 1ms; scroll-behavior: auto; }
  .marquee__track { animation: none; }
  .scroll-hint__line::after { animation: none; transform: scaleY(1); }
}
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: 1ms; animation-iteration-count: 1; transition-duration: 1ms; }
.reduce-motion .marquee__track { animation: none; }
.reduce-motion .media__video { display: none; }
@media (prefers-reduced-motion: reduce) { .media__video { display: none; } }

/* Staub-Canvas im Hero, Lenis-Glättung */
.hero__dust { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
html.lenis, html.lenis body { height: auto; }
html.lenis-smooth { scroll-behavior: auto; }
html.lenis-stopped { overflow: clip; }
