@layer components {
    .product-card__visual {
        aspect-ratio: 1 / 1;
    }

    .product-card__visual img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .product-gallery__main {
        position: relative;
    }

    .product-gallery__arrow {
        position: absolute;
        z-index: 2;
        top: 50%;
        display: grid;
        width: 44px;
        height: 44px;
        place-items: center;
        padding: 0;
        border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
        border-radius: 50%;
        color: var(--text);
        background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
        box-shadow: var(--shadow-sm);
        cursor: pointer;
        transform: translateY(-50%);
        backdrop-filter: blur(14px);
    }

    .product-gallery__arrow:hover {
        color: #ffffff;
        border-color: transparent;
        background: linear-gradient(135deg, var(--primary), var(--violet));
    }

    .product-gallery__arrow--previous {
        left: 1rem;
    }

    .product-gallery__arrow--next {
        right: 1rem;
    }

    [dir="rtl"] .product-gallery__arrow--previous {
        right: 1rem;
        left: auto;
    }

    [dir="rtl"] .product-gallery__arrow--next {
        right: auto;
        left: 1rem;
    }

    .product-gallery__dots {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.45rem;
        margin-top: 0.85rem;
    }

    .product-gallery__dot {
        width: 9px;
        height: 9px;
        padding: 0;
        border: 0;
        border-radius: 999px;
        background: color-mix(in srgb, var(--text-muted) 42%, transparent);
        cursor: pointer;
        transition: width 170ms ease, background-color 170ms ease;
    }

    .product-gallery__dot.is-active {
        width: 30px;
        background: linear-gradient(90deg, var(--primary), var(--violet));
    }

    .catalog-result-summary {
        margin-bottom: 1rem;
        color: var(--text-muted);
        font-size: 0.82rem;
    }

    .catalog-pagination {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        gap: 1rem;
        margin-top: 2rem;
        padding: 0.75rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--surface);
        box-shadow: var(--shadow-sm);
    }

    .catalog-pagination__pages {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.4rem;
    }

    .catalog-pagination__page,
    .catalog-pagination__control {
        display: inline-flex;
        min-width: 42px;
        min-height: 42px;
        align-items: center;
        justify-content: center;
        gap: 0.45rem;
        padding: 0.65rem 0.85rem;
        border: 1px solid var(--border);
        border-radius: 999px;
        color: var(--text-soft);
        background: var(--surface-soft);
        font-size: 0.82rem;
        font-weight: 800;
    }

    .catalog-pagination__page:hover,
    .catalog-pagination__control:hover,
    .catalog-pagination__page.is-current {
        color: #ffffff;
        border-color: transparent;
        background: linear-gradient(135deg, var(--primary), var(--violet));
    }

    .catalog-pagination__control.is-disabled {
        cursor: not-allowed;
        opacity: 0.45;
    }

    @media (max-width: 680px) {
        .product-gallery__arrow {
            width: 40px;
            height: 40px;
        }

        .catalog-pagination {
            grid-template-columns: 1fr 1fr;
        }

        .catalog-pagination__pages {
            grid-column: 1 / -1;
            grid-row: 1;
        }

        .catalog-pagination__control {
            width: 100%;
        }
    }

    @media (max-width: 430px) {
        .product-gallery__thumbnails {
            grid-template-columns: repeat(3, 1fr);
        }

        .catalog-pagination__control span:not([aria-hidden]) {
            display: none;
        }
    }
}

/* =========================================================
   GALERIE DYNAMIQUE PAR VARIANTE
   ========================================================= */
@layer components {
    .product-gallery__arrow[hidden],
    .product-gallery__dots[hidden],
    .product-gallery__thumbnails[hidden],
    [data-product-main-image][hidden],
    [data-product-gallery-empty][hidden] {
        display: none !important;
    }

    .product-thumbnail[data-gallery-kind="variant"] {
        position: relative;
        border-color: color-mix(in srgb, var(--violet) 38%, transparent);
    }

    .product-thumbnail[data-gallery-kind="variant"]::after {
        position: absolute;
        right: 0.35rem;
        bottom: 0.35rem;
        width: 9px;
        height: 9px;
        border: 2px solid var(--surface-solid);
        border-radius: 50%;
        background: var(--violet);
        content: "";
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.24);
    }

    .product-thumbnail[data-gallery-kind="variant"].is-active {
        border-color: var(--violet);
        box-shadow: 0 0 0 3px var(--violet-soft);
    }
}

/* =========================================================
   RESPONSIVE — CONTENU DE LA FICHE PRODUIT
   ========================================================= */
@layer components {
    @media (max-width: 680px) {
        .product-content.section--compact {
            padding-block: 3.5rem;
            padding-inline: 0.35rem;
        }

        .product-content .product-rich-description,
        .product-content .product-content__inner {
            width: 100%;
        }
    }

    @media (max-width: 430px) {
        .product-content.section--compact {
            padding-block: 3rem;
            padding-inline: 0.45rem;
        }
    }
}

/* SHAPLINE V21 BEGIN PRODUCT CARD HOVER */
@layer components {
    .product-card__visual--hover-swap {
        isolation: isolate;
    }

    .product-card__visual--hover-swap .product-card__image {
        grid-area: 1 / 1;
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition:
            opacity 260ms ease,
            transform 320ms ease;
    }

    .product-card__visual--hover-swap .product-card__image--secondary {
        position: absolute;
        inset: 0;
        z-index: 1;
        opacity: 0;
        transform: scale(1.015);
    }

    .product-card__visual--hover-swap .product-card__image--primary {
        z-index: 0;
        opacity: 1;
    }

    @media (hover: hover) and (pointer: fine) {
        .product-card:hover
            .product-card__visual--hover-swap
            .product-card__image--primary {
            opacity: 0;
            transform: scale(1.015);
        }

        .product-card:hover
            .product-card__visual--hover-swap
            .product-card__image--secondary {
            opacity: 1;
            transform: scale(1.04);
        }
    }

    @media (hover: none) {
        .product-card__visual--hover-swap .product-card__image--secondary {
            display: none;
        }
    }

    @media (prefers-reduced-motion: reduce) {
        .product-card__visual--hover-swap .product-card__image {
            transition: none;
        }
    }
}


/* =========================================================
   CATALOGUE — RECHERCHE ET FILTRES DYNAMIQUES
   ========================================================= */

@layer components {
    .catalog-filter-panel {
        display: grid;
        gap: 1rem;
        margin-block: 1.5rem;
        padding: clamp(1rem, 3vw, 1.5rem);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--surface);
        box-shadow: var(--shadow-sm);
    }

    .catalog-filter-panel__primary {
        display: grid;
        grid-template-columns:
            minmax(220px, 0.65fr)
            minmax(280px, 1.35fr);
        gap: 1rem;
    }

    .catalog-filter-panel__search {
        min-width: 0;
    }

    .catalog-dynamic-filters {
        display: grid;
        grid-template-columns:
            repeat(
                auto-fit,
                minmax(min(100%, 220px), 1fr)
            );
        gap: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border);
    }

    .catalog-dynamic-filter {
        display: grid;
        align-content: start;
        gap: 0.65rem;
        min-width: 0;
        margin: 0;
        padding: 1rem;
        border: 1px solid var(--border);
        border-radius: 15px;
        background: var(--surface-soft);
    }

    .catalog-dynamic-filter legend {
        padding-inline: 0.3rem;
        color: var(--text);
        font-size: 0.82rem;
        font-weight: 850;
    }

    .catalog-dynamic-filter__choices {
        display: grid;
        gap: 0.45rem;
    }

    .catalog-filter-choice {
        display: flex;
        align-items: center;
        gap: 0.55rem;
        padding: 0.55rem 0.65rem;
        border-radius: 10px;
        color: var(--text-soft);
        background: var(--surface-solid);
        cursor: pointer;
        font-size: 0.8rem;
    }

    .catalog-filter-choice:hover {
        background: var(--surface-hover);
    }

    .catalog-filter-panel__actions {
        display: flex;
        justify-content: flex-end;
        gap: 0.65rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border);
    }

    @media (max-width: 760px) {
        .catalog-filter-panel__primary {
            grid-template-columns: 1fr;
        }
    }

    @media (max-width: 520px) {
        .catalog-filter-panel__actions {
            flex-direction: column-reverse;
        }

        .catalog-filter-panel__actions .btn {
            width: 100%;
        }
    }
}
/* SHAPLINE V21 END PRODUCT CARD HOVER */

/* SHAPLINE MULTILINGUAL TAGS + FILTER ROW V2 */
@layer components {
    /*
     * Le formulaire entier devient la ligne de composition. Les wrappers
     * primary/dynamic ne créent plus de colonnes séparées : leurs enfants
     * peuvent donc se placer les uns à la suite des autres tant qu'il reste
     * de la largeur disponible.
     */
    .catalog-filter-panel {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-end;
        gap: 1rem;
    }

    .catalog-filter-panel__primary,
    .catalog-dynamic-filters {
        display: contents;
    }

    .catalog-filter-panel__primary > .form-field,
    .catalog-dynamic-filter {
        min-width: min(100%, 220px);
        flex: 1 1 220px;
    }

    .catalog-filter-panel__search {
        min-width: min(100%, 300px);
        flex: 2 1 340px !important;
    }

    /*
     * Le fieldset reste présent pour l'accessibilité, mais devient
     * visuellement équivalent aux autres .form-field du catalogue.
     */
    .catalog-dynamic-filter {
        display: grid;
        align-content: start;
        gap: 0.48rem;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
    }

    .catalog-dynamic-filter legend {
        display: block;
        float: none;
        width: 100%;
        margin: 0;
        padding: 0;
        color: var(--text);
        font-size: 0.84rem;
        font-weight: 780;
        line-height: 1.35;
    }

    .catalog-dynamic-filter .form-control {
        width: 100%;
        margin: 0;
    }

    .catalog-dynamic-filter__choices {
        display: flex;
        flex-wrap: wrap;
        gap: 0.45rem;
    }

    .catalog-filter-choice {
        min-height: 44px;
        flex: 0 1 auto;
    }

    .catalog-filter-panel__actions {
        width: 100%;
        flex: 1 0 100%;
    }

    @media (max-width: 760px) {
        .catalog-filter-panel {
            display: grid;
            grid-template-columns: 1fr;
            align-items: stretch;
        }

        .catalog-filter-panel__primary > .form-field,
        .catalog-dynamic-filter,
        .catalog-filter-panel__search,
        .catalog-filter-panel__actions {
            width: 100%;
            min-width: 0;
        }

        .catalog-dynamic-filter__choices {
            display: grid;
            grid-template-columns: 1fr;
        }
    }
}
