/* ==========================================
   GRILLE CSS MODERNE - COLORIAGES A IMPRIMER
   coloriageGridModerne.css
   
   Ce fichier contient les styles pour la nouvelle
   structure CSS Grid des pages de coloriages.
   Appliquer uniquement aux pages migrées.
   ========================================== */

/* ==========================================
   SECTION CONTAINER
   ========================================== */

/* Section container pour éviter le débordement */
.coloriages-section {
    overflow: hidden;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    padding: 0 2%;
}

/* ==========================================
   GRILLE PRINCIPALE - ULTRA FLUIDE ET AÉRÉE
   ========================================== */

.coloriages-grid {
    display: grid;
    /* 
     * Grille auto-adaptative : 
     * - minmax(220px, 1fr) : colonnes min 220px, réparties équitablement
     * - auto-fit : remplit l'espace disponible, réduit colonnes si nécessaire
     */
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    /* 
     * Gap ROBUSTE avec minimum STRICT à 40px :
     * - Minimum 40px (jamais moins, garantit l'aération)
     * - Préféré 6vw (s'adapte à la largeur viewport)
     * - Maximum 70px (évite les écarts excessifs)
     */
    gap: clamp(40px, 6vw, 70px);
    padding: clamp(25px, 5vw, 50px) 0;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0 auto;
}

/* ==========================================
   CARTES DE COLORIAGE
   ========================================== */

/* Carte individuelle de coloriage - AVEC MARGE DE SÉCURITÉ */
.coloriage-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    /* Marge de sécurité : garantit l'aération même si gap au minimum */
    margin: 5px;
    padding: 5px;
}

/* Figure dans les cartes grid */
.coloriage-card figure {
    margin: 0;
    padding: 15px;
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: inline-block;
}

.coloriage-card figure:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.coloriage-card figure img {
    border-radius: 8px;
    transition: transform 0.3s ease;
    max-width: 100%;
    height: auto;
}

.coloriage-card figure:hover img {
    transform: scale(1.03);
}

/* Lien PDF dans les cartes */
.coloriage-card .coloriage-btn-pdf {
    margin-top: 12px;
}

/* ==========================================
   SECTION ALBUMS PDF (NOUVELLE STRUCTURE)
   ========================================== */

.albums-section {
    margin-top: 40px;
    padding-top: 20px;
}

.albums-intro {
    text-align: center;
    margin-bottom: 30px;
}

.albums-intro h2 {
    color: #ffffcc;
    font-weight: normal;
    font-size: 16px;
    text-decoration: underline;
    margin-bottom: 20px;
}

.albums-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    justify-items: center;
}

.album-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.album-card img {
    max-width: 225px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.album-card:hover img {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.album-card .coloriage-btn-pdf {
    margin-top: 15px;
}

/* ==========================================
   LÉGENDES POUR NOUVEAU CSS GRID
   ========================================== */

.ColoriageGridCaption {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-align: center;
    padding: 5px 8px;
    line-height: 1.3;
}

/* ==========================================
   LIENS ET BOUTONS
   ========================================== */

/* Bouton PDF - Nouvelle classe dédiée (remplace legacy .liensgg) */
.coloriage-btn-pdf {
    display: inline-block;
    margin-top: 12px;
    padding: 8px 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff !important;
    text-decoration: none;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

.coloriage-btn-pdf:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);
}

/* Lien coloriage (vignette cliquable) */
.coloriageLink {
    text-decoration: none;
    color: inherit;
    display: block;
}

.coloriageLink:hover {
    text-decoration: none;
}

/* ==========================================
   FENÊTRE MODALE
   ========================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    opacity: 1;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border: none;
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(-20px);
    transition: transform 0.3s ease;
    overflow: visible;
    position: relative;
}

.modal.show .modal-content {
    transform: scale(1) translateY(0);
}

/* Header de la modale */
.modal-header {
    display: flex;
    justify-content: flex-end;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Bouton fermeture - bien visible en haut à droite */
.modal .close {
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    transition: all 0.3s ease;
    line-height: 1;
    float: none;
    position: absolute;
    top: -15px;
    right: -15px;
    z-index: 10001;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
    border: 3px solid #fff;
}

.modal .close:hover,
.modal .close:focus {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    transform: scale(1.1);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.5);
}

/* Loader */
.modal-loader {
    display: none;
    text-align: center;
    padding: 60px 40px;
    background: #fff;
}

.modal-loader.show {
    display: block;
}

.modal-loader::after {
    content: '';
    display: inline-block;
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: modalSpin 1s linear infinite;
}

@keyframes modalSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Iframe */
#modalIframe {
    display: block;
    border: none;
    width: 100%;
    min-height: 500px;
    background: #fff;
}

/* ==========================================
   RESPONSIVE DESIGN - GRILLE MODERNE
   ========================================== */

/* Tablette / petit desktop : ajustements fins */
@media screen and (max-width: 960px) {
    .coloriages-grid {
        /* Colonnes plus petites pour permettre 2 sur tablette */
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        /* Gap fluide maintenu */
        gap: clamp(25px, 4vw, 50px);
    }

    .albums-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: clamp(20px, 4vw, 35px);
    }

    .modal-content {
        max-width: 80%;
        margin: 8% auto;
    }

    #modalIframe {
        min-height: 450px;
    }
}

/* Mobile : colonne unique avec espacement fluide */
@media screen and (max-width: 640px) {
    .coloriages-grid {
        grid-template-columns: 1fr;
        /* Gap fluide pour mobile - minimum 25px */
        gap: clamp(25px, 6vw, 40px);
        padding: clamp(15px, 4vw, 25px) 0;
    }

    .coloriage-card figure {
        padding: 12px;
        width: 100%;
        max-width: 280px;
    }

    .albums-grid {
        grid-template-columns: 1fr;
        gap: clamp(20px, 5vw, 30px);
    }

    .album-card img {
        max-width: 200px;
    }

    .ColoriageGridCaption {
        font-size: 13px;
    }

    .coloriage-btn-pdf {
        font-size: 11px;
        padding: 7px 14px;
    }

    .modal-content {
        max-width: 95%;
        margin: 3% auto;
        border-radius: 12px;
    }

    .modal .close {
        width: 32px;
        height: 32px;
        font-size: 24px;
        top: 8px;
        right: 8px;
    }

    #modalIframe {
        min-height: 400px;
    }

    .modal-loader {
        padding: 40px 20px;
    }
}