/*
 * Divi Child Guard - Cinematic Motion Header
 *
 * Modes:
 * - Push In
 * - Pull Back
 * - Back & Forth
 *
 * Speeds:
 * - Slow
 * - Medium
 * - Fast
 *
 * Uses the native Divi section background.
 * No JavaScript.
 */


/* =========================================================
   BASE
   ========================================================= */

body.dcg-mh-on
#main-content
.et_pb_section:has(h1) {
    --dcg-mh-loop-duration: 9s;
    --dcg-mh-oneway-duration: 16s;

    will-change: background-position, background-size;
    backface-visibility: hidden;
}


/* =========================================================
   SPEED
   One-way modes intentionally run longer than Back & Forth.
   ========================================================= */

body.dcg-mh-on.dcg-mh-speed-slow
#main-content
.et_pb_section:has(h1) {
    --dcg-mh-loop-duration: 14s;
    --dcg-mh-oneway-duration: 22s;
}

body.dcg-mh-on.dcg-mh-speed-medium
#main-content
.et_pb_section:has(h1) {
    --dcg-mh-loop-duration: 9s;
    --dcg-mh-oneway-duration: 16s;
}

body.dcg-mh-on.dcg-mh-speed-fast
#main-content
.et_pb_section:has(h1) {
    --dcg-mh-loop-duration: 6.5s;
    --dcg-mh-oneway-duration: 11s;
}


/* =========================================================
   PUSH IN
   One-way cinematic move from wide to close.
   Runs once and holds the final frame.
   ========================================================= */

body.dcg-mh-on.dcg-mh-push
#main-content
.et_pb_section:has(h1) {
    animation-name: dcgMhPushIn;
    animation-duration: var(--dcg-mh-oneway-duration);
    animation-timing-function: ease-in-out;
    animation-iteration-count: 1;
    animation-direction: normal;
    animation-fill-mode: forwards;
}

@keyframes dcgMhPushIn {

    0% {
        background-size: 106% auto;
        background-position: 48% 51%;
    }

    100% {
        background-size: 120% auto;
        background-position: 54% 47%;
    }
}


/* =========================================================
   PULL BACK
   One-way cinematic move from close to wide.
   Runs once and holds the final frame.
   ========================================================= */

body.dcg-mh-on.dcg-mh-pull
#main-content
.et_pb_section:has(h1) {
    animation-name: dcgMhPullBack;
    animation-duration: var(--dcg-mh-oneway-duration);
    animation-timing-function: ease-in-out;
    animation-iteration-count: 1;
    animation-direction: normal;
    animation-fill-mode: forwards;
}

@keyframes dcgMhPullBack {

    0% {
        background-size: 120% auto;
        background-position: 54% 47%;
    }

    100% {
        background-size: 106% auto;
        background-position: 48% 51%;
    }
}


/* =========================================================
   BACK & FORTH
   Original Cinematic Drift motion.
   Continuous smooth alternating movement.
   ========================================================= */

body.dcg-mh-on.dcg-mh-bidirectional
#main-content
.et_pb_section:has(h1) {
    animation:
        dcgMhCinematic
        var(--dcg-mh-loop-duration)
        ease-in-out
        infinite
        alternate;
}

@keyframes dcgMhCinematic {

    0% {
        background-size: 108% auto;
        background-position: 48% 50%;
    }

    45% {
        background-size: 114% auto;
        background-position: 55% 46%;
    }

    100% {
        background-size: 110% auto;
        background-position: 51% 53%;
    }
}


@keyframes dcgMhCinematic {

    0% {
        background-size: auto 108%;
        background-position: 48% 50%;
    }

    45% {
        background-size: auto 114%;
        background-position: 55% 46%;
    }

    100% {
        background-size: auto 110%;
        background-position: 51% 53%;
    }
}


/* =========================================================
   TABLET AND MOBILE
   ========================================================= */

@media (max-width: 980px) {

    body.dcg-mh-on.dcg-mh-push
    #main-content
    .et_pb_section:has(h1) {
        animation-name: dcgMhPushInMobile;
    }

    body.dcg-mh-on.dcg-mh-pull
    #main-content
    .et_pb_section:has(h1) {
        animation-name: dcgMhPullBackMobile;
    }

    body.dcg-mh-on.dcg-mh-bidirectional
    #main-content
    .et_pb_section:has(h1) {
        animation-name: dcgMhCinematicMobile;
    }
}


@keyframes dcgMhPushInMobile {

    0% {
        background-size: auto 106%;
        background-position: 48% 51%;
    }

    100% {
        background-size: auto 120%;
        background-position: 54% 47%;
    }
}


@keyframes dcgMhPullBackMobile {

    0% {
        background-size: auto 120%;
        background-position: 54% 47%;
    }

    100% {
        background-size: auto 106%;
        background-position: 48% 51%;
    }
}


@keyframes dcgMhCinematicMobile {

    0% {
        background-size: auto 108%;
        background-position: 48% 50%;
    }

    45% {
        background-size: auto 114%;
        background-position: 55% 46%;
    }

    100% {
        background-size: auto 110%;
        background-position: 51% 53%;
    }
}


/* =========================================================
   ACCESSIBILITY
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    body.dcg-mh-on
    #main-content
    .et_pb_section:has(h1) {
        animation: none !important;
        will-change: auto;
    }
}