/**
 * Gallery Slider Styles
 * Modern slider with thumbnails and lightbox for WordPress galleries
 */

/* ==========================================================================
   Gallery Slider Container
   ========================================================================== */

.gallery-slider {
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: var(--spacing-8) auto;
    border-radius: var(--rounded-xl);
    overflow: hidden;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   Main Image Display
   ========================================================================== */

.gallery-slider__main {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    background: var(--color-bg-alt);
    cursor: zoom-in;
    overflow: hidden;
}

.gallery-slider__main-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.gallery-slider__main-image.transitioning {
    opacity: 0.7;
    transform: scale(0.98);
}

/* Caption Overlay */
.gallery-slider__caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--spacing-6) var(--spacing-5) var(--spacing-4);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.4) 60%, transparent);
    color: #fff;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    line-height: var(--leading-snug);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    opacity: 1;
    transition: opacity 0.3s ease;
}

.gallery-slider__caption:empty {
    display: none;
}

/* Counter Badge */
.gallery-slider__counter {
    position: absolute;
    top: var(--spacing-3);
    right: var(--spacing-3);
    padding: var(--spacing-1) var(--spacing-3);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    border-radius: var(--rounded-full);
}

/* Navigation Arrows */
.gallery-slider__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: var(--rounded-full);
    color: var(--color-secondary);
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: var(--shadow-lg);
}

.gallery-slider__nav svg {
    width: 24px;
    height: 24px;
    stroke-width: 2.5;
}

.gallery-slider__nav--prev {
    left: var(--spacing-3);
}

.gallery-slider__nav--next {
    right: var(--spacing-3);
}

.gallery-slider:hover .gallery-slider__nav {
    opacity: 1;
}

.gallery-slider__nav:hover {
    background: var(--color-primary);
    color: var(--color-secondary);
    transform: translateY(-50%) scale(1.1);
}

.gallery-slider__nav:active {
    transform: translateY(-50%) scale(0.95);
}

/* ==========================================================================
   Thumbnail Strip
   ========================================================================== */

.gallery-slider__thumbs {
    display: flex;
    justify-content: center;
    gap: var(--spacing-3);
    padding: var(--spacing-4) var(--spacing-5);
    background: linear-gradient(to bottom, var(--color-bg-alt), var(--color-surface));
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.gallery-slider__thumbs::-webkit-scrollbar {
    display: none;
}

.gallery-slider__thumb {
    position: relative;
    flex-shrink: 0;
    width: 120px;
    height: 80px;
    padding: 4px;
    border: none;
    border-radius: var(--rounded-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--color-bg-alt);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.gallery-slider__thumb::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--rounded-lg);
    border: 2px solid transparent;
    transition: all 0.35s ease;
    z-index: 2;
    pointer-events: none;
}

.gallery-slider__thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.gallery-slider__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    margin: 0 !important;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), filter 0.3s ease;
    filter: saturate(0.9);
}

.gallery-slider__thumb:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15), 0 4px 8px rgba(0, 0, 0, 0.1);
}

.gallery-slider__thumb:hover::before {
    border-color: var(--color-text-muted);
}

.gallery-slider__thumb:hover::after {
    opacity: 1;
}

.gallery-slider__thumb:hover img {
    filter: saturate(1.1) brightness(1.02);
}

.gallery-slider__thumb.active {
    transform: translateY(-4px) scale(1.08);
    box-shadow:
        0 0 0 3px var(--color-primary),
        0 8px 25px rgba(var(--color-primary-rgb), 0.4),
        0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery-slider__thumb.active::before {
    border-color: var(--color-primary);
    border-width: 3px;
}

.gallery-slider__thumb.active img {
    filter: saturate(1.15) brightness(1.05);
}

/* Subtle pulse animation for active thumbnail */
@keyframes thumbPulse {

    0%,
    100% {
        box-shadow:
            0 0 0 3px var(--color-primary),
            0 8px 25px rgba(var(--color-primary-rgb), 0.4);
    }

    50% {
        box-shadow:
            0 0 0 4px var(--color-primary),
            0 8px 30px rgba(var(--color-primary-rgb), 0.5);
    }
}

.gallery-slider__thumb.active {
    animation: thumbPulse 2s ease-in-out infinite;
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: var(--z-modal);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.gallery-lightbox__close {
    position: absolute;
    top: var(--spacing-4);
    right: var(--spacing-4);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: var(--rounded-full);
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.gallery-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.gallery-lightbox__close svg {
    width: 24px;
    height: 24px;
}

.gallery-lightbox__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
    max-height: 85vh;
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-lightbox.active .gallery-lightbox__content {
    transform: scale(1);
}

.gallery-lightbox__image {
    max-width: 100%;
    max-height: calc(85vh - 60px);
    object-fit: contain;
    border-radius: var(--rounded-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.gallery-lightbox__caption {
    margin-top: var(--spacing-4);
    padding: var(--spacing-3) var(--spacing-6);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--rounded-lg);
    color: #fff;
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    text-align: center;
    max-width: 600px;
}

.gallery-lightbox__caption:empty {
    display: none;
}

/* Lightbox Navigation */
.gallery-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: var(--rounded-full);
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.gallery-lightbox__nav:hover {
    background: var(--color-primary);
    color: var(--color-secondary);
}

.gallery-lightbox__nav svg {
    width: 28px;
    height: 28px;
}

.gallery-lightbox__nav--prev {
    left: var(--spacing-4);
}

.gallery-lightbox__nav--next {
    right: var(--spacing-4);
}

/* Counter in Lightbox */
.gallery-lightbox__counter {
    position: absolute;
    bottom: var(--spacing-4);
    left: 50%;
    transform: translateX(-50%);
    padding: var(--spacing-2) var(--spacing-4);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--rounded-full);
    color: #fff;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 768px) {
    .gallery-slider {
        border-radius: var(--rounded-lg);
        margin: var(--spacing-6) auto;
    }

    .gallery-slider__main {
        aspect-ratio: 4 / 3;
    }

    .gallery-slider__nav {
        width: 40px;
        height: 40px;
        opacity: 0.8;
    }

    .gallery-slider__nav svg {
        width: 20px;
        height: 20px;
    }

    .gallery-slider__thumb {
        width: 100px;
        height: 66px;
    }

    .gallery-slider__thumbs {
        justify-content: flex-start;
        padding: var(--spacing-3) var(--spacing-4);
    }

    .gallery-lightbox__nav {
        width: 44px;
        height: 44px;
    }

    .gallery-lightbox__nav svg {
        width: 22px;
        height: 22px;
    }

    .gallery-lightbox__close {
        top: var(--spacing-3);
        right: var(--spacing-3);
        width: 40px;
        height: 40px;
    }

    .gallery-lightbox__caption {
        font-size: var(--text-sm);
        padding: var(--spacing-2) var(--spacing-4);
    }
}

@media (max-width: 480px) {
    .gallery-slider__main {
        aspect-ratio: 1 / 1;
    }

    .gallery-slider__thumb {
        width: 80px;
        height: 54px;
    }

    .gallery-slider__thumb.active {
        animation: none;
    }

    .gallery-slider__caption {
        font-size: var(--text-xs);
        padding: var(--spacing-4) var(--spacing-3) var(--spacing-3);
    }

    .gallery-lightbox__nav--prev {
        left: var(--spacing-2);
    }

    .gallery-lightbox__nav--next {
        right: var(--spacing-2);
    }
}

/* ==========================================================================
   Hide Original Gallery When Slider Is Active
   ========================================================================== */

.gallery.gallery-slider-enabled {
    display: none !important;
}

/* ==========================================================================
   Dark Mode Adjustments
   ========================================================================== */

[data-theme="dark"] .gallery-slider {
    border-color: var(--color-border);
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .gallery-slider__nav {
    background: rgba(30, 30, 30, 0.95);
    color: #fff;
}

[data-theme="dark"] .gallery-slider__nav:hover {
    background: var(--color-primary);
    color: var(--color-secondary);
}

[data-theme="dark"] .gallery-slider__thumbs {
    background: var(--color-surface);
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.gallery-slider {
    animation: fadeIn 0.5s ease;
}