/**
 * Infinite Scroll & Sticky Filters Styles for Monsieurplus / Microconcept
 */

/* ==========================================================================
   1. STICKY FILTER BAR ON DESKTOP & NOTEBOOK
   ========================================================================== */
@media (min-width: 1024px) {
    #layered-navigation.c-filters {
        position: -webkit-sticky;
        position: sticky;
        top: 12rem; /* Exact height of sticky header (4rem top + 8rem main) */
        z-index: 100;
        background: #ffffff;
        transition: padding 0.25s ease, box-shadow 0.25s ease;
    }

    /* When the filter bar is docked/stuck at the top during scroll */
    #layered-navigation.c-filters.is-sticky-bar {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
        padding-bottom: 0 !important;
        margin-bottom: 2rem !important;
    }

    #layered-navigation.c-filters.is-sticky-bar .c-filters__aside {
        display: none !important;
    }

    #layered-navigation.c-filters.is-sticky-bar .c-filters__panel {
        padding: 1rem 0 !important;
    }

    /* Keep dropdown options from overflowing screen on notebooks */
    .c-filters__options.is-expanded {
        max-height: calc(100vh - 18rem);
        overflow-y: auto;
    }
}

/* ==========================================================================
   2. INFINITE SCROLL LOADER & PAGINATION ADJUSTMENTS
   ========================================================================== */
/* Hide standard pagination when infinite scroll is enabled */
.infinite-scroll-enabled #catalog-listing .c-pagination,
.infinite-scroll-enabled #catalog-listing .pager {
    display: none !important;
}

/* Sentinel element for trigger */
.c-infinite-sentinel {
    height: 1px;
    width: 100%;
    margin-top: 10px;
    margin-bottom: 20px;
    pointer-events: none;
    visibility: hidden;
}

/* Loader indicator */
.c-infinite-loader {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 3rem 1rem;
    margin: 1.5rem auto 2.5rem;
    color: #4a4c54;
    font-size: 1.5rem;
    font-weight: 500;
    text-align: center;
}

.c-infinite-loader__spinner {
    width: 26px;
    height: 26px;
    border: 3px solid #dcdcdf;
    border-top-color: #2b3990;
    border-radius: 50%;
    animation: mcInfiniteSpin 0.75s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

.c-infinite-loader__text {
    display: inline-block;
    vertical-align: middle;
}

@keyframes mcInfiniteSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Smooth appearance for newly appended products */
li.c-catalog__item[data-catalog-page] {
    animation: mcFadeInProduct 0.35s ease-out;
}

@keyframes mcFadeInProduct {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   3. BACK TO TOP BUTTON
   ========================================================================== */
.c-back-to-top {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #2b3990;
    color: #ffffff;
    border: none;
    outline: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.85);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                background-color 0.2s ease,
                box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.c-back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.c-back-to-top:hover {
    background-color: #1e2865;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.c-back-to-top:active {
    transform: translateY(0) scale(0.96);
}

.c-back-to-top svg {
    display: block;
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 2.5;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (max-width: 767px) {
    .c-back-to-top {
        bottom: 20px;
        right: 20px;
        width: 42px;
        height: 42px;
    }
    .c-back-to-top svg {
        width: 20px;
        height: 20px;
    }
}
