/* Variables pour réutiliser les valeurs courantes */
:root {
    --overlay-bg: rgba(0, 0, 0, 0.7);
    --container-bg: rgba(232, 232, 232, 0.8);
    --transition-standard: 0.3s ease-in-out;
    --border-radius-standard: 10px;
    --spacing-standard: 20px;
    --thumbnail-size: 200px;
    --animation-duration: 0.3s;
}

/* Conteneur des miniatures */
#thumbnails-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--thumbnail-size), 1fr));
    gap: 10px;
    padding: var(--spacing-standard);
}

/* Conteneur pour une miniature individuelle */
.thumbnail-item {
    position: relative; /* Nécessaire pour positionner la légende absolument */
    display: inline-block; /* Ou utilise les propriétés grid/flex du parent */
    overflow: hidden; /* Cache ce qui dépasse si nécessaire */
    cursor: pointer; /* Garde le curseur pointeur */
    /* Tu peux ajuster la taille ici ou laisser le parent grid s'en occuper */
    width: var(--thumbnail-size);
    /* height: auto; */ /* Ou une hauteur fixe si tu préfères */
    vertical-align: top; /* Bon alignement si display: inline-block */
    border: 1px solid #ccc; /* Applique la bordure ici si tu veux */
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

/* Applique le hover sur l'item */
.thumbnail-item:hover {
    transform: scale(1.05);
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}

/* Style de l'image miniature à l'intérieur de l'item */
.thumbnail-item .thumbnail {
    display: block; /* Assure qu'elle prend toute la largeur/hauteur */
    width: 100%;
    height: auto; /* Ou une hauteur fixe */
    object-fit: cover; /* Recadre l'image si nécessaire */
    border: none; /* Retire la bordure de l'image si elle est sur .thumbnail-item */
    transition: none; /* Retire les transitions de l'image elle-même */
}

/* Style de la légende */
.thumbnail-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.7); /* Fond semi-transparent */
    color: #fff; /* Texte blanc */
    padding: 5px 8px; /* Espacement intérieur */
    font-size: 0.8em; /* Taille de police plus petite */
    text-align: center;
    opacity: 0; /* Cachée par défaut */
    transition: opacity 0.3s ease-in-out; /* Animation d'apparition */
    pointer-events: none; /* Empêche la légende de bloquer le clic sur l'item */
    /* Optionnel: Limiter le nombre de lignes */
}

/* Fait apparaître la légende au survol du conteneur .thumbnail-item */
.thumbnail-item:hover .thumbnail-caption {
    opacity: 1;
}

/* Ajuste le style du conteneur principal si nécessaire */
/* Si tu utilises display: grid sur .mso-gallery-thumbnails */
.mso-gallery-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--thumbnail-size, 150px), 1fr)); /* Ajuste la taille min */
    gap: 10px;
    padding: var(--spacing-standard, 10px);
}

.thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}

/* Overlay en plein écran */
#fullscreen-overlay {
    position: fixed;
    inset: 0; /* Remplace top, right, bottom, left: 0 */
    background-color: var(--overlay-bg);
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--transition-standard);
    display: none;
}

#fullscreen-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Styles communs pour les boutons de navigation */
.nav-button {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 85%;
    max-width: 180px;
    background: transparent;
    border: none;
    color: transparent;
    font-size: 2.5rem;
    cursor: pointer;
    z-index: 1010;
    transition: background-color 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    padding: 0;
}

.nav-button:hover {
    color: #eee;
}

.nav-button:disabled {
    color: #666;
    cursor: not-allowed;
    opacity: 0.4;
    background-color: transparent !important;
}

#image-container #prev-btn {
    left: 0;
    justify-content: flex-start;
    padding-left: var(--spacing-standard);
    border-radius: var(--border-radius-standard) 0 0 var(--border-radius-standard);
}

#image-container #next-btn {
    right: 0;
    justify-content: flex-end;
    padding-right: var(--spacing-standard);
    border-radius: 0 var(--border-radius-standard) var(--border-radius-standard) 0;
}

/* Bouton de fermeture */
#image-container #close-btn {
    position: absolute;
    top: -26px;
    right: -26px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: var(--container-bg);
    border: none;
    color: white;
    font-size: 1.4rem;
    font-weight: bold;
    line-height: 1px;
    cursor: pointer;
    padding: 5px;
    z-index: 1015;
    transition: color 0.2s ease, background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#close-btn:hover {
    color: #f00;
    background-color: rgba(232, 232, 232, 0.9);
}

/* Image en plein écran et conteneur */
#image-container {
    position: absolute;
    top: 50%;
    left: 50%;
    padding: var(--spacing-standard);
    background-color: rgba(232, 232, 232, 1);
    border-radius: var(--border-radius-standard);
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
}

/* Nouveau conteneur pour l'image et les boutons */
.image-and-nav-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
}

#fullscreen-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: auto; /* Centrage */
}

/* Style de la légende */
#image-caption {
    position: absolute;
    bottom: 10px; /* Ou ajuste */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px 15px;
    margin-top: 8px;
    border-radius: 5px;
    font-size: 16px;
    text-align: center;
    transition: opacity var(--transition-standard);
    max-width: 90%;
    word-wrap: break-word;
    flex-shrink: 0;
    box-sizing: border-box;
}


/* Indicateur de chargement */
#loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--overlay-bg);
    color: #fff;
    padding: 10px 15px;
    border-radius: 5px;
    display: none;
    z-index: 1100;
}

/* Cache pour les images préchargées */
#preload-cache {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    visibility: hidden;
}

#image-container-inner {
    position: relative; /* Ou absolute si #image-container gère le positionnement */
    width: 100%;
    height: 100%;
    display: flex; /* Pour centrer l'image si besoin */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity var(--animation-duration, 0.3s) ease-in-out, transform var(--animation-duration, 0.3s) ease-in-out;
    transform: translateX(0);
}




/* animation flip */
.flip-in-from-left {
    animation: slideUpInFromLeft 0.3s ease forwards;
}
.flip-in-from-right {
    animation: slideUpInFromRight 0.3s ease forwards;
}
.flip-out-left {
    animation: slideUpOutLeft 0.3s ease forwards;
}
.flip-out-right {
    animation: slideUpOutRight 0.3s ease forwards;
}

@keyframes slideUpInFromLeft {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

@keyframes slideUpInFromRight {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
@keyframes slideUpOutLeft {
    from { transform: translateY(0); opacity: 1; }
    to   { transform: translateY(-100%); opacity: 0; }
}

@keyframes slideUpOutRight {
    from { transform: translateY(0); opacity: 1; }
    to   { transform: translateY(100%); opacity: 0; }
}

.slide-in-from-left {
    animation: slideInFromLeft 0.3s forwards;
}

.slide-in-from-right {
    animation: slideInFromRight 0.3s forwards;
}

.slide-out-left {
    animation: slideOutLeft 0.3s forwards;
}

.slide-out-right {
    animation: slideOutRight 0.3s forwards;
}

@keyframes slideInFromLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

@keyframes slideInFromRight {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(-100%); opacity: 0; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(100%); opacity: 0; }
}

/* Appliqué à l'image pendant le slide-out */
.slide-out-left #fullscreen-image,
.slide-out-right #fullscreen-image {
    animation: fadeOut 0.3s forwards;
}

/* Et pendant le slide-in, on la fait apparaître */
.slide-in-from-left #fullscreen-image,
.slide-in-from-right #fullscreen-image {
    animation: fadeIn 0.3s forwards;
}



/* --- Fade Animation --- */
.fade-in {
    animation: fadeIn 0.3s forwards;
}

.fade-out {
    animation: fadeOut 0.3s forwards;
}

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

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

.fade-zoom-in {
    animation: fadeZoomIn 0.3s ease forwards;
}
.fade-zoom-out {
    animation: fadeZoomOut 0.3s ease forwards;
}

@keyframes fadeZoomIn {
    from { opacity: 0; transform: scale(0); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes fadeZoomOut {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0); }
}

.rotate-in {
    animation: rotateIn 0.5s ease both;
}
.rotate-out {
    animation: rotateOut 0.5s ease both;
}

@keyframes rotateIn {
    from {
        transform: rotate(-180deg);
        opacity: 0;
    }
    to {
        transform: rotate(0deg);
        opacity: 1;
    }
}

@keyframes rotateOut {
    from {
        transform: rotate(0deg);
        opacity: 1;
    }
    to {
        transform: rotate(180deg);
        opacity: 0;
    }
}

.diagonal-in-left {
    animation: diagonalInLeft 0.5s ease both;
}
.diagonal-out-left {
    animation: diagonalOutLeft 0.5s ease both;
}

.diagonal-in-right {
    animation: diagonalInRight 0.5s ease both;
}
.diagonal-out-right {
    animation: diagonalOutRight 0.5s ease both;
}

@keyframes diagonalInLeft {
    from {
        transform: translate(-100%, 100%);
        opacity: 0;
    }
    to {
        transform: translate(0, 0);
        opacity: 1;
    }
}
@keyframes diagonalOutLeft {
    from {
        transform: translate(0, 0);
        opacity: 1;
    }
    to {
        transform: translate(100%, -100%);
        opacity: 0;
    }
}
@keyframes diagonalInRight {
    from {
        transform: translate(100%, 100%);
        opacity: 0;
    }
    to {
        transform: translate(0, 0);
        opacity: 1;
    }
}
@keyframes diagonalOutRight {
    from {
        transform: translate(0, 0);
        opacity: 1;
    }
    to {
        transform: translate(-100%, -100%);
        opacity: 0;
    }
}




.bounce-in {
    animation: bounceIn 0.6s ease both;
}

.bounce-out {
    animation: bounceOut 0.4s ease both;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes bounceOut {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.3);
        opacity: 0;
    }
}