/* ═══════════════════════════════════════════════════════════
   SCROLL-FX — Scroll-Storytelling für die Startseite
   Nur transform/opacity werden animiert. Alle scroll-getriebenen
   Regeln sind unter html.has-scrollfx gescoped (Bootstrap im
   <head>): ohne JS oder mit prefers-reduced-motion bleibt die
   Seite komplett statisch. Die Engine (scroll.js) schreibt --p
   (0..1) auf jedes [data-fx-scene]-Element.
   ═══════════════════════════════════════════════════════════ */

/* ── INTRO: Satz-Segmente hellen beim Scrollen auf ─────────── */

html.has-scrollfx .intro-seg {
  transition: none;
}
html.has-scrollfx .intro-seg:nth-child(1) {
  opacity: calc(0.22 + clamp(0, calc((var(--p, 0) - 0.25) / 0.15), 1) * 0.78);
}
html.has-scrollfx .intro-seg:nth-child(2) {
  opacity: calc(0.22 + clamp(0, calc((var(--p, 0) - 0.35) / 0.15), 1) * 0.78);
}
html.has-scrollfx .intro-seg:nth-child(3) {
  opacity: calc(0.22 + clamp(0, calc((var(--p, 0) - 0.45) / 0.15), 1) * 0.78);
}

/* ── PROJEKT-KARTEN: Parallax-Tiefe ────────────────────────── */

.card-project-media {
  position: absolute;
  inset: 0;
}

.card-project-media picture,
.card-project-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

html.has-scrollfx .card-project-media {
  --par: 8;
  inset: -7% 0;
  transform: translateY(calc((var(--p, 0.5) - 0.5) * var(--par) * 1%));
}

@media (max-width: 768px) {
  html.has-scrollfx .card-project-media { --par: 5; }
}

/* ── ÜBER MICH: Drohnen-Zoom auf dem Porträt ───────────────── */

.about-media {
  overflow: hidden;
  border-radius: var(--r-sm);
}

html.has-scrollfx .about-media img {
  transform: scale(calc(1.30 - clamp(0, calc((var(--p, 0) - 0.10) / 0.50), 1) * 0.30));
  transform-origin: 50% 28%;
}

/* ── HEADLINE-REVEALS: maskiertes Slide-Up ─────────────────── */

html.has-scrollfx [data-reveal] { overflow: hidden; }

html.has-scrollfx .reveal-line {
  display: block;
  transform: translateY(112%);
  transition: transform 0.9s var(--ease-smooth) 0.12s;
}

html.has-scrollfx [data-reveal].is-visible .reveal-line {
  transform: none;
}

/* ── ABLAUF: Linie zieht sich durch die Schritte ─────────── */

html.has-scrollfx .step-rows--line {
  --f: clamp(0, calc((var(--p, 1) - 0.2) / 0.5), 1);
}
html.has-scrollfx .step-rows--line::after {
  transform: scaleY(var(--f));
}
html.has-scrollfx .step-rows--line .step-row {
  --on: clamp(0, calc((var(--f) - var(--t)) / 0.04), 1);
}
html.has-scrollfx .step-rows--line .step-row:nth-child(1) { --t: 0.04; }
html.has-scrollfx .step-rows--line .step-row:nth-child(2) { --t: 0.20; }
html.has-scrollfx .step-rows--line .step-row:nth-child(3) { --t: 0.44; }
html.has-scrollfx .step-rows--line .step-row:nth-child(4) { --t: 0.60; }
html.has-scrollfx .step-rows--line .step-row:nth-child(5) { --t: 0.84; }
html.has-scrollfx .step-rows--line .step-row::before {
  transform: scale(var(--on));
  transition: transform 0.45s var(--ease-spring);
}
html.has-scrollfx .step-rows--line .step-num,
html.has-scrollfx .step-rows--line .step-title {
  opacity: calc(0.4 + var(--on) * 0.6);
  transition: opacity 0.35s ease;
}

@media (max-width: 820px) {
  html.has-scrollfx .step-rows--line {
    --f: clamp(0, calc((var(--p, 1) - 0.16) / 0.6), 1);
  }
}

/* ── LEITUNG: läuft aus dem Bauplan zu „Wofür" und „Für wen" ─ */

html.has-scrollfx .vp-flow {
  --f: clamp(0, calc((var(--p, 1) - 0.16) / 0.32), 1);
}
html.has-scrollfx .vp-line--a::before {
  transform: scaleY(clamp(0, calc(var(--f) / 0.3), 1));
}
html.has-scrollfx .vp-line--b::before {
  transform: scaleX(clamp(0, calc((var(--f) - 0.2) / 0.55), 1));
}
html.has-scrollfx .vp-line--c::before {
  transform: scaleY(clamp(0, calc((var(--f) - 0.75) / 0.13), 1));
}
html.has-scrollfx .vp-line--a::after {
  opacity: clamp(0, calc((var(--f) - 0.28) / 0.04), 1);
  transition: opacity 0.25s ease;
}
html.has-scrollfx .vp-line--c::after {
  opacity: clamp(0, calc((var(--f) - 0.86) / 0.04), 1);
  transition: opacity 0.25s ease;
}
html.has-scrollfx .vp-use:nth-child(1) { --on: clamp(0, calc((var(--f) - 0.28) / 0.05), 1); }
html.has-scrollfx .vp-use:nth-child(2) { --on: clamp(0, calc((var(--f) - 0.86) / 0.05), 1); }
html.has-scrollfx .vp-use-icon {
  transform: scale(var(--on));
  transition: transform 0.5s var(--ease-spring);
}

@media (max-width: 820px) {
  html.has-scrollfx .vp-flow {
    --f: clamp(0, calc((var(--p, 1) - 0.14) / 0.42), 1);
  }
  html.has-scrollfx .vp-line--a::before { transform: scaleY(clamp(0, calc(var(--f) / 0.2), 1)); }
  html.has-scrollfx .vp-line--a::after { opacity: clamp(0, calc((var(--f) - 0.18) / 0.04), 1); }
  html.has-scrollfx .vp-use:nth-child(1) { --on: clamp(0, calc((var(--f) - 0.18) / 0.05), 1); }
  html.has-scrollfx .vp-use:nth-child(2) { --on: clamp(0, calc((var(--f) - 0.9) / 0.05), 1); }
  html.has-scrollfx .vp-use:first-child::before {
    transform: scaleY(clamp(0, calc((var(--f) - 0.2) / 0.7), 1));
  }
}

/* ── PLAN: Sektion bleibt stehen, der Plan legt sich von links
     über das Luftbild, erst danach geht es weiter ─────────────
     Wrapper 260svh: Das Festhalten läuft von --p 0,28 bis 0,72,
     der Wipe liegt mit kurzen Haltephasen dazwischen. Wipe nur
     mit transform: Der Rahmen fährt herein, das Bild gegenläufig. */

html.has-scrollfx .plan-sec { padding-top: 0; }
html.has-scrollfx .plan-pin {
  --w: clamp(0, calc((var(--p, 1) - 0.33) / 0.34), 1);
  height: 260svh;
}
html.has-scrollfx .plan-stage {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100svh;
  padding: 5.25rem 0 1.5rem;
}
html.has-scrollfx .plan-stage .section-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  min-height: 0;
}
html.has-scrollfx .plan-stage .section-header {
  flex-shrink: 0;
  margin-bottom: clamp(0.9rem, 2.2svh, 1.4rem);
}
/* Das Bild nimmt die Resthöhe unter dem Text, mittig und ohne Beschnitt */
html.has-scrollfx .plan-fx {
  flex: 1;
  min-height: 0;
  container-type: size;
}
html.has-scrollfx .plan-fx-frame {
  width: min(100cqw, calc(100cqh * 1.6064));
  margin-inline: auto;
}
html.has-scrollfx .plan-fx-clip {
  transform: translateX(calc((var(--w) - 1) * 100%));
}
html.has-scrollfx .plan-fx-clip img {
  transform: translateX(calc((1 - var(--w)) * 100%));
}
html.has-scrollfx .plan-fx-line {
  display: block;
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  border-right: 2px solid var(--on-media);
  background: linear-gradient(90deg, rgba(73,116,185,0) 78%, rgba(73,116,185,0.38) 100%);
  transform: translateX(calc((var(--w) - 1) * 100%));
  opacity: calc(clamp(0, calc(var(--w) * 14), 1) * clamp(0, calc((1 - var(--w)) * 14), 1));
}

@media (max-width: 820px) {
  /* Handy: Bild füllt die Resthöhe, per cover auf das Dach zugeschnitten */
  html.has-scrollfx .plan-fx-frame {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }
}

/* ── AUFSTIEG: Sektion bleibt stehen, die Drohne steigt ────────
     Baut auf .plan-pin und .plan-stage auf. Das Zoomen läuft nur
     mit transform, mit kurzen Haltephasen vorher und nachher. */

html.has-scrollfx .lift-pin {
  --z: clamp(0, calc((var(--p, 1) - 0.33) / 0.34), 1);
}
html.has-scrollfx .lift-frame {
  width: min(100cqw, calc(100cqh * 1.7778));
}
html.has-scrollfx .lift-img {
  transform: scale(calc(2.7 - 1.7 * var(--z)));
}
@media (max-width: 820px) {
  html.has-scrollfx .lift-frame { width: 100%; }
}

/* ── FILMSTREIFEN: Sektion bleibt stehen, die Bilder laufen quer ──
     Baut auf .plan-pin und .plan-stage auf. Wrapper 340svh: Das
     Festhalten läuft von --p 0,23 bis 0,77, die Fahrt von 0,26 bis
     0,74. Der Weg ist Reihenbreite minus Sichtbreite, alles in cqw. */

html.has-scrollfx .strip-pin {
  --x: clamp(0, calc((var(--p, 1) - 0.26) / 0.48), 1);
  height: 340svh;
}
html.has-scrollfx .strip-pin .section-inner { justify-content: center; }
html.has-scrollfx .strip-track {
  overflow: visible;
  scroll-snap-type: none;
  transform: translateX(calc(var(--x) * -1 * (var(--n) * var(--fw) + (var(--n) - 1) * var(--gap) + 2 * var(--pad) - 100cqw)));
}

/* ── SCHNITT-ZEITLEISTE: Sektion bleibt stehen, der Abspielkopf läuft ──
     Nur ab 821 px. Wrapper 300svh: Festhalten von --p 0,25 bis 0,75,
     der Kopf fährt von 0,28 bis 0,72 von Clip 1 zu Clip 5. */

@media (min-width: 821px) {
  html.has-scrollfx .cut-sec { padding-top: 0; }
  html.has-scrollfx .cut-pin {
    --x: clamp(0, calc((var(--p, 1) - 0.28) / 0.44), 1);
    height: 300svh;
  }
  html.has-scrollfx .cut-stage {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100svh;
    padding: 5.25rem 0 1.5rem;
  }
  html.has-scrollfx .cut-stage .section-inner { width: 100%; }
  html.has-scrollfx .cut-head { opacity: 1; }
  html.has-scrollfx .cut-clip,
  html.has-scrollfx .cut-step {
    --d: max(calc(var(--x) * (var(--n) - 1) - var(--i)), calc(var(--i) - var(--x) * (var(--n) - 1)));
    --a: clamp(0, calc((0.62 - var(--d)) * 4), 1);
  }
  html.has-scrollfx .cut-end { margin-top: 0; }
}

/* ── will-change nur auf live-Szenen (IO-gesteuert) ────────── */

html.has-scrollfx .card-project.fx-live .card-project-media { will-change: transform; }
html.has-scrollfx .about-split.fx-live .about-media img { will-change: transform; }
html.has-scrollfx .step-rows--line.fx-live::after { will-change: transform; }
html.has-scrollfx .plan-pin.fx-live .plan-fx-clip,
html.has-scrollfx .plan-pin.fx-live .plan-fx-clip img,
html.has-scrollfx .plan-pin.fx-live .plan-fx-line { will-change: transform; }
html.has-scrollfx .lift-pin.fx-live .lift-img { will-change: transform; }
html.has-scrollfx .strip-pin.fx-live .strip-track { will-change: transform; }
html.has-scrollfx .cut-pin.fx-live .cut-head { will-change: transform; }

/* ── REDUCED MOTION: alles statisch (Gürtel + Hosenträger; die
     has-scrollfx-Klasse wird bei reduce ohnehin nie gesetzt) ── */

@media (prefers-reduced-motion: reduce) {
  .intro-seg,
  .card-project-media,
  .about-media img,
  .plan-fx-clip,
  .plan-fx-clip img,
  .lift-img,
  .strip-track,
  .step-rows--line::after,
  .vp-line::before,
  .vp-line::after,
  .vp-use-icon,
  .vp-use::before,
  .step-rows--line .step-row::before,
  .step-rows--line .step-num,
  .step-rows--line .step-title,
  .reveal-line {
    transform: none !important;
    opacity: 1 !important;
    transition: none !important;
  }
}

/* Leistungsseiten: Lead-Absatz mit bis zu 4 Saetzen */
html.has-scrollfx .intro-seg:nth-child(4) {
  opacity: calc(0.22 + clamp(0, calc((var(--p, 0) - 0.55) / 0.15), 1) * 0.78);
}
