/*
 * The eagle of the logo flying in (MILESTONES #21.10, moved here from assets/css/home-motion.css on 15.10 so that it
 * flies on every page with the new header: home, How it works and the app pages restyled after the home page).
 * template-parts/home/hero-logo.php prints the logo inline with .amh-eagle-in while the Customizer switch is on;
 * loaded by Amerlink_Genesis_Home_Hero::enqueue_header_assets(). Nothing moves for prefers-reduced-motion.
 */

/* ---------- Logo eagle (#21.10, template-parts/home/hero-logo.php): the inline logo; with .amh-eagle-in (printed when
 * the Customizer switch is on) the eagle flies in from the left on every load, with four wing beats, glides and lands
 * by the name. Lengths are in units of the logo drawing (601 x 132, about 2.4 per pixel of a 255 px logo). */

/* .amh-logo in front: the app pages load bootstrap.min.css, whose svg:not(:root) { overflow: hidden } outweighs the
 * class alone and cut the eagle to the logo box. */
.amh-logo .amh-logo-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible; /* the eagle starts outside the logo, the lowered wing reaches below it */
}

/* Only when motion is welcome: the class is in the markup on every load. 1.8 s, a glide without a wing beat along a
 * cubic Bezier curve (from -340,-58 over -225,-66 and -95,42 to the logo), taken by arc length at full speed and braking
 * at the end, tilted with its tangent; the near (raised) wing is spread forward 18-25 deg (turned over its root 203,94)
 * and rises to the pose of the logo for the landing. The curve is sampled every 2 % (generated keyframes). */
@media (prefers-reduced-motion: no-preference) {
    /* It also fades in at the start: where the logo stands far from the edge (wide screens) it starts on screen. */
    .amh-eagle-in .amh-logo-eagle {
        transform-origin: 126px 66px;
        animation: amo-eagle-fly 1.8s linear both, amo-eagle-appear .5s ease-out both;
    }

    .amh-eagle-in .amh-logo-eagle-wing {
        transform-origin: 203px 94px;
        animation: amo-eagle-beat 1.8s ease-in-out both;
    }

    .amh-eagle-in .amh-logo-eagle-body {
        transform-origin: 150px 100px;
        animation: amo-eagle-beat-rear 1.8s ease-in-out both;
    }
}

@keyframes amo-eagle-appear {
    from {
        opacity: 0;
    }
}

@keyframes amo-eagle-fly {
    0% {
        translate: -340px -58px;
        rotate: -2.4deg;
    }

    2% {
        translate: -332px -58.4px;
        rotate: -0.8deg;
    }

    4% {
        translate: -324.2px -58.4px;
        rotate: 0.6deg;
    }

    6% {
        translate: -316.3px -58.1px;
        rotate: 1.9deg;
    }

    8% {
        translate: -308.4px -57.5px;
        rotate: 3.2deg;
    }

    10% {
        translate: -300.6px -56.7px;
        rotate: 4.3deg;
    }

    12% {
        translate: -292.8px -55.6px;
        rotate: 5.3deg;
    }

    14% {
        translate: -285px -54.2px;
        rotate: 6.3deg;
    }

    16% {
        translate: -277.3px -52.7px;
        rotate: 7.1deg;
    }

    18% {
        translate: -269.6px -51px;
        rotate: 7.9deg;
    }

    20% {
        translate: -261.9px -49.1px;
        rotate: 8.6deg;
    }

    22% {
        translate: -254.3px -47.1px;
        rotate: 9.2deg;
    }

    24% {
        translate: -246.7px -45px;
        rotate: 9.7deg;
    }

    26% {
        translate: -239.2px -42.7px;
        rotate: 10.2deg;
    }

    28% {
        translate: -231.6px -40.4px;
        rotate: 10.6deg;
    }

    30% {
        translate: -224.1px -37.9px;
        rotate: 11deg;
    }

    32% {
        translate: -216.6px -35.4px;
        rotate: 11.2deg;
    }

    34% {
        translate: -209.2px -32.9px;
        rotate: 11.5deg;
    }

    36% {
        translate: -201.8px -30.3px;
        rotate: 11.7deg;
    }

    38% {
        translate: -194.3px -27.6px;
        rotate: 11.8deg;
    }

    40% {
        translate: -186.9px -25px;
        rotate: 11.8deg;
    }

    42% {
        translate: -179.5px -22.3px;
        rotate: 11.9deg;
    }

    44% {
        translate: -172px -19.6px;
        rotate: 11.8deg;
    }

    46% {
        translate: -164.6px -17px;
        rotate: 11.7deg;
    }

    48% {
        translate: -157.1px -14.4px;
        rotate: 11.5deg;
    }

    50% {
        translate: -149.7px -11.8px;
        rotate: 11.3deg;
    }

    52% {
        translate: -142.3px -9.3px;
        rotate: 11deg;
    }

    54% {
        translate: -134.7px -6.8px;
        rotate: 10.7deg;
    }

    56% {
        translate: -127.2px -4.4px;
        rotate: 10.3deg;
    }

    58% {
        translate: -119.7px -2.2px;
        rotate: 9.7deg;
    }

    60% {
        translate: -112.1px -0.1px;
        rotate: 9.1deg;
    }

    62% {
        translate: -104.4px 1.9px;
        rotate: 8.5deg;
    }

    64% {
        translate: -96.8px 3.8px;
        rotate: 7.7deg;
    }

    66% {
        translate: -89px 5.4px;
        rotate: 6.8deg;
    }

    68% {
        translate: -81.3px 6.9px;
        rotate: 5.7deg;
    }

    70% {
        translate: -73.5px 8px;
        rotate: 4.6deg;
    }

    72% {
        translate: -65.6px 8.9px;
        rotate: 3.2deg;
    }

    74% {
        translate: -57.8px 9.5px;
        rotate: 1.8deg;
    }

    76% {
        translate: -49.9px 9.7px;
        rotate: 0.1deg;
    }

    78% {
        translate: -42.1px 9.6px;
        rotate: -1.7deg;
    }

    80% {
        translate: -34.2px 9px;
        rotate: -3.6deg;
    }

    82% {
        translate: -26.8px 7.9px;
        rotate: -5.7deg;
    }

    84% {
        translate: -20px 6.6px;
        rotate: -7.7deg;
    }

    86% {
        translate: -14.1px 5.1px;
        rotate: -9.4deg;
    }

    88% {
        translate: -9.3px 3.6px;
        rotate: -10deg;
    }

    90% {
        translate: -5.6px 2.3px;
        rotate: -9.2deg;
    }

    92% {
        translate: -2.9px 1.2px;
        rotate: -7.3deg;
    }

    94% {
        translate: -1.2px 0.5px;
        rotate: -4.9deg;
    }

    96% {
        translate: -0.4px 0.2px;
        rotate: -2.5deg;
    }

    98% {
        translate: 0px 0px;
        rotate: -0.7deg;
    }

    100% {
        translate: 0px 0px;
        rotate: 0deg;
    }
}

@keyframes amo-eagle-beat {
    0% {
        scale: 1 0.95;
        rotate: 22deg;
    }

    30% {
        scale: 1 0.95;
        rotate: 18deg;
    }

    58% {
        scale: 1 0.95;
        rotate: 24deg;
    }

    82% {
        scale: 1 0.95;
        rotate: 20deg;
    }

    100% {
        scale: 1 1;
        rotate: 0deg;
    }
}

@keyframes amo-eagle-beat-rear {
    0% {
        scale: 1 0.88;
    }

    58% {
        scale: 1 0.85;
    }

    82% {
        scale: 1 0.88;
    }

    100% {
        scale: 1 1;
    }
}
