/* =====================================================================
   Animations Extra
   Layered on top of styles.css / components.css / animations3d.css.
   Adds: page transitions, scroll progress, split-text, conic borders,
   marquee, sparkle/blob/aurora, magnetic underline, micro-interactions.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. Page Transitions (driven by JS in animations-extra.js)
   --------------------------------------------------------------------- */

#main-content {
    transition:
        opacity 260ms cubic-bezier(0.22, 0.61, 0.36, 1),
        transform 320ms cubic-bezier(0.22, 0.61, 0.36, 1),
        filter 240ms cubic-bezier(0.22, 0.61, 0.36, 1);
    transform-origin: 50% 0%;
    will-change: opacity, transform, filter;
}

#main-content.page-leaving {
    opacity: 0;
    transform: translateY(14px) scale(0.992);
    filter: blur(6px);
}

#main-content.page-entering {
    opacity: 0;
    transform: translateY(22px) scale(0.985);
    filter: blur(10px);
}

#main-content.page-entered {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
}

/* ---------------------------------------------------------------------
   2. Top Scroll Progress Bar
   --------------------------------------------------------------------- */

#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    z-index: 1100;
    background: linear-gradient(90deg, #10b981 0%, #06b6d4 50%, #f59e0b 100%);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.55), 0 0 24px rgba(6, 182, 212, 0.35);
    transition: width 90ms linear, opacity 200ms ease-out;
    border-radius: 0 2px 2px 0;
    pointer-events: none;
}

#scroll-progress.idle { opacity: 0.45; }

/* ---------------------------------------------------------------------
   3. Split-Text Reveal
   .split-reveal applied via JS — wraps each word in a span.split-word
   --------------------------------------------------------------------- */

.split-word {
    display: inline-block;
    opacity: 0;
    transform: translateY(28px) rotateX(-22deg);
    transform-origin: 50% 100%;
    filter: blur(8px);
    transition:
        opacity 0.7s cubic-bezier(0.2, 0.9, 0.3, 1),
        transform 0.8s cubic-bezier(0.2, 0.9, 0.3, 1),
        filter 0.7s ease-out;
    will-change: opacity, transform, filter;
}

.split-word.in {
    opacity: 1;
    transform: translateY(0) rotateX(0);
    filter: blur(0);
}

/* keep spaces visible between words */
.split-space { display: inline-block; width: 0.3em; }

/* ---------------------------------------------------------------------
   4. Conic / Aurora Animated Borders
   Add class .border-aurora to any element. Uses a pseudo behind it.
   --------------------------------------------------------------------- */

.border-aurora {
    position: relative;
    z-index: 0;
    isolation: isolate;
}

.border-aurora::before {
    content: '';
    position: absolute;
    inset: -1.5px;
    border-radius: inherit;
    padding: 1.5px;
    background: conic-gradient(
        from 0deg,
        #10b981, #06b6d4, #f59e0b, #ec4899, #10b981
    );
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    z-index: -1;
    opacity: 0.85;
    animation: auroraSpin 6s linear infinite;
}

@keyframes auroraSpin {
    to { transform: rotate(1turn); }
}

/* Cards in featured grids — subtle aurora on hover */
.feature-card,
.benefit-card,
.choice-card {
    position: relative;
}

.feature-card::after,
.benefit-card::after,
.choice-card::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: conic-gradient(
        from var(--ang, 0deg),
        transparent 0%,
        rgba(16, 185, 129, 0.45) 18%,
        rgba(6, 182, 212, 0.6) 36%,
        rgba(245, 158, 11, 0.55) 54%,
        transparent 75%
    );
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    opacity: 0;
    transition: opacity 350ms ease;
    pointer-events: none;
    z-index: 2;
}

.feature-card:hover::after,
.benefit-card:hover::after,
.choice-card:hover::after {
    opacity: 1;
    animation: angSpin 4s linear infinite;
}

@property --ang {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

@keyframes angSpin {
    to { --ang: 360deg; }
}

/* ---------------------------------------------------------------------
   5. Brand Logos — gentle drift on hover (no duplicate-DOM needed)
   --------------------------------------------------------------------- */

.brands-logos { transition: gap 400ms ease; }
.brands-logos:hover { gap: var(--space-12); }

.brand-logo {
    transition:
        transform 350ms cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 250ms ease,
        color 250ms ease,
        text-shadow 350ms ease;
}

.brand-logo:hover {
    transform: translateY(-4px) scale(1.08);
    text-shadow: 0 6px 22px rgba(16, 185, 129, 0.45);
}

/* ---------------------------------------------------------------------
   6. Aurora background blob (decorative)
   --------------------------------------------------------------------- */

.aurora-bg {
    position: absolute;
    inset: -10% -5%;
    z-index: -1;
    pointer-events: none;
    filter: blur(70px) saturate(1.2);
    opacity: 0.5;
    background:
        radial-gradient(40% 50% at 20% 30%, rgba(16, 185, 129, 0.45), transparent 70%),
        radial-gradient(35% 40% at 80% 60%, rgba(6, 182, 212, 0.4),  transparent 70%),
        radial-gradient(30% 30% at 50% 80%, rgba(245, 158, 11, 0.35), transparent 70%);
    animation: auroraDrift 18s ease-in-out infinite alternate;
}

@keyframes auroraDrift {
    0%   { transform: translate3d(0, 0, 0)         scale(1); }
    50%  { transform: translate3d(2%, -3%, 0)     scale(1.05); }
    100% { transform: translate3d(-2%, 2%, 0)     scale(0.97); }
}

/* ---------------------------------------------------------------------
   7. Hero Visual Parallax (driven by JS)
   --------------------------------------------------------------------- */

.parallax {
    will-change: transform;
    transition: transform 80ms linear;
}

/* ---------------------------------------------------------------------
   8. Sparkle / Twinkle (decorative)
   .sparkle-host > .sparkle  spawned via JS or pre-placed
   --------------------------------------------------------------------- */

.sparkle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    box-shadow:
        0 0 8px rgba(255, 255, 255, 0.9),
        0 0 22px rgba(16, 185, 129, 0.65);
    pointer-events: none;
    animation: sparkleLife 1.4s ease-out forwards;
}

@keyframes sparkleLife {
    0%   { transform: scale(0) rotate(0deg);   opacity: 0; }
    20%  { transform: scale(1) rotate(60deg);  opacity: 1; }
    100% { transform: scale(0.2) rotate(180deg); opacity: 0; }
}

/* ---------------------------------------------------------------------
   9. Confetti (used by JS confetti emitter)
   --------------------------------------------------------------------- */

.confetti-piece {
    position: fixed;
    top: -16px;
    width: 10px;
    height: 14px;
    pointer-events: none;
    z-index: 99999;
    border-radius: 2px;
    animation: confettiFall var(--dur, 2.6s) cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
    will-change: transform, opacity;
}

@keyframes confettiFall {
    0%   { transform: translate3d(0, 0, 0) rotateZ(0deg); opacity: 1; }
    100% {
        transform: translate3d(var(--dx, 60px), 110vh, 0) rotateZ(var(--rot, 540deg));
        opacity: 0;
    }
}

/* ---------------------------------------------------------------------
   10. Magnetic Underline for nav links (additive over existing ::after)
   --------------------------------------------------------------------- */

.nav-links a {
    transition: color 200ms ease, letter-spacing 250ms ease;
}

.nav-links a:hover {
    letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------------
   11. Button Pulse Halo (works on .btn-primary)
   --------------------------------------------------------------------- */

.btn-primary {
    isolation: isolate;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55);
    z-index: -1;
}

.btn-primary:hover::after {
    animation: btnPulse 1.4s ease-out infinite;
}

@keyframes btnPulse {
    0%   { box-shadow: 0 0 0 0   rgba(16, 185, 129, 0.55); }
    70%  { box-shadow: 0 0 0 18px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0   rgba(16, 185, 129, 0); }
}

/* ---------------------------------------------------------------------
   12. Animated checklist tick (auto applies to .check-icon on enter)
   --------------------------------------------------------------------- */

.benefit-features li {
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.benefit-card.in-view .benefit-features li { opacity: 1; transform: translateX(0); }
.benefit-card.in-view .benefit-features li:nth-child(1) { transition-delay: 60ms; }
.benefit-card.in-view .benefit-features li:nth-child(2) { transition-delay: 140ms; }
.benefit-card.in-view .benefit-features li:nth-child(3) { transition-delay: 220ms; }
.benefit-card.in-view .benefit-features li:nth-child(4) { transition-delay: 300ms; }

.check-icon {
    transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.benefit-features li:hover .check-icon {
    transform: rotate(360deg) scale(1.18);
}

/* ---------------------------------------------------------------------
   13. Smart hover-tilt fallback (cards without JS tilt)
   --------------------------------------------------------------------- */

.hover-pop {
    transition:
        transform 350ms cubic-bezier(0.2, 0.9, 0.3, 1.2),
        box-shadow 350ms ease;
}

.hover-pop:hover {
    transform: translateY(-6px) scale(1.015);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(16, 185, 129, 0.18);
}

/* ---------------------------------------------------------------------
   14. Reveal helper (.reveal + JS observer adds .reveal-in)
   --------------------------------------------------------------------- */

.reveal {
    opacity: 0;
    transform: translateY(36px);
    transition:
        opacity 0.75s cubic-bezier(0.2, 0.9, 0.3, 1),
        transform 0.75s cubic-bezier(0.2, 0.9, 0.3, 1);
    will-change: opacity, transform;
}

.reveal-left  { transform: translateX(-50px); }
.reveal-right { transform: translateX( 50px); }
.reveal-zoom  { transform: scale(0.88); }
.reveal-rot   { transform: perspective(900px) rotateX(20deg) translateY(40px); transform-origin: 50% 100%; }

.reveal.reveal-in,
.reveal-left.reveal-in,
.reveal-right.reveal-in,
.reveal-zoom.reveal-in,
.reveal-rot.reveal-in {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1) rotateX(0);
}

/* stagger-by-children */
.stagger > * { transition-delay: calc(var(--i, 0) * 80ms); }

/* ---------------------------------------------------------------------
   15. Form input focus aurora glow
   --------------------------------------------------------------------- */

.form-input,
.form-textarea,
.form-select {
    background-clip: padding-box;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    animation: focusFlicker 2.4s ease-in-out;
}

@keyframes focusFlicker {
    0%, 100% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.18), 0 0 22px rgba(16, 185, 129, 0.25); }
    50%      { box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.22),  0 0 28px rgba(6, 182, 212, 0.3); }
}

/* ---------------------------------------------------------------------
   16. Logo tilt + shimmer
   --------------------------------------------------------------------- */

.nav-logo {
    perspective: 600px;
}

.logo-icon {
    display: inline-block;
    transition: transform 400ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.nav-logo:hover .logo-icon {
    transform: rotate(-12deg) scale(1.15);
}

.logo-text {
    background-size: 200% auto;
    animation: gradientShift 6s ease-in-out infinite;
}

/* ---------------------------------------------------------------------
   17. Toast micro-bounce
   --------------------------------------------------------------------- */

.toast {
    animation: toastIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

@keyframes toastIn {
    0%   { opacity: 0; transform: translateX(60px) scale(0.92); }
    60%  { opacity: 1; transform: translateX(-6px) scale(1.02); }
    100% { opacity: 1; transform: translateX(0)    scale(1);    }
}

/* ---------------------------------------------------------------------
   18. Hero scroll indicator — soft glow trail
   --------------------------------------------------------------------- */

.scroll-arrow {
    box-shadow: 0 0 18px rgba(16, 185, 129, 0.25);
}

/* ---------------------------------------------------------------------
   19. Section dividers — animated gradient line
   --------------------------------------------------------------------- */

.section-header {
    position: relative;
}

.section-header h2 {
    position: relative;
    display: inline-block;
}

.section-header h2::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -12px;
    width: 0;
    height: 3px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, transparent, #10b981, #06b6d4, #f59e0b, transparent);
    border-radius: 999px;
    animation: dividerGrow 1.6s 0.2s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
}

@keyframes dividerGrow {
    to { width: 70%; }
}

/* ---------------------------------------------------------------------
   20. FAQ — answer slide
   --------------------------------------------------------------------- */

.faq-answer {
    transition:
        max-height 0.45s cubic-bezier(0.2, 0.9, 0.3, 1),
        opacity 0.3s ease-out 0.05s;
    opacity: 0;
}

.faq-item.active .faq-answer {
    opacity: 1;
}

/* ---------------------------------------------------------------------
   21. Reduced motion respect
   --------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    #scroll-progress { display: none; }
    .split-word { opacity: 1; transform: none; filter: none; }
    .reveal, .reveal-left, .reveal-right, .reveal-zoom, .reveal-rot {
        opacity: 1; transform: none;
    }
}

/* ---------------------------------------------------------------------
   22. Mobile dampening (lighter effects on small screens)
   --------------------------------------------------------------------- */

@media (max-width: 640px) {
    .border-aurora::before { animation-duration: 10s; }
    .feature-card::after,
    .benefit-card::after,
    .choice-card::after { display: none; }
    #main-content.page-entering { filter: blur(4px); }
}
