/* ==========================================================
   Chiedza – animation layer
   ----------------------------------------------------------
   - One set of motion tokens (easing + durations) for the whole site.
   - Uses opacity, filter, clip-path and the individual `translate` /
     `scale` / `rotate` properties so it composes with the site's own
     `transform` styles instead of clobbering them.
   - Everything hidden-until-animated is gated behind `.cz-anim`
     (set by an inline script in <head>) and by classes that JS adds,
     so content is fully visible if JavaScript does not run.
   - prefers-reduced-motion: no motion, everything visible.
   ========================================================== */

:root {
    --cz-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --cz-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --cz-ease-back: cubic-bezier(0.34, 1.45, 0.64, 1);
    --cz-ease: var(--cz-ease-out);
    --cz-fast: 0.25s;
    --cz-base: 0.45s;
    --cz-slow: 0.8s;
    --cz-gold: #f4b942;
}

/* ==========================================================
   1. Page entrance / exit
   ========================================================== */
.cz-anim body {
    animation: czFade 0.45s ease-out backwards;
}

.cz-anim body.cz-leaving {
    opacity: 0;
    transition: opacity 0.22s ease-in;
}

@keyframes czFade {
    from { opacity: 0; }
}

.cz-anim .navbar {
    animation: czNavIn 0.7s var(--cz-ease-out) backwards;
}

@keyframes czNavIn {
    from { translate: 0 -14px; opacity: 0; }
}

@keyframes czFadeDown {
    from { translate: 0 -8px; opacity: 0; }
}

@keyframes czRise {
    from { translate: 0 14px; opacity: 0; }
}

/* ==========================================================
   2. Navigation
   ========================================================== */
@media (min-width: 969px) {
    /* Links settle in one after another on load */
    .cz-anim .nav-links > li {
        animation: czFadeDown 0.6s var(--cz-ease-out) both;
        animation-delay: calc(0.12s + var(--cz-i, 0) * 0.045s);
    }

    /* Hover underline that grows from the centre (active links keep theirs) */
    .cz-anim .nav-links > li:not(.active) > a::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: 2px;
        border-radius: 2px;
        background: #ffbe00;
        scale: 0 1;
        transition: scale 0.4s var(--cz-ease-out);
        pointer-events: none;
    }

    .cz-anim .nav-links > li:not(.active) > a:hover::after {
        scale: 1 1;
    }

    /* Dropdown: grows out of the toggle with a soft scale, items cascade */
    .cz-anim .dropdown-menu {
        transform-origin: 50% 0;
        scale: 0.96;
        transition:
            opacity 0.28s var(--cz-ease-out),
            transform 0.45s var(--cz-ease-out),
            scale 0.45s var(--cz-ease-out),
            visibility 0.28s;
    }

    .cz-anim .dropdown:hover .dropdown-menu {
        scale: 1;
    }

    .cz-anim .dropdown-menu > li {
        opacity: 0;
        translate: 0 -6px;
        transition: opacity 0.25s ease, translate 0.4s var(--cz-ease-out);
    }

    .cz-anim .dropdown:hover .dropdown-menu > li {
        opacity: 1;
        translate: 0 0;
    }

    .cz-anim .dropdown:hover .dropdown-menu > li:nth-child(2) { transition-delay: 0.04s; }
    .cz-anim .dropdown:hover .dropdown-menu > li:nth-child(3) { transition-delay: 0.08s; }
    .cz-anim .dropdown:hover .dropdown-menu > li:nth-child(4) { transition-delay: 0.12s; }

    .cz-anim .dropdown-toggle i {
        transition: transform 0.45s var(--cz-ease-out);
    }
}

@media (max-width: 968px) {
    /* Mobile menu: fades/slides in and out (display is transitioned discretely) */
    .cz-anim .nav-links {
        animation: none;
        transition:
            opacity 0.3s var(--cz-ease-out),
            translate 0.4s var(--cz-ease-out),
            display 0.3s allow-discrete;
    }

    .cz-anim .nav-links:not(.show) {
        opacity: 0;
        translate: 0 -10px;
    }

    .cz-anim .nav-links.show {
        opacity: 1;
        translate: 0 0;
    }

    @starting-style {
        .cz-anim .nav-links.show {
            opacity: 0;
            translate: 0 -10px;
        }
    }

    .cz-anim .nav-links.show > li {
        animation: czFadeDown 0.45s var(--cz-ease-out) both;
        animation-delay: calc(0.04s + var(--cz-i, 0) * 0.035s);
    }

    .cz-anim .dropdown.open .dropdown-menu {
        animation: czFadeDown 0.35s var(--cz-ease-out);
    }

    .cz-anim .dropdown-toggle i {
        transition: transform 0.4s var(--cz-ease-out);
    }

    /* Burger <-> close icon swap gets a little turn */
    .cz-anim .menu-toggle i.fa-times { animation: czIconTurnA 0.35s var(--cz-ease-out); }
    .cz-anim .menu-toggle i.fa-bars { animation: czIconTurnB 0.35s var(--cz-ease-out); }
}

@keyframes czIconTurnA {
    from { rotate: -90deg; opacity: 0; scale: 0.6; }
}

@keyframes czIconTurnB {
    from { rotate: 90deg; opacity: 0; scale: 0.6; }
}

/* ==========================================================
   3. Scroll progress bar
   ========================================================== */
.cz-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: linear-gradient(90deg, var(--cz-gold), #ffd77a);
    transform-origin: 0 50%;
    transform: scaleX(0);
    z-index: 2000;
    pointer-events: none;
    will-change: transform;
}

/* ==========================================================
   4. The original site's `.animate-on-scroll`
   ========================================================== */
/* Never hide content if the animation layer is not running. */
html:not(.cz-anim) .animate-on-scroll {
    opacity: 1;
    transform: none;
}

.cz-anim .animate-on-scroll {
    transition:
        opacity 0.9s var(--cz-ease-out),
        transform 0.9s var(--cz-ease-out),
        box-shadow 0.45s ease,
        background-color 0.45s ease,
        border-color 0.45s ease;
}

/* ==========================================================
   5. Scroll reveals (classes added by animations.js)
   Only the *start* state is styled; the end state is the element's
   own styling, so nothing is overridden once it has arrived.
   ========================================================== */
.cz-anim .cz-reveal {
    transition:
        opacity 0.8s var(--cz-ease-out),
        translate 0.95s var(--cz-ease-out),
        scale 0.95s var(--cz-ease-out),
        filter 0.8s var(--cz-ease-out),
        clip-path 1s var(--cz-ease-out);
    transition-delay: var(--cz-delay, 0s);
}

.cz-anim .cz-reveal:not(.cz-in) {
    opacity: 0;
    translate: 0 28px;
}

.cz-anim .cz-reveal[data-cz="left"]:not(.cz-in) { translate: -40px 0; }
.cz-anim .cz-reveal[data-cz="right"]:not(.cz-in) { translate: 40px 0; }
.cz-anim .cz-reveal[data-cz="fade"]:not(.cz-in) { translate: 0 0; }

.cz-anim .cz-reveal[data-cz="zoom"]:not(.cz-in) {
    translate: 0 16px;
    scale: 0.96;
    filter: blur(4px);
}

/* Headings rise out of a mask */
.cz-anim .cz-reveal[data-cz="heading"] {
    clip-path: inset(-20% -10% -20% -10%);
}

.cz-anim .cz-reveal[data-cz="heading"]:not(.cz-in) {
    translate: 0 0.45em;
    clip-path: inset(-20% -10% 100% -10%);
}

/* Small decorative lines under titles draw outwards */
.cz-anim .cz-reveal[data-cz="line"] {
    transition: opacity 0.4s ease, scale 1s var(--cz-ease-out);
    transition-delay: calc(var(--cz-delay, 0s) + 0.15s);
}

.cz-anim .cz-reveal[data-cz="line"]:not(.cz-in) {
    translate: 0 0;
    scale: 0 1;
}

/* Images inside clipped frames: slow settle as they appear */
.cz-anim .cz-img {
    transition: scale 1.6s var(--cz-ease-out);
}

.cz-anim .cz-img:not(.cz-in) {
    scale: 1.1;
}

/* ==========================================================
   6. Heroes
   ========================================================== */
/* Page heroes: a separate background layer (added by JS) gets a
   Ken Burns settle + scroll parallax; the section keeps its own
   background underneath as a fallback. */
.cz-anim .page-hero.cz-hero {
    isolation: isolate;
}

.cz-hero-bg {
    position: absolute;
    inset: -8% 0 -8% 0;
    z-index: -1;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    pointer-events: none;
    will-change: transform;
    animation: czKenBurns 2.4s var(--cz-ease-out) both;
}

@keyframes czKenBurns {
    from { scale: 1.14; filter: blur(3px) brightness(0.85); }
    to { scale: 1.02; filter: none; }
}

.cz-hero-bg {
    scale: 1.02;
}

/* Hero copy: staggered rise; the title is revealed through a mask */
.cz-anim .page-hero .hero-content > * {
    animation: czHeroRise 1s var(--cz-ease-out) both;
}

.cz-anim .page-hero .hero-content > :nth-child(1) { animation-delay: 0.1s; }
.cz-anim .page-hero .hero-content > :nth-child(2) { animation-delay: 0.22s; }
.cz-anim .page-hero .hero-content > :nth-child(3) { animation-delay: 0.34s; }
.cz-anim .page-hero .hero-content > :nth-child(n+4) { animation-delay: 0.44s; }

.cz-anim .page-hero .hero-content > .hero-badge {
    animation-name: czBadgePop;
    animation-duration: 0.8s;
}

.cz-anim .page-hero .hero-content > .hero-title {
    animation-name: czMaskRise;
    animation-duration: 1.1s;
}

@keyframes czHeroRise {
    from { opacity: 0; translate: 0 26px; }
}

@keyframes czBadgePop {
    from { opacity: 0; scale: 0.8; translate: 0 10px; }
}

@keyframes czMaskRise {
    from { opacity: 0; translate: 0 0.5em; clip-path: inset(-20% -10% 100% -10%); }
    to { opacity: 1; translate: 0 0; clip-path: inset(-20% -10% -20% -10%); }
}

/* Scroll-linked hero copy (values set by JS) */
/* Own stacking layer above the hero overlay (opacity/translate create one) */
.cz-anim .page-hero > .cz-hero-copy {
    position: relative;
    z-index: 2;
    will-change: translate, opacity;
}

/* ==========================================================
   7. Cards & hover micro-interactions
   ========================================================== */
.cz-anim .glass-card:not(.cz-reveal):not(.animate-on-scroll) {
    transition-timing-function: var(--cz-ease-out);
    transition-duration: 0.45s;
}

/* Shine sweep across buttons on hover */
.cz-anim .cz-shine {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.cz-anim .cz-shine::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
    translate: -120% 0;
    transition: translate 0.8s var(--cz-ease-out);
    pointer-events: none;
    z-index: 1;
}

.cz-anim .cz-shine:hover::after {
    translate: 120% 0;
}

/* Tactile press feedback on buttons */
.cz-anim :is(a, button)[class*="btn"]:active,
.cz-anim .submit-btn:active,
.cz-anim .newsletter-btn:active {
    scale: 0.97;
}

/* Footer social icons */
.cz-anim .site-footer a i {
    transition: scale 0.35s var(--cz-ease-back), rotate 0.35s var(--cz-ease-back);
}

.cz-anim .site-footer a:hover i {
    scale: 1.18;
    rotate: -8deg;
}

/* Partner marquee: soft edges + gentle lift on hover */
.cz-anim .airlines-track {
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}

.cz-anim .airlines-slide img {
    transition: filter 0.3s ease, opacity 0.3s ease, scale 0.4s var(--cz-ease-out);
}

.cz-anim .airlines-slide img:hover {
    scale: 1.08;
}

/* ==========================================================
   8. Home hero slider (parallax values set by JS)
   ========================================================== */
.cz-anim .hero-slider .slide-bg {
    will-change: transform;
}

/* Previous slide's copy drifts up and out before the crossfade */
.cz-anim .slide.exit .slide-content > * {
    opacity: 0;
    translate: 0 -18px;
    filter: blur(4px);
    transition: opacity 0.6s ease, translate 0.7s var(--cz-ease-out), filter 0.6s ease;
}

/* ==========================================================
   9. Pillars circle
   ========================================================== */
.cz-anim .pillars-circle.cz-circle-wait :is(path[data-pillar], .segment-label-text, .center-circle, .center-text, .rotating-arrows) {
    opacity: 0;
}

.cz-anim .pillars-circle .circle-svg :is(path[data-pillar], .segment-label-text, .center-circle, .center-text) {
    transform-origin: 350px 350px;
}

.cz-anim .pillars-circle.cz-circle-in path[data-pillar] {
    animation: czSegIn 1.1s var(--cz-ease-out) backwards;
}

.cz-anim .pillars-circle.cz-circle-in path[data-pillar="retention"] { animation-delay: 0.09s; }
.cz-anim .pillars-circle.cz-circle-in path[data-pillar="completion"] { animation-delay: 0.18s; }
.cz-anim .pillars-circle.cz-circle-in path[data-pillar="employability"] { animation-delay: 0.27s; }

.cz-anim .pillars-circle.cz-circle-in :is(.center-circle, .center-text) {
    animation: czCenterPop 0.8s var(--cz-ease-back) 0.25s backwards;
}

.cz-anim .pillars-circle.cz-circle-in .segment-label-text {
    animation: czFade 0.6s ease 0.55s backwards;
}

.cz-anim .pillars-circle.cz-circle-in .rotating-arrows {
    animation: rotateArrows 20s linear infinite, czFade 0.8s ease 0.6s backwards;
}

@keyframes czSegIn {
    from { opacity: 0; scale: 0.55; rotate: -40deg; }
}

@keyframes czCenterPop {
    from { opacity: 0; scale: 0.4; }
}

/* Hovered / active segment eases outwards from the centre, its label follows */
.cz-anim .circle-svg path[data-pillar="access"]:is(:hover, .active),
.cz-anim .circle-svg:has(path[data-pillar="access"]:is(:hover, .active)) .segment-label-text[data-pillar="access"] { translate: -9px -9px; }
.cz-anim .circle-svg path[data-pillar="retention"]:is(:hover, .active),
.cz-anim .circle-svg:has(path[data-pillar="retention"]:is(:hover, .active)) .segment-label-text[data-pillar="retention"] { translate: 9px -9px; }
.cz-anim .circle-svg path[data-pillar="completion"]:is(:hover, .active),
.cz-anim .circle-svg:has(path[data-pillar="completion"]:is(:hover, .active)) .segment-label-text[data-pillar="completion"] { translate: 9px 9px; }
.cz-anim .circle-svg path[data-pillar="employability"]:is(:hover, .active),
.cz-anim .circle-svg:has(path[data-pillar="employability"]:is(:hover, .active)) .segment-label-text[data-pillar="employability"] { translate: -9px 9px; }

.cz-anim .pillar-description-item {
    transition:
        opacity 0.45s var(--cz-ease-out),
        transform 0.5s var(--cz-ease-out),
        background-color 0.35s ease,
        border-color 0.35s ease;
}

/* ==========================================================
   10. Impact page: stat batches cascade in
   ========================================================== */
.cz-anim .stats-batch {
    transition: opacity 0.6s var(--cz-ease-out), transform 0.7s var(--cz-ease-out);
}

.cz-anim .stats-batch .impact-stat-card {
    transition:
        opacity 0.5s var(--cz-ease-out),
        translate 0.7s var(--cz-ease-out),
        transform 0.45s var(--cz-ease-out),
        box-shadow 0.45s ease;
}

.cz-anim .stats-batch:not(.active) .impact-stat-card {
    opacity: 0;
    translate: 0 18px;
}

.cz-anim .stats-batch.active .impact-stat-card:nth-child(2) { transition-delay: 0.08s, 0.08s, 0s, 0s; }
.cz-anim .stats-batch.active .impact-stat-card:nth-child(3) { transition-delay: 0.16s, 0.16s, 0s, 0s; }

.cz-anim .batch-dot {
    transition: width 0.45s var(--cz-ease-out), background-color 0.3s ease, border-radius 0.45s var(--cz-ease-out);
}

/* Count-up numbers keep a steady width while counting */
.cz-counting {
    font-variant-numeric: tabular-nums;
}

/* ==========================================================
   11. Expanding text (priorities "Read more")
   ========================================================== */
@supports (interpolate-size: allow-keywords) {
    .cz-anim .priority-long-description {
        interpolate-size: allow-keywords;
        max-height: none;
        height: 0;
        transition:
            height 0.55s var(--cz-ease-out),
            opacity 0.4s ease,
            margin-top 0.55s var(--cz-ease-out);
    }

    .cz-anim .priority-long-description.expanded {
        height: auto;
        max-height: none;
    }
}

.cz-anim .priority-long-description p {
    transition: translate 0.6s var(--cz-ease-out);
}

.cz-anim .priority-long-description:not(.expanded) p {
    translate: 0 -10px;
}

.cz-anim .priority-expand-btn i,
.cz-anim .read-more-btn i {
    transition: transform 0.45s var(--cz-ease-out);
}

/* ==========================================================
   12. Lightboxes (home mini-gallery + gallery page)
   Fade in/out (display is transitioned discretely), image scales in.
   ========================================================== */
.cz-anim .lightbox-modal {
    opacity: 0;
    transition: opacity 0.35s var(--cz-ease-out), display 0.35s allow-discrete;
}

.cz-anim .lightbox-modal.active {
    opacity: 1;
}

@starting-style {
    .cz-anim .lightbox-modal.active {
        opacity: 0;
    }
}

.cz-anim .lightbox-modal :is(.lightbox-content-wrapper, .lightbox-content) {
    transition: scale 0.35s var(--cz-ease-out), opacity 0.3s ease;
}

.cz-anim .lightbox-modal.active :is(.lightbox-content-wrapper, .lightbox-content) {
    animation: czLightboxIn 0.55s var(--cz-ease-out) backwards;
}

.cz-anim .lightbox-modal:not(.active) :is(.lightbox-content-wrapper, .lightbox-content) {
    scale: 0.95;
    opacity: 0;
}

.cz-anim .lightbox-modal.active .lightbox-caption {
    animation: czRise 0.6s var(--cz-ease-out) 0.15s backwards;
}

@keyframes czLightboxIn {
    from { opacity: 0; scale: 0.9; filter: blur(6px); }
}

.cz-anim :is(.lightbox-close, .lightbox-prev, .lightbox-next) {
    transition: color 0.3s ease, background-color 0.3s ease, scale 0.35s var(--cz-ease-back);
}

.cz-anim :is(.lightbox-close, .lightbox-prev, .lightbox-next):hover {
    scale: 1.1;
}

/* ==========================================================
   13. Forms & feedback
   ========================================================== */
.cz-anim :is(.form-group, .newsletter-input-group) :is(input, textarea, select) {
    transition: border-color 0.3s ease, box-shadow 0.35s var(--cz-ease-out), background-color 0.3s ease;
}

.cz-anim :is(.form-feedback, .newsletter-message):is(.success, .error) {
    animation: czRise 0.5s var(--cz-ease-out) both;
}

.cz-anim :is(.form-feedback, .newsletter-message).error {
    animation: czRise 0.5s var(--cz-ease-out) both, czNudge 0.45s ease 0.15s;
}

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

/* Submit buttons breathe while the request is in flight */
.cz-anim form [type="submit"]:disabled {
    cursor: progress;
    animation: czBusy 0.9s ease-in-out infinite alternate;
}

@keyframes czBusy {
    to { opacity: 0.65; }
}

/* Donate page "Copied" toast */
.cz-anim .copy-toast {
    translate: 0 16px;
    scale: 0.95;
    transition: opacity 0.3s ease, translate 0.5s var(--cz-ease-back), scale 0.5s var(--cz-ease-back);
}

.cz-anim .copy-toast.show {
    translate: 0 0;
    scale: 1;
}

/* ==========================================================
   14. Reduced motion: no movement, everything visible
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
    .cz-anim *,
    .cz-anim *::before,
    .cz-anim *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
        scroll-behavior: auto !important;
    }

    .cz-anim .animate-on-scroll,
    .cz-anim .cz-reveal,
    .cz-anim .cz-img,
    .cz-anim .stats-batch .impact-stat-card {
        opacity: 1 !important;
        transform: none !important;
        translate: none !important;
        scale: none !important;
        filter: none !important;
        clip-path: none !important;
    }

    .cz-progress {
        display: none;
    }
}
