/*
 * Micro-animations for every page (enqueued in functions.php).
 *
 * Moves use the individual `translate` / `scale` properties, so they add to a
 * component's own `transform` instead of replacing it. Component selectors
 * start with `html` to outrank the page stylesheets, whatever their load order.
 * Scroll reveals are switched on by js/motion.js.
 */

:root {
    --wi-ease-out: cubic-bezier(.22, 1, .36, 1);
    --wi-ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

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

@keyframes wi-drop {
    from { opacity: 0; translate: 0 -6px; }
}

@keyframes wi-rise {
    from { opacity: 0; translate: 0 10px; }
}

@keyframes wi-pop-in {
    from { opacity: 0; scale: .92; }
}

@keyframes wi-pop {
    50% { scale: 1.06; }
}

@keyframes wi-shake {
    20%, 60% { translate: -4px 0; }
    40%, 80% { translate: 4px 0; }
}

@keyframes wi-bar-grow {
    from { scale: 0 1; }
}

@media (prefers-reduced-motion: no-preference) {

    /* ---------- form fields: ease focus and error colours ---------- */

    :where(input:not([type="checkbox"], [type="radio"], [type="range"]), textarea, select) {
        transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
    }

    /* ---------- buttons: lift on hover, press on click ---------- */

    html .oh .oh-btn,
    html .ocat .ocat-btn,
    html .oaf .oaf-btn,
    html .osb .osb-btn,
    html .ocl .ocl-btn,
    html .cp .cp-btn,
    html .oed .oed-btn,
    html .oec .oec-btn,
    html .olg .olg-btn,
    html .onf .onf-btn,
    html .ore .ore-btn,
    html .oty .oty-btn,
    html .ojl .ojl-btn,
    html .va .va-btn,
    html #header.osh .osh-btn,
    html footer#footer.osf-footer .osf-btn,
    html .jl-btn,
    html .wh-button,
    html .wi-feedback button {
        transition: color .15s ease, background-color .15s ease, border-color .15s ease,
            box-shadow .2s ease, translate .2s var(--wi-ease-out), scale .12s ease;
    }

    @media (hover: hover) {
        html .oh .oh-btn:hover,
        html .ocat .ocat-btn:hover,
        html .oaf .oaf-btn:hover,
        html .osb .osb-btn:hover,
        html .ocl .ocl-btn:hover,
        html .cp .cp-btn:hover,
        html .oed .oed-btn:hover,
        html .oec .oec-btn:hover,
        html .olg .olg-btn:hover,
        html .onf .onf-btn:hover,
        html .ore .ore-btn:hover,
        html .oty .oty-btn:hover,
        html .ojl .ojl-btn:hover,
        html .va .va-btn:hover,
        html #header.osh .osh-btn:hover,
        html footer#footer.osf-footer .osf-btn:hover,
        html .jl-btn:hover,
        html .wh-button:hover {
            translate: 0 -1px;
        }

        html .oh .oh-btn--primary:hover,
        html .ocat .ocat-btn--primary:hover,
        html .oaf .oaf-btn--primary:hover,
        html .onf .onf-btn--primary:hover,
        html .ore .ore-btn--primary:hover,
        html .oty .oty-btn--primary:hover,
        html .ojl .ojl-btn--cta:hover,
        html #header.osh .osh-btn--primary:hover {
            box-shadow: 0 8px 20px rgba(20, 33, 61, .16);
        }
    }

    html .oh .oh-btn:active,
    html .ocat .ocat-btn:active,
    html .oaf .oaf-btn:active,
    html .osb .osb-btn:active,
    html .ocl .ocl-btn:active,
    html .cp .cp-btn:active,
    html .oed .oed-btn:active,
    html .oec .oec-btn:active,
    html .olg .olg-btn:active,
    html .onf .onf-btn:active,
    html .ore .ore-btn:active,
    html .oty .oty-btn:active,
    html .ojl .ojl-btn:active,
    html .va .va-btn:active,
    html #header.osh .osh-btn:active,
    html footer#footer.osf-footer .osf-btn:active,
    html .jl-btn:active,
    html .wh-button:active,
    html .wi-feedback button:active {
        translate: 0 0;
        scale: .97;
        box-shadow: none;
    }

    /* Copied: the button pops once (affiliate link). */
    html .oaf .oaf-btn.is-copied {
        animation: wi-pop .3s var(--wi-ease-spring);
    }

    /* ---------- cards and tiles that are links: lift a little ---------- */

    html .ocat-entry,
    html .ore .ore-tile,
    html #header.osh .osh-tile {
        transition: color .15s ease, background-color .15s ease, border-color .15s ease,
            box-shadow .2s ease, translate .2s var(--wi-ease-out), scale .12s ease;
    }

    @media (hover: hover) {
        html .ocat-entry:hover,
        html .ore .ore-tile:hover,
        html #header.osh .osh-tile:hover {
            translate: 0 -2px;
        }
    }

    html .ore .ore-tile:active {
        translate: 0 0;
        scale: .98;
    }

    html .ore .ore-tile.is-picked {
        animation: wi-pop .3s var(--wi-ease-spring);
    }

    /* ---------- chips: press on click, pop when picked ---------- */

    html .ocat .ocat-chip,
    html .ocat .ocat-item,
    html .ocat .ocat-lang,
    html .onf .onf-chip,
    html .va .va-chip,
    html .oh .oh-emp-skill,
    html .wi-skill-picker .sp-chip,
    html .wi-job-search-chip {
        transition: color .15s ease, background-color .15s ease, border-color .15s ease,
            box-shadow .15s ease, scale .12s ease;
    }

    html .ocat .ocat-chip:active,
    html .ocat .ocat-item:active,
    html .ocat .ocat-lang:active,
    html .onf .onf-chip:active,
    html .va .va-chip:active,
    html .oh .oh-emp-skill:active,
    html .wi-skill-picker .sp-chip:active,
    html .wi-job-search-chip:active {
        scale: .96;
    }

    html .wi-skill-picker .sp-chip[aria-pressed="true"],
    html :is(.wi-skill-picker, .sp-progress) .sp-dot.is-on {
        animation: wi-pop .28s var(--wi-ease-spring);
    }

    /* ---------- header: desktop mega menu ---------- */

    /* The panel unfolds from the pill: a bit more travel and a slight zoom. */
    html #header.osh .osh-mega {
        transform-origin: 50% 0;
        scale: .98;
        transition: opacity .15s ease, transform .15s ease, scale .15s ease, visibility 0s linear .15s;
    }

    html #header.osh .osh-navitem.is-open .osh-mega,
    html #header.osh .osh-navitem:has(:focus-visible):not(.is-dismissed) .osh-mega {
        scale: 1;
        transition: opacity .2s ease, transform .28s var(--wi-ease-out), scale .28s var(--wi-ease-out);
    }

    /* Columns follow one after another. */
    html #header.osh .osh-navitem.is-open .osh-mega > *,
    html #header.osh .osh-navitem:has(:focus-visible):not(.is-dismissed) .osh-mega > * {
        animation: wi-rise .3s var(--wi-ease-out) both;
    }

    html #header.osh .osh-navitem.is-open .osh-mega > :nth-child(2),
    html #header.osh .osh-navitem:has(:focus-visible):not(.is-dismissed) .osh-mega > :nth-child(2) {
        animation-delay: .04s;
    }

    html #header.osh .osh-navitem.is-open .osh-mega > :nth-child(n+3),
    html #header.osh .osh-navitem:has(:focus-visible):not(.is-dismissed) .osh-mega > :nth-child(n+3) {
        animation-delay: .08s;
    }

    /* Links slide a touch to the right, the promo card lifts. */
    html #header.osh .osh-mega-links a,
    html #header.osh .osh-mega-all,
    html #header.osh .osh-links a {
        transition: color .15s ease, background-color .15s ease, translate .2s var(--wi-ease-out);
    }

    html #header.osh .osh-mega-promo {
        transition: border-color .15s ease, box-shadow .2s ease, translate .2s var(--wi-ease-out), scale .12s ease;
    }

    html #header.osh .osh-mega-promo .osh-icon {
        transition: scale .25s var(--wi-ease-spring);
    }

    @media (hover: hover) {
        html #header.osh .osh-mega-links a:hover,
        html #header.osh .osh-mega-all:hover,
        html #header.osh .osh-links a:hover {
            translate: 3px 0;
        }

        html #header.osh .osh-mega-promo:hover {
            translate: 0 -2px;
            box-shadow: 0 10px 24px rgba(20, 33, 61, .1);
        }

        html #header.osh .osh-mega-promo:hover .osh-icon {
            scale: 1.12;
        }
    }

    html #header.osh .osh-mega-promo:active {
        translate: 0 0;
        scale: .98;
    }

    /* ---------- header: mobile tab bar and sheets ---------- */

    html #header.osh .osh-tab {
        transition: color .15s ease, background-color .15s ease, scale .12s ease;
    }

    html #header.osh .osh-tab:active {
        scale: .94;
    }

    /* The sheet itself slides up (css/site-header.css); its content follows. */
    html #header.osh :is(.osh-mega-sheet, .osh-account):not([hidden]) > * {
        animation: wi-rise .32s var(--wi-ease-out) .06s both;
    }

    html #header.osh :is(.osh-mega-sheet, .osh-account):not([hidden]) > :nth-child(3) { animation-delay: .09s; }
    html #header.osh :is(.osh-mega-sheet, .osh-account):not([hidden]) > :nth-child(4) { animation-delay: .12s; }
    html #header.osh :is(.osh-mega-sheet, .osh-account):not([hidden]) > :nth-child(n+5) { animation-delay: .15s; }

    /* ---------- dialogs, dropdowns, accordions ---------- */

    dialog[open] {
        animation: wi-pop-in .22s var(--wi-ease-out);
    }

    dialog[open]::backdrop {
        animation: wi-fade .22s ease;
    }

    .select2-container--open .select2-dropdown {
        animation: wi-drop .16s var(--wi-ease-out);
    }

    details[open] > summary ~ * {
        animation: wi-drop .22s var(--wi-ease-out);
    }

    /* ---------- feedback: errors, done states ---------- */

    html .ore .ore-error:not([hidden]),
    html .wh-status.is-error,
    html .wh-status.is-hint,
    html .wh-status.is-done .wh-done {
        animation: wi-drop .2s var(--wi-ease-out);
    }

    html .ore .ore-input.is-invalid {
        animation: wi-shake .32s ease;
    }

    html .oty .oty-badge,
    html .ojl .ojl-ty-badge {
        animation: wi-pop-in .45s var(--wi-ease-spring) .1s both;
    }

    /* ---------- progress bars fill up from the left ---------- */

    html .emp-start-bar i,
    html .cb-personality-progress i,
    html .cb-talent-progress i {
        transform-origin: left center;
        animation: wi-bar-grow .8s var(--wi-ease-out) .15s both;
    }

    /* ---------- scroll reveal (js/motion.js) ---------- */

    .wi-reveal {
        opacity: 0;
        translate: 0 16px;
    }

    html .wi-reveal.is-in {
        opacity: 1;
        translate: 0 0;
        transition: opacity .5s ease, translate .6s var(--wi-ease-out);
        transition-delay: var(--wi-delay, 0s);
    }
}

@media print {
    .wi-reveal {
        opacity: 1 !important;
        translate: none !important;
    }
}
