/**
 * Matchbeast Storefront Motion & Tactile Polish
 *
 * Performance-first Shopify-style browsing smoothness for Flatsome + WooCommerce:
 * - Native cross-document View Transitions (viewport root crossfade, zero header morph glitch)
 * - Delayed 2px GPU-composited top navigation progress hairline
 * - Refined cubic-bezier deceleration for sticky header, mobile drawer, and FunnelKit slide cart
 * - Desktop-only subtle card image zoom targeting .image-none (compatible with homepage image reveal)
 * - Below-the-fold & Infinite Scroll GPU-only staggered reveal (0ms LCP / 0 CLS impact)
 */

:root {
    --mb-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --mb-ease-std: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   1. Cross-Document View Transitions (Chrome / Edge / Safari 18.2+)
   ========================================================================== */
@view-transition {
    navigation: auto;
}

::view-transition-old(root) {
    animation: 160ms var(--mb-ease-std) both mb-vt-fade-out;
}

::view-transition-new(root) {
    animation: 180ms var(--mb-ease-out) both mb-vt-fade-in;
}

@keyframes mb-vt-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes mb-vt-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==========================================================================
   2. Delayed 2px Top Navigation Hairline Progress Bar
   ========================================================================== */
#mb-nav-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: #111111;
    z-index: 999999;
    pointer-events: none;
    transform-origin: 0 50%;
    transform: scaleX(0);
    opacity: 0;
    will-change: transform, opacity;
}

#mb-nav-progress.is-active {
    opacity: 1;
    transform: scaleX(0.84);
    transition:
        opacity 140ms var(--mb-ease-std),
        transform 1800ms cubic-bezier(0.12, 0.8, 0.2, 1);
}

#mb-nav-progress.is-done {
    opacity: 0;
    transform: scaleX(1);
    transition:
        transform 180ms var(--mb-ease-out),
        opacity 220ms var(--mb-ease-std) 80ms;
}

/* ==========================================================================
   3. Sticky Header, Mobile Off-Canvas & FunnelKit Slide Cart Curves
   ========================================================================== */
#header.sticky-jump .header-wrapper.stuck:not(.ux-no-animation) {
    animation-duration: 340ms;
    animation-timing-function: var(--mb-ease-out);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06), 0 6px 20px rgba(0, 0, 0, 0.04) !important;
}

.off-canvas-left .mfp-content,
.off-canvas-right .mfp-content,
.off-canvas .mobile-sidebar-slide .sidebar-menu {
    transition-duration: 320ms;
    transition-timing-function: var(--mb-ease-out);
}

#fkcart-modal .fkcart-preview-ui {
    transition-duration: 340ms;
    transition-timing-function: var(--mb-ease-out);
}

/* ==========================================================================
   4. Product Grid Placeholder Surface, Desktop Hover Zoom & Reveal Motion
   ========================================================================== */
.products .product-small .box-image,
#main .row .product-small .box-image,
.related-products-wrapper .product-small .box-image {
    background-color: #f5f5f5;
}

.products .product-small .title-wrapper .name a,
#main .row .product-small .title-wrapper .name a {
    transition: color 180ms var(--mb-ease-std);
}

@media (hover: hover) and (pointer: fine) {
    /* Target .image-none inside .box-image (overflow: hidden) so we never collide
       with homepage img[data-mbperf-reveal][data-no-lazy] !important opacity rule. */
    .products .product-small .box-image .image-none,
    #main .row .product-small .box-image .image-none,
    .related-products-wrapper .product-small .box-image .image-none {
        transition: transform 480ms var(--mb-ease-out);
        transform: translateZ(0);
    }

    .products .product-small .box:hover .box-image .image-none,
    #main .row .product-small .box:hover .box-image .image-none,
    .related-products-wrapper .product-small .box:hover .box-image .image-none {
        transform: scale(1.035);
    }
}

/* Below-the-fold & Infinite Scroll entrance (JS only marks strictly offscreen items) */
.mb-reveal {
    opacity: 0;
    transform: translate3d(0, 12px, 0);
    will-change: opacity, transform;
}

.mb-reveal.is-revealed {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    transition:
        opacity 380ms var(--mb-ease-out) var(--mb-reveal-delay, 0ms),
        transform 380ms var(--mb-ease-out) var(--mb-reveal-delay, 0ms);
}

.page-load-status {
    padding: 20px 0 28px;
}

/* ==========================================================================
   5. Single Product & Tactile Interactive Micro-Feedback
   ========================================================================== */
.flatsome-custom-swatches .swatch-item,
.single-product .single_add_to_cart_button,
.woocommerce-pagination ul.page-numbers li a,
.mb-seo-desc-toggle,
.single-product .product-thumbnails .col a {
    transition-timing-function: var(--mb-ease-out);
}

.single-product .single_add_to_cart_button:not(.disabled):not(:disabled):active,
.flatsome-custom-swatches .swatch-item:not(.disabled):active,
.mb-seo-desc-toggle:active,
.button.primary:not(.disabled):not(:disabled):active {
    transform: scale(0.985);
}

/* Mobile native tap feel: eliminate default grey/blue tap box while keeping focus-visible */
@media (pointer: coarse) {
    .product-small a,
    .button,
    .flatsome-custom-swatches .swatch-item,
    .header-nav a,
    .mb-seo-desc-toggle {
        -webkit-tap-highlight-color: transparent;
    }
}

.product-small a:focus-visible,
.flatsome-custom-swatches .swatch-item:focus-visible,
.mb-seo-desc-toggle:focus-visible {
    outline: 2px solid #111111;
    outline-offset: 2px;
}

/* ==========================================================================
   6. Accessibility: Reduced Motion Respect
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    @view-transition {
        navigation: none;
    }

    #mb-nav-progress {
        display: none !important;
    }

    .sticky-jump .stuck:not(.ux-no-animation) {
        animation: none !important;
    }

    .products .product-small .box-image .image-none,
    #main .row .product-small .box-image .image-none,
    .related-products-wrapper .product-small .box-image .image-none {
        transition: none !important;
        transform: none !important;
    }

    .mb-reveal,
    .mb-reveal.is-revealed {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
        will-change: auto !important;
    }

    .single-product .single_add_to_cart_button:active,
    .flatsome-custom-swatches .swatch-item:active,
    .mb-seo-desc-toggle:active,
    .button.primary:active {
        transform: none !important;
    }
}
