/* ==========================================================================
   Motion-Schicht
   – Ohne JS ist alles sichtbar (.js fehlt).
   – Reduced Motion: Betriebssystem-Einstellung ODER Schalter im Footer (.reduce-motion).
   – CSS Scroll-Driven Animations zuerst (@supports), GSAP-Fallback in parallax.js.
   – Animiert werden nur transform, opacity, clip-path.
   ========================================================================== */

/* ---------- Reveals (durch reveal.js per IntersectionObserver ausgelöst) ---------- */
.js:not(.reduce-motion) [data-reveal]:not([data-reveal="lines"]) {
  opacity: 0;
  transform: translate3d(0, 12px, 0);
  transition: opacity var(--dur-m) var(--ease-out), transform var(--dur-m) var(--ease-out);
  transition-delay: var(--delay, 0ms);
}
.js:not(.reduce-motion) [data-reveal].is-in { opacity: 1; transform: none; }

/* Zeilenweiser Mask-Reveal für Headlines */
.js:not(.reduce-motion) [data-reveal="lines"].is-split .line {
  display: block;
  overflow: clip;
  /* Platz für Umlaut-Punkte und Unterlängen, ohne den Zeilenabstand zu ändern */
  padding-block: 0.12em;
  margin-block: -0.12em;
}
.js:not(.reduce-motion) [data-reveal="lines"].is-split .line > span {
  display: inline-block;
  transform: translate3d(0, 110%, 0);
  transition: transform 900ms var(--ease-out);
  transition-delay: calc(var(--li, 0) * 90ms + var(--delay, 0ms));
}
.js:not(.reduce-motion) [data-reveal="lines"].is-split.is-in .line > span { transform: none; }
/* Bis der Splitter gelaufen ist, keine nackte Headline aufblitzen lassen */
.js:not(.reduce-motion) [data-reveal="lines"]:not(.is-split) { opacity: 0; }

/* ---------- Bereichskarten-Choreografie ---------- */
.js:not(.reduce-motion) [data-cards] [data-card] {
  opacity: 0;
  transform: translate3d(0, 64px, 0);
  transition: opacity var(--dur-m) var(--ease-out), transform 1000ms var(--ease-out);
  transition-delay: calc(var(--i) * 90ms);
}
.js:not(.reduce-motion) [data-cards] .area-card--s,
.js:not(.reduce-motion) [data-cards] .area-card--m { transform: translate3d(0, 96px, 0); transition-delay: calc(var(--i) * 90ms + 120ms); }
.js:not(.reduce-motion) [data-cards] [data-card] .area-card__media { clip-path: inset(100% 0 0 0); transition: clip-path 1100ms var(--ease-in-out); transition-delay: calc(var(--i) * 90ms + 80ms); }
.js:not(.reduce-motion) [data-cards].is-in [data-card] { opacity: 1; transform: none; }
.js:not(.reduce-motion) [data-cards].is-in [data-card] .area-card__media { clip-path: inset(0 0 0 0); }

/* ---------- Parallax (CSS Scroll-Driven, nur mit Bewegung) ---------- */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    html:not(.reduce-motion) [data-parallax] {
      animation: parallax linear both;
      animation-timeline: view();
      animation-range: cover;
    }
    html:not(.reduce-motion) [data-frame-parallax] > * {
      inset: -9% 0;
      animation: frame-parallax linear both;
      animation-timeline: view();
      animation-range: cover;
    }

    /* Hero: zwei Ebenen am Seiten-Scroll */
    html:not(.reduce-motion) [data-hero-layer="bg"] {
      animation: hero-bg linear both;
      animation-timeline: scroll(root);
      animation-range: 0 100vh;
    }
    html:not(.reduce-motion) [data-hero-layer="text"] {
      animation: hero-text linear both;
      animation-timeline: scroll(root);
      animation-range: 0 90vh;
    }

    /* Scroll-Fortschritt */
    html:not(.reduce-motion) .scroll-progress span {
      animation: progress linear both;
      animation-timeline: scroll(root);
    }

    /* Speed-Lines ziehen beim Hineinscrollen durch */
    html:not(.reduce-motion) .speedlines i {
      animation: speedline linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 55%;
    }
    html:not(.reduce-motion) .speedlines i:nth-child(even) { animation-range: entry 15% cover 65%; }
  }
}

@keyframes parallax {
  from { transform: translate3d(calc(var(--px, 0) * -1px * var(--pscale, 1)), calc(var(--py, 0) * -1px * var(--pscale, 1)), 0); }
  to   { transform: translate3d(calc(var(--px, 0) * 1px * var(--pscale, 1)), calc(var(--py, 0) * 1px * var(--pscale, 1)), 0); }
}
@keyframes frame-parallax {
  from { transform: translate3d(0, -7%, 0); }
  to   { transform: translate3d(0, 7%, 0); }
}
@keyframes hero-bg { to { transform: translate3d(0, 35vh, 0) scale(1.08); } }
@keyframes hero-text { to { opacity: 0.15; transform: translate3d(0, -6vh, 0); } }
@keyframes progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes speedline { from { transform: scaleX(0) translateX(-20%); opacity: 0; } to { transform: scaleX(1) translateX(0); opacity: 1; } }

/* Parallax auf kleinen Bildschirmen auf 40 % drosseln */
@media (max-width: 767px) {
  [data-parallax] { --pscale: 0.4; }
}

/* JS-Fallback setzt diese Klasse, wenn GSAP die Parallax übernimmt */
.gsap-parallax [data-frame-parallax] > * { inset: -9% 0; }

/* ---------- Marquee ---------- */
@media (prefers-reduced-motion: no-preference) {
  html:not(.reduce-motion) .marquee__track { animation: marquee 38s linear infinite; }
  html:not(.reduce-motion) .marquee:hover .marquee__track,
  html:not(.reduce-motion) .marquee:focus-within .marquee__track,
  html:not(.reduce-motion) .marquee:focus .marquee__track { animation-play-state: paused; }
}
@keyframes marquee { to { transform: translate3d(-100%, 0, 0); } }

/* ---------- Reduced Motion: keine Bewegung, nur kurze Fades ---------- */
.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
  animation-duration: 0.01ms;
  animation-iteration-count: 1;
  transition-duration: 0.01ms;
  scroll-behavior: auto;
}
.reduce-motion .media__video { display: none; }
.reduce-motion .media__toggle { display: none; }
.reduce-motion .marquee { overflow-x: auto; }
.reduce-motion .marquee__track[aria-hidden="true"] { display: none; }
.reduce-motion .scroll-cue span { animation: none; }
.reduce-motion .menu { transition: opacity var(--dur-xs) linear; clip-path: none; opacity: 0; }
.reduce-motion .menu.is-open { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms; animation-iteration-count: 1; transition-duration: 0.01ms; }
  .media__video, .media__toggle { display: none; }
  .marquee__track[aria-hidden="true"] { display: none; }
}

/* View Transitions zwischen Seiten: kurzer Crossfade, Header bleibt stehen */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 260ms; animation-timing-function: var(--ease-out); }
.masthead { view-transition-name: masthead; }
.reduce-motion::view-transition-group(*) { animation: none; }
