/**
 * Styles pour le carrousel de photos moderne
 * Avec lightbox et animations fluides
 */

/* ============================================
   CARROUSEL PRINCIPAL
   ============================================ */

.photo-carousel-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    background: var(--color-white);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    position: relative;
}

/*
 * Réserver une hauteur avant l'initialisation JS (évite CLS).
 * Utilise :empty car le conteneur est vide côté HTML avant l'hydration.
 */
.photo-carousel-container:empty {
    aspect-ratio: 1/1;
}

.photo-carousel-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1/1;
    overflow: hidden;
    background: var(--color-white);
}

/* Track du carrousel */
.carousel-track-container {
    width: 100%;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    position: relative;
    background: var(--color-white);
}

.carousel-track {
    display: flex;
    height: 100%;
    width: 100%;
}

.carousel-slide {
    flex: 0 0 100%;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-white);
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.carousel-slide::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.carousel-slide:hover::after {
    background: rgba(0, 0, 0, 0.1);
}

.carousel-slide::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 60px;
    height: 60px;
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"%3E%3Ccircle cx="11" cy="11" r="8"%3E%3C/circle%3E%3Cpath d="m21 21-4.35-4.35"%3E%3C/path%3E%3Cline x1="11" y1="8" x2="11" y2="14"%3E%3C/line%3E%3Cline x1="8" y1="11" x2="14" y2="11"%3E%3C/line%3E%3C/svg%3E');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 2;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
}

.carousel-slide:hover::before {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.carousel-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
    cursor: pointer !important;
}

.carousel-image:hover {
    transform: scale(1.02);
}

.carousel-slide.active .carousel-image {
    animation: zoomIn 0.5s ease-out;
}

@keyframes zoomIn {
    from {
        transform: scale(1.05);
        opacity: 0.8;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Boutons de navigation */
.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    color: var(--color-primary);
}

.carousel-nav:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.carousel-nav:active {
    transform: translateY(-50%) scale(0.95);
}

.carousel-nav-prev {
    left: 16px;
}

.carousel-nav-next {
    right: 16px;
}

.carousel-nav svg {
    width: 24px;
    height: 24px;
}

/* Indicateurs (dots) */
.carousel-indicators {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 16px;
    border-radius: 24px;
    backdrop-filter: blur(8px);
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid white;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.carousel-dot:hover {
    transform: scale(1.2);
    background: rgba(255, 255, 255, 0.5);
}

.carousel-dot.active {
    background: white;
    width: 28px;
    border-radius: 6px;
}

/* Compteur */
.carousel-counter {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    z-index: 10;
    backdrop-filter: blur(8px);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.carousel-counter .current {
    color: var(--color-accent);
    font-weight: 700;
}

/* Placeholder (aucune photo) */
.carousel-placeholder {
    width: 100%;
    aspect-ratio: 1/1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 3px dashed var(--color-border-light);
    color: var(--color-gray);
    gap: 16px;
    border-radius: var(--border-radius-md);
}

.carousel-placeholder svg {
    opacity: 0.3;
    stroke: rgba(0, 0, 0, 0.3);
}

.carousel-placeholder p {
    font-size: 16px;
    font-weight: 500;
    margin: 0;
    color: rgba(0, 0, 0, 0.4);
}

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

.photo-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.photo-lightbox.active {
    display: block;
    opacity: 1;
}

.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.lightbox-image-container {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: lightboxZoomIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes lightboxZoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Boutons lightbox */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.lightbox-close:hover {
    background: white;
    transform: rotate(90deg) scale(1.1);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    border: none;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    color: var(--color-primary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.lightbox-nav:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 40px;
}

.lightbox-next {
    right: 40px;
}

.lightbox-nav svg {
    width: 32px;
    height: 32px;
}

.lightbox-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    color: var(--color-primary);
    padding: 10px 24px;
    border-radius: 24px;
    font-size: 16px;
    font-weight: 600;
    z-index: 10;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-family: var(--font-primary);
}

.lightbox-counter .current {
    color: var(--color-accent);
}

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

@media (max-width: 768px) {
    .photo-carousel-wrapper {
        aspect-ratio: 4/3;
    }

    .carousel-nav {
        width: 40px;
        height: 40px;
    }

    .carousel-nav-prev {
        left: 8px;
    }

    .carousel-nav-next {
        right: 8px;
    }

    .carousel-nav svg {
        width: 20px;
        height: 20px;
    }

    .carousel-indicators {
        bottom: 12px;
        padding: 6px 12px;
        gap: 8px;
    }

    .carousel-dot {
        width: 8px;
        height: 8px;
    }

    .carousel-dot.active {
        width: 20px;
    }

    .carousel-counter {
        top: 12px;
        right: 12px;
        padding: 4px 10px;
        font-size: 12px;
    }

    /* Lightbox mobile */
    .lightbox-content {
        padding: 40px 10px;
    }

    .lightbox-close {
        top: 15px;
        right: 15px;
        width: 44px;
        height: 44px;
    }

    .lightbox-nav {
        width: 48px;
        height: 48px;
    }

    .lightbox-prev {
        left: 15px;
    }

    .lightbox-next {
        right: 15px;
    }

}

/* Mobile/tactile: flèches plus discrètes (ne masquent pas la photo) */
@media (hover: none) and (pointer: coarse) {
    .carousel-nav {
        background: rgba(255, 255, 255, 0.18);
        box-shadow: none;
        opacity: 0.35;
        -webkit-tap-highlight-color: transparent;
    }

    .carousel-nav:hover,
    .carousel-nav:active,
    .carousel-nav:focus {
        background: rgba(255, 255, 255, 0.18);
        box-shadow: none;
        opacity: 0.35;
        transform: translateY(-50%);
    }

    .lightbox-nav {
        background: rgba(255, 255, 255, 0.18);
        box-shadow: none;
        opacity: 0.35;
        color: white;
        -webkit-tap-highlight-color: transparent;
    }

    .lightbox-nav:hover,
    .lightbox-nav:active,
    .lightbox-nav:focus {
        background: rgba(255, 255, 255, 0.18);
        box-shadow: none;
        opacity: 0.35;
        transform: translateY(-50%);
    }
}
    .lightbox-counter {
        bottom: 20px;
        padding: 8px 18px;
        font-size: 14px;
    }

    .lightbox-image {
        max-height: 80vh;
    }
}

@media (max-width: 480px) {
    .photo-carousel-wrapper {
        aspect-ratio: 1/1;
    }

    .carousel-nav {
        width: 36px;
        height: 36px;
    }

    .carousel-nav svg {
        width: 18px;
        height: 18px;
    }

    .carousel-placeholder p {
        font-size: 16px;
    }

    .carousel-placeholder svg {
        width: 60px;
        height: 60px;
    }
}

/* Accessibilité */
@media (prefers-reduced-motion: reduce) {
    .carousel-track,
    .carousel-nav,
    .carousel-dot,
    .lightbox-image-container,
    .lightbox-close,
    .lightbox-nav {
        transition: none;
        animation: none;
    }
}

/* Focus visible pour accessibilité */
.carousel-nav:focus-visible,
.carousel-dot:focus-visible,
.lightbox-close:focus-visible,
.lightbox-nav:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}
