/**
 * Gallery Slideshow Styles
 * Version: 1.0.0
 */

/* Hide gallery with slideshow class immediately before JS loads */
.wp-block-gallery.slideshow,
.wp-block-gallery.has-nested-images.slideshow,
.wp-block-gallery.slideshow figure,
.wp-block-gallery.has-nested-images.slideshow figure,
.wp-block-gallery.fixed-slideshow,
.wp-block-gallery.fixed-slideshow figure {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    left: -99999px !important;
}

/* Loading state for slideshow container */
.gs-slideshow-container.gs-loading {
    min-height: 300px;
    background: linear-gradient(90deg, #f0f0f0 25%, #f5f5f5 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: gsShimmer 1.5s ease-in-out infinite;
    position: relative;
}

.gs-slideshow-container.gs-loading:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: #666;
    border-radius: 50%;
    animation: gsSpin 0.6s linear infinite;
}

@keyframes gsShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Slideshow Wrapper - Full Width Container */
.gs-slideshow-wrapper {
    position: relative;
    width: 100vw;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    overflow: hidden;
}

/* Fixed Position Slideshow - Between Header and Main */
.gs-slideshow-wrapper.gs-fixed-position {
    position: relative;
    width: 100vw;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0;
    margin-left: 0;
    margin-right: 0;
    transform: none;
}

/* Remove any theme margins/padding when in fixed position */
.page .gs-slideshow-wrapper.gs-fixed-position {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* When slideshow is in fixed position, ensure main content follows naturally */
.page .gs-slideshow-wrapper.gs-fixed-position + main,
.page .gs-slideshow-wrapper.gs-fixed-position + #primary {
    margin-top: 0;
}

/* Keep gallery hidden even after wrapping - more specific selectors */
.gs-slideshow-wrapper > .wp-block-gallery.slideshow,
.gs-slideshow-wrapper > .wp-block-gallery.has-nested-images.slideshow,
.gs-slideshow-wrapper > figure.wp-block-gallery.slideshow,
.gs-slideshow-wrapper > figure.wp-block-gallery.has-nested-images.slideshow {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -99999px !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
}

/* Slideshow Container */
.gs-slideshow-container {
    position: relative;
    width: 100%;
    height: auto;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gs-slideshow-container.viewport-height {
    height: 100vh;
}

.gs-slideshow-container.viewport-height .gs-slide img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.gs-slideshow-container.custom-height {
    height: var(--custom-height, 600px);
    overflow: hidden;
}

.gs-slideshow-container.aspect-ratio {
    height: auto;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
}

/* Slides Wrapper */
.gs-slides-wrapper {
    position: relative;
    width: 100%;
    min-height: 200px; /* Minimum height to prevent collapse */
    display: flex;
    transition: transform 0.6s ease-in-out;
}

.gs-slides-wrapper.fade-transition {
    display: block;
    position: relative;
}

/* Custom height mode - slides wrapper fills container */
.gs-slideshow-container.custom-height .gs-slides-wrapper {
    height: 100%;
    min-height: unset;
}

/* Individual Slide */
.gs-slide {
    position: relative;
    width: 100%;
    height: auto;
    opacity: 0;
    transition: opacity 0.6s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Fade transition mode - slides need absolute positioning */
.fade-transition .gs-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
}

/* Custom height with fade transition */
.gs-slideshow-container.custom-height .fade-transition .gs-slide {
    height: 100%;
}

.gs-slide.active {
    opacity: 1;
    z-index: 2;
}

.gs-slide.prev {
    z-index: 1;
}

/* Slide transition */
.gs-slides-wrapper:not(.fade-transition) .gs-slide {
    position: relative;
    flex: 0 0 100%;
    opacity: 1;
}

/* Slide Image */
.gs-slide img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

/* Custom height mode - crop images */
.gs-slideshow-container.custom-height .gs-slide {
    height: 100%;
}

.gs-slideshow-container.custom-height .gs-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
}

.gs-slide.cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Navigation Arrows */
.gs-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    z-index: 10;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.gs-nav-arrow:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.gs-nav-prev {
    left: 20px;
}

.gs-nav-next {
    right: 20px;
}

.gs-nav-arrow:before {
    content: '';
    display: block;
    width: 12px;
    height: 12px;
    border-top: 3px solid #333;
    border-right: 3px solid #333;
}

.gs-nav-prev:before {
    transform: rotate(-135deg);
    margin-left: 4px;
}

.gs-nav-next:before {
    transform: rotate(45deg);
    margin-right: 4px;
}

/* Navigation Dots */
.gs-dots {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 30px;
}

.gs-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
}

.gs-dot:hover {
    background: rgba(255, 255, 255, 0.8);
}

.gs-dot.active {
    background: #fff;
    transform: scale(1.2);
}

/* Thumbnails Navigation */
.gs-thumbnails {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    overflow-x: auto;
    gap: 5px;
    padding: 10px;
    z-index: 10;
}

.gs-thumbnail {
    flex: 0 0 auto;
    width: 80px;
    height: 80px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s ease;
    border: 2px solid transparent;
}

.gs-thumbnail:hover {
    opacity: 0.8;
}

.gs-thumbnail.active {
    opacity: 1;
    border-color: #fff;
}

.gs-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Caption */
.gs-caption {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 15px 30px;
    border-radius: 5px;
    max-width: 80%;
    text-align: center;
    z-index: 10;
    font-size: 16px;
    line-height: 1.4;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gs-caption.visible {
    opacity: 1;
}

/* Play/Pause Button */
.gs-play-pause {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.gs-play-pause:hover {
    opacity: 1;
}

.gs-play-pause:before,
.gs-play-pause:after {
    content: '';
    display: block;
    background: #333;
}

.gs-play-pause.playing:before,
.gs-play-pause.playing:after {
    width: 4px;
    height: 16px;
    margin: 0 2px;
}

.gs-play-pause.paused:before {
    width: 0;
    height: 0;
    border-left: 12px solid #333;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    margin-left: 3px;
}

/* Progress Bar */
.gs-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 11;
}

.gs-progress-bar {
    height: 100%;
    background: #fff;
    width: 0;
    transition: width linear;
}

/* Loading Spinner */
.gs-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: gsSpin 1s linear infinite;
    z-index: 15;
    display: none;
}

.gs-loading.active {
    display: block;
}

@keyframes gsSpin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Fullscreen Button */
.gs-fullscreen {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 5px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.gs-fullscreen:hover {
    opacity: 1;
}

.gs-fullscreen svg {
    width: 20px;
    height: 20px;
    fill: #333;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .gs-nav-arrow {
        width: 40px;
        height: 40px;
    }
    
    .gs-nav-prev {
        left: 10px;
    }
    
    .gs-nav-next {
        right: 10px;
    }
    
    .gs-dots {
        bottom: 20px;
        padding: 8px 15px;
    }
    
    .gs-dot {
        width: 10px;
        height: 10px;
    }
    
    .gs-caption {
        bottom: 80px;
        font-size: 14px;
        padding: 10px 20px;
    }
    
    .gs-thumbnails {
        height: 80px;
    }
    
    .gs-thumbnail {
        width: 60px;
        height: 60px;
    }
}

/* Touch/Swipe Indicators */
.gs-touch-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 20;
}

.gs-touch-indicator.show {
    opacity: 1;
}

.gs-touch-indicator svg {
    width: 60px;
    height: 60px;
    fill: rgba(255, 255, 255, 0.8);
}

/* Hide scrollbars on thumbnails */
.gs-thumbnails::-webkit-scrollbar {
    height: 5px;
}

.gs-thumbnails::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.gs-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
}

.gs-thumbnails::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Prevent selection during drag */
.gs-slideshow-container.dragging {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}