/* 
 * Studio5Sens - Correctifs pour l'alignement vertical des cartes
 * Cette feuille de style corrige les problèmes de chevauchement des cartes dans les colonnes
 */

/* ========= CORRECTIONS POUR LE CHEVAUCHEMENT DES CARTES ========= */

/* Structure de base du portfolio */
#portfolio.portfolio.row {
    display: block !important;
    /* Annulation de flex pour éviter les problèmes de mise en page */
    margin: 0 -15px;
    overflow: hidden;
    clear: both;
}

/* Corriger les articles (cartes) */
.portfolio-item {
    float: left;
    padding: 0 15px;
    margin-bottom: 50px !important;
    /* Espace suffisant entre les rangées */
    position: relative;
    box-sizing: border-box;
}

/* Forcer le dimensionnement correct des colonnes responsive */
@media (min-width: 992px) {
    .col-lg-3 {
        width: 25%;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .col-md-4 {
        width: 33.333%;
    }
}

@media (min-width: 576px) and (max-width: 767px) {
    .col-sm-6 {
        width: 50%;
    }
}

@media (max-width: 575px) {
    .portfolio-item {
        width: 100%;
    }
}

/* Encapsuler le contenu complet de la carte */
.portfolio-item article {
    margin-bottom: 0 !important;
}

/* Ajuster les grids internes pour contenir tout le contenu */
.grid-inner {
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    background-color: white;
    overflow: visible !important;
    /* Permet aux éléments h6 de sortir de la carte */
    position: relative;
    margin-bottom: 30px;
    /* Espace supplémentaire en bas */
    height: auto !important;
    display: block;
}

/* Style pour les informations administratives (h6) */
.portfolio-item h6 {
    font-size: 0.7rem !important;
    color: #888;
    margin: 5px 0 25px !important;
    padding: 0 15px !important;
    text-align: center;
    font-style: italic;
    line-height: 1.3 !important;
    position: relative;
    z-index: 1;
    clear: both;
}

/* Image container */
.portfolio-image {
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* Images dans la galerie */
.portfolio-image img {
    max-width: 100% !important;
    height: auto !important;
    max-height: 300px !important;
    display: block;
    margin: 0 auto;
    object-fit: cover;
}

/* Description */
.portfolio-desc {
    padding: 15px !important;
    text-align: center;
    position: relative;
    z-index: 1;
}

/* Titre dans la description */
.portfolio-desc .titre h2 {
    font-size: 18px !important;
    margin: 0 0 10px !important;
    line-height: 1.3 !important;
}

/* Chapeau (intro text) */
#chapeau {
    min-height: auto !important;
    margin-bottom: 15px !important;
}

/* Boutons */
.button {
    margin: 10px auto !important;
    display: inline-block;
}

/* Nettoyage des flottements après chaque rangée */
.row:after,
#portfolio:after,
.portfolio-item:after {
    content: "";
    display: table;
    clear: both;
}

/* ========= CORRECTIONS POUR LA HAUTEUR DES CARTES ========= */

/* Normaliser les hauteurs dans chaque rangée */
@media (min-width: 768px) {
    .row {
        display: flex;
        flex-wrap: wrap;
    }

    .row:before,
    .row:after {
        display: none;
    }

    /* Correction des flottements */
    .clearfix:before,
    .clearfix:after,
    .container:before,
    .container:after {
        content: " ";
        display: table;
    }

    .clearfix:after,
    .container:after {
        clear: both;
    }
}

/* ========= STYLE POUR PANEL ADMIN ========= */

.admin-panel {
    margin: 0 0 30px 0 !important;
}

/* ========= CORRECTIONS SUPPLÉMENTAIRES POUR ÉCRANS MOBILES ========= */

@media (max-width: 767px) {
    .portfolio-item {
        margin-bottom: 40px !important;
    }

    .grid-inner {
        margin-bottom: 20px;
    }

    .portfolio-item h6 {
        margin: 0 0 20px !important;
    }
}

/* ========= SOLUTION DE SECOURS RADICALE ========= */

/* Cette solution est un peu drastique mais garantit que les cartes ne se chevauchent pas */
h6 {
    position: relative !important;
    display: block !important;
    clear: both !important;
    float: none !important;
    margin-top: 10px !important;
    margin-bottom: 20px !important;
    padding-top: 0 !important;
    padding-bottom: 10px !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Assurer que le conteneur principal peut s'étendre pour accommoder tous les éléments */
.container {
    overflow: visible !important;
}

/* Éliminer tout chevauchement potentiel */
* {
    overflow: visible;
}

/* Alignement correct des titres */
.titre {
    clear: both;
}

/* Faire en sorte que les cartes forment une grille claire */
.gutter-20>[class*="col-"] {
    padding-right: 10px;
    padding-left: 10px;
}

/* Style de grille forcé */
.grid-container {
    display: block;
    margin-left: -10px;
    margin-right: -10px;
    width: calc(100% + 20px) !important;
}

/* Solution pour iOS Safari qui peut avoir des problèmes avec les hauteurs */
@supports (-webkit-touch-callout: none) {
    .portfolio-item {
        margin-bottom: 60px !important;
        /* Plus d'espace sur iOS */
    }
}