
/*----------------------------------------------------------------------- 
Variablen können inline überschrieben werden um Änderungen vorzunehmen 
------------------------------------------------------------------------*/

:root{
    --scroll-timeline: scroll();
    --view-timeline: view();
    --view-timeline-inset: 5% 5%;
    --animation-play-state: running;

    --animation-range-start: 0%;
    --animation-range-end: 100%;

    --animation-timing-function: linear;
    --animation-fill-mode: both;
    --animation-direction: normal;

    --animation-duration: 0.6s;
    --animation-delay: 0s;
    --animation-iteration-count: 1;  
}


/*----------------------------------------------------------------------- 
Klassen zum Zuweisen und Steuern der Animationen
------------------------------------------------------------------------*/

/* Animation relativ zum Scroll Progress */
.pfx-scroll{
    animation-timeline: var(--scroll-timeline);
    animation-range-start: var(--animation-range-start);
    animation-range-end: var(--animation-range-end);
    animation-timing-function: var(--animation-timing-function);
    animation-fill-mode: var(--animation-fill-mode);
    animation-direction: var(--animation-direction);
    animation-play-state: var(--animation-play-state);
    animation-duration: auto;
    animation-delay: 0s;
    animation-name: var(--animation-name);
    
}

/* Animation während das Objekt den Viewport durchläuft */
.pfx-view{
    animation-timeline: var(--view-timeline);
    view-timeline-inset: var(--view-timeline-inset);
    animation-range-start: var(--animation-range-start);
    animation-range-end: var(--animation-range-end);
    animation-timing-function: var(--animation-timing-function);
    animation-fill-mode: var(--animation-fill-mode);
    animation-direction: var(--animation-direction);
    animation-play-state: var(--animation-play-state);
    animation-duration: auto;
    animation-delay: 0s;
    animation-name: var(--animation-name); 
}

/*  generelle nicht Scroll gesteuerte Keyframe basierende Animationen
    benötogt java script observer - wie viel sichtbar sein muss bevor die
    Animation startet wird durch inline: --visibility-threshold: ; geregelt
    ansonsten wird der standard wert genutzt 0.4
    
    der Name des Keyframes wird inline als Variable gesetzt*/
.pfx-keyframe{
    animation-range-start: var(--animation-range-start);
    animation-range-end: var(--animation-range-end);
    animation-timing-function: var(--animation-timing-function);
    animation-fill-mode: var(--animation-fill-mode);
    animation-direction: var(--animation-direction);
    animation-duration: var(--animation-duration);
    animation-delay: var(--animation-delay);
    animation-play-state: var(--animation-play-state);
    animation-iteration-count: var(--animation-iteration-count);
    
    --visibility-threshold: 0.4;
    --animation-timing-function: ease-in;
}

.pfx-keyframe.is-visible{
    animation-name: var(--animation-name);
}

/*----------------------------------------------------------------------- 
Scroll Container für view timelines, die animationen kopeln 
sich an den Fortschritt dieses Containers im Viewport, anstelle ihres
eigenen.
------------------------------------------------------------------------*/

/* der Container selbst seine Höhe bestimmt wie viel gescrollt
    werden muss bis alle Animatioenn durchgelaufen sind */

.scroll-container{ 
    height: var(--scroll-height);
    view-timeline-name: --scroll-container;
}

/* das einzelne Element welches relativ zum Container animiert wird */
.scroll-animated {
  --scroll-container-range-start: 15%;
  --scroll-container-range-end: 80%;

  animation-name: var(--animation-name);
  animation-timeline: --scroll-container;
  animation-range-start: var(--scroll-container-range-start);
  animation-range-end: var(--scroll-container-range-end);
  animation-duration: 1ms;
  animation-fill-mode: both;
  animation-timing-function: var(--animation-timing-function);
}

/* ein Element welches sich zwar innerhalb des scrol-containers befindet
    allerdings seine eigene view timeline hatt und von der Timeline
    des containers entkoppelt ist */
.view-animated {
  --fallback-animation-timeline: view();
  --fallback-animation-range-start: 15%;
  --fallback-animation-range-end: 20%;

  animation-name: var(--animation-name);
  animation-timeline: view();
  animation-range-start: var(--fallback-animation-range-start);
  animation-range-end: var(--fallback-animation-range-end);
  animation-duration: 1ms;
  animation-fill-mode: both;
  animation-timing-function: var(--animation-timing-function);
}

/*----------------------------------------------------------------------- 
Parallax Effekt für BG Images - BG Image muss als extra Container über dem Content angelegt werden
------------------------------------------------------------------------*/
/*  has-parallax benötigt entweder eine feste größe, oder ein padding damit er sich nach der größe des
    inhaltes richtet */

.has-parallax{
    overflow: clip;
    position: relative;

    display:flex;
    align-items: center;
    justify-content: center;
}

.has-parallax .parallax-bg-image{
    position: absolute;
    inset: 0;
    width: 100%;
    height: 130%;
    background-size: cover;
    background-position: center;
    z-index:1;
    
    animation: parallaxShift linear;
    animation-timeline: view();
    animation-fill-mode: both;
    animation-iteration-count: 1;
}

/* hier kommt der content rein z.B. Text, */
.has-parallax .content{
    z-index: 2;
    position: relative;
    height: 100%;
}

@keyframes parallaxShift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-200px);

  }
}


/*----------------------------------------------------------------------- 
fertige Animations Klassen die direkt auf Elemente angewendet werden können
------------------------------------------------------------------------*/

.pfx-cinematic-fade-in{
    animation-name: cinematic-fade-in;
    animation-duration: 1ms;
    animation-fill-mode: both;
    animation-timeline: view(95% 0%);
    animation-direction: normal;
    animation-iteration-count: 1;
}
/*----------------------------------------------------------------------- 
keyframes
------------------------------------------------------------------------*/
/* cinematic fade-in */

@keyframes cinematic-fade-in{
    0%{
        opacity: 0;
        filter: blur(15px);
        transform: translateY(40px) scale(0.9);

    }
    100%{
        opacity: 1;
        filter: blur(0px);
        transform: translateY(0) scale(1);
    }
}


.pfx-observer-running .pfx-keyframe[style*="--animation-name: cinematic-fade-in"]{
    opacity: 0;
}




/* fade in effekt */
@keyframes fade-in{
    0%{
        opacity: 0;
    }
    100%{
        opacity: 1;
    }
}

.pfx-observer-running .pfx-keyframe[style*="--animation-name: fade-in"]{
    opacity: 0;
}


/* fade-up effekt */

@keyframes fade-up{
    0%{
        opacity: 0;
        transform: translateY(20px);
    }
    100%{
        opacity: 1;
        transform: translateY(0px);
    }
}

.pfx-observer-running .pfx-keyframe[style*="--animation-name: fade-up"]{
    opacity: 0;
    transform: translateY(20px);
}



/* fade-left */


@keyframes fade-left{
    0%{
        opacity: 0;
        transform: translateX(-20px);
    }
    100%{
        opacity: 1;
        transform: translateX(0px);
    }
}

.pfx-observer-running .pfx-keyframe[style*="--animation-name: fade-left"]{
    opacity: 0;
    transform: translateX(-20px);
}


/* fade-right */


@keyframes fade-right{
    0%{
        opacity: 0;
        transform: translateX(20px);
    }
    100%{
        opacity: 1;
        transform: translateX(0px);
    }
}

.pfx-observer-running .pfx-keyframe[style*="--animation-name: fade-right"]{
    opacity: 0;
    transform: translateX(20px);
}

/* 360% spin */

@keyframes spin-360{
    0%{
        transform: rotate(0deg);
    }
    100%{
        transform: rotate(360deg);
    }
}

.pfx-observer-running .pfx-keyframe[style*="--animation-name: spin-360"]{
        --visibility-threshold: 0;
        --animation-duration: 4s;
}

/* elevate */

@keyframes elevate{
    0%{
        transform: scale(0.95) translateY(0);
        box-shadow: 5px 5px 15px rgba(0,0,0,0.1);
    
    }
    100%{
        transform: scale(1) translateY(10px);
        box-shadow: 5px 10px 15px rgba(0,0,0,0.3);
    }
}

.pfx-observer-running .pfx-keyframe[style*="--animation-name: elevate"],
.pfx-view[style*="--animation-name: elevate"],
.pfx-scroll[style*="--animation-name: fade-elevate"]{

    /* transform: scale(0.95); */
    --animation-fill-mode: both;
    --animation-iteration-count: infinite;
    --animation-timing-function: linear;
    --animation-duration: 3s;
    --animation-direction: alternate;
}