/* === MASONRY GALLERY === */

.masonry-gallery-container {
    width: 100%;
    max-width: 100%;
}

.masonry-gallery-grid {
    display: column;
    column-count: 1;
    column-gap: var(--grid-gap, 10px);
    max-width: 100%;
}

.masonry-gallery-item {
    display: inline-block;
    width: 100%;
    margin-bottom: calc(var(--grid-gap, 10px) - 6px);
    break-inside: avoid;
    cursor: pointer;
    transition: transform 0.3s ease;
    position: relative;
    overflow: hidden;
}

.masonry-gallery-item:hover {
    transform: scale(1.02);
}

.masonry-gallery-item img {
    width: 100%;
    height: auto;
    border-radius: var(--border-radius, 8px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
    display: block;
    margin: 0;
    padding: 0;
    vertical-align: top;
}

.masonry-gallery-item img:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* === OVERLAY AU HOVER === */

.masonry-gallery-item .image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        180deg,
        transparent 0%,
        transparent 50%,
        rgba(0, 0, 0, 0.3) 70%,
        rgba(0, 0, 0, 0.8) 100%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: var(--border-radius, 8px);
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    padding: 15px;
}

.masonry-gallery-item:hover .image-overlay {
    opacity: 1;
}

.masonry-gallery-item .image-overlay .image-info {
    color: white;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.masonry-gallery-item:hover .image-overlay .image-info {
    transform: translateY(0);
}

.masonry-gallery-item .image-overlay h5 {
    margin: 0 0 5px 0;
    font-size: 16px;
    font-weight: bold;
	color:white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.masonry-gallery-item .image-overlay p {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
	color:white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/* === RESPONSIVE COLUMNS AVEC MIN-WIDTH === */

@media (min-width: 480px) {
    .masonry-gallery-grid {
        column-count: 2;
    }
}

/* Utilisation du min-width personnalisé */
.masonry-gallery-container {
    --breakpoint-1: calc(var(--min-width) * 2);
    --breakpoint-2: calc(var(--min-width) * 3);
    --breakpoint-3: calc(var(--min-width) * 4);
    --breakpoint-4: calc(var(--min-width) * 5);
}

/* Media queries dynamiques basées sur min-width */
@media (min-width: 480px) {
    .masonry-gallery-grid {
        column-count: 2;
    }
}

@media (min-width: 768px) {
    .masonry-gallery-container {
        container-type: inline-size;
    }
    
    .masonry-gallery-grid {
        column-count: 3;
    }
}

@media (min-width: 1024px) {
    .masonry-gallery-grid {
        column-count: var(--columns, 3);
    }
}

@media (min-width: 1200px) {
    .masonry-gallery-grid {
        column-count: var(--columns, 4);
    }
}

/* === CALCUL RESPONSIVE AUTOMATIQUE === */

/* Si min-width = 250px */
@media (min-width: 500px) { /* 250 * 2 */
    .masonry-gallery-container[style*="--min-width: 250px"] .masonry-gallery-grid {
        column-count: 2;
    }
}

@media (min-width: 750px) { /* 250 * 3 */
    .masonry-gallery-container[style*="--min-width: 250px"] .masonry-gallery-grid {
        column-count: 3;
    }
}

@media (min-width: 1000px) { /* 250 * 4 */
    .masonry-gallery-container[style*="--min-width: 250px"] .masonry-gallery-grid {
        column-count: 4;
    }
}

/* Si min-width = 200px */
@media (min-width: 400px) { /* 200 * 2 */
    .masonry-gallery-container[style*="--min-width: 200px"] .masonry-gallery-grid {
        column-count: 2;
    }
}

@media (min-width: 600px) { /* 200 * 3 */
    .masonry-gallery-container[style*="--min-width: 200px"] .masonry-gallery-grid {
        column-count: 3;
    }
}

@media (min-width: 800px) { /* 200 * 4 */
    .masonry-gallery-container[style*="--min-width: 200px"] .masonry-gallery-grid {
        column-count: 4;
    }
}

/* Si min-width = 300px */
@media (min-width: 600px) { /* 300 * 2 */
    .masonry-gallery-container[style*="--min-width: 300px"] .masonry-gallery-grid {
        column-count: 2;
    }
}

@media (min-width: 900px) { /* 300 * 3 */
    .masonry-gallery-container[style*="--min-width: 300px"] .masonry-gallery-grid {
        column-count: 3;
    }
}

@media (min-width: 1200px) { /* 300 * 4 */
    .masonry-gallery-container[style*="--min-width: 300px"] .masonry-gallery-grid {
        column-count: 4;
    }
}

/* === NO GAP === */

.masonry-gallery-grid.no-gap {
    column-gap: 0;
}

.masonry-gallery-grid.no-gap .masonry-gallery-item {
    margin-bottom: 0;
}


/* === LIGHTBOX === */

.masonry-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 80px 80px 120px 80px; /* Marges pour navigation et texte */
    box-sizing: border-box;
}

.masonry-lightbox.active {
    display: flex;
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    image-rendering: optimizeQuality;
}

/* === IMAGES PORTRAIT === */
.lightbox-content img[data-orientation="portrait"] {
    height: 100%;
    width: auto;
    max-width: 100%;
}

/* === IMAGES PAYSAGE === */
.lightbox-content img[data-orientation="landscape"] {
    width: 100%;
    height: auto;
    max-height: 100%;
}

/* === IMAGES CARRÉES === */
.lightbox-content img[data-orientation="square"] {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
}

.lightbox-close {
    position: fixed;
    top: 20px;
    right: 30px;
    font-size: 40px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-nav {
    position: fixed;
	display: block;
	height: 40px;
	width: 40px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 44px;
    color: white;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    padding: 7px 13px;
    border-radius: 50%;
    transition: background 0.3s;
	border: 1px solid rgba(255, 255, 255, 0.5);
    z-index: 100000;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-info {
    position: fixed;
    bottom: 40px;
    left: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px;
    text-align: center;
    z-index: 100000;
    max-height: 80px;
    overflow-y: hidden;
}

.lightbox-info h5 {
    margin: 0 0 5px 0;
    font-size: 1.1rem;
    font-weight: bold;
	color: white;
}

.lightbox-info p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.9;
	color: white;
}

/* === EMPÊCHER LE SCROLL === */
body.lightbox-open {
    overflow: hidden;
}

/* === RESPONSIVE LIGHTBOX === */

@media (max-width: 1024px) {
    .masonry-lightbox {
        padding: 60px 60px 100px 60px;
    }
}

@media (max-width: 768px) {
    .masonry-lightbox {
        padding: 50px 20px 80px 20px;
    }
    
    .lightbox-content {
        max-width: 100%;
        max-height: 100%;
    }
    
    .lightbox-close {
        top: 10px;
        right: 15px;
        font-size: 30px;
        width: 40px;
        height: 40px;
    }
    
    .lightbox-nav {
        font-size: 24px;
        padding: 8px 12px;
    }
    
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
    
    .lightbox-info {
        bottom: 10px;
        left: 10px;
        right: 10px;
        padding: 10px;
        max-height: 60px;
    }
    
    .lightbox-info h5 {
        font-size: 16px;
    }
    
    .lightbox-info p {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .masonry-lightbox {
        padding: 40px 10px 70px 10px;
    }
    
    .lightbox-nav {
        font-size: 20px;
        padding: 6px 10px;
    }
    
    .lightbox-info {
        padding: 8px;
        max-height: 50px;
    }
    
    .lightbox-info h5 {
        font-size: 14px;
    }
    
    .lightbox-info p {
        font-size: 12px;
    }
}

