/**
 * Styles Frontend pour Photo Gallery Manager
 */

.pgm-gallery {
    box-sizing: border-box;
    width: 100%;
    margin: 25px 0;
}

.pgm-gallery *,
.pgm-gallery *::before,
.pgm-gallery *::after {
    box-sizing: border-box;
}

/* Grille CSS standard */
.pgm-layout-grid .pgm-gallery-inner {
    display: grid;
    grid-template-columns: repeat(var(--pgm-cols, 3), 1fr);
    gap: var(--pgm-gap, 15px);
}

/* Disposition 2 : Mosaïque Pinterest (Hauteurs décalées / Cascade) */
.pgm-layout-masonry .pgm-gallery-inner {
    display: block !important;
    column-count: var(--pgm-cols, 3) !important;
    column-gap: var(--pgm-gap, 15px) !important;
}

.pgm-layout-masonry .pgm-item {
    display: inline-block !important;
    width: 100% !important;
    margin: 0 0 var(--pgm-gap, 15px) 0 !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    -webkit-column-break-inside: avoid !important;
    vertical-align: top !important;
    background: transparent !important;
}

.pgm-layout-masonry .pgm-item .pgm-image-wrapper {
    width: 100% !important;
    height: auto !important;
    background: transparent !important;
}

/* Rythme visuel authentique façon Pinterest :
   Lorsque toutes les photos d'un dossier ont le même format d'appareil et qu'on est en ratio original,
   ce rythme dynamique applique des proportions décalées élégantes pour un effet cascade 100% Pinterest */
.pgm-layout-masonry.pgm-ratio-original .pgm-item:nth-child(5n + 1) .pgm-image {
    aspect-ratio: 4 / 5 !important;
    width: 100% !important;
    height: auto !important;
    object-fit: cover !important;
}

.pgm-layout-masonry.pgm-ratio-original .pgm-item:nth-child(5n + 2) .pgm-image {
    aspect-ratio: 16 / 11 !important;
    width: 100% !important;
    height: auto !important;
    object-fit: cover !important;
}

.pgm-layout-masonry.pgm-ratio-original .pgm-item:nth-child(5n + 3) .pgm-image {
    aspect-ratio: 1 / 1 !important;
    width: 100% !important;
    height: auto !important;
    object-fit: cover !important;
}

.pgm-layout-masonry.pgm-ratio-original .pgm-item:nth-child(5n + 4) .pgm-image {
    aspect-ratio: 3 / 4 !important;
    width: 100% !important;
    height: auto !important;
    object-fit: cover !important;
}

.pgm-layout-masonry.pgm-ratio-original .pgm-item:nth-child(5n + 5) .pgm-image {
    aspect-ratio: 4 / 3 !important;
    width: 100% !important;
    height: auto !important;
    object-fit: cover !important;
}

/* Disposition 3 : Mosaïque Justifiée (Style Flickr / Google Photos) */
.pgm-layout-justified .pgm-gallery-inner {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: var(--pgm-gap, 15px) !important;
}

.pgm-layout-justified .pgm-item {
    flex: 1 1 240px !important;
    height: 280px !important;
    max-width: 100% !important;
}

.pgm-layout-justified .pgm-item .pgm-image-wrapper,
.pgm-layout-justified .pgm-item .pgm-link {
    height: 100% !important;
}

.pgm-layout-justified .pgm-image {
    height: 100% !important;
    width: 100% !important;
    object-fit: cover !important;
}

/* Disposition 4 : Collage Bento / Artistique */
.pgm-layout-bento .pgm-gallery-inner {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    grid-auto-rows: 220px !important;
    gap: var(--pgm-gap, 15px) !important;
}

.pgm-layout-bento .pgm-item {
    height: 100% !important;
}

.pgm-layout-bento .pgm-item:nth-child(6n + 1) {
    grid-column: span 2 !important;
    grid-row: span 2 !important;
}

.pgm-layout-bento .pgm-item:nth-child(6n + 4) {
    grid-column: span 2 !important;
}

.pgm-layout-bento .pgm-item .pgm-image-wrapper,
.pgm-layout-bento .pgm-item .pgm-link {
    height: 100% !important;
}

.pgm-layout-bento .pgm-image {
    height: 100% !important;
    width: 100% !important;
    object-fit: cover !important;
}

/* Disposition 5 : Carrousel / Slider horizontal */
.pgm-layout-carousel {
    position: relative;
}

.pgm-carousel-nav {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 12px;
}

.pgm-carousel-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #dcdcde;
    background: #ffffff;
    color: #1d2327;
    font-size: 24px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
    padding: 0;
}

.pgm-carousel-btn:hover {
    background: #2271b1;
    color: #ffffff;
    border-color: #2271b1;
    transform: scale(1.08);
}

.pgm-layout-carousel .pgm-gallery-inner {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    gap: var(--pgm-gap, 15px);
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}

.pgm-layout-carousel .pgm-gallery-inner::-webkit-scrollbar {
    height: 6px;
}

.pgm-layout-carousel .pgm-gallery-inner::-webkit-scrollbar-thumb {
    background: #c3c4c7;
    border-radius: 3px;
}

.pgm-layout-carousel .pgm-item {
    flex: 0 0 calc((100% - (var(--pgm-cols, 3) - 1) * var(--pgm-gap, 15px)) / var(--pgm-cols, 3));
    scroll-snap-align: start;
}

/* Éléments de la galerie */
/* Éléments de la galerie avec optimisation de rendu */
.pgm-item {
    margin: 0;
    position: relative;
    background: transparent !important;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    transform: translateZ(0); /* Accélération matérielle GPU */
    line-height: 0;
    height: auto !important;
    min-height: 0 !important;
}

.pgm-item:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.pgm-link {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    line-height: 0;
}

/* Conteneur d'image : épouse strictement la photo */
.pgm-image-wrapper {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: auto;
    aspect-ratio: auto;
    min-height: 0;
    line-height: 0;
    background: transparent !important;
}

/* En ratio original : aucun ratio carré forcé, hauteur 100% naturelle */
.pgm-ratio-original .pgm-image-wrapper {
    aspect-ratio: auto !important;
    height: auto !important;
    min-height: 0 !important;
}

/* Ratios forcés uniquement si explicitement configurés */
.pgm-ratio-1-1 .pgm-image-wrapper {
    aspect-ratio: 1 / 1 !important;
}

.pgm-ratio-4-3 .pgm-image-wrapper {
    aspect-ratio: 4 / 3 !important;
}

.pgm-ratio-16-9 .pgm-image-wrapper {
    aspect-ratio: 16 / 9 !important;
}

/* Image principale avec priorité absolue sur les styles de thèmes */
.pgm-image {
    display: block !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    line-height: 0 !important;
    opacity: 1 !important;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
    will-change: transform !important;
}

/* En ratio original dans la grille classique : l'image est en flux normal et impose sa hauteur exacte au pixel près */
.pgm-layout-grid.pgm-ratio-original .pgm-image {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
}

/* En mosaïque Pinterest originale : affichage fluide et plein cadre sans aucun espace blanc */
.pgm-layout-masonry.pgm-ratio-original .pgm-image {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    display: block !important;
}

/* En ratio forcé (1:1, 4:3, 16:9) : l'image DOIT recouvrir 100% du cadre sans aucun espace */
.pgm-ratio-1-1 .pgm-image,
.pgm-ratio-4-3 .pgm-image,
.pgm-ratio-16-9 .pgm-image {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* Effets de survol */
.pgm-hover-zoom .pgm-image {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.pgm-hover-zoom:hover .pgm-image {
    transform: scale(1.08);
}

.pgm-hover-opacity .pgm-image {
    transition: opacity 0.3s ease;
}

.pgm-hover-opacity:hover .pgm-image {
    opacity: 0.85;
}

/* Légende en Overlay au survol */
.pgm-caption-none .pgm-overlay,
.pgm-caption-none .pgm-caption-below {
    display: none !important;
}

.pgm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.2) 60%, transparent 100%);
    display: flex;
    align-items: flex-end;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.pgm-item:hover .pgm-overlay {
    opacity: 1;
}

.pgm-overlay-text {
    transform: translateY(10px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    color: #ffffff;
    width: 100%;
}

.pgm-item:hover .pgm-overlay-text {
    transform: translateY(0);
}

.pgm-overlay-title {
    display: block;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 4px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.pgm-overlay-caption {
    display: block;
    font-size: 13px;
    opacity: 0.9;
    line-height: 1.3;
}

/* Légende en dessous */
.pgm-caption-below {
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid #f0f0f1;
}

.pgm-caption-title {
    display: block;
    font-size: 14px;
    color: #1d2327;
    margin-bottom: 4px;
}

.pgm-caption-desc {
    font-size: 12px;
    color: #646970;
    margin: 0;
    line-height: 1.4;
}

/* Responsive - Tablettes */
@media (max-width: 900px) {
    .pgm-layout-grid .pgm-gallery-inner {
        grid-template-columns: repeat(min(2, var(--pgm-cols, 2)), 1fr) !important;
    }

    .pgm-layout-masonry .pgm-gallery-inner {
        column-count: 2 !important;
    }
}

/* Responsive - Mobiles */
@media (max-width: 600px) {
    .pgm-layout-grid .pgm-gallery-inner {
        grid-template-columns: 1fr !important;
    }

    .pgm-layout-masonry .pgm-gallery-inner {
        column-count: 1 !important;
    }
}

/* ==========================================================================
   Listing des galeries d'albums [photo_galleries] (Page d'accueil)
   ========================================================================== */
.pgm-galleries-listing {
    box-sizing: border-box;
    width: 100%;
    margin: 30px 0;
}

.pgm-galleries-grid {
    display: grid;
    grid-template-columns: repeat(var(--pgm-cols, 3), 1fr);
    gap: var(--pgm-gap, 20px);
}

.pgm-gallery-card {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.pgm-gallery-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
}

.pgm-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.pgm-card-cover-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #23282d;
}

.pgm-card-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.pgm-gallery-card:hover .pgm-card-cover {
    transform: scale(1.08);
}

.pgm-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f1;
    color: #a7aaad;
}

.pgm-card-placeholder .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
}

.pgm-card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    z-index: 2;
}

.pgm-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px 16px 14px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 60%, transparent 100%);
    color: #ffffff;
    z-index: 2;
    transition: background 0.3s ease;
}

.pgm-card-title {
    margin: 0 0 4px 0;
    font-size: 17px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.3;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.pgm-card-action {
    display: inline-block;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    transition: transform 0.2s ease, color 0.2s ease;
}

.pgm-gallery-card:hover .pgm-card-action {
    color: #ffffff;
    transform: translateX(4px);
}

.pgm-notice {
    padding: 12px 16px;
    background: #fff8e5;
    border-left: 4px solid #ffb900;
    color: #8a6d3b;
    margin: 15px 0;
    border-radius: 0 4px 4px 0;
}

@media (max-width: 900px) {
    .pgm-galleries-grid {
        grid-template-columns: repeat(min(2, var(--pgm-cols, 2)), 1fr) !important;
    }
}

@media (max-width: 600px) {
    .pgm-galleries-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================================================
   Pagination de la Galerie [photo_gallery per_page="..."]
   ========================================================================== */
.pgm-pagination {
    text-align: center;
    margin-top: 35px;
    padding-top: 20px;
    border-top: 1px solid #f0f0f1;
    clear: both;
}

.pgm-pagination-info {
    font-size: 13px;
    color: #646970;
    margin-bottom: 14px;
    font-weight: 500;
}

.pgm-pagination-list {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}

.pgm-page-item {
    margin: 0;
}

.pgm-page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 42px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid #dcdcde;
    background: #ffffff;
    color: #1d2327;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.pgm-page-link:hover {
    border-color: #2271b1;
    color: #2271b1;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.pgm-page-item.is-active .pgm-page-link {
    background: #2271b1;
    color: #ffffff;
    border-color: #2271b1;
    box-shadow: 0 3px 10px rgba(34, 113, 177, 0.35);
    pointer-events: none;
}

.pgm-page-item.is-disabled .pgm-page-link {
    opacity: 0.35;
    pointer-events: none;
    background: #f6f7f7;
    border-color: #e2e4e7;
    box-shadow: none;
}

.pgm-page-prev,
.pgm-page-next {
    font-size: 13px;
    gap: 4px;
}

.pgm-page-hidden {
    display: none !important;
}

/* Ellipsis dans la pagination tronquée */
.pgm-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pgm-page-dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 42px;
    color: #646970;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 2px;
    user-select: none;
}
