/**
 * FeastFlow — Frontend Smooth Scroll Animations & Auto Scroll-to-Top Widget
 * CodeCanyon Commercial Release Standards Compliant
 * Zero Inline Styles | Noticeable Luxury Scroll Motion | GPU Accelerated
 */

/* ==========================================================================
   1. NOTICEABLE & LUXURIOUS SCROLL-REVEAL ENTRANCE ANIMATIONS
   --------------------------------------------------------------------------
   - Clear, beautiful glide-in (44px vertical travel, 0.9s smooth easing).
   - Distinct, elegant staggered delays (0.13s step) between sibling cards.
   - Zero layout shifts (CLS) & 100% GPU compositor execution.
   ========================================================================== */

/* State for off-screen elements waiting to be scrolled into view */
.ff-anim-ready {
    opacity: 0 !important;
    transform: translate3d(0, 24px, 0) !important;
    transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.65s cubic-bezier(0.16, 1, 0.3, 1) !important;
    will-change: opacity, transform;
}

/* State when scrolled into view */
.ff-anim-ready.ff-in-view {
    opacity: 1 !important;
    transform: translate3d(0, 0, 0) !important;
    will-change: auto; /* Release GPU compositor memory after reveal */
}

/* Noticeable staggered sequential delays for cards in rows/grids */
.ff-anim-ready.ff-in-view.ff-stagger-0 {
    transition-delay: 0.03s !important;
}
.ff-anim-ready.ff-in-view.ff-stagger-1 {
    transition-delay: 0.12s !important;
}
.ff-anim-ready.ff-in-view.ff-stagger-2 {
    transition-delay: 0.21s !important;
}
.ff-anim-ready.ff-in-view.ff-stagger-3 {
    transition-delay: 0.30s !important;
}

/* Hero Section Subtle Fluid Entrance on Initial Page Load */
.ff-hero,
.ff-hero-violet,
.ff-hero-fullbg,
.ff-about-hero,
.ff-pricing-hero,
.ff-for-hero,
.ff-contact-hero {
    animation: ffHeroEntrance 0.65s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes ffHeroEntrance {
    0% {
        opacity: 0.88;
    }
    100% {
        opacity: 1;
    }
}


/* ==========================================================================
   2. AUTO SCROLL-TO-TOP FLOATING WIDGET (Dynamic SVG Progress Ring)
   ========================================================================== */

.ff-scroll-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1040;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(13, 21, 38, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #ffffff;
    box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.4),
                0 0 20px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translate3d(0, 16px, 0) scale(0.9);
    pointer-events: none;
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                background-color 0.25s ease,
                box-shadow 0.25s ease,
                border-color 0.25s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

/* Visible State */
.ff-scroll-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translate3d(0, 0, 0) scale(1);
    pointer-events: auto;
}

/* Hover & Focus Interactions */
.ff-scroll-top:hover {
    transform: translate3d(0, -4px, 0) scale(1.04);
    background: rgba(17, 28, 48, 0.95);
    border-color: var(--theme-primary, #00c896);
    box-shadow: 0 14px 30px -4px rgba(0, 0, 0, 0.5),
                0 0 24px rgba(var(--theme-primary-rgb, 0, 200, 150), 0.35);
    color: #ffffff;
}

.ff-scroll-top:focus-visible {
    outline: 2px solid var(--theme-primary, #00c896);
    outline-offset: 3px;
}

.ff-scroll-top:active {
    transform: translate3d(0, -1px, 0) scale(0.95);
}

/* SVG Circular Progress Indicator */
.ff-scroll-top-progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.ff-scroll-top-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.12);
    stroke-width: 2.5;
}

.ff-scroll-top-bar {
    fill: none;
    stroke: var(--theme-primary, #00c896);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-dasharray: 125.66;
    stroke-dashoffset: 125.66;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
    transition: stroke-dashoffset 0.12s linear;
}

/* Inner Centered Arrow Icon */
.ff-scroll-top-icon {
    position: relative;
    z-index: 2;
    font-size: 0.95rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--theme-primary, #00c896);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), color 0.25s ease;
}

.ff-scroll-top:hover .ff-scroll-top-icon {
    transform: translateY(-2px);
    color: #ffffff;
}


/* ==========================================================================
   3. THEME-SPECIFIC OVERRIDES (Midnight Violet & Editorial Light)
   ========================================================================== */

/* Theme: Midnight Violet */
body[data-theme="midnight-violet"] .ff-scroll-top {
    background: rgba(16, 11, 36, 0.9);
    border-color: rgba(192, 132, 252, 0.2);
}

body[data-theme="midnight-violet"] .ff-scroll-top:hover {
    border-color: #c084fc;
    box-shadow: 0 14px 30px -4px rgba(0, 0, 0, 0.6),
                0 0 25px rgba(192, 132, 252, 0.4);
}

body[data-theme="midnight-violet"] .ff-scroll-top-bar {
    stroke: #c084fc;
}

body[data-theme="midnight-violet"] .ff-scroll-top-icon {
    color: #c084fc;
}

/* Theme: Editorial Light */
body[data-theme="editorial-light"] .ff-scroll-top {
    background: rgba(255, 255, 255, 0.94);
    border-color: rgba(15, 23, 42, 0.12);
    box-shadow: 0 10px 25px -4px rgba(15, 23, 42, 0.12),
                0 4px 12px rgba(15, 23, 42, 0.06);
    color: #0f172a;
}

body[data-theme="editorial-light"] .ff-scroll-top-track {
    stroke: rgba(15, 23, 42, 0.08);
}

body[data-theme="editorial-light"] .ff-scroll-top-bar {
    stroke: #e8394d;
}

body[data-theme="editorial-light"] .ff-scroll-top-icon {
    color: #e8394d;
}

body[data-theme="editorial-light"] .ff-scroll-top:hover {
    background: #ffffff;
    border-color: #e8394d;
    box-shadow: 0 14px 32px -4px rgba(232, 57, 77, 0.25),
                0 4px 16px rgba(15, 23, 42, 0.08);
    color: #e8394d;
}

body[data-theme="editorial-light"] .ff-scroll-top:hover .ff-scroll-top-icon {
    color: #e8394d;
}


/* ==========================================================================
   4. RESPONSIVE POSITIONING & ACCESSIBILITY OVERRIDES
   ========================================================================== */

@media (max-width: 767.98px) {
    .ff-scroll-top {
        bottom: 1.25rem;
        right: 1.25rem;
        width: 44px;
        height: 44px;
    }

    .ff-scroll-top-progress {
        width: 44px;
        height: 44px;
    }

    .ff-scroll-top-icon {
        font-size: 0.88rem;
    }
}

/* Respect User Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    .ff-anim-ready {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
        will-change: auto !important;
    }

    .ff-hero,
    .ff-hero-violet,
    .ff-hero-fullbg,
    .ff-about-hero,
    .ff-pricing-hero,
    .ff-for-hero,
    .ff-contact-hero {
        animation: none !important;
        transform: none !important;
        opacity: 1 !important;
        will-change: auto !important;
    }

    .ff-scroll-top {
        transition: opacity 0.2s ease, visibility 0.2s ease !important;
    }

    .ff-scroll-top-bar {
        transition: none !important;
    }
}
