/**
 * Styles pour la lightbox d'images
 * Style rétro/pixel art cohérent avec le design du site
 */

/* Conteneur principal de la lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.lightbox-open {
    opacity: 1;
}

/* Overlay sombre */
.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

/* Conteneur du contenu */
.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Conteneur de l'image */
.lightbox-image-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100%;
    max-height: 100%;
}

/* Image */
.lightbox-image {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    display: block;
    border: 4px solid var(--border-dark, #2C1810);
    background: white;
    box-shadow:
        0 0 0 4px var(--bg-light, #FFF8DC),
        0 8px 0 0 rgba(0, 0, 0, 0.3);
    transition: opacity 0.2s ease;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Légende */
.lightbox-caption {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: var(--bg-light, #FFF8DC);
    border: 2px solid var(--border-dark, #2C1810);
    color: var(--text-primary, #2C1810);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    text-align: center;
    max-width: 80vw;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
}

/* Boutons de navigation (style pixel art) */
.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    background: var(--primary, #FF6B6B);
    border: 3px solid #4a4a4a;  /* Forcé à la couleur du mode sombre */
    color: var(--bg-light, #FFF8DC);
    font-size: 2rem;
    font-weight: bold;
    width: 50px;
    height: 50px;
    cursor: pointer;
    z-index: 10001;
    transition: all 0.2s ease;
    font-family: 'Courier New', monospace;
    box-shadow:
        inset -2px -2px 0 rgba(0, 0, 0, 0.3),
        inset 2px 2px 0 rgba(255, 255, 255, 0.3),
        2px 2px 0 rgba(0, 0, 0, 0.3);
}

.lightbox-close:hover {
    transform: translateY(-2px);
    box-shadow:
        inset -2px -2px 0 rgba(0, 0, 0, 0.3),
        inset 2px 2px 0 rgba(255, 255, 255, 0.3),
        4px 4px 0 rgba(0, 0, 0, 0.3);
    background: var(--primary-hover, #FF5252);
}

.lightbox-prev:hover,
.lightbox-next:hover {
    transform: translateY(calc(-50% - 2px));
    box-shadow:
        inset -2px -2px 0 rgba(0, 0, 0, 0.3),
        inset 2px 2px 0 rgba(255, 255, 255, 0.3),
        4px 4px 0 rgba(0, 0, 0, 0.3);
    background: var(--primary-hover, #FF5252);
}

.lightbox-close:active {
    transform: translateY(0);
    box-shadow:
        inset -2px -2px 0 rgba(255, 255, 255, 0.3),
        inset 2px 2px 0 rgba(0, 0, 0, 0.3),
        1px 1px 0 rgba(0, 0, 0, 0.3);
}

.lightbox-prev:active,
.lightbox-next:active {
    transform: translateY(-50%);
    box-shadow:
        inset -2px -2px 0 rgba(255, 255, 255, 0.3),
        inset 2px 2px 0 rgba(0, 0, 0, 0.3),
        1px 1px 0 rgba(0, 0, 0, 0.3);
}

/* Positionnement du bouton fermer */
.lightbox-close {
    top: 20px;
    right: 20px;
    border-radius: 0;
}

.lightbox-close span {
    display: block;
    line-height: 44px;
    text-align: center;
}

/* Positionnement des boutons prev/next */
.lightbox-prev,
.lightbox-next {
    top: 50%;
    transform: translateY(-50%);
    border-radius: 0;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-prev span,
.lightbox-next span {
    display: block;
    line-height: 44px;
    text-align: center;
}

/* Images cliquables - indication visuelle */
img[data-lightbox-enabled] {
    transition: all 0.2s ease;
}

img[data-lightbox-enabled]:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Responsive pour mobile */
@media (max-width: 768px) {
    .lightbox-image {
        max-width: 95vw;
        max-height: 80vh;
        border-width: 2px;
    }

    .lightbox-close,
    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
        border-width: 2px;
    }

    .lightbox-close span,
    .lightbox-prev span,
    .lightbox-next span {
        line-height: 36px;
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-caption {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Animation de chargement */
.lightbox-image.loading {
    opacity: 0.5;
}

/* Curseur zoom sur les images */
.article-content img,
.preview-content img,
figure img,
.img-grid img,
.markdown-body img {
    cursor: zoom-in;
}

/* Focus styles pour l'accessibilité */
.lightbox-close:focus,
.lightbox-prev:focus,
.lightbox-next:focus {
    outline: 3px solid var(--accent, #4ECDC4);
    outline-offset: 2px;
}

/* Support du mode sombre si défini */
@media (prefers-color-scheme: dark) {
    .lightbox-overlay {
        background-color: rgba(0, 0, 0, 0.95);
    }

    .lightbox-caption {
        background: var(--bg-dark, #1a1a1a);
        color: var(--text-light, #FFF8DC);
        border-color: var(--border-light, #FFF8DC);
    }
}

/* Désactiver la sélection de texte sur les boutons */
.lightbox-close,
.lightbox-prev,
.lightbox-next {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}