/* Shared carousel for product-page lists and store-aware CMS home sections. */
.sg-home-product-section {
    margin: 0 0 50px;
}

.sg-home-product-section__products {
    margin-top: 22px;
}

.sg-product-carousel {
    --sg-carousel-columns: 4;
    --sg-carousel-gap: 15px;
    --sg-carousel-item-width: calc((100% - 45px) / 4);
    position: relative;
    width: 100%;
}

.sg-product-carousel__viewport {
    overflow: hidden;
    width: 100%;
}

html body .sg-product-carousel .sg-product-list .sg-product-grid {
    align-items: stretch !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: var(--sg-carousel-gap) !important;
    grid-auto-rows: unset !important;
    grid-template-columns: none !important;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    touch-action: pan-x pan-y;
}

html body .sg-product-carousel .sg-product-list .sg-product-grid::-webkit-scrollbar {
    display: none;
}

html body .sg-product-carousel .sg-product-grid > .sg-product-grid__item {
    flex: 0 0 var(--sg-carousel-item-width) !important;
    max-width: var(--sg-carousel-item-width) !important;
    scroll-snap-align: start;
    width: var(--sg-carousel-item-width) !important;
}

/* Promotion sections that still include the side banner keep three cards on
 * desktop. The full-width Italian home promotion section uses the shared
 * default of four. Tablet and mobile use the responsive rules below. */
@media (min-width: 1025px) {
    #our-promotions .sg-product-carousel,
    .cms-saida-gusto-espresso-rivenditori #le-nostre-promo .sg-product-carousel {
        --sg-carousel-columns: 3;
        --sg-carousel-item-width: calc(33.333333% - 10px);
    }
}

.sg-product-carousel__arrow {
    align-items: center;
    appearance: none;
    background: #fff;
    border: 1px solid rgba(32, 19, 15, .16);
    border-radius: 50%;
    box-shadow: 0 6px 18px rgba(32, 19, 15, .16);
    color: #74411f;
    cursor: pointer;
    display: flex;
    height: 44px;
    justify-content: center;
    margin: 0;
    padding: 0;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease, color .2s ease;
    width: 44px;
    z-index: 4;
}

.sg-product-carousel__arrow--previous {
    left: -18px;
}

.sg-product-carousel__arrow--next {
    right: -18px;
}

/* Codazon clips the complete legacy row with overflow:hidden. The viewport
 * still clips the sliding cards, while the row and section wrappers allow the
 * navigation controls to sit across the carousel boundary. */
html body.cms-index-index .block-list,
html body.cms-index-index #i-piu-visti,
html body.cms-index-index #i-piu-venduti,
html body.cms-index-index #le-nostre-novita,
html body.cms-index-index #le-nostre-promo,
html body.cms-index-index #most-viewed,
html body.cms-index-index #best-selling,
html body.cms-index-index #our-news,
html body.cms-index-index #our-promotions,
html body.cms-index-index .sg-home-product-section,
html body.cms-index-index .sg-home-product-section__products,
html body .sg-home-product-carousel {
    overflow: visible !important;
    position: relative;
}

html body .sg-home-product-carousel .sg-product-carousel__arrow {
    z-index: 30;
}

@media (min-width: 1025px) {
    html body .sg-home-product-carousel .sg-product-carousel__arrow--previous {
        left: -18px;
    }

    html body .sg-home-product-carousel .sg-product-carousel__arrow--next {
        right: -18px;
    }
}

.sg-product-carousel__arrow svg {
    fill: none;
    height: 21px;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
    width: 21px;
}

.sg-product-carousel__arrow:hover,
.sg-product-carousel__arrow:focus-visible {
    background: #74411f;
    border-color: #74411f;
    box-shadow: 0 7px 20px rgba(32, 19, 15, .22);
    color: #fff;
}

.sg-product-carousel__arrow:focus-visible {
    outline: 3px solid rgba(211, 168, 74, .5);
    outline-offset: 3px;
}

.sg-product-carousel__arrow:disabled {
    cursor: default;
    opacity: .32;
    pointer-events: none;
}

.sg-product-carousel:not(.is-ready) .sg-product-carousel__arrow,
.sg-product-carousel.is-static .sg-product-carousel__arrow {
    display: none;
}

.sg-product-carousel__status {
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* The legacy CMS block places these two carousels in col-sm-12 wrappers.
 * Give each ranking its own full-width row without requiring inline styles or
 * changing the rest of the CMS block markup. */
html body #i-piu-visti,
html body #i-piu-venduti,
html body #most-viewed,
html body #best-selling {
    clear: both;
    flex: 0 0 100%;
    float: none;
    max-width: 100%;
    width: 100%;
}

/* The original CMS block contains both rankings in the same Bootstrap row.
 * Once each carousel is full-width, restore a clear visual break before the
 * second one without adding spacing to the standalone V2 sections. */
html body .block-list > #i-piu-venduti,
html body .block-list > #best-selling {
    margin-top: 48px !important;
}

/* The legacy product-page theme injects a Font Awesome cart glyph on every
 * .tocart::before after this component stylesheet has loaded. ProductCard
 * already renders its own accessible inline SVG; suppress the duplicate and
 * keep the intended icon visible in both simple and composite card actions. */
html body .sg-product-carousel .sg-card .action.tocart::before,
html body .sg-product-carousel .sg-card button.action.primary.tocart::before {
    content: none !important;
    display: none !important;
}

html body .sg-product-carousel .sg-card .sg-card__primary-icon,
html body .sg-product-carousel .sg-card .sg-card__format-add-icon {
    display: inline-flex !important;
    opacity: 1;
    visibility: visible !important;
}

html body .sg-product-carousel .sg-card .sg-card__primary-icon svg,
html body .sg-product-carousel .sg-card .sg-card__format-add-icon svg {
    display: block !important;
}

/* Codazon limits home buttons to 146px and forces a single line. ProductCard
 * actions need the full card width, especially in the narrower CMS columns. */
html body .sg-home-product-carousel .sg-card form[data-sg-card-tocart='1'] {
    min-width: 0;
    width: 100% !important;
}

html body .sg-home-product-carousel .sg-card .sg-card__primary--add-to-cart {
    box-sizing: border-box !important;
    height: auto !important;
    max-width: none !important;
    min-height: 48px !important;
    padding: 10px 12px !important;
    white-space: normal !important;
    width: 100% !important;
}

/* Out-of-stock simple products keep the same full-width action footprint as
 * every other primary ProductCard button in the home carousels. */
html body .sg-home-product-carousel .sg-card .sg-card__footer > .sg-card__primary--notify {
    box-sizing: border-box !important;
    display: inline-flex !important;
    max-width: none !important;
    min-height: 48px !important;
    padding: 10px 12px !important;
    white-space: normal !important;
    width: 100% !important;
}

html body #i-piu-visti .sg-card .sg-card__primary--add-to-cart,
html body #i-piu-venduti .sg-card .sg-card__primary--add-to-cart,
html body #most-viewed .sg-card .sg-card__primary--add-to-cart,
html body #best-selling .sg-card .sg-card__primary--add-to-cart {
    padding: 10px 12px !important;
}

html body .sg-home-product-carousel .sg-card .sg-card__primary-label {
    line-height: 1.15;
    min-width: 0;
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: normal !important;
}

html body .sg-home-product-carousel .sg-card .sg-card__primary-icon {
    flex: 0 0 24px;
}

@media (max-width: 1024px) {
    .sg-product-carousel {
        --sg-carousel-columns: 2;
        --sg-carousel-item-width: calc((100% - 15px) / 2);
    }

    .sg-product-carousel__arrow--previous {
        left: 6px;
    }

    .sg-product-carousel__arrow--next {
        right: 6px;
    }
}

@media (max-width: 767px) {
    .sg-home-product-section {
        margin-bottom: 36px;
    }

    .sg-home-product-section__products {
        margin-top: 18px;
    }

    .sg-product-carousel {
        --sg-carousel-columns: 1;
        --sg-carousel-gap: 13px;
        --sg-carousel-item-width: 100%;
    }

    .sg-product-carousel__arrow {
        height: 40px;
        width: 40px;
    }

    html body .block-list > #i-piu-venduti,
    html body .block-list > #best-selling {
        margin-top: 34px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    html body .sg-product-carousel .sg-product-list .sg-product-grid {
        scroll-behavior: auto;
    }

    .sg-product-carousel__arrow {
        transition: none;
    }
}
