/* Target the specific block style.
    We use high specificity to override standard Grid styles
*/

/* 1. The Container */
.wp-block-query.is-style-horizontal-slider {
    position: relative; /* Context for absolute arrows */
    max-width: 100%;
    --hql-btn-bg: #ffffff;
    --hql-btn-color: #333333;
    --hql-btn-hover-bg: #f0f0f0;
    --hql-btn-hover-color: #000000;
}

/* 2. The List (Flex Row) */
.wp-block-query.is-style-horizontal-slider .wp-block-post-template {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 20px; /* Space between cards */
    overflow-x: auto;

    /* Smooth Scroll & Snap */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;

    /* Hide Scrollbar (Optional - keep generic browser scrollbar hidden) */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE 10+ */

    padding-bottom: 20px; /* Space for shadow/hover effects */
}

/* Hide scrollbar for Chrome/Safari */
.wp-block-query.is-style-horizontal-slider.wp-block-post-template::-webkit-scrollbar {
    display: none;
}

/* 3. The Items (Cards) */
.wp-block-query.is-style-horizontal-slider .wp-block-post-template > li {
    /* DEFAULT / MOBILE: Fixed width for horizontal scrolling */
    flex: 0 0 320px;
    scroll-snap-align: start;
    margin-bottom: 0 !important;

    /* Ensure the internal .productCard fills the height if needed */
    display: flex;
    flex-direction: column;
}

/* DESKTOP (1200px+): Grid-like proportions for Columns 1-15 */
@media (min-width: 1200px) {

    /* Formula: (100% width - ((Columns - 1) * Gap)) / Columns */

    .wp-block-query.is-style-horizontal-slider > .columns-1.wp-block-post-template > li {
        flex: 0 0 100%;
        width: 100%;
    }

    .wp-block-query.is-style-horizontal-slider > .columns-2.wp-block-post-template > li {
        flex: 0 0 calc((100% - 20px) / 2);
        width: calc((100% - 20px) / 2);
    }

    .wp-block-query.is-style-horizontal-slider > .columns-3.wp-block-post-template > li {
        flex: 0 0 calc((100% - 40px) / 3);
        width: calc((100% - 40px) / 3);
    }

    .wp-block-query.is-style-horizontal-slider > .columns-4.wp-block-post-template > li {
        flex: 0 0 calc((100% - 60px) / 4);
        width: calc((100% - 60px) / 4);
    }

    .wp-block-query.is-style-horizontal-slider > .columns-5.wp-block-post-template > li {
        flex: 0 0 calc((100% - 80px) / 5);
        width: calc((100% - 80px) / 5);
    }

    .wp-block-query.is-style-horizontal-slider > .columns-6.wp-block-post-template > li {
        flex: 0 0 calc((100% - 100px) / 6);
        width: calc((100% - 100px) / 6);
    }

    .wp-block-query.is-style-horizontal-slider > .columns-7.wp-block-post-template > li {
        flex: 0 0 calc((100% - 120px) / 7);
        width: calc((100% - 120px) / 7);
    }

    .wp-block-query.is-style-horizontal-slider > .columns-8.wp-block-post-template > li {
        flex: 0 0 calc((100% - 140px) / 8);
        width: calc((100% - 140px) / 8);
    }

    .wp-block-query.is-style-horizontal-slider > .columns-9.wp-block-post-template > li {
        flex: 0 0 calc((100% - 160px) / 9);
        width: calc((100% - 160px) / 9);
    }

    .wp-block-query.is-style-horizontal-slider > .columns-10.wp-block-post-template > li {
        flex: 0 0 calc((100% - 180px) / 10);
        width: calc((100% - 180px) / 10);
    }

    .wp-block-query.is-style-horizontal-slider > .columns-11.wp-block-post-template > li {
        flex: 0 0 calc((100% - 200px) / 11);
        width: calc((100% - 200px) / 11);
    }

    .wp-block-query.is-style-horizontal-slider > .columns-12.wp-block-post-template > li {
        flex: 0 0 calc((100% - 220px) / 12);
        width: calc((100% - 220px) / 12);
    }

    .wp-block-query.is-style-horizontal-slider > .columns-13.wp-block-post-template > li {
        flex: 0 0 calc((100% - 240px) / 13);
        width: calc((100% - 240px) / 13);
    }

    .wp-block-query.is-style-horizontal-slider > .columns-14.wp-block-post-template > li {
        flex: 0 0 calc((100% - 260px) / 14);
        width: calc((100% - 260px) / 14);
    }

    .wp-block-query.is-style-horizontal-slider > .columns-15.wp-block-post-template > li {
        flex: 0 0 calc((100% - 280px) / 15);
        width: calc((100% - 280px) / 15);
    }
}

/* MOBILE RESPONSIVENESS: Make cards slightly smaller on phones */
@media (max-width: 768px) {
    .wp-block-query.is-style-horizontal-slider.wp-block-post-template > li {
        flex: 0 0 85vw; /* Show mostly one card on small screens */
    }
}


/* 4. Navigation Buttons (Added via JS) */
.hql-nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--hql-btn-color);
    background: var(--hql-btn-bg);
    border: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 40px;
    height: 120px;
    border-radius: 0.25rem;
    z-index: 10;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0px 3px 10px rgba(150, 150, 150, 0.8);
}

.hql-nav-button:hover {
    opacity: 1;
    background: var(--hql-btn-hover-bg);
    color: var(--hql-btn-hover-color);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.hql-prev {
    left: -20px; /* Hang slightly off the edge */
}

.hql-next {
    right: -20px; /* Hang slightly off the edge */
}

/* Hide buttons on mobile if touch scrolling is preferred */
@media (max-width: 600px) {
    .hql-prev {
        left: -5px; /* Hang slightly off the edge */
    }

    .hql-next {
        right: -5px; /* Hang slightly off the edge */
    }
}