/*
 * Hintergrund-Grafik (Seitenlayout, „Hintergrund-Grafik anzeigen“): fixiert und
 * waagerecht zentriert hinter dem Inhalt. Die Deckkraft sitzt nur am Bild, Boxen mit
 * späterem Glas-Effekt zeichnen es so weich.
 */
.km-motion-graphic {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: -1;
    width: var(--km-motion-graphic-width, 100vw);
    max-width: none;
    height: auto;
    opacity: var(--km-motion-graphic-opacity, .05);
    /* Ohne Skript (reduzierte Bewegung, kein JS) steht die Grafik mittig */
    translate: -50% -50%;
    pointer-events: none;
    user-select: none;
}

/* Verborgen, bis km-motion.js sie positioniert hat; ohne JS oder bei reduzierter Bewegung gilt die Ruhestellung */
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
    .km-motion-graphic:not(.km-motion-graphic--ready) {
        visibility: hidden;
    }
}

/*
 * km-motion.js setzt --km-motion-progress (0 bis 1, gefedert): Bei 0 liegt die Grafik
 * unter dem Fenster, bei 1 an der Endposition. Die Strecke von der Startposition (100vh)
 * dorthin: Fensterhöhe mal --km-motion-graphic-end-vh plus Grafikhöhe mal --km-motion-graphic-end-h.
 *   Oben hinaus      1, 1  (Unterkante am oberen Fensterrand)
 *   Oben anliegend   1, 0  (Oberkante am oberen Fensterrand)
 *   Unten anliegend  0, 1  (Unterkante am unteren Fensterrand)
 */
.km-motion-graphic--js {
    top: 0;
    translate: -50% calc(100vh - (100vh * var(--km-motion-graphic-end-vh, 1) + 100% * var(--km-motion-graphic-end-h, 1)) * var(--km-motion-progress, 0));
    will-change: translate;
}

.km-motion-graphic--end-top-flush {
    --km-motion-graphic-end-h: 0;
}

.km-motion-graphic--end-bottom {
    --km-motion-graphic-end-vh: 0;
}

.km-motion-graphic--o5 { --km-motion-graphic-opacity: 0.05; }
.km-motion-graphic--o10 { --km-motion-graphic-opacity: 0.1; }
.km-motion-graphic--o15 { --km-motion-graphic-opacity: 0.15; }
.km-motion-graphic--o20 { --km-motion-graphic-opacity: 0.2; }
.km-motion-graphic--o25 { --km-motion-graphic-opacity: 0.25; }
.km-motion-graphic--o30 { --km-motion-graphic-opacity: 0.3; }
.km-motion-graphic--o35 { --km-motion-graphic-opacity: 0.35; }
.km-motion-graphic--o40 { --km-motion-graphic-opacity: 0.4; }
.km-motion-graphic--o45 { --km-motion-graphic-opacity: 0.45; }
.km-motion-graphic--o50 { --km-motion-graphic-opacity: 0.5; }
.km-motion-graphic--o55 { --km-motion-graphic-opacity: 0.55; }
.km-motion-graphic--o60 { --km-motion-graphic-opacity: 0.6; }
.km-motion-graphic--o65 { --km-motion-graphic-opacity: 0.65; }
.km-motion-graphic--o70 { --km-motion-graphic-opacity: 0.7; }
.km-motion-graphic--o75 { --km-motion-graphic-opacity: 0.75; }
.km-motion-graphic--o80 { --km-motion-graphic-opacity: 0.8; }
.km-motion-graphic--o85 { --km-motion-graphic-opacity: 0.85; }
.km-motion-graphic--o90 { --km-motion-graphic-opacity: 0.9; }
.km-motion-graphic--o95 { --km-motion-graphic-opacity: 0.95; }
.km-motion-graphic--o100 { --km-motion-graphic-opacity: 1; }

/*
 * Breite pro Breakpoint (Seitenlayout, „Größe je Breakpoint“) für die Bootstrap-5-Breiten.
 * Im Layer, damit ein Theme mit anderen Breiten dieselben Klassen ungelayert überschreiben
 * kann: Ungelayerte Regeln gewinnen immer.
 */
@layer km-motion-defaults {
    .km-motion-graphic-size-50 { --km-motion-graphic-width: 50vw; }
    .km-motion-graphic-size-75 { --km-motion-graphic-width: 75vw; }
    .km-motion-graphic-size-100 { --km-motion-graphic-width: 100vw; }
    .km-motion-graphic-size-125 { --km-motion-graphic-width: 125vw; }
    .km-motion-graphic-size-150 { --km-motion-graphic-width: 150vw; }
    .km-motion-graphic-size-200 { --km-motion-graphic-width: 200vw; }

    @media (min-width: 576px) {
        .km-motion-graphic-size-sm-50 { --km-motion-graphic-width: 50vw; }
        .km-motion-graphic-size-sm-75 { --km-motion-graphic-width: 75vw; }
        .km-motion-graphic-size-sm-100 { --km-motion-graphic-width: 100vw; }
        .km-motion-graphic-size-sm-125 { --km-motion-graphic-width: 125vw; }
        .km-motion-graphic-size-sm-150 { --km-motion-graphic-width: 150vw; }
        .km-motion-graphic-size-sm-200 { --km-motion-graphic-width: 200vw; }
    }

    @media (min-width: 768px) {
        .km-motion-graphic-size-md-50 { --km-motion-graphic-width: 50vw; }
        .km-motion-graphic-size-md-75 { --km-motion-graphic-width: 75vw; }
        .km-motion-graphic-size-md-100 { --km-motion-graphic-width: 100vw; }
        .km-motion-graphic-size-md-125 { --km-motion-graphic-width: 125vw; }
        .km-motion-graphic-size-md-150 { --km-motion-graphic-width: 150vw; }
        .km-motion-graphic-size-md-200 { --km-motion-graphic-width: 200vw; }
    }

    @media (min-width: 992px) {
        .km-motion-graphic-size-lg-50 { --km-motion-graphic-width: 50vw; }
        .km-motion-graphic-size-lg-75 { --km-motion-graphic-width: 75vw; }
        .km-motion-graphic-size-lg-100 { --km-motion-graphic-width: 100vw; }
        .km-motion-graphic-size-lg-125 { --km-motion-graphic-width: 125vw; }
        .km-motion-graphic-size-lg-150 { --km-motion-graphic-width: 150vw; }
        .km-motion-graphic-size-lg-200 { --km-motion-graphic-width: 200vw; }
    }

    @media (min-width: 1200px) {
        .km-motion-graphic-size-xl-50 { --km-motion-graphic-width: 50vw; }
        .km-motion-graphic-size-xl-75 { --km-motion-graphic-width: 75vw; }
        .km-motion-graphic-size-xl-100 { --km-motion-graphic-width: 100vw; }
        .km-motion-graphic-size-xl-125 { --km-motion-graphic-width: 125vw; }
        .km-motion-graphic-size-xl-150 { --km-motion-graphic-width: 150vw; }
        .km-motion-graphic-size-xl-200 { --km-motion-graphic-width: 200vw; }
    }

    @media (min-width: 1400px) {
        .km-motion-graphic-size-xxl-50 { --km-motion-graphic-width: 50vw; }
        .km-motion-graphic-size-xxl-75 { --km-motion-graphic-width: 75vw; }
        .km-motion-graphic-size-xxl-100 { --km-motion-graphic-width: 100vw; }
        .km-motion-graphic-size-xxl-125 { --km-motion-graphic-width: 125vw; }
        .km-motion-graphic-size-xxl-150 { --km-motion-graphic-width: 150vw; }
        .km-motion-graphic-size-xxl-200 { --km-motion-graphic-width: 200vw; }
    }
}

/* Schwarz, im Dunkel-Modus weiß: bei wenigen Prozent Deckkraft wirkt das wie die Textfarbe */
.km-motion-graphic--mono {
    filter: brightness(0);

    @media (prefers-color-scheme: dark) {
        filter: brightness(0) invert(1);
    }
}

/*
 * Einblend-Animationen (Seitenlayout, „Einblend-Animationen“): km-motion.js setzt
 * km-reveal (versteckt, nur unterhalb des Fensters) und km-reveal--in (blendet ein).
 * Deckkraft nur an der Box selbst, nie an einem Wrapper mit Boxen darin: Ein Vorfahr
 * mit opacity < 1 würde einen Glas-Effekt (backdrop-filter) der Boxen abschneiden.
 * Keyframes statt transition, damit Hover-Übergänge der Elemente unberührt bleiben.
 */
@media (prefers-reduced-motion: no-preference) {
    .km-reveal:not(.km-reveal--in) {
        opacity: 0;
        translate: 0 2rem;
        scale: .98;
    }

    .km-reveal--in {
        animation: km-reveal var(--km-duration-slow, .8s) var(--km-ease-out, cubic-bezier(.22, 1, .36, 1)) var(--km-reveal-delay, 0s) backwards;
    }

    /* Trennlinien zeichnen sich von ihrer Ausrichtung aus */
    .km-divider.km-reveal {
        transform-origin: left;

        &.km-divider--align-center { transform-origin: center; }
        &.km-divider--align-end { transform-origin: right; }
    }

    .km-divider.km-reveal:not(.km-reveal--in) {
        opacity: 1;
        translate: none;
        scale: 0 1;
    }

    .km-divider.km-reveal--in {
        animation-name: km-reveal-line;
    }

    /* Bilder im Slider setzen sich, die Folie schneidet sie ab */
    .swiper-slide.km-reveal:not(.km-reveal--in) img {
        scale: 1.06;
    }

    .swiper-slide.km-reveal--in img {
        animation: km-reveal-settle calc(var(--km-duration-slow, .8s) * 1.5) var(--km-ease-out, cubic-bezier(.22, 1, .36, 1)) var(--km-reveal-delay, 0s) backwards;
    }
}

@keyframes km-reveal {
    from {
        opacity: 0;
        translate: 0 2rem;
        scale: .98;
    }
}

@keyframes km-reveal-line {
    from {
        scale: 0 1;
    }
}

@keyframes km-reveal-settle {
    from {
        scale: 1.06;
    }
}

/* Sanftes Scrollen: Regeln aus lenis.css (Lenis 1.3, MIT, public/vendor/lenis) */
html.lenis,
html.lenis body {
    height: auto;
}

.lenis:not(.lenis-autoToggle).lenis-stopped {
    overflow: clip;
}

.lenis [data-lenis-prevent],
.lenis [data-lenis-prevent-wheel],
.lenis [data-lenis-prevent-touch],
.lenis [data-lenis-prevent-vertical],
.lenis [data-lenis-prevent-horizontal] {
    overscroll-behavior: contain;
}

.lenis.lenis-smooth iframe {
    pointer-events: none;
}

.lenis.lenis-autoToggle {
    transition-property: overflow;
    transition-duration: 1ms;
    transition-behavior: allow-discrete;
}
