/* =============================================================================
   coloriages.css — Page des coloriages (components/coloriages.php).
   Grille d'images : bouton « Télécharger » en haut à droite de chaque coloriage.
   Mobile : une colonne. Tablette et plus : grille qui s'adapte à la largeur.
   ============================================================================= */

.colorings {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem var(--gutter) 3rem;
}

.colorings-title {
    padding-bottom: 0.5rem;
}

.colorings-intro {
    max-width: 36rem;
    margin: 0 auto 2rem;
    font-size: 1.05rem;
    color: var(--blue-text);
}

/* ---------- GRILLE ---------- */

.colorings-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Mobile : un coloriage par ligne */
.coloring {
    position: relative;
    flex: 0 1 100%;
    max-width: 26rem;
    padding: 0.75rem 0.75rem 0;
    border-radius: var(--radius-l);
    background-color: var(--white-pure);
    box-shadow: var(--shadow-soft);
}

.coloring-image {
    display: block;
    width: 100%;
    aspect-ratio: 210 / 297;
    /* format A4 portrait : la grille reste alignée avant le chargement */
    object-fit: contain;
    border-radius: var(--radius-m);
    background-color: var(--grey-light);
}

.coloring-name {
    padding: 0.75rem 0.25rem 0.9rem;
    font-weight: 700;
    color: var(--blue-text);
}

/* ---------- BOUTON TÉLÉCHARGER (en haut à droite) ---------- */

.coloring-download {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: radial-gradient(var(--green-dark), var(--green-dark-2));
    color: var(--white-pure);
    box-shadow: 0 4px 12px rgba(15, 56, 52, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.coloring-download svg {
    width: 1.35rem;
    height: 1.35rem;
}

.coloring-download:hover,
.coloring-download:focus-visible {
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 6px 16px rgba(15, 56, 52, 0.45);
}

.coloring-download:focus-visible {
    outline: 3px solid var(--green-mint);
    outline-offset: 2px;
}

/* ---------- TABLETTE ET PLUS ---------- */

@media (min-width: 768px) {
    .colorings-list {
        gap: 1.5rem;
    }

    /* Chaque coloriage : entre 14 et 18rem, autant par ligne que l'écran le permet */
    .coloring {
        flex: 0 1 clamp(14rem, 26vw, 18rem);
        max-width: none;
    }
}


/* ---------- MINIATURE CLIQUABLE ---------- */

.coloring-zoom {
    display: block;
    border-radius: var(--radius-m);
    cursor: zoom-in;
}

.coloring-zoom:focus-visible {
    outline: 3px solid var(--green-mint);
    outline-offset: 3px;
}

.coloring-zoom .coloring-image {
    transition: transform 0.25s ease;
}

.coloring-zoom:hover .coloring-image {
    transform: scale(1.02);
}

/* ---------- VUE PLEIN ÉCRAN (<dialog>) ---------- */

/* Page figée tant que la vue est ouverte */
.is-viewer-open {
    overflow: hidden;
}

.coloring-viewer {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
}

/* Fond sombre et flouté sur le reste du site */
.coloring-viewer::backdrop {
    background: rgba(10, 30, 28, 0.82);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.coloring-viewer[open] {
    display: grid;
    place-items: center;
    animation: coloring-viewer-in 0.2s ease;
}

.coloring-viewer-frame {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;                         /* titre collé sous l'image */
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 4.5rem var(--gutter) 2rem;   /* place pour la croix et le bouton en haut */
}

.coloring-viewer-image {
    max-width: 100%;
    max-height: calc(100dvh - 10rem);     /* place pour les boutons en haut et le titre en bas */
    width: auto;
    height: auto;
    border-radius: var(--radius-m);
    background-color: var(--white-pure);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    cursor: default;
}

.coloring-viewer-title {
    font-weight: 700;
    color: var(--white-pure);
    text-align: center;
}

/* Croix (en haut à droite) et téléchargement (à sa gauche) */
.coloring-viewer-close,
.coloring-viewer-download {
    position: fixed;
    top: 1rem;
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
}

.coloring-viewer-close {
    right: 1rem;
    border: none;
    background-color: var(--white-pure);
    color: var(--green-dark);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.coloring-viewer-close svg {
    width: 1.4rem;
    height: 1.4rem;
}

.coloring-viewer-close:hover,
.coloring-viewer-close:focus-visible {
    transform: scale(1.08);
}

.coloring-viewer-close:focus-visible {
    outline: 3px solid var(--green-mint);
    outline-offset: 2px;
}

.coloring-viewer-download {
    right: 4.75rem;
}

@keyframes coloring-viewer-in {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .coloring-viewer[open] {
        animation: none;
    }
}