/* ============================================================
   ACCUEIL — CATALOGUE + NOUVEAUTÉS + NOTRE SÉLECTION
   ============================================================ */

.ebox-home-showcase {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 34px;
    align-items: start;

    width: 100%;
    max-width: none;

    margin: 24px 0 0;
    padding: 0;

    box-sizing: border-box;
}

.ebox-home-showcase__sidebar,
.ebox-home-showcase__content {
    min-width: 0;
}

.ebox-home-showcase__sidebar .ebox-filters-sidebar {
    position: static !important;
    top: auto !important;

    width: 100%;
    margin: 0;
}


/* ============================================================
   RANGÉES : NOUVEAUTÉS / NOTRE SÉLECTION
   ============================================================ */

.ebox-home-row {
    position: relative;

    width: 100%;
    margin: 0 0 38px;
}

.ebox-home-row:last-child {
    margin-bottom: 0;
}


/* ============================================================
   BANDEAU DE TITRE
   Inspiration de l’ancien site, adaptée au nouveau design
   ============================================================ */

.ebox-home-row__header {
    position: relative;

    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;

    width: 100%;
    min-height: 58px;

    margin: 0 0 22px;
    padding: 0;

    border-bottom: 5px solid #b5813e;
    box-sizing: border-box;
}

.ebox-home-row__title {
    position: relative;
    z-index: 2;

    display: inline-flex;
    align-items: center;
    gap: 10px;

    min-width: 360px;
    max-width: 70%;

    margin: 0;
    padding: 13px 62px 13px 20px;

    background:
        linear-gradient(
            180deg,
            #ead9c4 0%,
            #d8bea1 100%
        );

    color: #4a2a16;

    border: 1px solid #c9ab8b;
    border-bottom: 0;
    border-radius: 14px 72px 0 14px;

    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    text-transform: uppercase;

    box-shadow: 0 4px 12px rgba(74, 42, 22, .10);

    box-sizing: border-box;
}

.ebox-home-row__icon {
    flex: 0 0 auto;

    color: #5a3219;

    font-size: 25px;
    line-height: 1;
}


/* ===== Lien à droite du bandeau ===== */

.ebox-home-row__more {
    position: relative;
    z-index: 3;

    display: inline-flex;
    align-items: center;
    gap: 8px;

    margin: 0 4px 8px auto;
    padding: 5px 8px;

    background: #f7f3ed;
    color: #4a2a16;

    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;

    text-decoration: none !important;
    white-space: nowrap;

    transition:
        color .2s ease,
        transform .2s ease;
}

.ebox-home-row__more:hover,
.ebox-home-row__more:focus-visible {
    color: #7a4828;
    transform: translateX(3px);
    outline: none;
}


/* ============================================================
   PRODUITS — 4 COUVERTURES PAR LIGNE
   ============================================================ */

.ebox-home-row__products {
    position: relative;

    width: 100%;
    min-width: 0;
}

.ebox-home-row__products .woocommerce {
    width: 100%;
    margin: 0;
}


/* ============================================================
   CARROUSEL
   ============================================================ */

.ebox-home-carousel {
    position: relative;
    width: 100%;
    min-width: 0;
}

.ebox-home-carousel__viewport {
    width: 100% !important;
    min-width: 0 !important;

    overflow-x: auto !important;
    overflow-y: hidden !important;

    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;

    -webkit-overflow-scrolling: touch;
}

.ebox-home-carousel__viewport::-webkit-scrollbar {
    display: none;
}


/* ===== Conteneur WooCommerce ===== */

.ebox-home-row__products {
    width: 100% !important;
    min-width: 0 !important;
}

.ebox-home-row__products .woocommerce {
    width: 100% !important;
    margin: 0 !important;
}


/* ===== Une seule ligne horizontale ===== */

.ebox-home-row__products ul.products {
    --ebox-carousel-gap: 28px;

    display: flex !important;
    flex-flow: row nowrap !important;
    align-items: stretch !important;

    gap: var(--ebox-carousel-gap) !important;

    width: 100% !important;
    min-width: 100% !important;

    margin: 0 !important;
    padding: 0 !important;

    list-style: none !important;
}

.ebox-home-row__products ul.products::before,
.ebox-home-row__products ul.products::after {
    display: none !important;
}


/* Centrage lorsqu’il y a moins de quatre ouvrages */

.ebox-home-row__products ul.products.is-centered {
    justify-content: center !important;
}


/* ===== Exactement quatre cartes visibles ===== */

.ebox-home-row__products ul.products li.product {
    flex: 0 0 calc(
        (100% - (3 * var(--ebox-carousel-gap))) / 4
    ) !important;

    width: calc(
        (100% - (3 * var(--ebox-carousel-gap))) / 4
    ) !important;

    min-width: 0 !important;
    max-width: none !important;

    display: flex !important;
    flex-direction: column !important;

    float: none !important;
    clear: none !important;

    margin: 0 !important;
    padding: 0 !important;

    scroll-snap-align: start;

    background: #fff !important;
    border-radius: 12px !important;
    overflow: hidden !important;

    box-shadow: 0 8px 24px rgba(74, 42, 22, .09) !important;
}


/* ============================================================
   CARTES ET COUVERTURES UNIFORMES
   ============================================================ */

.ebox-home-row__products .ebox-book-card {
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;

    width: 100% !important;
    height: 100% !important;
}

.ebox-home-row__products .ebox-book-card__cover {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    width: 100% !important;
    height: 330px !important;
    min-height: 330px !important;
    max-height: 330px !important;

    padding: 10px !important;

    background: #f8fafc !important;
    overflow: hidden !important;

    box-sizing: border-box !important;
}

.ebox-home-row__products .ebox-book-card__cover img {
    display: block !important;

    width: auto !important;
    max-width: 100% !important;

    height: auto !important;
    max-height: 310px !important;

    margin: 0 auto !important;

    object-fit: contain !important;
    object-position: center center !important;
}

.ebox-home-row__products .ebox-book-card__body {
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;

    width: 100% !important;
    padding: 12px 14px 16px !important;

    text-align: center !important;
    box-sizing: border-box !important;
}

.ebox-home-row__products .ebox-book-card__title {
    margin: 0 0 8px !important;

    font-size: 16px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
}

.ebox-home-row__products .ebox-book-card__author {
    margin: 4px 0 9px !important;

    font-size: 13px !important;
    line-height: 1.4 !important;
}

.ebox-home-row__products .ebox-book-card__meta {
    margin-bottom: 8px !important;
    font-size: 13px !important;
}

.ebox-home-row__products .ebox-book-card__price {
    margin-top: auto !important;

    font-size: 16px !important;
    font-weight: 700 !important;
}


/* ============================================================
   FLÈCHES DU CARROUSEL
   ============================================================ */

.ebox-home-carousel__button {
    position: absolute;
    z-index: 20;
    top: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 44px;
    height: 44px;

    margin: 0;
    padding: 0;

    border: 1px solid rgba(74, 42, 22, .14);
    border-radius: 50%;

    background: #fff !important;
    color: #4a2a16 !important;

    font-size: 28px;
    line-height: 1;

    cursor: pointer;

    box-shadow: 0 6px 18px rgba(74, 42, 22, .15);

    transform: translateY(-50%);

    transition:
        transform .2s ease,
        opacity .2s ease,
        background-color .2s ease;
}

.ebox-home-carousel__button:hover,
.ebox-home-carousel__button:focus-visible {
    background: #efe4d6 !important;

    transform:
        translateY(-50%)
        scale(1.06);

    outline: none;
}

.ebox-home-carousel__button--prev {
    left: -38px;
}

.ebox-home-carousel__button--next {
    right: -38px;
}

.ebox-home-carousel__button:disabled {
    opacity: .3;
    cursor: default;
    pointer-events: none;
}

.ebox-home-carousel__button[hidden] {
    display: none !important;
}


/* Supprimer définitivement l’ancienne fausse flèche */

.ebox-home-row::after {
    content: none !important;
    display: none !important;
}


/* ============================================================
   ALIGNEMENT AVEC LE HERO
   ============================================================ */

.home .entry-content > .wp-block-shortcode:has(.ebox-home-showcase) {
    width: 100% !important;
    max-width: none !important;

    margin: 0 !important;
    padding: 0 !important;
}

.home .ebox-home-showcase {
    width: 100% !important;
    max-width: none !important;
}


/* ============================================================
   RESPONSIVE — TABLETTE
   ============================================================ */

@media (max-width: 1100px) {

    .ebox-home-showcase {
        grid-template-columns: 1fr;
    }

    .ebox-home-showcase__sidebar .ebox-filters-sidebar {
        position: static !important;
    }

    .ebox-home-row__products ul.products li.product {
        flex-basis: calc(
            (100% - (2 * var(--ebox-carousel-gap))) / 3
        ) !important;

        width: calc(
            (100% - (2 * var(--ebox-carousel-gap))) / 3
        ) !important;
    }
}


/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */

@media (max-width: 760px) {

    .ebox-home-showcase {
        gap: 24px;
    }

    .ebox-home-row {
        margin-bottom: 30px;
    }

    .ebox-home-row__header {
        align-items: stretch;
        flex-direction: column;
        gap: 0;

        min-height: 0;

        border-bottom-width: 4px;
    }

    .ebox-home-row__title {
        width: 100%;
        min-width: 0;
        max-width: 100%;

        padding: 12px 18px;

        border-radius: 12px 42px 0 0;

        font-size: 21px;
    }

    .ebox-home-row__more {
        align-self: flex-end;

        margin: 4px 0 5px;
        padding: 4px 0;
    }

    .ebox-home-row__products ul.products {
        --ebox-carousel-gap: 18px;
    }

    .ebox-home-row__products ul.products li.product {
        flex-basis: calc(
            (100% - var(--ebox-carousel-gap)) / 2
        ) !important;

        width: calc(
            (100% - var(--ebox-carousel-gap)) / 2
        ) !important;
    }

    .ebox-home-row__products .ebox-book-card__cover {
        height: 280px !important;
        min-height: 280px !important;
        max-height: 280px !important;
    }

    .ebox-home-row__products .ebox-book-card__cover img {
        max-height: 260px !important;
    }

    .ebox-home-carousel__button {
        width: 38px;
        height: 38px;

        font-size: 24px;
    }

    .ebox-home-carousel__button--prev {
        left: -12px;
    }

    .ebox-home-carousel__button--next {
        right: -12px;
    }
}


/* ============================================================
   RESPONSIVE — PETIT MOBILE
   ============================================================ */

@media (max-width: 480px) {

    .ebox-home-row__title {
        gap: 8px;

        padding: 11px 15px;

        border-radius: 10px 28px 0 0;

        font-size: 18px;
    }

    .ebox-home-row__icon {
        font-size: 21px;
    }

    .ebox-home-row__more {
        font-size: 13px;
    }

    .ebox-home-row__products ul.products li.product {
        flex-basis: 100% !important;
        width: 100% !important;
    }

    .ebox-home-carousel__button {
        display: none !important;
    }
}


/* ============================================================
   ACCUEIL — BOUTON SERVICES
   ============================================================ */

.ebox-home-services-button {
    display: flex;
    align-items: center;
    justify-content: space-between;

    width: 100%;
    margin: 16px 0;
    padding: 20px 22px;

    box-sizing: border-box;

    background: #4a2a16;
    color: #ffffff !important;

    border: 0;
    border-radius: 12px;

    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);

    font-family: inherit;
    font-size: 20px;
    line-height: 1.2;
    font-weight: 700;

    text-transform: uppercase;
    text-decoration: none !important;
}

.ebox-home-services-button:hover,
.ebox-home-services-button:focus {
    background: #62391f;
    color: #ffffff !important;
    text-decoration: none !important;
}

.ebox-home-services-button__arrow {
    margin-left: auto;
    font-size: 24px;
    line-height: 1;
    font-weight: 400;
}


/* ============================================================
   NOTRE SÉLECTION — 2 LIGNES × 4 OUVRAGES
   ============================================================ */

.ebox-home-row--selection .ebox-home-row__products ul.products {
    display: grid !important;

    grid-template-rows: repeat(2, auto) !important;
    grid-auto-flow: column !important;

    /*
     * Chaque groupe de 4 colonnes = une page.
     * 2 lignes × 4 colonnes = 8 ouvrages visibles.
     */
    grid-auto-columns: calc(
        (100% - (3 * var(--ebox-carousel-gap))) / 4
    ) !important;

    align-items: stretch !important;

    width: max-content !important;
    min-width: 100% !important;
}

/* Chaque carte garde exactement 1/4 de la largeur visible */

.ebox-home-row--selection
.ebox-home-row__products
ul.products
li.product {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;

    flex: none !important;
}



/* ============================================================
   ACCUEIL — CARROUSELS 1 LIGNE / 5 CARTES
   ============================================================ */

.ebox-home-carousel {
    position: relative;
    width: 100%;
    min-width: 0;
}

.ebox-home-carousel__viewport {
    width: 100% !important;
    min-width: 0 !important;

    overflow-x: auto !important;
    overflow-y: hidden !important;

    scroll-behavior: smooth;
    scrollbar-width: none;

    -webkit-overflow-scrolling: touch;
}

.ebox-home-carousel__viewport::-webkit-scrollbar {
    display: none;
}


/* ===== Une seule ligne horizontale ===== */

.ebox-home-row__products {
    width: 100% !important;
    min-width: 0 !important;
}

.ebox-home-row__products .woocommerce {
    width: 100% !important;
    margin: 0 !important;
}

.ebox-home-row__products ul.products {
    --ebox-carousel-gap: 20px;

    display: flex !important;
    flex-flow: row nowrap !important;
    align-items: stretch !important;

    gap: var(--ebox-carousel-gap) !important;

    width: 100% !important;
    min-width: 100% !important;

    margin: 0 !important;
    padding: 0 !important;
}

.ebox-home-row__products ul.products::before,
.ebox-home-row__products ul.products::after {
    display: none !important;
}


/* ===== Exactement 5 cartes visibles ===== */

.ebox-home-row__products ul.products li.product {
    flex: 0 0 calc(
        (100% - (4 * var(--ebox-carousel-gap))) / 5
    ) !important;

    width: calc(
        (100% - (4 * var(--ebox-carousel-gap))) / 5
    ) !important;

    min-width: 0 !important;
    max-width: none !important;

    float: none !important;
    clear: none !important;

    margin: 0 !important;
}


/* ===== Centrer si moins de 5 ouvrages ===== */

.ebox-home-row__products ul.products.is-centered {
    justify-content: center !important;
}


/* ===== Flèches ===== */

.ebox-home-carousel__button {
    position: absolute;
    z-index: 20;
    top: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 42px;
    height: 42px;

    padding: 0;

    border: 1px solid rgba(74, 42, 22, .14);
    border-radius: 50%;

    background: #fff !important;
    color: #4a2a16 !important;

    cursor: pointer;

    box-shadow: 0 6px 18px rgba(74, 42, 22, .15);

    transform: translateY(-50%);
}

.ebox-home-carousel__button--prev {
    left: -22px;
}

.ebox-home-carousel__button--next {
    right: -22px;
}

.ebox-home-carousel__button:disabled {
    opacity: .3;
    pointer-events: none;
}

.ebox-home-carousel__button[hidden] {
    display: none !important;
}

.ebox-home-carousel__button span {
    font-size: 26px;
    line-height: 1;
}


/* ===== Supprimer ancienne fausse flèche éventuelle ===== */

.ebox-home-row::after {
    content: none !important;
    display: none !important;
}


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1100px) {

    .ebox-home-row__products ul.products li.product {
        flex-basis: calc(
            (100% - (3 * var(--ebox-carousel-gap))) / 4
        ) !important;

        width: calc(
            (100% - (3 * var(--ebox-carousel-gap))) / 4
        ) !important;
    }
}

@media (max-width: 850px) {

    .ebox-home-row__products ul.products li.product {
        flex-basis: calc(
            (100% - (2 * var(--ebox-carousel-gap))) / 3
        ) !important;

        width: calc(
            (100% - (2 * var(--ebox-carousel-gap))) / 3
        ) !important;
    }
}

@media (max-width: 600px) {

    .ebox-home-row__products ul.products {
        --ebox-carousel-gap: 16px;
    }

    .ebox-home-row__products ul.products li.product {
        flex-basis: calc(
            (100% - var(--ebox-carousel-gap)) / 2
        ) !important;

        width: calc(
            (100% - var(--ebox-carousel-gap)) / 2
        ) !important;
    }
}

@media (max-width: 420px) {

    .ebox-home-row__products ul.products li.product {
        flex-basis: 100% !important;
        width: 100% !important;
    }

    .ebox-home-carousel__button {
        display: none !important;
    }
}


/* ============================================================
   CORRECTION FINALE — NOTRE SÉLECTION SUR UNE SEULE LIGNE
   ============================================================ */

.ebox-home-row--selection
.ebox-home-row__products
ul.products {
    display: flex !important;
    flex-flow: row nowrap !important;
    align-items: stretch !important;

    gap: 20px !important;

    width: 100% !important;
    min-width: 100% !important;

    margin: 0 !important;
    padding: 0 !important;
}

.ebox-home-row--selection
.ebox-home-row__products
ul.products
li.product {
    flex: 0 0 calc((100% - 80px) / 5) !important;

    width: calc((100% - 80px) / 5) !important;

    min-width: 0 !important;
    max-width: none !important;

    margin: 0 !important;
}


<div class="ebox-home-selection-grid">

    <?php
    echo do_shortcode(
        '[products ids="' .
        esc_attr(
            implode(',', $selection_ids)
        ) .
        '" columns="5" orderby="post__in"]'
    );
    ?>

</div>


/* ============================================================
   NOTRE SÉLECTION — RESPONSIVE MOBILE
   ============================================================ */

.ebox-home-selection-grid {
    width: 100%;
    min-width: 0;
}

.ebox-home-selection-grid .woocommerce {
    width: 100%;
}

.ebox-home-selection-grid ul.products {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 20px !important;

    width: 100% !important;
    min-width: 0 !important;

    margin: 0 !important;
    padding: 0 !important;
}

.ebox-home-selection-grid ul.products li.product {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;

    margin: 0 !important;
    float: none !important;
    clear: none !important;

    overflow: visible !important;
}

.ebox-home-selection-grid .ebox-book-card,
.ebox-home-selection-grid .ebox-book-card__body,
.ebox-home-selection-grid .ebox-book-card__title,
.ebox-home-selection-grid .ebox-book-card__author,
.ebox-home-selection-grid .ebox-book-card__meta,
.ebox-home-selection-grid .ebox-book-card__price {
    min-width: 0 !important;
    width: 100% !important;
}

.ebox-home-selection-grid .ebox-book-card__title,
.ebox-home-selection-grid .ebox-book-card__author,
.ebox-home-selection-grid .ebox-book-card__price {
    overflow-wrap: normal !important;
    word-break: normal !important;
    white-space: normal !important;
    hyphens: auto;
}


/* Tablette */

@media (max-width: 1100px) {

    .ebox-home-selection-grid ul.products {
        grid-template-columns:
            repeat(4, minmax(0, 1fr)) !important;
    }
}


/* Petite tablette */

@media (max-width: 900px) {

    .ebox-home-selection-grid ul.products {
        grid-template-columns:
            repeat(3, minmax(0, 1fr)) !important;
    }
}


/* Mobile */

@media (max-width: 768px) {

    .ebox-home-selection-grid ul.products {
        grid-template-columns:
            repeat(2, minmax(0, 1fr)) !important;

        gap: 16px !important;
    }

    .ebox-home-selection-grid .ebox-book-card__cover {
        height: 240px !important;
        min-height: 240px !important;
        max-height: 240px !important;
    }

    .ebox-home-selection-grid .ebox-book-card__cover img {
        max-height: 220px !important;
    }

    .ebox-home-selection-grid .ebox-book-card__title {
        font-size: 15px !important;
        line-height: 1.35 !important;
    }
}


/* Petit mobile */

@media (max-width: 480px) {

    .ebox-home-selection-grid ul.products {
        grid-template-columns: 1fr !important;
    }

    .ebox-home-selection-grid .ebox-book-card__cover {
        height: 320px !important;
        min-height: 320px !important;
        max-height: 320px !important;
    }

    .ebox-home-selection-grid .ebox-book-card__cover img {
        max-height: 300px !important;
    }
}