/**
 * BambuUP motion layer.
 *
 * Everything is scoped to html.bambu-motion, which is only added (in <head>) when the
 * visitor has not asked for reduced motion. Animations use the individual `translate`
 * and `scale` properties so they never override the theme's own `transform` rules.
 */

@keyframes bambu-fade-up {
    from {
        opacity: 0;
        translate: 0 28px;
    }

    to {
        opacity: 1;
        translate: 0 0;
    }
}

@keyframes bambu-fade-up-small {
    from {
        opacity: 0;
        translate: 0 10px;
    }

    to {
        opacity: 1;
        translate: 0 0;
    }
}

@keyframes bambu-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes bambu-zoom-in {
    from {
        opacity: 0;
        scale: 0.96;
    }

    to {
        opacity: 1;
        scale: 1;
    }
}

@keyframes bambu-draw-x {
    from {
        scale: 0 1;
    }

    to {
        scale: 1 1;
    }
}

@keyframes bambu-draw-y {
    from {
        scale: 1 0;
    }

    to {
        scale: 1 1;
    }
}

.bambu-motion {
    --bambu-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Hero entrance: pure CSS so it plays on first paint and never waits for JS. */
.bambu-motion .bambu-page .innovation-hero-heading,
.bambu-motion .bambu-page .innovation-hero-description,
.bambu-motion .bambu-page .innovation-hero-actions,
.bambu-motion .bambu-page .hero-section .metric-item,
.bambu-motion .bambu-page .hero .breadcrumb,
.bambu-motion .bambu-page .hero .hero-title,
.bambu-motion .bambu-page .hero .hero-sub,
.bambu-motion .bambu-page .hero .hero-ctas {
    animation: bambu-fade-up 900ms var(--bambu-ease-out) both;
}

.bambu-motion .bambu-page .innovation-hero-heading,
.bambu-motion .bambu-page .hero .breadcrumb {
    animation-delay: 80ms;
}

.bambu-motion .bambu-page .innovation-hero-description,
.bambu-motion .bambu-page .hero .hero-title {
    animation-delay: 200ms;
}

.bambu-motion .bambu-page .innovation-hero-actions,
.bambu-motion .bambu-page .hero .hero-sub {
    animation-delay: 320ms;
}

.bambu-motion .bambu-page .hero .hero-ctas {
    animation-delay: 440ms;
}

.bambu-motion .bambu-page .hero-section .metric-item:nth-child(1) { animation-delay: 480ms; }
.bambu-motion .bambu-page .hero-section .metric-item:nth-child(2) { animation-delay: 560ms; }
.bambu-motion .bambu-page .hero-section .metric-item:nth-child(3) { animation-delay: 640ms; }
.bambu-motion .bambu-page .hero-section .metric-item:nth-child(4) { animation-delay: 720ms; }

/* Scroll reveal: classes are assigned by assets/js/animations.js. */
.bambu-motion .bambu-reveal {
    opacity: 0;
}

.bambu-motion .bambu-reveal.is-revealed {
    animation: bambu-fade-up 800ms var(--bambu-ease-out) var(--bambu-reveal-delay, 0ms) both;
}

.bambu-motion .bambu-reveal-fade.is-revealed {
    animation-name: bambu-fade-in;
}

.bambu-motion .bambu-reveal-zoom.is-revealed {
    animation-name: bambu-zoom-in;
}

/* Lines are drawn rather than faded, so they stay visible but collapsed. */
.bambu-motion .bambu-reveal-draw {
    opacity: 1;
    scale: 0 1;
    transform-origin: left center;
}

.bambu-motion .bambu-reveal-draw.is-revealed {
    animation: bambu-draw-x 1400ms var(--bambu-ease-out) var(--bambu-reveal-delay, 0ms) both;
}

@media (max-width: 767px) {
    .bambu-motion .bambu-reveal-draw {
        scale: 1 0;
        transform-origin: center top;
    }

    .bambu-motion .bambu-reveal-draw.is-revealed {
        animation-name: bambu-draw-y;
    }
}

/* Partner logos: endless marquee (track and clones are built by animations.js). */
@keyframes bambu-marquee {
    from {
        translate: 0 0;
    }

    to {
        translate: calc(-100% / var(--bambu-marquee-groups, 2)) 0;
    }
}

.bambu-motion .bambu-page .partners-row.is-marquee {
    display: block;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}

.bambu-motion .bambu-page .partners-track {
    display: flex;
    width: max-content;
    animation: bambu-marquee var(--bambu-marquee-duration, 30s) linear infinite;
}

.bambu-motion .bambu-page .partners-row.is-marquee:hover .partners-track,
.bambu-motion .bambu-page .partners-row.is-marquee:focus-within .partners-track {
    animation-play-state: paused;
}

.bambu-motion .bambu-page .partners-group {
    display: flex;
    flex: none;
    align-items: center;
    gap: clamp(48px, 7vw, 96px);
    padding-right: clamp(48px, 7vw, 96px);
}

.bambu-motion .bambu-page .partners-group .partner-name {
    flex: none;
    white-space: nowrap;
    transition: opacity 300ms ease, scale 300ms var(--bambu-ease-out);
}

.bambu-motion .bambu-page .partners-group .partner-name:is(:hover, :focus-visible) {
    opacity: 1;
    scale: 1.08;
}

/* Mega menu: stagger the links each time a panel opens. */
@media (min-width: 1200px) {
    .bambu-motion .bambu-page .site-header.is-mega-menu-open .mega-menu-panel.is-active :is(.mega-menu-intro, .mega-menu-innovation-heading, .mega-menu-links > *, .mega-menu-innovation-column, .mega-menu-feature) {
        animation: bambu-fade-up-small 420ms var(--bambu-ease-out) both;
    }

    .bambu-motion .bambu-page .mega-menu-panel.is-active :is(.mega-menu-links, .mega-menu-innovation-columns) > :nth-child(2) { animation-delay: 40ms; }
    .bambu-motion .bambu-page .mega-menu-panel.is-active :is(.mega-menu-links, .mega-menu-innovation-columns) > :nth-child(3) { animation-delay: 80ms; }
    .bambu-motion .bambu-page .mega-menu-panel.is-active :is(.mega-menu-links, .mega-menu-innovation-columns) > :nth-child(4) { animation-delay: 120ms; }
    .bambu-motion .bambu-page .mega-menu-panel.is-active :is(.mega-menu-links, .mega-menu-innovation-columns) > :nth-child(5) { animation-delay: 160ms; }
    .bambu-motion .bambu-page .mega-menu-panel.is-active :is(.mega-menu-links, .mega-menu-innovation-columns) > :nth-child(n+6) { animation-delay: 200ms; }
    .bambu-motion .bambu-page .mega-menu-panel.is-active .mega-menu-feature { animation-delay: 140ms; }
}

/* Hover effects only on devices with a real pointer, so taps never leave cards "stuck". */
@media (hover: hover) and (pointer: fine) {
    .bambu-motion .bambu-page :is(
        .audience-card-seeker,
        .audience-card-provider,
        .news-card,
        .service-card-primary,
        .service-card-secondary,
        .opportunity-card,
        .featured-challenge-card,
        .impact-side-card,
        .testimonials-section .card-grid > *,
        .about-feature-card,
        .about-perspectives-grid > article,
        .services-persona,
        .opp-inner .card,
        .challenge-card,
        .pricing-plan-card,
        .data-report-card,
        .community-news-card,
        .community-event-card,
        .startup-value-card,
        .startup-opportunity-card,
        .startup-feature-story,
        .leader-card,
        .iaas-insight-card
    ) {
        transition: translate 350ms var(--bambu-ease-out), box-shadow 350ms var(--bambu-ease-out);
    }

    .bambu-motion .bambu-page :is(
        .audience-card-seeker,
        .audience-card-provider,
        .news-card,
        .service-card-primary,
        .service-card-secondary,
        .opportunity-card,
        .featured-challenge-card,
        .impact-side-card,
        .testimonials-section .card-grid > *,
        .about-feature-card,
        .about-perspectives-grid > article,
        .services-persona,
        .opp-inner .card,
        .challenge-card,
        .pricing-plan-card,
        .data-report-card,
        .community-news-card,
        .community-event-card,
        .startup-value-card,
        .startup-opportunity-card,
        .startup-feature-story,
        .leader-card,
        .iaas-insight-card
    ):hover {
        translate: 0 -6px;
        box-shadow: 0 22px 44px -18px rgba(7, 17, 39, 0.35);
    }

    /* Image zoom inside cards that already clip their content. */
    .bambu-motion .bambu-page :is(
        .seeker-card-image,
        .provider-card-image,
        .news-card-image,
        .service-image-frame > div,
        .service-image-frame-secondary > div,
        .opportunity-image-wrapper > div:first-child,
        .challenge-feature-image,
        .vietnam-report-image-wrapper img,
        .card-img-wrap img,
        .data-report-card-image img,
        .community-event-image img,
        .iaas-insight-image img,
        .leader-image img
    ) {
        transition: scale 700ms var(--bambu-ease-out);
    }

    .bambu-motion .bambu-page :is(.audience-card-seeker:hover .seeker-card-image, .audience-card-provider:hover .provider-card-image),
    .bambu-motion .bambu-page .news-card:hover .news-card-image,
    .bambu-motion .bambu-page .service-card-primary:hover .service-image-frame > div,
    .bambu-motion .bambu-page .service-card-secondary:hover .service-image-frame-secondary > div,
    .bambu-motion .bambu-page .opportunity-card:hover .opportunity-image-wrapper > div:first-child,
    .bambu-motion .bambu-page .featured-challenge-card:hover .challenge-feature-image,
    .bambu-motion .bambu-page .featured-report:hover .vietnam-report-image-wrapper img,
    .bambu-motion .bambu-page .card:hover .card-img-wrap img,
    .bambu-motion .bambu-page .data-report-card:hover .data-report-card-image img,
    .bambu-motion .bambu-page .community-event-card:hover .community-event-image img,
    .bambu-motion .bambu-page .iaas-insight-card:hover .iaas-insight-image img,
    .bambu-motion .bambu-page .leader-card:hover .leader-image img {
        scale: 1.06;
    }

    /* Gradient call-to-action buttons. */
    .bambu-motion .bambu-page :is(.btn-grad-pill, .btn-outline-pill, .signup-button, .cta-contact-btn, .innovation-hero-action) {
        transition: translate 250ms var(--bambu-ease-out), filter 250ms ease, box-shadow 250ms ease, opacity 0.2s ease, background-color 0.2s ease;
    }

    .bambu-motion .bambu-page :is(.btn-grad-pill, .btn-outline-pill, .signup-button, .cta-contact-btn, .innovation-hero-action):hover {
        translate: 0 -2px;
        filter: brightness(1.08) saturate(1.1);
    }

    .bambu-motion .bambu-page :is(.btn-grad-pill, .signup-button, .innovation-hero-action-primary):hover {
        box-shadow: 0 14px 28px -10px rgba(59, 122, 181, 0.55);
    }

    /* Arrow nudges on text links. */
    .bambu-motion .bambu-page :is(.section-action-icon, .cta-contact-btn svg, .signup-arrow-icon, .innovation-hero-action img, .external-arrow-icon, .btn-arrow) {
        transition: translate 250ms var(--bambu-ease-out);
    }

    .bambu-motion .bambu-page .section-action-control:hover .section-action-icon,
    .bambu-motion .bambu-page .cta-contact-btn:hover svg,
    .bambu-motion .bambu-page .signup-button:hover .signup-arrow-icon {
        translate: 4px 0;
    }

    .bambu-motion .bambu-page :is(.innovation-hero-action, .btn-grad-pill, .btn-outline-pill):hover :is(img, .external-arrow-icon, .btn-arrow) {
        translate: 2px -2px;
    }
}
