/**
 * Styles pour la grille de sous-catégories
 * Design responsive avec overlay sur les images
 */


/* Container principal */
.cm-grid-sous-categories-wrapper {
    width: 100%;
    /* margin: 2rem 0;
    padding-top: 2rem; */
    clear: both;
    display: block;
    position: relative;
    z-index: auto;
}

/* Clearfix pour éviter les superpositions */
.cm-grid-sous-categories-wrapper::after {
    content: "";
    display: table;
    clear: both;
}

/* Grille responsive */
.cm-grid-sous-categories {
    display: grid;
    gap: 1.5rem;
    width: 100%;
    position: static;
}

/* Colonnes par défaut (desktop - 4 colonnes) */
.cm-grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.cm-grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.cm-grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.cm-grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.cm-grid-cols-5 { grid-template-columns: repeat(5, 1fr); }
.cm-grid-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* Carte de catégorie */
.cm-category-card {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #f5f5f5;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    aspect-ratio: 4 / 3;
    width: 100%;
    display: block;
    margin-bottom: 0;
}

.cm-category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

/* Lien de la carte */
.cm-category-card-link {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

/* Wrapper d'image */
.cm-category-image-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.cm-category-image-wrapper img,
.cm-category-image-wrapper .cm-category-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transition: transform 0.3s ease;
    display: block;
    mix-blend-mode: multiply;
    filter: contrast(1.1) brightness(1.05);
}

.cm-category-card:hover .cm-category-image-wrapper img {
    transform: scale(1.05);
}

/* Overlay sombre */
.cm-category-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    transition: background 0.3s ease;
}

.cm-category-card:hover .cm-category-overlay {
    background: rgba(0, 0, 0, 0.6);
}

/* Image non disponible */
.cm-category-no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #9e9e9e;
    color: white;
    font-size: 0.9rem;
}

/* Titre de la catégorie */
.cm-category-title-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    padding: 1.5rem;
    z-index: 2;
    text-align: center;
}

.cm-category-title {
    color: white !important;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    line-height: 1.3;
}

/* Message quand aucune catégorie */
.no-categories {
    text-align: center;
    padding: 2rem;
    color: #666;
    font-size: 1.1rem;
}

/* Spacer mobile - invisible par défaut */
.cm-grid-spacer-mobile {
    display: none;
}

/* --- RESPONSIVE --- */

/* Tablette (768px - 1024px) : 2 colonnes */
@media screen and (max-width: 1024px) {
    .cm-grid-sous-categories-wrapper {
        /* margin: 3rem 0;
        padding: 2rem 0; */
    }
    
    .cm-grid-cols-3,
    .cm-grid-cols-4,
    .cm-grid-cols-5,
    .cm-grid-cols-6 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .cm-grid-sous-categories {
        gap: 1.25rem;
    }
    
    .cm-category-card {
        min-height: 180px;
    }
    
    .cm-category-title {
        font-size: 1.1rem;
    }
    
    .cm-category-title-wrapper {
        padding: 1.25rem;
    }
}

/* Mobile (moins de 768px) : 1 colonne */
@media screen and (max-width: 767px) {
    .cm-grid-sous-categories-wrapper {
        /* margin: 3rem 0 0 0 !important;
        padding: 2rem 0 0 0 !important; */
        width: 100%;
        display: block;
        overflow: visible;
    }
    
    .cm-grid-sous-categories {
        display: block;
        width: 100%;
        margin-bottom: 0;
    }
    
    .cm-category-card {
        aspect-ratio: 4 / 3;
        min-height: 200px;
        margin-bottom: 2rem;
        display: block;
        width: 100%;
        position: relative;
        clear: both;
    }
    
    .cm-category-card:last-child {
        margin-bottom: 2rem;
    }
    
    .cm-category-title {
        font-size: 1.1rem;
    }
    
    .cm-category-title-wrapper {
        padding: 1.25rem;
    }
    
    /* Activer le spacer mobile */
    .cm-grid-spacer-mobile {
        display: block !important;
        height: 15rem !important;
        width: 100%;
        clear: both;
        float: none;
    }
}

/* Très petit mobile (moins de 480px) */
@media screen and (max-width: 480px) {
    .cm-grid-sous-categories-wrapper {
        /* margin: 3rem 0 0 0 !important;
        padding: 2rem 0 0 0 !important; */
    }
    
    .cm-category-card {
        min-height: 180px;
        margin-bottom: 1.5rem;
    }
    
    .cm-category-card:last-child {
        margin-bottom: 1.5rem;
    }
    
    .cm-category-title {
        font-size: 1rem;
    }
    
    .cm-category-title-wrapper {
        padding: 1rem;
    }
    
    /* Spacer encore plus grand sur petit mobile */
    .cm-grid-spacer-mobile {
        height: 20rem !important;
    }
}
