/**
 * Galleries Frontend Styles
 *
 * @package LDStarter
 * @subpackage Galleries
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    --lds-gallery-columns: 4;
    --lds-gallery-gap: 16px;
    --lds-gallery-row-height: 200px;
    --lds-gallery-bg: transparent;
    --lds-gallery-border: #e5e7eb;
    --lds-gallery-radius: 8px;
    --lds-gallery-transition: 0.3s ease;
}

/* ============================================
   Base Styles
   ============================================ */
.lds-gallery {
    width: 100%;
    margin: 1.5rem 0;
}

.lds-gallery__item {
    margin: 0;
    overflow: hidden;
    border-radius: var(--lds-gallery-radius);
    background: var(--lds-gallery-bg);
}

.lds-gallery__link {
    display: block;
    position: relative;
    height: 100%;
}

.lds-gallery__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--lds-gallery-transition);
}

.lds-gallery__item:hover .lds-gallery__image {
    transform: scale(1.05);
}

/* Zoom Icon */
.lds-gallery__zoom {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border-radius: 50%;
    opacity: 0;
    transition: opacity var(--lds-gallery-transition), transform var(--lds-gallery-transition);
    pointer-events: none;
}

.lds-gallery__link:hover .lds-gallery__zoom,
.lds-gallery__link:focus .lds-gallery__zoom {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ============================================
   GRID STYLE
   ============================================ */
.lds-gallery--grid .lds-gallery__grid {
    display: grid;
    grid-template-columns: repeat(var(--lds-gallery-columns), 1fr);
    gap: var(--lds-gallery-gap);
}

.lds-gallery--grid .lds-gallery__item {
    aspect-ratio: 1;
}

/* Grid Responsive */
@media (max-width: 1024px) {
    .lds-gallery--grid .lds-gallery__grid {
        grid-template-columns: repeat(min(var(--lds-gallery-columns), 3), 1fr);
    }
}

@media (max-width: 768px) {
    .lds-gallery--grid .lds-gallery__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .lds-gallery--grid .lds-gallery__grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   MASONRY STYLE
   ============================================ */
.lds-gallery--masonry .lds-gallery__masonry {
    column-count: var(--lds-gallery-columns);
    column-gap: var(--lds-gallery-gap);
}

.lds-gallery--masonry .lds-gallery__item {
    break-inside: avoid;
    margin-bottom: var(--lds-gallery-gap);
}

.lds-gallery--masonry .lds-gallery__image {
    height: auto;
}

/* Masonry Responsive */
@media (max-width: 1024px) {
    .lds-gallery--masonry .lds-gallery__masonry {
        column-count: 3;
    }
}

@media (max-width: 768px) {
    .lds-gallery--masonry .lds-gallery__masonry {
        column-count: 2;
    }
}

@media (max-width: 480px) {
    .lds-gallery--masonry .lds-gallery__masonry {
        column-count: 1;
    }
}

/* ============================================
   JUSTIFIED STYLE
   ============================================ */
.lds-gallery--justified .lds-gallery__justified {
    display: flex;
    flex-wrap: wrap;
    gap: var(--lds-gallery-gap);
}

.lds-gallery--justified .lds-gallery__item {
    height: var(--lds-gallery-row-height);
    min-width: 100px;
}

.lds-gallery--justified .lds-gallery__item:last-child {
    flex-grow: 0;
}

/* Justified Responsive */
@media (max-width: 768px) {
    .lds-gallery--justified {
        --lds-gallery-row-height: 150px;
    }
}

@media (max-width: 480px) {
    .lds-gallery--justified .lds-gallery__item {
        flex-grow: 1 !important;
        flex-basis: 100% !important;
        height: auto;
        aspect-ratio: 16/9;
    }
}

/* ============================================
   CAROUSEL STYLE
   ============================================ */
.lds-gallery--carousel {
    position: relative;
}

.lds-gallery--carousel .lds-gallery__carousel {
    position: relative;
    overflow: hidden;
    border-radius: var(--lds-gallery-radius);
}

.lds-gallery--carousel .lds-gallery__track {
    display: flex;
    transition: transform 0.5s ease;
}

.lds-gallery--carousel .lds-gallery__slide {
    flex: 0 0 100%;
    aspect-ratio: 16/9;
    margin: 0;
}

.lds-gallery--carousel .lds-gallery__image {
    object-fit: contain;
    background: #000;
}

/* Navigation Buttons */
.lds-gallery__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: background var(--lds-gallery-transition), transform var(--lds-gallery-transition);
}

.lds-gallery__nav:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.1);
}

.lds-gallery__nav:focus {
    outline: 2px solid var(--color-primary, #3b82f6);
    outline-offset: 2px;
}

.lds-gallery__nav--prev {
    left: 16px;
}

.lds-gallery__nav--next {
    right: 16px;
}

.lds-gallery__nav svg {
    width: 24px;
    height: 24px;
    color: #333;
}

/* Dots */
.lds-gallery__dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.lds-gallery__dot {
    width: 12px;
    height: 12px;
    border: 1px solid #6B7280;
    border-radius: 50%;
    background: var(--lds-gallery-border);
    cursor: pointer;
    padding: 0;
    transition: background var(--lds-gallery-transition), transform var(--lds-gallery-transition);
}

.lds-gallery__dot:hover,
.lds-gallery__dot.is-active {
    background: var(--color-primary, #3b82f6);
    transform: scale(1.2);
}

.lds-gallery__dot:focus {
    outline: 2px solid var(--color-focus, var(--color-primary, #3b82f6));
    outline-offset: 2px;
}

/* Bouton pause du défilement automatique (ajouté par le script) */
.lds-gallery__dots {
    align-items: center;
}

.lds-gallery__pause {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-right: 8px;
    padding: 0;
    border: 1px solid #6B7280;
    border-radius: 50%;
    background: #fff;
    color: #1F2937;
    cursor: pointer;
}

.lds-gallery__pause svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.lds-gallery__pause:focus-visible {
    outline: 2px solid var(--color-focus, var(--color-primary, #3b82f6));
    outline-offset: 2px;
}

/* Carousel Responsive */
@media (max-width: 768px) {
    .lds-gallery__nav {
        width: 36px;
        height: 36px;
    }

    .lds-gallery__nav svg {
        width: 20px;
        height: 20px;
    }

    .lds-gallery__nav--prev {
        left: 8px;
    }

    .lds-gallery__nav--next {
        right: 8px;
    }

    .lds-gallery__dots {
        gap: 6px;
    }

    .lds-gallery__dot {
        width: 10px;
        height: 10px;
    }
}

/* ============================================
   ERROR MESSAGE
   ============================================ */
.lds-gallery-error {
    padding: 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 4px;
    color: #dc2626;
    font-size: 14px;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .lds-gallery__image,
    .lds-gallery__zoom,
    .lds-gallery__nav,
    .lds-gallery__dot,
    .lds-gallery--carousel .lds-gallery__track {
        transition: none;
    }

    .lds-gallery__item:hover .lds-gallery__image {
        transform: none;
    }
}

/* Focus visible for keyboard navigation (contour intérieur : la figure
   rogne tout ce qui dépasse) */
.lds-gallery__link:focus-visible {
    outline: 3px solid var(--color-focus, var(--color-primary, #3b82f6));
    outline-offset: -3px;
}
