/* ========================================
 * PAGE-RECETTE-LIGHTBOX.CSS
 * Contient les styles pour la modale d'agrandissement des images
 * ======================================== */

/* ======================================
 * STYLES LIGHTBOX
 * ====================================== */

/* Styles pour la lightbox */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.image-lightbox.active {
    opacity: 1;
    visibility: visible;
}

/* Sur mobile, désactiver temporairement les animations pour éviter le clignotement */
@media (max-width: 768px) and (pointer: coarse) {
    .image-lightbox {
        transition: none;
    }
    
    .image-lightbox.active {
        transition: opacity 0.2s ease;
    }
}

.lightbox-fadeIn {
    animation: fadeIn 0.3s ease forwards;
}

.lightbox-fadeOut {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeIn {
    from { 
        opacity: 0;
        visibility: hidden;
    }
    to { 
        opacity: 1;
        visibility: visible;
    }
}

@keyframes fadeOut {
    from { 
        opacity: 1;
        visibility: visible;
    }
    to { 
        opacity: 0;
        visibility: hidden;
    }
}

/* Sur mobile, simplifier les animations */
@media (max-width: 768px) and (pointer: coarse) {
    @keyframes fadeIn {
        0% { opacity: 0; }
        100% { opacity: 1; }
    }
    
    @keyframes fadeOut {
        0% { opacity: 1; }
        100% { opacity: 0; }
    }
}

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

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /*align-items: center; */
}

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

.lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
    opacity: 0;
}

.lightbox-image.loaded {
    opacity: 1;
    animation: imageLoadedAnimation 0.3s ease forwards;
}

/* Sur mobile, désactiver l'animation de chargement pour éviter le clignotement */
@media (max-width: 768px) and (pointer: coarse) {
    .lightbox-image {
        opacity: 1;
        transition: none;
    }
    
    .lightbox-image.loaded {
        animation: none;
    }
}

.lightbox-image.zoomed {
    cursor: move;
    border: none;
    box-shadow: none;
}

@keyframes imageLoadedAnimation {
    from { 
        opacity: 0; 
        transform: scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}

/* Sur mobile, simplifier l'animation */
@media (max-width: 768px) and (pointer: coarse) {
    @keyframes imageLoadedAnimation {
        from { opacity: 1; }
        to { opacity: 1; }
    }
}

.lightbox-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color, #ff6b6b);
    animation: spin 1s ease-in-out infinite;
    z-index: 1;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.lightbox-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.lightbox-button {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.lightbox-button svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.lightbox-close {
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    z-index: 10;
}

.lightbox-close:hover {
    background-color: rgba(255, 107, 107, 0.8);
    transform: rotate(90deg);
}

.lightbox-prev, .lightbox-next {
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-prev:hover, .lightbox-next:hover {
    background-color: rgba(255, 107, 107, 0.8);
}

.lightbox-zoom {
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
}

.lightbox-zoom:hover {
    background-color: rgba(255, 107, 107, 0.8);
}

.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
    z-index: 5;
}

.lightbox-caption {
    width: 100%;
    max-width: 800px;
    text-align: center;
    color: white;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px;
    margin-top: 15px;
    font-size: 16px;
    border-radius: 4px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Styles pour l'affichage de la source de l'image */
.lightbox-source {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 0px;
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 20px;
    color: white;
    font-size: 14px;
}

.lightbox-source-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
    padding: 2px;
    flex-shrink: 0;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-source-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lightbox-source-name {
    font-weight: 400;
    color: #fff;
    font-size: 14px;
}

.lightbox-source-link {
    color: #87CEEB;
    text-decoration: none;
    font-size: 12px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.lightbox-source-link:hover {
    opacity: 1;
    text-decoration: underline;
}

/* ======================================
 * MEDIA QUERIES (RESPONSIVE)
 * ====================================== */

@media screen and (max-width: 768px) {
    .lightbox-content {
        max-width: 95%;
    }
    
    .lightbox-button {
        width: 40px;
        height: 40px;
    }
    
    .lightbox-button svg {
        width: 20px;
        height: 20px;
    }
    
    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
    }
    
    .lightbox-prev, .lightbox-next {
        width: 40px;
        height: 40px;
    }
    
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
    
    .lightbox-caption {
        font-size: 14px;
        padding: 8px;
        margin-top: 10px;
    }
}

@media screen and (max-width: 480px) {
    .lightbox-button {
        width: 36px;
        height: 36px;
    }
    
    .lightbox-button svg {
        width: 18px;
        height: 18px;
    }
    
    .lightbox-close {
        width: 32px;
        height: 32px;
    }
    
    .lightbox-prev, .lightbox-next {
        width: 36px;
        height: 36px;
    }
    
    .lightbox-prev {
        left: 5px;
    }
    
    .lightbox-next {
        right: 5px;
    }
    
    .lightbox-counter {
        padding: 3px 10px;
        font-size: 12px;
    }
    
    .lightbox-caption {
        font-size: 12px;
        padding: 5px;
        margin-top: 8px;
    }
    
    .lightbox-source {
        font-size: 12px;
        padding: 6px 12px;
        margin-top: 8px;
    }
    
    .lightbox-source-logo {
        width: 20px;
        height: 20px;
    }
    
    .lightbox-source-link {
        font-size: 11px;
    }
}
