/* Custom Thumbnail System - Clean & Professional */

/* Hide original Squarespace thumbnails completely */
.gallery-slideshow-thumbnails,
.gallery-slideshow-thumbnails-scroll,
.gallery-slideshow-thumbnails-thumb,
.gallery-slideshow-thumbnails-image-wrapper {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Force hide any direct image children that aren't in our custom thumbnail system */
.gallery-slideshow-wrapper > img,
.gallery-slideshow-controls > img {
    display: none !important;
}

/* Custom thumbnail container */
.custom-thumbnails {
    display: flex !important;
    gap: 12px;
    justify-content: flex-start; /* Left align for proper carousel scrolling */
    margin: 0;
    padding: 0;
    width: auto !important; /* Let it size to content */
    min-width: 100%;
    position: relative;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    z-index: 10;
}

/* Individual thumbnail */
.custom-thumbnail {
    position: relative;
    width: 80px !important;
    height: 80px !important;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    display: block !important;
    background: #f8f8f8;
}

.custom-thumbnail:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.custom-thumbnail.active {
    border-color: #000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.custom-thumbnail.active img {
    opacity: 1;
}

/* Thumbnail image */
.custom-thumbnail img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    object-position: center;
    display: block !important;
    opacity: 0.6;
    transition: all 0.3s ease;
    max-width: 80px !important;
    max-height: 80px !important;
}

.custom-thumbnail:hover img {
    transform: scale(1.05);
}

/* Loading state */
.custom-thumbnail.loading {
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-thumbnail.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top: 2px solid #666;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive design */
@media (max-width: 768px) {
    .custom-thumbnails {
        gap: 8px;
        margin: 15px auto;
    }

    .custom-thumbnail {
        width: 80px !important;
        height: 80px !important;
        border-radius: 6px;
    }

    .custom-thumbnail img {
        max-width: 80px !important;
        max-height: 80px !important;
    }

    /* Ensure custom thumbnail container is visible on mobile */
    .custom-thumbnails-container {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .custom-thumbnails-wrapper {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .custom-thumbnails {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .custom-thumbnail {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

@media (max-width: 480px) {
    .custom-thumbnail {
        width: 60px !important;
        height: 60px !important;
        border-radius: 4px;
    }

    .custom-thumbnail img {
        max-width: 60px !important;
        max-height: 60px !important;
    }

    .custom-thumbnails {
        gap: 6px;
    }

    /* Ensure custom thumbnail container is visible on small mobile */
    .custom-thumbnails-container {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .custom-thumbnails-wrapper {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .custom-thumbnails {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .custom-thumbnail {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* Integration with existing gallery */
.gallery-slideshow-wrapper {
    position: relative;
}

.custom-thumbnails-container {
    width: 800px !important; /* Fixed width like documentary.html */
    max-width: 800px; /* Fixed max-width for centered carousel */
    margin: 20px auto !important; /* Center the container */
    overflow: hidden !important; /* Hide overflow for carousel effect */
    position: relative;
    display: block !important;
    background: transparent;
    z-index: 15;
    box-sizing: border-box; /* Include padding/border in width calculation */
}

.custom-thumbnails-wrapper {
    width: 100% !important;
    overflow: hidden !important; /* Hide overflow for carousel scrolling */
    position: relative;
    display: block !important; /* Changed from flex to block for carousel */
    background: transparent;
    margin: 0 auto;
    padding: 20px 0;
    box-sizing: border-box; /* Include padding in width calculation */
}

/* Smooth slide transitions for main gallery */
.gallery-slideshow-item {
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
    transform: translateX(0) !important;
}

.gallery-slideshow-item:not([data-active="true"]) {
    opacity: 0 !important;
    transform: translateX(-100%) !important;
    pointer-events: none !important;
}

.gallery-slideshow-item[data-active="true"] {
    opacity: 1 !important;
    transform: translateX(0) !important;
    pointer-events: auto !important;
}

/* Slide-in animation for new active slides */
@keyframes slideInFromRight {
    0% {
        opacity: 0;
        transform: translateX(100%);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

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

.gallery-slideshow-item.slide-in-right {
    animation: slideInFromRight 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-slideshow-item.slide-in-left {
    animation: slideInFromLeft 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}