/* Cascina Bonfiglio — SEZIONE: I più amati / Best seller (Figma 12:86)
   Misure esatte da Figma "Copy all layers as CSS". Canvas 1728px. */

.cb-bestsellers {
    position: relative;
    background: #FFF5E6;
    padding: 120px 0 140px;
    box-sizing: border-box;
}

/* Curva superiore cream (Figma 12:86 Vector 3) — l'SVG nel markup ha gia'
   il path con fill #FFF5E6 che si raccorda al bg bianco della sezione sopra. */
.cb-bestsellers__curve {
    position: absolute;
    top: -1px;
    left: 0;
    width: 100%;
    height: 90px;
    display: block;
    pointer-events: none;
    z-index: 0;
}

.cb-bestsellers__inner {
    position: relative;
    z-index: 1;
    max-width: 1438px;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
    text-align: center;
}
@media (max-width: 1700px) {
    .cb-bestsellers__inner { padding: 0 var(--cb-gutter); }
}

/* Kicker uppercase */
.cb-bestsellers__kicker {
    margin: 0;
    font-family: var(--cb-font-body);
    font-weight: 700;
    font-size: 14px;
    line-height: 47px;
    letter-spacing: 1.174px;
    text-transform: uppercase;
    color: var(--cb-text);
}

/* Titolo "I più amati" */
.cb-bestsellers__title {
    margin: 0 0 60px;
    font-family: var(--cb-font-body);
    font-weight: 400;
    font-size: 36px;
    line-height: 47px;
    letter-spacing: 1.174px;
    color: var(--cb-text);
}
.cb-bestsellers__title-accent {
    font-family: var(--cb-font-accent); font-style: italic;
    font-weight: 700;
    font-size: 1.35em;
    color: #000000;
    padding-left: .05em;
}

/* Slider wrapper — frecce a fianco del grid, fuori dalle card */
.cb-bestsellers__slider {
    position: relative;
    max-width: 1438px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Grid 4 card visibili — gap Figma 17px. Le card oltre la 4ª sono accessibili via slider. */
.cb-bestsellers__grid {
    display: flex;
    gap: 17px;
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    padding: 12px 0 20px;            /* spazio verticale per non tagliare l'ombra */
    overflow-x: auto;
    overflow-y: visible;             /* lascia respirare l'ombra in alto/basso */
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
}
.cb-bestsellers__grid::-webkit-scrollbar { display: none; }
.cb-bestsellers__grid > .cb-bs-card {
    flex: 0 0 calc((100% - 51px) / 4);   /* sempre 4 card visibili come Figma */
    scroll-snap-align: start;
}

/* ---------- Frecce slider (flex outside grid) ---------- */
.cb-bestsellers__arrow {
    position: relative;
    flex: 0 0 46px;
    width: 46px;
    height: 47px;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
    z-index: 5;
    transition: transform .2s ease, opacity .2s ease;
}
.cb-bestsellers__arrow svg {
    display: block;
    width: 100%;
    height: 100%;
}
.cb-bestsellers__arrow:hover {
    transform: scale(1.08);
}
.cb-bestsellers__arrow[disabled] {
    cursor: not-allowed;
}

/* ---------- Card ---------- */
.cb-bs-card {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .3s ease;
    cursor: pointer;
}
.cb-bs-card:hover {
    transform: translateY(-4px);
}
/* Pagination dots: nascosti di default, mostrati solo dentro @media mobile più sotto. */
.cb-bs-dots { display: none; }

/* Img reale: ora visibile a TUTTI i breakpoint (refactor anche desktop) — la card
   prende altezza naturale = img + body, niente crop di "cover" che nascondeva il
   vasetto sotto il body bianco. !important per battere eventuali override del tema
   parent (hello-elementor) o di Woo che mettevano max-height/aspect-ratio. */
.cb-bs-card__img {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    aspect-ratio: auto !important;
    object-fit: contain !important;
    border-radius: 20px 20px 0 0;
}

/* Reset bg color ereditato da tema parent / Woo su hover/focus/active (era rosso indesiderato). */
article.cb-bs-card,
article.cb-bs-card:hover,
article.cb-bs-card:focus,
article.cb-bs-card:focus-within,
article.cb-bs-card:active,
.cb-bs-card__link,
.cb-bs-card__link:link,
.cb-bs-card__link:visited,
.cb-bs-card__link:hover,
.cb-bs-card__link:focus,
.cb-bs-card__link:focus-visible,
.cb-bs-card__link:active,
.cb-bs-card__hover {
    background-color: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    text-decoration: none !important;
}

/* Hover: fade alla seconda foto della galleria (consistenza prodotto). */
.cb-bs-card__hover {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-size: cover;
    background-position: center 15%;
    background-repeat: no-repeat;
    border-radius: inherit;
    opacity: 0;
    transition: opacity .35s ease;
    pointer-events: none;
}
.cb-bs-card.has-hover-img:hover .cb-bs-card__hover,
.cb-bs-card.has-hover-img:active .cb-bs-card__hover,
.cb-bs-card.has-hover-img:focus-within .cb-bs-card__hover,
.cb-bs-card.has-hover-img.is-hovered .cb-bs-card__hover {
    opacity: 1;
}
/* Hover sempre attivo: su touch scatta al tap (foto2 visibile per un attimo). */

/* Link a tutta card che porta al dettaglio prodotto.
   Cuore preferiti e bottone "Aggiungi" stanno sopra (z-index) per restare cliccabili. */
.cb-bs-card__link {
    position: absolute;
    inset: 0;
    z-index: 1;
    text-indent: -9999px;
    overflow: hidden;
    background: transparent;
}
.cb-bs-card__link:focus-visible {
    outline: 2px solid #A8C780;
    outline-offset: -4px;
    border-radius: 20px;
}
.cb-bs-card__badges,
.cb-bs-card__body { position: absolute; z-index: 2; }
.cb-bs-card__fav,
.cb-bs-card__btn { position: relative; z-index: 3; }

/* Badges container (Frame 27): absolute top-left, gap 9px */
.cb-bs-card__badges {
    position: absolute;
    top: 18px;
    left: 20px;
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    align-items: center;
    max-width: calc(100% - 40px);
}

/* Pill bianca con testo nero */
/* Stato stock: badge dark/orange uppercase, sovrascrive lo stile bianco default. */
.cb-bs-card__badge--out {
    background: #2C1A0E !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cb-bs-card__badge--backorder {
    background: #E08F2E !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cb-bs-card__badge {
    display: inline-block;
    background: #ffffff;
    color: #000000;
    font-family: var(--cb-font-body);
    font-weight: 400;
    font-size: 9.80437px;
    letter-spacing: 0.492812px;
    text-transform: uppercase;
    padding: 7.003px 12px;
    border-radius: 70.0312px;
    line-height: 1;
    white-space: nowrap;
}

/* Bottone preferiti (cuore) in linea con i badge, a sinistra */
.cb-bs-card__fav {
    width: 27.17px;
    height: 25.82px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform .15s ease;
}
.cb-bs-card__fav svg { display: block; width: 100%; height: 100%; }
.cb-bs-card__fav:hover { transform: scale(1.08); }

/* Footer bianco: in flow normale (relative) sotto l'img, prende altezza dal contenuto.
   z-index 2 per restare sopra l'hover span (absolute z-index 0) anche durante il fade. */
.cb-bs-card__body {
    position: relative;
    z-index: 2;
    width: 100%;
    background: #ffffff;
    border-radius: 0 0 20px 20px;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.cb-bs-card__weight {
    margin: 0;
    font-family: var(--cb-font-body);
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0.895188px;
    color: #000000;
}
.cb-bs-card__title {
    margin: 0;
    font-family: var(--cb-font-body);
    font-weight: 700;
    font-size: 22px;
    line-height: 1.2;
    color: #000000;
    height: 50px;
    margin-block-end: 30px;
}
.cb-bs-card__foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}
.cb-bs-card__price-wrap {
    display: flex;
    flex-direction: column;
    line-height: 1;
    gap: 2px;
}
.cb-bs-card__price {
    font-family: var(--cb-font-body);
    font-weight: 700;
    font-size: 28px;
    color: #000000;
}
.cb-bs-card__unit {
    font-family: var(--cb-font-body);
    font-size: 16px;
    font-weight: 400;
    color: #000000;
}
.cb-bs-card__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 140px;
    height: 42px;
    background: #A8C780;
    color: #ffffff;
    font-family: var(--cb-font-body);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.703704px;
    text-decoration: none;
    padding: 10px;
    border-radius: 100px;
    box-sizing: border-box;
    transition: background .2s ease, transform .2s ease;
}
.cb-bs-card__btn svg {
    width: 14px;
    height: 14px;
}
.cb-bs-card__btn:hover {
    background: #97b870;
    transform: translateY(-1px);
}
/* Variante disabilitata "In produzione" → arancione, no hover. */
.cb-bs-card__btn--disabled,
.cb-bs-card__btn.cb-bs-card__btn--disabled {
    background: #E08F2E !important;
    color: #fff !important;
    cursor: not-allowed;
    pointer-events: none;
}
.cb-bs-card__btn--disabled:hover { background: #E08F2E !important; transform: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 1500px) {
    /* height card rimossa: card adattiva sull'altezza naturale dell'img. */
    .cb-bs-card__body { padding: 18px; }
    /* title rule spostata in default (vale a tutti i viewport). */
    .cb-bs-card__price { font-size: 24px; }
    .cb-bs-card__btn { width: 130px; font-size: 14px; }
}
@media (max-width: 1280px) {
    .cb-bestsellers { padding: 90px 0 110px; }
    .cb-bestsellers__grid > .cb-bs-card { flex: 0 0 calc((100% - 34px) / 3); }
    /* height card rimossa: altezza naturale. */
    .cb-bs-card__body { padding: 16px; gap: 4px; }
    .cb-bs-card__title { font-size: 19px; }
    .cb-bs-card__weight { font-size: 13px; }
    .cb-bs-card__price { font-size: 20px; }
    .cb-bs-card__unit { font-size: 13px; }
    .cb-bs-card__btn { width: 110px; height: 38px; font-size: 13px; gap: 6px; }
    .cb-bs-card__btn svg { width: 12px; height: 12px; }
}
@media (max-width: 1100px) {
    /* Carosello unico mode su mobile + tablet (era 2 colonne wrap fino a 641px). */
    .cb-bestsellers__inner { padding: 0 !important; max-width: none !important; }
    .cb-bestsellers__slider { overflow: visible; }
    .cb-bestsellers__grid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: visible;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: 14vw;
        gap: 14px;
        padding: 8px 14vw;
        margin: 0;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .cb-bestsellers__grid::-webkit-scrollbar { display: none; }
    .cb-bestsellers__grid > .cb-bs-card {
        flex: 0 0 72vw;
        max-width: 360px;
        height: auto;
        min-height: 0;
        scroll-snap-align: center;
    }
    .cb-bestsellers__arrow { display: none; }
    /* Sotto 1100px passiamo all'img reale per non tagliare il vasetto:
       cover su card portrait ingrandiva troppo la foto. */
    .cb-bs-card {
        background-image: none !important;
        height: auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .cb-bs-card__img {
        display: block;
        width: 100%;
        height: auto;
        border-radius: 20px 20px 0 0;
    }
    .cb-bs-card__body {
        position: static;
        height: auto;
    }
    /* Hover sempre attivo (anche mobile/tablet): foto2 fade al tap. */
}
@media (max-width: 1024px) {
    .cb-bestsellers { padding: 70px 0 90px; }
    .cb-bestsellers__title { font-size: 32px; line-height: 42px; margin-bottom: 40px; }
    /* Carosello mantenuto (regole base in @media 1100). NIENTE wrap: ridava 2 colonne. */
    .cb-bs-card { min-height: 0; }
}
@media (max-width: 640px) {
    .cb-bestsellers { padding: 40px 0 60px; }
    .cb-bestsellers__title { font-size: 24px; line-height: 32px; margin-bottom: 28px; text-align: center; padding: 0 16px; }
    .cb-bestsellers__kicker { padding: 0 16px; }
    /* Cliente: "anche i più amati devono andare in carosello" + "prodotto principale
       al centro con peek prev/next evidenti". Stessi calcoli viewport-relative del
       carosello categories: grid larga full viewport, padding 14vw, card 72vw. */
    .cb-bestsellers__inner { padding: 0 !important; max-width: none !important; }
    .cb-bestsellers__slider { overflow: visible; }
    .cb-bestsellers__grid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: visible;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: 14vw;
        gap: 14px;
        padding: 8px 14vw;
        margin: 0;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .cb-bestsellers__grid::-webkit-scrollbar { display: none; }
    .cb-bestsellers__grid > .cb-bs-card {
        flex: 0 0 72vw;
        max-width: 320px;
        min-height: 350px;
        height: auto;
        scroll-snap-align: center;
    }
    .cb-bs-card {
        aspect-ratio: auto;
        min-height: auto;
        height: auto;
        border-radius: 18px;
        background-image: none !important;     /* mobile usa <img> reale per altezza naturale */
        display: flex;
        flex-direction: column;
    }
    .cb-bs-card__img {
        display: block;
        width: 100%;
        height: auto;
        border-radius: 18px 18px 0 0;
        object-fit: cover;
    }
    .cb-bs-card__badges { top: 10px; left: 10px; gap: 5px; }
    .cb-bs-card__badge { font-size: 8.5px; padding: 5px 8px; }
    .cb-bs-card__fav { width: 22px; height: 21px; }
    .cb-bs-card__body {
        position: static;                       /* esce dall'absolute: la card cresce in flow */
        height: auto;
        padding: 16px 18px 18px;
        gap: 8px;
        border-radius: 0 0 14px 14px;
    }
    .cb-bs-card__title { font-size: 20px; line-height: 1.15; min-height: 50px; }
    .cb-bs-card__weight { font-size: 14px; }
    .cb-bs-card__price { font-size: 26px; }
    .cb-bs-card__unit { font-size: 14px; }
    .cb-bs-card__foot {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-top: 12px;
    }
    .cb-bs-card__btn {
        width: auto;
        min-width: 120px;
        height: 42px;
        font-size: 15px;
        padding: 0 26px;
        gap: 12px;
        border-radius: 100px;
    }
    .cb-bs-card__btn svg,
    .cb-bs-card__btn svg path { width: 24px; height: 24px; stroke-width: 1 !important; }
    /* Listing.css aggiunge un secondo "+" via ::after sui .cb-card__cta — lo nascondo qui. */
    .cb-bs-card__btn.cb-card__cta::after { content: none !important; display: none !important; }
    .cb-bestsellers__arrow { display: none; }

    /* Pagination dots sotto al carosello — generati da bestsellers.js solo su mobile.
       Design Figma: anello esterno spesso + gap + cerchio interno solido. */
    .cb-bs-dots {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 14px;
        padding: 20px 0 0;
    }
    .cb-bs-dots__dot {
        width: 16px;
        height: 16px;
        border: 2px solid #C7C0B6;
        border-radius: 50%;
        background: transparent;
        padding: 0;
        position: relative;
        cursor: pointer;
        transition: border-color .2s;
    }
    .cb-bs-dots__dot::before {
        content: '';
        position: absolute;
        inset: 3px;
        border-radius: 50%;
        background: #C7C0B6;
        transition: background .2s;
    }
    .cb-bs-dots__dot.is-active {
        border-color: var(--cb-green);
    }
    .cb-bs-dots__dot.is-active::before {
        background: var(--cb-green);
    }
}
@media (max-width: 380px) {
    .cb-bs-card__title { font-size: 14px; }
    .cb-bs-card__price { font-size: 16px; }
    .cb-bs-card__btn { font-size: 12px; }
}
