/* Product card carousels (assets/js/card-carousel.js): home Featured Products
   and the Flash Sale / Mega Sale rows. The arrows sit in their own columns on
   both sides of the row, never over a card, and each click, swipe or
   auto-slide shows a whole new row of cards. The cards per row below are the
   defaults; the home page prints its own from Admin → Home Sections
   (include/home-sections.php). */
.mcdodo-products-slider-wrapper[data-card-carousel] {
    --cc-arrow: 44px;
    --cc-gap: 16px;
    --cc-per-view: 6;
    position: relative;
    display: grid;
    grid-template-columns: var(--cc-arrow) minmax(0, 1fr) var(--cc-arrow);
    align-items: center;
    column-gap: 12px;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
    overflow: visible;
    box-sizing: border-box;
}

.mcdodo-products-slider-wrapper[data-card-carousel] > .mcdodo-products-slider {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    gap: var(--cc-gap);
    padding: 12px 4px 20px; /* room for the hover lift and the card shadow */
    scroll-padding-inline: 4px;
    scroll-behavior: auto;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
}

@media (hover: none) {
    .mcdodo-products-slider-wrapper[data-card-carousel] > .mcdodo-products-slider {
        scroll-snap-type: x mandatory;
    }
}

.mcdodo-products-slider[data-cc="track"] > .mcdodo-product-card.pcv2 {
    flex: 0 0 calc((100% - (var(--cc-per-view) - 1) * var(--cc-gap)) / var(--cc-per-view));
    width: auto;
    min-width: 0;
    scroll-snap-align: start;
}

/* Row by row: the script marks the first card of each row (.cc-row-start) and
   only those are snap points, so a swipe stops on the next row, never on a
   card in the middle of one, and a fast swipe cannot skip a row. */
.mcdodo-products-slider-wrapper[data-card-carousel] > .mcdodo-products-slider.cc-rows {
    scroll-snap-type: x mandatory;
}

[data-card-carousel] [data-cc="track"].cc-rows > *,
.mcdodo-products-slider[data-cc="track"].cc-rows > .mcdodo-product-card.pcv2 {
    scroll-snap-align: none;
}

[data-card-carousel] [data-cc="track"].cc-rows > .cc-row-start,
.mcdodo-products-slider[data-cc="track"].cc-rows > .mcdodo-product-card.pcv2.cc-row-start {
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

/* Empty space that completes the last row when it has fewer cards (the
   script sets its width), so the last row also shows only new cards */
[data-card-carousel] [data-cc="track"] > .cc-spacer {
    flex: 0 0 auto;
    min-width: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Arrows */
.mcdodo-products-slider-wrapper[data-card-carousel] > .mcdodo-slider-btn {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    transform: none;
    grid-row: 1;
    align-self: center;
    margin-bottom: 8px; /* centre on the cards, not on the row's padding */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--cc-arrow);
    height: var(--cc-arrow);
    /* index_mobile.php sets button { min-width/min-height: 44px !important } on phones,
       which would push the arrows out of their columns and over the cards */
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #1e293b;
    font-size: 1rem;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .08);
    cursor: pointer;
    z-index: 1;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease,
                box-shadow .2s ease, opacity .2s ease, transform .2s ease;
}

.mcdodo-products-slider-wrapper[data-card-carousel] > .mcdodo-prev {
    grid-column: 1;
}

.mcdodo-products-slider-wrapper[data-card-carousel] > .mcdodo-next {
    grid-column: 3;
}

.mcdodo-products-slider-wrapper[data-card-carousel] > .mcdodo-slider-btn:hover:not(:disabled) {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    box-shadow: 0 6px 18px rgba(37, 99, 235, .3);
    transform: scale(1.06);
}

.mcdodo-products-slider-wrapper[data-card-carousel] > .mcdodo-slider-btn:active:not(:disabled) {
    transform: scale(.94);
}

.mcdodo-products-slider-wrapper[data-card-carousel] > .mcdodo-slider-btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Start / end of the row */
[data-card-carousel] [data-cc="prev"]:disabled,
[data-card-carousel] [data-cc="next"]:disabled {
    opacity: .35;
    cursor: default;
    box-shadow: none;
}

/* Every card fits: no arrows (their columns stay, so rows line up) */
[data-card-carousel].cc-static [data-cc="prev"],
[data-card-carousel].cc-static [data-cc="next"] {
    visibility: hidden;
}

[data-theme="dark"] .mcdodo-products-slider-wrapper[data-card-carousel] > .mcdodo-slider-btn {
    background: #2d2d2d;
    border-color: #404040;
    color: #e5e7eb;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .4);
}

[data-theme="dark"] .mcdodo-products-slider-wrapper[data-card-carousel] > .mcdodo-slider-btn:hover:not(:disabled) {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* Cards per row (defaults, see the top of this file) */
@media (max-width: 1439px) {
    .mcdodo-products-slider-wrapper[data-card-carousel] { --cc-per-view: 5; }
}

@media (max-width: 1199px) {
    .mcdodo-products-slider-wrapper[data-card-carousel] { --cc-per-view: 4; }
}

@media (max-width: 991px) {
    .mcdodo-products-slider-wrapper[data-card-carousel] {
        --cc-per-view: 3;
        --cc-arrow: 40px;
        padding: 0 12px;
        column-gap: 8px;
    }
}

@media (max-width: 767px) {
    .mcdodo-products-slider-wrapper[data-card-carousel] {
        --cc-per-view: 2;
        --cc-arrow: 32px;
        --cc-gap: 10px;
        padding: 0 6px;
        column-gap: 6px;
    }

    .mcdodo-products-slider-wrapper[data-card-carousel] > .mcdodo-products-slider {
        padding: 8px 2px 14px;
        scroll-padding-inline: 2px;
    }

    .mcdodo-products-slider-wrapper[data-card-carousel] > .mcdodo-slider-btn {
        margin-bottom: 6px;
        font-size: .8rem;
    }

    .mcdodo-products-slider[data-cc="track"] > .mcdodo-product-card.pcv2 {
        height: auto;
    }

    .mcdodo-products-slider[data-cc="track"] > .mcdodo-product-card.pcv2 .pcv2-img {
        height: 150px;
    }
}
