/* Post Media Gallery - Multiple Images/Videos - style Pinterest (masonry), hauteur auto */

.post-media-gallery {
    margin: 1rem 0;
    border-radius: 0;
    overflow: hidden;
    width: 100%;
    display: block;
}

/* Dès qu'il y a plusieurs médias : style Pinterest (masonry avec colonnes) */
.post-media-gallery[data-media-count="2"],
.post-media-gallery[data-media-count="3"],
.post-media-gallery[data-media-count="4"],
.post-media-gallery[data-media-count="5"],
.post-media-gallery[data-media-count="6"],
.post-media-gallery[data-media-count="7"],
.post-media-gallery[data-media-count="8"],
.post-media-gallery[data-media-count="9"],
.post-media-gallery[data-media-count="10"] {
    column-gap: 0.5rem !important;
    gap: 0.5rem !important;
}

/* 2 colonnes pour 2 ou 4+ médias */
.post-media-gallery[data-media-count="2"],
.post-media-gallery[data-media-count="4"],
.post-media-gallery[data-media-count="5"],
.post-media-gallery[data-media-count="6"],
.post-media-gallery[data-media-count="7"],
.post-media-gallery[data-media-count="8"],
.post-media-gallery[data-media-count="9"],
.post-media-gallery[data-media-count="10"] {
    column-count: 2 !important;
    display: block !important;
}

/* 3 colonnes pour 3 médias */
.post-media-gallery[data-media-count="3"] {
    column-count: 3 !important;
    display: block !important;
}

.post-media-item {
    position: relative;
    width: 100%;
    margin-bottom: 0.5rem;
    display: block;
    break-inside: avoid;
    page-break-inside: avoid;
}

.post-media-gallery[data-media-count="2"] .post-media-item,
.post-media-gallery[data-media-count="3"] .post-media-item,
.post-media-gallery[data-media-count="4"] .post-media-item,
.post-media-gallery[data-media-count="5"] .post-media-item,
.post-media-gallery[data-media-count="6"] .post-media-item,
.post-media-gallery[data-media-count="7"] .post-media-item,
.post-media-gallery[data-media-count="8"] .post-media-item,
.post-media-gallery[data-media-count="9"] .post-media-item,
.post-media-gallery[data-media-count="10"] .post-media-item {
    margin-bottom: 0.5rem;
}

.post-media-gallery[data-media-count="2"] .post-media-item:last-child,
.post-media-gallery[data-media-count="3"] .post-media-item:last-child,
.post-media-gallery[data-media-count="4"] .post-media-item:last-child,
.post-media-gallery[data-media-count="5"] .post-media-item:last-child,
.post-media-gallery[data-media-count="6"] .post-media-item:last-child,
.post-media-gallery[data-media-count="7"] .post-media-item:last-child,
.post-media-gallery[data-media-count="8"] .post-media-item:last-child,
.post-media-gallery[data-media-count="9"] .post-media-item:last-child,
.post-media-gallery[data-media-count="10"] .post-media-item:last-child {
    margin-bottom: 0;
}

.post-media-item:last-child {
    margin-bottom: 0;
}

.post-media-item img,
.post-media-item video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    vertical-align: middle;
}

/* Single media - pas de grid */
.post-media-gallery[data-media-count="1"] .post-media-item {
    margin-bottom: 0;
}

.post-media-gallery[data-media-count="1"] .post-media-item img,
.post-media-gallery[data-media-count="1"] .post-media-item video {
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    background: var(--gray-100);
    border-radius: 12px;
}

.post-media-gallery[data-media-count="1"] .youtube-like-video-wrapper,
.post-media-gallery[data-media-count="1"] .post-video-container {
    aspect-ratio: auto;
    height: auto;
    min-height: auto;
}

/* 2 images : 2 colonnes Pinterest, hauteur auto */
.post-media-gallery[data-media-count="2"] .post-media-item img,
.post-media-gallery[data-media-count="2"] .post-media-item video {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

/* 3 images : 3 colonnes Pinterest, hauteur auto */
.post-media-gallery[data-media-count="3"] .post-media-item img,
.post-media-gallery[data-media-count="3"] .post-media-item video {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

/* 4+ images : 2 colonnes Pinterest, hauteur auto */
.post-media-gallery[data-media-count="4"] .post-media-item img,
.post-media-gallery[data-media-count="4"] .post-media-item video,
.post-media-gallery[data-media-count="5"] .post-media-item img,
.post-media-gallery[data-media-count="5"] .post-media-item video,
.post-media-gallery[data-media-count="6"] .post-media-item img,
.post-media-gallery[data-media-count="6"] .post-media-item video,
.post-media-gallery[data-media-count="7"] .post-media-item img,
.post-media-gallery[data-media-count="7"] .post-media-item video,
.post-media-gallery[data-media-count="8"] .post-media-item img,
.post-media-gallery[data-media-count="8"] .post-media-item video,
.post-media-gallery[data-media-count="9"] .post-media-item img,
.post-media-gallery[data-media-count="9"] .post-media-item video,
.post-media-gallery[data-media-count="10"] .post-media-item img,
.post-media-gallery[data-media-count="10"] .post-media-item video {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

/* More than 6 media - show first 6, "Voir plus" pour le reste */
.post-media-gallery[data-media-count] .post-media-item:nth-child(n+7) {
    display: none;
}

.post-media-gallery.post-media-gallery-expanded .post-media-item:nth-child(n+7) {
    display: block;
}

/* Bouton Voir plus (s’étend sur toute la largeur sous la grille) */
.post-media-voir-plus {
    column-span: all;
    display: block;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.625rem 1rem;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.post-media-voir-plus:hover {
    background: #e5e7eb;
    color: #1f2937;
}

.post-media-gallery-expanded .post-media-voir-plus {
    margin-bottom: 0;
}

/* Ensure all images in gallery are properly displayed (hauteur auto pour style Pinterest) */
.post-media-gallery .post-media-image {
    width: 100%;
    height: auto;
    display: block;
}

/* Fix for images that might not have proper container */
.post-media-gallery .post-media-item {
    overflow: hidden;
    background: #f3f4f6;
}

.post-media-gallery .post-media-item img {
    min-height: 0;
}

/* YouTube embeds in gallery */
.post-media-gallery .youtube-embed,
.youtube-embed {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 0; /* Remove border radius for full width */
    background-color: #000;
    width: 100%;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.post-media-gallery .youtube-embed iframe,
.youtube-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1;
}

/* Hover effect for images */
.post-media-item img,
.post-media-item video {
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.post-media-item img:hover,
.post-media-item video:hover {
    transform: scale(1.02);
    opacity: 0.95;
}

/* Media counter badge */
.media-count-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10;
}

/* Mobile responsive : Pinterest (colonnes), hauteur auto */
@media (max-width: 768px) {
    .post-media-gallery {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
    }

    .post-media-item {
        width: 100%;
        margin-bottom: 0.25rem;
    }

    .post-media-gallery[data-media-count="2"],
    .post-media-gallery[data-media-count="4"],
    .post-media-gallery[data-media-count="5"],
    .post-media-gallery[data-media-count="6"] {
        column-count: 2 !important;
        column-gap: 0.25rem !important;
    }

    .post-media-gallery[data-media-count="3"] {
        column-count: 3 !important;
        column-gap: 0.25rem !important;
    }

    .post-media-gallery[data-media-count="1"] .post-media-item img,
    .post-media-gallery[data-media-count="1"] .post-media-item video {
        width: 100%;
        height: auto;
        max-height: none;
        object-fit: contain;
        border-radius: 0;
    }

    .post-media-gallery[data-media-count="2"] .post-media-item img,
    .post-media-gallery[data-media-count="2"] .post-media-item video,
    .post-media-gallery[data-media-count="3"] .post-media-item img,
    .post-media-gallery[data-media-count="3"] .post-media-item video,
    .post-media-gallery[data-media-count="4"] .post-media-item img,
    .post-media-gallery[data-media-count="4"] .post-media-item video,
    .post-media-gallery[data-media-count="5"] .post-media-item img,
    .post-media-gallery[data-media-count="5"] .post-media-item video,
    .post-media-gallery[data-media-count="6"] .post-media-item img,
    .post-media-gallery[data-media-count="6"] .post-media-item video {
        width: 100%;
        height: auto;
        border-radius: 4px;
    }

    .post-media-gallery .youtube-embed {
        width: 100%;
        padding-bottom: 56.25%;
    }
}

/* ========== Feed page profil : même grille Pinterest que le feed accueil ========== */
.profile-feed-section .post-card .post-media-gallery[data-media-count="2"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="3"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="4"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="5"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="6"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="7"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="8"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="9"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="10"] {
    column-gap: 0.5rem !important;
    display: block !important;
}

.profile-feed-section .post-card .post-media-gallery[data-media-count="2"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="4"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="5"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="6"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="7"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="8"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="9"],
.profile-feed-section .post-card .post-media-gallery[data-media-count="10"] {
    column-count: 2 !important;
}

.profile-feed-section .post-card .post-media-gallery[data-media-count="3"] {
    column-count: 3 !important;
}

.profile-feed-section .post-card .post-media-gallery .post-media-item {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 0.5rem;
}

.profile-feed-section .post-card .post-media-gallery .post-media-item img,
.profile-feed-section .post-card .post-media-gallery .post-media-item video,
.profile-feed-section .post-card .post-media-gallery .post-media-image {
    width: 100%;
    height: auto !important;
    display: block;
    object-fit: unset;
}

