/*
 * Carrousel produits à onglets.
 *
 * Le défilement repose sur scroll-snap natif : pas de librairie, la cinétique
 * tactile est celle du système, et le JS ne sert qu'à la pagination et aux
 * onglets. Le nombre de cartes visibles et l'espacement viennent d'Elementor
 * via --mcs-pc-per-view et --mcs-pc-gap.
 */

.mcs-pc {
    --mcs-pc-per-view: 4;
    --mcs-pc-gap: 16px;
    --mcs-pc-ratio: 1;
}

/* ------------------------------------------------------------------ En-tête */

.mcs-pc__head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin-bottom: 24px;
}

.mcs-pc__headings {
    flex: 0 0 auto;
}

.mcs-pc__heading {
    display: none;
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
}

.mcs-pc__heading.is-active {
    display: block;
}

.mcs-pc__tabs {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    gap: 40px;
    justify-content: center;
}

.mcs-pc__tab {
    appearance: none;
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    cursor: pointer;
    color: inherit;
    font: inherit;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    opacity: 0.55;
    transition: opacity 0.2s ease;
}

.mcs-pc__tab:hover,
.mcs-pc__tab:focus-visible {
    opacity: 1;
}

.mcs-pc__tab.is-active {
    font-weight: 700;
    opacity: 1;
}

.mcs-pc__view-alls {
    flex: 0 0 auto;
    /* Ancré tout à droite, y compris quand la barre d'onglets est absente. */
    margin-left: auto;
}

.mcs-pc__view-all {
    display: none;
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    white-space: nowrap;
}

.mcs-pc__view-all.is-active {
    display: inline-block;
}

/* ---------------------------------------------------------------- Défilement */

.mcs-pc__panel[hidden] {
    display: none;
}

.mcs-pc__viewport {
    position: relative;
}

.mcs-pc__track {
    display: flex;
    gap: var(--mcs-pc-gap);
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.mcs-pc__track::-webkit-scrollbar {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .mcs-pc__track {
        scroll-behavior: auto;
    }
}

.mcs-pc__slide {
    display: flex;
    flex: 0 0 calc(
        (100% - (var(--mcs-pc-per-view) - 1) * var(--mcs-pc-gap)) / var(--mcs-pc-per-view)
    );
    scroll-snap-align: start;
}

/* -------------------------------------------------------------------- Carte */

/* La carte est un panneau : l'image et le texte partagent le même fond et la
   même marge intérieure, comme sur une vitrine imprimée. */
.mcs-pc__card {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    box-sizing: border-box;
    padding: 20px;
    background-color: #f4f4f4;
}

.mcs-pc__badge {
    margin: 0 0 14px;
    min-height: 1.2em;
    font-size: 12px;
    letter-spacing: 0.08em;
    line-height: 1.2;
    text-transform: uppercase;
}

.mcs-pc__media {
    display: block;
    box-sizing: border-box;
    aspect-ratio: 1 / var(--mcs-pc-ratio);
    overflow: hidden;
}

/* Conteneur des deux photos : c'est lui, et non la zone rembourrée, qui sert
   de référence à la photo de survol — sinon elle déborderait de la marge. */
.mcs-pc__images {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
}

.mcs-pc__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.4s ease;
}

.mcs-pc__img--hover {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.mcs-pc__card:hover .mcs-pc__img--hover {
    opacity: 1;
}

/* Sans seconde photo, un léger zoom signale quand même le survol. */
.mcs-pc__card:hover .mcs-pc__media:not(.mcs-pc__media--swap) .mcs-pc__img {
    transform: scale(1.03);
}

.mcs-pc__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    padding-top: 18px;
}

.mcs-pc__title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.mcs-pc__title {
    /* Deux lignes au plus : au-delà, un titre à rallonge décalerait le prix
       d'une carte à l'autre et casserait l'alignement de la rangée. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.35;
}

.mcs-pc__title a {
    color: inherit;
    text-decoration: none;
}

.mcs-pc__cart {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    opacity: 0.75;
    transition: opacity 0.2s ease;
}

.mcs-pc__cart:hover,
.mcs-pc__cart:focus-visible {
    opacity: 1;
}

.mcs-pc__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    /* Colle la ligne de prix au bas de la carte : les prix restent alignés
       que le titre tienne sur une ligne ou sur deux. */
    margin-top: auto;
    padding-top: 10px;
}

.mcs-pc__price {
    font-size: 17px;
    font-weight: 700;
}

.mcs-pc__price del {
    opacity: 0.5;
    font-weight: 400;
    margin-right: 4px;
}

.mcs-pc__colors {
    color: inherit;
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 3px;
    white-space: nowrap;
}

/* --------------------------------------------------------------- Navigation */

.mcs-pc__arrow {
    position: absolute;
    top: calc(50% - 24px);
    z-index: 2;
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
    color: #111;
    cursor: pointer;
    transform: translateY(-50%);
    transition: opacity 0.2s ease;
}

.mcs-pc__viewport:hover .mcs-pc__arrow,
.mcs-pc__arrow:focus-visible {
    display: flex;
}

.mcs-pc__arrow[disabled] {
    opacity: 0.35;
    cursor: default;
}

.mcs-pc__arrow--prev {
    left: 8px;
}

.mcs-pc__arrow--next {
    right: 8px;
}

.mcs-pc__dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.mcs-pc__dots:empty {
    display: none;
}

.mcs-pc__dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background-color: #d8d8d8;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.mcs-pc__dot.is-active {
    background-color: #111;
}

/* ------------------------------------------------------------- Éditeur seul */

.mcs-pc__notice {
    padding: 24px;
    border: 1px dashed currentColor;
    opacity: 0.6;
    text-align: center;
}

.mcs-pc__notice-line {
    margin: 0 0 4px;
    font-size: 13px;
    line-height: 1.5;
}

.mcs-pc__notice-line:first-child {
    margin-bottom: 12px;
    font-weight: 600;
}

.mcs-pc__notice-line:last-child {
    margin-bottom: 0;
}

/* -------------------------------------------------------------- Petit écran */

/*
 * Sous 768 px, l'en-tête se coupe en deux : titre et « Voir tout » se
 * partagent la première ligne, la barre d'onglets prend la seconde et défile
 * horizontalement plutôt que de s'empiler sur trois lignes.
 */
@media (max-width: 767px) {
    .mcs-pc__head {
        gap: 14px 16px;
    }

    .mcs-pc__headings {
        order: 1;
    }

    .mcs-pc__view-alls {
        order: 2;
    }

    .mcs-pc__tabs {
        order: 3;
        flex: 1 0 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .mcs-pc__tabs::-webkit-scrollbar {
        display: none;
    }

    .mcs-pc__tab {
        white-space: nowrap;
    }

    .mcs-pc__heading {
        font-size: 18px;
    }

    /* Une carte pleine largeur n'a pas besoin d'un titre tronqué à deux
       lignes : la place ne manque plus. */
    .mcs-pc__title {
        -webkit-line-clamp: 3;
    }

    .mcs-pc__dots {
        flex-wrap: wrap;
        margin-top: 16px;
    }
}

/* Sur écran tactile il n'y a pas de survol : ni flèches, ni seconde photo —
   que le navigateur n'a alors aucune raison de télécharger. */
@media (hover: none) {
    .mcs-pc__viewport:hover .mcs-pc__arrow {
        display: none;
    }

    .mcs-pc__img--hover {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mcs-pc__img,
    .mcs-pc__img--hover {
        transition: none;
    }

    .mcs-pc__card:hover .mcs-pc__media:not(.mcs-pc__media--swap) .mcs-pc__img {
        transform: none;
    }
}
