/*
 * Home page motion (MILESTONES #21, smoother entrances 21.8), after acez-front (resources/css/app.css: revealSoft / reveal-lg / -deal / -step /
 * -pop, the line drawing, the floating decorations). assets/js/home-motion.js arms the elements; nothing here hides
 * anything on its own. The entrances use the separate translate / scale / rotate properties, so the transform the
 * section stylesheets give an element stays untouched; after its entrance the element drops these classes.
 */

/* ---------- Entrances: text rises, large blocks rise or slide in from their side, cards are dealt, steps come in
 * from the left, small items pop. The move and the fade are two animations: the fade is linear and shorter, the move
 * decelerates slowly, so the element is seen travelling instead of appearing at once. */

/* The start pose holds only until the entrance begins (.amo-in): the animations then run from their `from` frame to
 * the element's own values (no `to` frame), so nothing waits hidden and jumps in at the end. */
.amo-armed:not(.amo-in) {
    opacity: 0;
}

.amo-armed.amo-soft:not(.amo-in) {
    translate: 0 30px;
}

.amo-armed.amo-lg:not(.amo-in) {
    translate: 0 52px;
    scale: .97;
}

.amo-armed.amo-left:not(.amo-in) {
    translate: -64px 0;
}

.amo-armed.amo-right:not(.amo-in) {
    translate: 64px 0;
}

.amo-armed.amo-deal:not(.amo-in) {
    translate: 0 40px;
    rotate: -2deg;
    scale: .95;
}

.amo-armed.amo-step:not(.amo-in) {
    translate: -40px 0;
}

.amo-armed.amo-pop:not(.amo-in) {
    scale: .82;
}

.amo-armed.amo-in {
    --amo-ease: cubic-bezier(.25, 1, .5, 1); /* easeOutQuart */
}

.amo-armed.amo-in.amo-soft {
    animation: amo-soft .95s var(--amo-ease) both, amo-fade .6s linear both;
}

.amo-armed.amo-in.amo-lg {
    animation: amo-lg 1.1s var(--amo-ease) both, amo-fade .7s linear both;
}

.amo-armed.amo-in.amo-left {
    animation: amo-left 1.1s var(--amo-ease) both, amo-fade .7s linear both;
}

.amo-armed.amo-in.amo-right {
    animation: amo-right 1.1s var(--amo-ease) both, amo-fade .7s linear both;
}

.amo-armed.amo-in.amo-deal {
    animation: amo-deal 1s var(--amo-ease) both, amo-fade .6s linear both;
}

.amo-armed.amo-in.amo-step {
    animation: amo-step .9s var(--amo-ease) both, amo-fade .55s linear both;
}

.amo-armed.amo-in.amo-pop {
    animation: amo-pop .75s cubic-bezier(.34, 1.4, .64, 1) both, amo-fade .4s linear both;
}

@keyframes amo-fade {
    from {
        opacity: 0;
    }
}

@keyframes amo-soft {
    from {
        translate: 0 30px;
    }
}

@keyframes amo-lg {
    from {
        translate: 0 52px;
        scale: .97;
    }
}

@keyframes amo-left {
    from {
        translate: -64px 0;
    }
}

@keyframes amo-right {
    from {
        translate: 64px 0;
    }
}

@keyframes amo-deal {
    from {
        translate: 0 40px;
        rotate: -2deg;
        scale: .95;
    }
}

@keyframes amo-step {
    from {
        translate: -40px 0;
    }
}

@keyframes amo-pop {
    from {
        scale: .82;
    }
}

/* A block sliding in from the right starts past the edge of the screen; the other sections with one already hide what
 * sticks out sideways (overflow-x: hidden), Quick Check does not. Clip, not hidden: no scroll box, nothing cut
 * vertically, and the section spans the page, so only what is off screen anyway is cut. */
.amq-section {
    overflow-x: clip;
}

/* Shorter moves on phones: the same distance reads as a jump on a small screen. (Blocks there span the width, so the
 * script gives them amo-lg instead of a side.) */
@media (max-width: 780px) {
    .amo-armed.amo-soft:not(.amo-in) {
        translate: 0 20px;
    }

    .amo-armed.amo-lg:not(.amo-in) {
        translate: 0 32px;
    }

    .amo-armed.amo-deal:not(.amo-in) {
        translate: 0 28px;
        rotate: -1.5deg;
    }

    .amo-armed.amo-step:not(.amo-in) {
        translate: -24px 0;
    }

    .amo-armed.amo-in.amo-soft {
        animation-name: amo-soft-short, amo-fade;
    }

    .amo-armed.amo-in.amo-lg {
        animation-name: amo-lg-short, amo-fade;
    }

    .amo-armed.amo-in.amo-deal {
        animation-name: amo-deal-short, amo-fade;
    }

    .amo-armed.amo-in.amo-step {
        animation-name: amo-step-short, amo-fade;
    }

    @keyframes amo-soft-short {
        from {
            translate: 0 20px;
        }
    }

    @keyframes amo-lg-short {
        from {
            translate: 0 32px;
            scale: .97;
        }
    }

    @keyframes amo-deal-short {
        from {
            translate: 0 28px;
            rotate: -1.5deg;
            scale: .95;
        }
    }

    @keyframes amo-step-short {
        from {
            translate: -24px 0;
        }
    }
}

/* ---------- Hero on load: it is on screen from the first paint, so it comes in here, without the script (a visitor
 * without JS sees the same; the background photo, the LCP image, is not animated). Filled backwards only: after the
 * entrance nothing holds these properties. On phones the cards and the note
 * are lower down and come in on scroll like the rest, from the script. */

.amh-eyebrow,
.amh-description,
.amh-cta-row {
    animation: amo-hero-rise .9s cubic-bezier(.25, 1, .5, 1) backwards, amo-fade .6s linear backwards;
}

/* The heading is the LCP element on wider screens: it is painted at once (no fade, which would hold the LCP back until
 * the end of the fade) and only glides into place. */
#amh-hero-title > span {
    animation: amo-hero-rise 1s cubic-bezier(.25, 1, .5, 1) backwards;
}

#amh-hero-title > span:first-child {
    animation-delay: .08s;
}

#amh-hero-title > span + span {
    animation-delay: .16s;
}

.amh-description {
    animation-delay: .26s;
}

.amh-cta-row {
    animation-delay: .36s;
}

@keyframes amo-hero-rise {
    from {
        translate: 0 22px;
    }
}

@media (min-width: 781px) {
    .amh-card {
        animation: amo-hero-rise .9s cubic-bezier(.25, 1, .5, 1) backwards, amo-fade .6s linear backwards;
    }

    .amh-card:nth-child(1) {
        animation-delay: .5s;
    }

    .amh-card:nth-child(2) {
        animation-delay: .6s;
    }

    .amh-card:nth-child(3) {
        animation-delay: .7s;
    }

    .amh-handwritten {
        animation: amo-fade .8s .85s linear backwards;
    }
}

/* ---------- Cards with a button or a link lift a little under the pointer. */

.amp-card,
.amr-guide {
    transition: translate .28s ease, box-shadow .28s ease;
}

.amp-card:hover,
.amp-card:focus-within,
.amr-guide:hover,
.amr-guide:focus-within {
    translate: 0 -6px;
    box-shadow: 0 26px 60px rgba(1, 33, 106, .12);
}

/* The arrows between the How It Works steps grow a little under the pointer (scale: their transform places them). */
.amw-arrow {
    transition: scale .25s ease;
}

.amw-arrow:hover {
    scale: 1.18;
}

/* ---------- Profile photos of How It Works taking turns (#21.11, home-motion.js adds .amw-rotating and moves .is-active):
 * the new photo fades in with a slight zoom over the old one, only opacity and scale. */

.amw-profile-photos.amw-rotating > .amw-profile-photo {
    opacity: 0;
    scale: .92;
    transition: opacity .9s ease, scale .9s cubic-bezier(.25, 1, .5, 1);
}

.amw-profile-photos.amw-rotating > .amw-profile-photo.is-active {
    z-index: 1; /* the new photo comes in over the old one, which stays whole until then: no see-through moment */
    opacity: 1;
    scale: 1;
}

.amw-profile-photos.amw-rotating > .amw-profile-photo.is-leaving {
    opacity: 1;
    scale: 1;
    transition: none;
}

/* ---------- Decorations in motion: the plane over Programs drifts, the labels on the Expert Help photo sway. */

.amp-plane {
    animation: amo-drift 7s ease-in-out infinite;
}

.ame-badge {
    animation: amo-sway 5s ease-in-out infinite;
}

.ame-badge:nth-child(2) {
    animation-delay: -1.7s;
}

.ame-badge:nth-child(3) {
    animation-delay: -3.4s;
}

@keyframes amo-drift {
    50% {
        translate: 0 -10px;
    }
}

@keyframes amo-sway {
    50% {
        translate: 0 -5px;
    }
}

/* Phones: lighter motion — no endless decorations, and quicker entrances (home-motion.js arms only the headings,
 * texts and large blocks there, and does not draw the dashed lines). */
@media (max-width: 780px) {
    .amp-plane,
    .ame-badge {
        animation: none;
    }

    .amo-armed.amo-in.amo-soft {
        animation-duration: .7s, .45s;
    }

    .amo-armed.amo-in.amo-lg {
        animation-duration: .8s, .5s;
    }
}

/* The pink line under the handwritten note in the hero draws itself once. */
.amh-handwritten::after {
    transform-origin: left center;
    animation: amo-underline .9s .6s cubic-bezier(.22, .61, .36, 1) both;
}

/* On wider screens the note fades in with the hero (above), so its line waits for it. */
@media (min-width: 781px) {
    .amh-handwritten::after {
        animation-delay: 1.3s;
    }
}

@keyframes amo-underline {
    from {
        scale: 0 1;
    }
}

/* ---------- Hero background slideshow (from 781 px; the script adds .amh-slides-on and the photos). */

.amh-slide {
    opacity: 0;
    object-position: 72% center; /* the photos keep their subject on the right, away from the heading */
}

.amh-slides-on .amh-background {
    z-index: -3;
    opacity: 0;
}

.amh-slides-on .amh-background.is-front,
.amh-slides-on .amh-background.is-back {
    opacity: 1;
    animation: amo-zoom 9.4s linear both; /* shown 7 s, plus the fade in and the fade out */
    transform-origin: 70% 45%;
}

.amh-slides-on .amh-background.is-front {
    z-index: -2;
    transition: opacity 1.2s ease;
}

.amh-slides-on.is-still .amh-background,
.amh-slides-on.is-paused .amh-background {
    animation-play-state: paused;
}

@keyframes amo-zoom {
    to {
        scale: 1.06;
    }
}

.amh-slides-toggle {
    position: absolute;
    z-index: 3;
    right: clamp(16px, 2vw, 32px);
    bottom: clamp(16px, 2vw, 28px);
    display: grid;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .38);
    border-radius: 50%;
    background: rgba(0, 32, 70, .42);
    color: #fff;
    cursor: pointer;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: background-color .2s ease;
}

.amh-slides-toggle[hidden] {
    display: none;
}

.amh-slides-toggle:hover {
    background: rgba(0, 32, 70, .7);
}

.amh-slides-toggle:focus-visible {
    outline: 3px solid var(--amh-blue);
    outline-offset: 3px;
}

.amh-slides-toggle svg {
    width: 14px;
    height: 14px;
}

/* The ChatLab chatbot launcher (template-parts/app/head_snippets_tpl.php: script.chatlab.com/aichatbot.js — fixed,
   60px, var(--launcher-bottom-margin) / var(--launcher-side-margin) from the bottom right, 20px by default) covered this
   button. The button sits at the hero's bottom, so how high it is on the screen depends on the window's height: no
   height of the launcher clears it on every screen. On the home page the launcher sits 20px higher than set (closed at
   any width, open only above 800px — below, the widget opens full screen with no margin), and while the widget is on
   the page this button moves left, out of the launcher's column. */
body.home .rcw-widget-container.rcw-close-widget-container {
    margin-bottom: calc(var(--launcher-bottom-margin, 20px) + 20px) !important;
}

@media (min-width: 801px) {
    body.home .rcw-widget-container {
        margin-bottom: calc(var(--launcher-bottom-margin, 20px) + 20px) !important;
    }
}

body.home:has(.rcw-widget-container) .amh-slides-toggle {
    right: calc(var(--launcher-side-margin, 20px) + 76px);
}

.amh-slides-toggle .amh-icon-play,
.amh-hero.is-paused .amh-slides-toggle .amh-icon-pause {
    display: none;
}

.amh-hero.is-paused .amh-slides-toggle .amh-icon-play {
    display: block;
}

.amh-slides-toggle .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Hero background effect (#21.9, template-parts/home/hero-effect.php): two growth lines from the bottom left.
 * Above the shade, under the content; the mask on the drawing fades out their last 340 px, where they end.
 * From 781 px (on phones the heading fills the hero). They draw themselves once, turning from the same dark blue into
 * their own colour, then stand still; home-motion.js fades them out and draws them again every 30 s and when the
 * visitor comes back to the hero (.is-fading, .is-reset). Paused with the slideshow (.is-still). */

.amh-fx {
    --amh-fx-start: #2c5c96;
    position: absolute;
    z-index: -1; /* after .amh-shade in the markup, so above it */
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    transition: opacity .8s ease;
}

.amh-fx.is-fading {
    opacity: 0;
}

/* 1:1 from the bottom left, like the hero content (the drawing is 1440 x 908); scaled up only past 1920 px. The fade is
 * in percent of the drawing, so it ends with the lines (x 1120) on every screen. */
.amh-fx svg {
    position: absolute;
    bottom: 0;
    left: 0;
    width: max(1440px, 75%);
    height: 908px;
    -webkit-mask-image: linear-gradient(90deg, #000 54%, transparent 78%);
    mask-image: linear-gradient(90deg, #000 54%, transparent 78%);
}

.amh-hero.is-still .amh-fx path {
    animation-play-state: paused;
}

/* pathLength="100": the dash pattern is in percent of the line, so 100 / 100 hides it and offset 0 shows it whole. */
.amh-fx-line,
.amh-fx-glow {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 100 100;
    stroke-dashoffset: 100;
    animation: amo-fx-draw-blue 4s cubic-bezier(.45, .05, .25, 1) .4s both;
}

.amh-fx-line {
    stroke-width: 4.5;
}

/* The glow: the same line, wide and blurred, under it. */
.amh-fx-glow {
    stroke-width: 16;
    stroke-opacity: .7;
    filter: url(#amh-fx-soft);
}

.amh-fx-pink {
    animation-name: amo-fx-draw-pink;
    animation-delay: .7s;
}

.amh-fx.is-reset path {
    animation: none;
}

@keyframes amo-fx-draw-blue {
    0%,
    15% {
        stroke: var(--amh-fx-start);
    }

    0% {
        stroke-dashoffset: 100;
    }

    100% {
        stroke-dashoffset: 0;
        stroke: var(--amh-blue);
    }
}

@keyframes amo-fx-draw-pink {
    0%,
    15% {
        stroke: var(--amh-fx-start);
    }

    0% {
        stroke-dashoffset: 100;
    }

    100% {
        stroke-dashoffset: 0;
        stroke: var(--amh-pink);
    }
}

@media (max-width: 780px) {
    .amh-fx {
        display: none;
    }
}

/* ---------- Reduced motion: nothing moves (the script does not arm anything either). */

@media (prefers-reduced-motion: reduce) {
    .amo-armed,
    .amo-armed.amo-in {
        opacity: 1;
        translate: none;
        rotate: none;
        scale: none;
        animation: none;
    }

    .amh-eyebrow,
    #amh-hero-title > span,
    .amh-description,
    .amh-cta-row,
    .amh-card,
    .amh-handwritten,
    .amh-fx *,
    .amp-plane,
    .ame-badge,
    .amh-handwritten::after,
    .amh-slides-on .amh-background {
        animation: none;
    }

    .amp-card,
    .amr-guide,
    .amw-arrow,
    .amw-profile-photos.amw-rotating > .amw-profile-photo {
        transition: none;
    }

    .amp-card:hover,
    .amp-card:focus-within,
    .amr-guide:hover,
    .amr-guide:focus-within {
        translate: none;
    }

    /* The growth lines stay as a still drawing in their own colours. */
    .amh-fx-line,
    .amh-fx-glow {
        stroke-dashoffset: 0;
        stroke: var(--amh-blue);
    }

    .amh-fx-pink {
        stroke: var(--amh-pink);
    }
}
