/**
 * PathwayAI Pro — Reference motion layer (99designs PYTIA spec)
 * ADDITIVE ONLY — transform + opacity. Requires html.pathway-ref-motion.
 * Does not override Learning World 3D motion.
 */

:root {
    --ref-ease: cubic-bezier(0.16, 1, 0.3, 1);
    --ref-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ref-dur-hero: 0.82s;
    --ref-dur-slide: 0.85s;
    --ref-dur-fast: 0.22s;
    --ref-ring-outer: 48s;
    --ref-ring-inner: 36s;
    --ref-orb-spin: 28s;
}

/* ── Background segmented rings (homepage ambient) ── */
@media (prefers-reduced-motion: no-preference) {
    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-public-home.home-cinematic .home-ambient::before,
    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-public-home.home-cinematic .home-ambient::after {
        content: "";
        position: absolute;
        left: var(--home-shade-x-px, 50%);
        top: var(--home-shade-y-px, 50%);
        border-radius: 50%;
        pointer-events: none;
        z-index: 2;
        opacity: 0.42;
        border: 3px dashed transparent;
        mask: radial-gradient(circle, transparent 58%, #000 59%, #000 68%, transparent 69%);
        -webkit-mask: radial-gradient(circle, transparent 58%, #000 59%, #000 68%, transparent 69%);
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-public-home.home-cinematic .home-ambient::before {
        /* Size rings to content column width so they stay equal L/R on the divs */
        width: min(var(--home-content-width, 92vw), 920px);
        height: min(var(--home-content-width, 92vw), 920px);
        margin: calc(min(var(--home-content-width, 92vw), 920px) / -2) 0 0 calc(min(var(--home-content-width, 92vw), 920px) / -2);
        border-color: rgba(168, 85, 247, 0.55);
        border-top-color: rgba(56, 189, 248, 0.65);
        border-right-color: rgba(168, 85, 247, 0.35);
        animation: refRingOuter var(--ref-ring-outer) linear infinite;
        will-change: transform;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-public-home.home-cinematic .home-ambient::after {
        width: min(calc(var(--home-content-width, 72vw) * 0.78), 680px);
        height: min(calc(var(--home-content-width, 72vw) * 0.78), 680px);
        margin: calc(min(calc(var(--home-content-width, 72vw) * 0.78), 680px) / -2) 0 0 calc(min(calc(var(--home-content-width, 72vw) * 0.78), 680px) / -2);
        border-color: rgba(56, 189, 248, 0.5);
        border-bottom-color: rgba(168, 85, 247, 0.45);
        animation: refRingInner var(--ref-ring-inner) linear infinite reverse;
        will-change: transform;
    }
}

@keyframes refRingOuter {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes refRingInner {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ── Hero entrance sequence (reference stagger) ── */
@media (prefers-reduced-motion: no-preference) {
    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-enter.page-public-home.home-cinematic .navbar {
        animation: refNavIn var(--ref-dur-hero) var(--ref-ease) both;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-enter.page-public-home.home-cinematic .hero.hero--winning h1.home-kinetic-title {
        animation: refHeroTextIn var(--ref-dur-hero) var(--ref-ease) 0.12s both;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-enter.page-public-home.home-cinematic .hero.hero--winning .subtitle.home-kinetic-sub {
        animation: refHeroTextIn var(--ref-dur-hero) var(--ref-ease) 0.24s both;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-enter.page-public-home.home-cinematic .hero.hero--winning .hero-actions,
    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-enter.page-public-home.home-cinematic .hero.hero--winning .hero-stats,
    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-enter.page-public-home.home-cinematic .hero.hero--winning .cta-row,
    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-enter.page-public-home.home-cinematic .hero.hero--winning .stats {
        animation: refHeroTextIn var(--ref-dur-hero) var(--ref-ease) 0.36s both;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-enter.page-public-home.home-cinematic .hero.hero--winning .meta {
        animation: refHeroTextIn var(--ref-dur-hero) var(--ref-ease) 0.3s both;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-enter.page-public-home.home-cinematic .hero-badge {
        animation: refFloatBob 4.5s ease-in-out infinite;
    }
}

@keyframes refNavIn {
    from {
        opacity: 0;
        transform: translate3d(0, -12px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes refHeroTextIn {
    from {
        opacity: 0;
        transform: translate3d(28px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes refFloatBob {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50% { transform: translate3d(0, -4px, 0); }
}

/* ── Override premium motion timings to match reference ── */
@media (prefers-reduced-motion: no-preference) {
    html.pathway-ref-motion.pathway-premium-motion:not(.pathway-reduced-motion) .pm-section-in {
        animation: refSectionIn 0.78s var(--ref-ease) both;
    }

    html.pathway-ref-motion.pathway-premium-motion:not(.pathway-reduced-motion) .pm-text-in {
        animation: refHeroTextIn 0.78s var(--ref-ease) both;
    }

    html.pathway-ref-motion.pathway-premium-motion:not(.pathway-reduced-motion) .reveal-on-load,
    html.pathway-ref-motion:not(.pathway-reduced-motion) .reveal-on-load,
    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-os-shell:not(.pathway-auth-page) .card.pm-section-in,
    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-os-shell:not(.pathway-auth-page) .card.ref-section-in {
        animation: refSectionIn 0.78s var(--ref-ease) both !important;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-enter.page-os-shell:not(.pathway-auth-page):not(.learning-world-page) .os-page-header__title {
        animation: refHeroTextIn 0.78s var(--ref-ease) 0.08s both;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-enter.page-os-shell:not(.pathway-auth-page):not(.learning-world-page) .os-page-header__kicker {
        animation: refHeroTextIn 0.78s var(--ref-ease) both;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) body.page-enter.page-os-shell:not(.pathway-auth-page):not(.learning-world-page) .os-page-lead {
        animation: refHeroTextIn 0.78s var(--ref-ease) 0.12s both;
    }
}

@keyframes refSectionIn {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes refCardIn {
    from {
        opacity: 0;
        transform: translate3d(0, 16px, 0) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

/* ── Testimonial carousel crossfade (reference ~7s / 0.85s) ── */
@media (prefers-reduced-motion: no-preference) {
    html.pathway-ref-motion:not(.pathway-reduced-motion) .testimonial-slider {
        min-height: 130px;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) .testimonial-slide {
        display: block !important;
        position: absolute;
        inset: 0;
        opacity: 0;
        transform: translate3d(18px, 0, 0);
        pointer-events: none;
        transition:
            opacity var(--ref-dur-slide) var(--ref-ease),
            transform var(--ref-dur-slide) var(--ref-ease);
        animation: none !important;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) .testimonial-slide.active {
        opacity: 1;
        transform: translate3d(0, 0, 0);
        pointer-events: auto;
        position: relative;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) .testimonial-slide.ref-slide-out {
        opacity: 0;
        transform: translate3d(-18px, 0, 0);
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) .slider-dots .dot {
        transition:
            transform var(--ref-dur-fast) var(--ref-ease),
            opacity var(--ref-dur-fast) ease,
            box-shadow var(--ref-dur-fast) ease;
        opacity: 0.45;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) .slider-dots .dot.active {
        opacity: 1;
        transform: scale(1.25);
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.28);
    }
}

/* ── Nav / social hover (reference lift) ── */
@media (prefers-reduced-motion: no-preference) {
    html.pathway-ref-motion:not(.pathway-reduced-motion):not(.pathway-motion-lite) body.page-os-shell:not(.learning-world-page) .topbar .nav a,
    html.pathway-ref-motion:not(.pathway-reduced-motion):not(.pathway-motion-lite) body.page-os-shell:not(.learning-world-page) .admin-topbar-nav a {
        transition:
            transform var(--ref-dur-fast) var(--ref-ease),
            opacity var(--ref-dur-fast) ease,
            color var(--ref-dur-fast) ease;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion):not(.pathway-motion-lite) body.page-os-shell:not(.learning-world-page) .topbar .nav a:hover,
    html.pathway-ref-motion:not(.pathway-reduced-motion):not(.pathway-motion-lite) body.page-os-shell:not(.learning-world-page) .admin-topbar-nav a:hover {
        transform: translate3d(0, -3px, 0);
    }
}

/* ── Auth visual orb spin (reference 28s) ── */
@media (prefers-reduced-motion: no-preference) {
    html.pathway-ref-motion:not(.pathway-reduced-motion) .pathway-auth-hero-art {
        animation-duration: var(--ref-orb-spin) !important;
    }

    html.pathway-ref-motion:not(.pathway-reduced-motion) .pathway-auth-card {
        animation-duration: 0.78s !important;
        animation-timing-function: var(--ref-ease) !important;
    }
}

/* Home: hide ambient rings — they stack as a 2nd shade behind the wave glow */
html.pathway-ref-motion body.page-public-home.home-cinematic .home-ambient::before,
html.pathway-ref-motion body.page-public-home.home-cinematic .home-ambient::after {
    display: none !important;
    content: none !important;
    opacity: 0 !important;
}

@media (prefers-reduced-motion: reduce) {
    html.pathway-ref-motion body.page-public-home.home-cinematic .home-ambient::before,
    html.pathway-ref-motion body.page-public-home.home-cinematic .home-ambient::after {
        display: none !important;
    }
}
