/*
  Zambia Air Force Centre of Advanced Learning — motion.
  Entrance animations, scroll reveals, hover movement and decorative graphics.
  Everything sits inside "prefers-reduced-motion: no-preference", so visitors
  who ask their device for less motion get a still page. Scroll reveals are
  switched on by assets/js/custom.js (class "js-motion" on <html>), so the page
  is fully visible without JavaScript.
*/

/* Decorative layers are hidden unless motion is welcome */
.scroll-progress {
    display: none;
}

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

    /* ---------- Scroll progress bar ---------- */

    .scroll-progress {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 20;
        width: 100%;
        height: 3px;
        background: var(--cal-gold);
        transform: scaleX(0);
        transform-origin: left center;
        pointer-events: none;
    }

    /* ---------- Hero ---------- */

    /* slow zoom on the photo that is showing */
    .main-banner .carousel-item.active {
        animation: cal-kenburns 9s ease-out both;
    }

    @keyframes cal-kenburns {
        from { transform: scale(1); }
        to   { transform: scale(1.12); }
    }

    /* headline arrives line by line */
    .main-banner .caption > * {
        animation: cal-rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    }

    .main-banner .caption > h6          { animation-delay: 0.25s; }
    .main-banner .caption > h2          { animation-delay: 0.45s; }
    .main-banner .caption > .motto      { animation-delay: 0.7s; }
    .main-banner .caption > .main-button { animation-delay: 0.9s; }

    @keyframes cal-rise {
        from { opacity: 0; transform: translateY(34px); }
        to   { opacity: 1; transform: none; }
    }

    /* the feature boxes slide up after the headline */
    .features .features-post {
        animation: cal-rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
        animation-delay: 1.1s;
    }

    .features .second-features { animation-delay: 1.25s; }
    .features .third-features  { animation-delay: 1.4s; }

    .features-content h4 i {
        transition: transform 0.4s ease;
    }

    .features-content:hover h4 i {
        transform: translateY(-4px) rotate(-8deg);
    }

    /* ---------- Scroll reveals (classes added by custom.js) ---------- */

    .reveal {
        opacity: 0;
        transform: translateY(32px);
        transition:
            opacity 0.8s ease,
            transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
        transition-delay: var(--reveal-delay, 0s);
        will-change: opacity, transform;
    }

    .reveal.from-left  { transform: translateX(-48px); }
    .reveal.from-right { transform: translateX(48px); }
    .reveal.zoom       { transform: scale(0.92); }

    /* gallery photos swing in like doors, alternating sides */
    .reveal.flip-left  { transform: perspective(900px) rotateY(-80deg); transform-origin: left center; }
    .reveal.flip-right { transform: perspective(900px) rotateY(80deg);  transform-origin: right center; }

    /* returning while scrolling back up: drop in from above */
    .reveal.from-above { transform: translateY(-44px) scale(0.94); }

    .reveal.is-visible {
        opacity: 1;
        transform: none;
    }

    /* sideways entrances must not give the page a horizontal scrollbar */
    .js-motion section.section {
        overflow-x: clip;
    }

    /* ---------- Pictures that arrive in pieces and assemble ----------
       custom.js cuts the picture into tiles (copies of the <img>, each
       clipped to one tile), scatters them, and lets them fly into place. */

    .assemble-wait {
        opacity: 0;
    }

    .assemble-host {
        position: relative;
    }

    .assemble-pieces {
        position: absolute;
        z-index: 2;
        pointer-events: none;
    }

    .assemble-pieces img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        margin: 0;
        opacity: 0;
        animation: none !important;
        will-change: transform, opacity;
    }

    /* the line above each section heading draws itself */
    .js-motion .section-heading h2:before {
        height: 0;
        transition: height 0.9s ease 0.2s;
    }

    .js-motion .section-heading.in-view h2:before {
        height: 100px;
    }

    /* ---------- Vision and mission typed out (custom.js) ----------
       The untyped remainder stays in the page, invisible, so the box keeps
       its final size and nothing jumps while the text appears. */

    .typed-rest {
        visibility: hidden;
    }

    .typed-caret {
        display: none;
        width: 0;
        height: 1em;
        margin: 0 2px;
        vertical-align: -0.12em;
        border-left: 3px solid var(--cal-gold);
        animation: cal-caret 0.75s steps(1) infinite;
    }

    .typing .typed-caret {
        display: inline-block;
    }

    @keyframes cal-caret {
        50% { opacity: 0; }
    }

    /* ---------- Decorative graphics behind the About section ---------- */

    section.why-us {
        position: relative;
        overflow: hidden;
    }

    section.why-us > .container {
        position: relative;
        z-index: 1;
    }

    section.why-us::before,
    section.why-us::after {
        content: '';
        position: absolute;
        pointer-events: none;
    }

    /* a slowly turning dashed ring */
    section.why-us::before {
        top: 90px;
        right: -110px;
        width: 340px;
        height: 340px;
        border: 2px dashed rgba(245, 164, 37, 0.45);
        border-radius: 50%;
        animation: cal-spin 60s linear infinite;
    }

    /* a drifting field of dots */
    section.why-us::after {
        left: -40px;
        bottom: 120px;
        width: 220px;
        height: 220px;
        background-image: radial-gradient(rgba(23, 34, 56, 0.16) 2px, transparent 2.5px);
        background-size: 22px 22px;
        animation: cal-drift 14s ease-in-out infinite alternate;
    }

    @keyframes cal-spin {
        to { transform: rotate(360deg); }
    }

    @keyframes cal-drift {
        from { transform: translate(0, 0); }
        to   { transform: translate(26px, -34px); }
    }

    /* ---------- Admissions ---------- */

    @media (min-width: 992px) and (hover: hover) {
        /* the photo stays put while the page scrolls over it */
        section.coming-soon {
            background-attachment: fixed;
        }
    }

    section.coming-soon .continer .counter .seconds .value {
        animation: cal-tick 1s ease-in-out infinite;
    }

    @keyframes cal-tick {
        0%, 100% { transform: scale(1); }
        8%       { transform: scale(1.12); }
        20%      { transform: scale(1); }
    }

    /* ---------- Staff page ---------- */

    .page-banner-text > * {
        animation: cal-rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    }

    .page-banner-text > h1 { animation-delay: 0.2s; }
    .page-banner-text > p  { animation-delay: 0.45s; }

    .staff-card {
        transition: transform 0.35s ease, box-shadow 0.35s ease;
    }

    /* The tree builds itself each time a level scrolls into view, in either
       direction: the trunk grows down, a branch bar opens outwards, and the
       cards arrive — from below when scrolling down, from above when
       scrolling up. Scrolled away, a level resets so it can play again. */
    .staff-card.reveal {
        transition:
            opacity 0.7s ease,
            transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
        transition-delay: var(--reveal-delay, 0s);
    }

    .staff-card.reveal.zoom {
        transform: translateY(44px) scale(0.9);
    }

    .js-motion .staff-tier:not(.is-top)::before {
        transform: scaleY(0);
        transform-origin: center top;
        transition: transform 0.5s ease;
    }

    .js-motion .staff-tier.in-view::before {
        transform: scaleY(1);
    }

    .js-motion .staff-bar {
        transform: translateX(-50%) scaleX(0);
        transition: transform 0.5s ease 0.3s;
    }

    .js-motion .staff-tier.in-view .staff-bar {
        transform: translateX(-50%) scaleX(1);
    }

    .js-motion .staff-bar-bottom {
        transition-delay: 0.7s;
    }

    /* the photo ring pulses once as its card lands */
    .staff-card.is-visible .staff-photo {
        animation: cal-ring 0.9s ease 0.35s both;
    }

    @keyframes cal-ring {
        0%   { box-shadow: 0 0 0 0 rgba(245, 164, 37, 0.55); }
        100% { box-shadow: 0 0 0 14px rgba(245, 164, 37, 0); }
    }

    .staff-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 14px 28px rgba(23, 34, 56, 0.15);
    }

    .staff-photo img {
        transition: transform 0.6s ease;
    }

    .staff-card:hover .staff-photo img {
        transform: scale(1.08);
    }

    /* ---------- News cards ---------- */

    .news-card {
        transition: transform 0.35s ease, box-shadow 0.35s ease;
    }

    .news-card:hover {
        transform: translateY(-6px);
        box-shadow: 0 14px 28px rgba(23, 34, 56, 0.15);
    }

    .news-card-media img {
        transition: transform 0.8s ease;
    }

    .news-card:hover .news-card-media img {
        transform: scale(1.06);
    }

    .news-more i {
        transition: transform 0.25s ease;
    }

    .news-more:hover i {
        transform: translateX(5px);
    }

    /* ---------- Hover movement ---------- */

    section.courses .owl-carousel .owl-stage-outer {
        padding-top: 12px;
        margin-top: -12px;
    }

    section.courses .item {
        transition: transform 0.35s ease, box-shadow 0.35s ease;
    }

    section.courses .item:hover {
        transform: translateY(-8px);
        box-shadow: 0 14px 28px rgba(23, 34, 56, 0.16);
    }

    section.courses .programme-top i {
        transition: transform 0.45s ease;
    }

    section.courses .item:hover .programme-top i {
        transform: translateY(-5px) rotate(-10deg) scale(1.1);
    }

    section.courses .item .down-content a i,
    .main-button a,
    section.coming-soon .action-panel .button,
    section.contact form button {
        transition: transform 0.25s ease, background-color 0.3s, color 0.3s, border-color 0.3s;
    }

    section.courses .item .down-content a:hover i {
        transform: translateX(5px);
    }

    .main-button a:hover,
    section.coming-soon .action-panel .button:hover,
    section.contact form button:hover {
        transform: translateY(-3px);
    }

    .affiliation {
        transition: transform 0.35s ease, box-shadow 0.35s ease;
    }

    .affiliation:hover {
        transform: translateY(-6px);
        box-shadow: 0 12px 24px rgba(23, 34, 56, 0.12);
    }

    .video-item.portrait figure {
        overflow: hidden;
    }

    /* let the pieces fly in from outside the frame */
    .video-item.portrait figure.assembling {
        overflow: visible;
    }

    .video-item.portrait figure > img {
        transition: transform 1.2s ease;
    }

    .video-item.portrait:hover figure > img {
        transform: scale(1.05);
    }

    .rank-stars i {
        animation: cal-twinkle 3.6s ease-in-out infinite;
    }

    .rank-stars i:nth-child(2) { animation-delay: 0.4s; }
    .rank-stars i:nth-child(3) { animation-delay: 0.8s; }

    @keyframes cal-twinkle {
        0%, 70%, 100% { transform: scale(1); opacity: 1; }
        80%           { transform: scale(1.3); opacity: 0.75; }
    }

}
