/**
 * Portfolio Gallery CSS - Updated
 * File: css/portfolio-gallery.css
 * Custom styling for LightGallery integration with ETN Studios theme
 */

/* Gallery Container - Remove card styling */
.portfolio-gallery-container {
    max-width: 100%;
    margin: 0 auto;
}

/* Article styling - Remove card styling completely */
.portfolio-article,
article.portfolio-article {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin-bottom: 0 !important;
}

/* Override any post/page styling that might interfere */
.has-portfolio-gallery .post,
.has-portfolio-gallery .page,
.has-portfolio-gallery article {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
}

/* Caption styling for active slide */
.gallery-caption {
    position: absolute;
    bottom: -60px; /* Position below the main gallery */
    left: 50%;
    transform: translateX(-50%);
    max-width: 80%;
    background: rgba(0, 0, 0, 0.8);
    color: var(--text-light, #f0f0f0);
    padding: 15px 20px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.gallery-caption.show {
    opacity: 1;
}

/* Adjust main gallery container to accommodate caption */
.portfolio-gallery-main {
    width: 100%;
    height: 60vh;
    min-height: 400px;
    max-height: 700px;
    position: relative;
    background: transparent !important; /* Remove background */
    border-radius: 0 !important; /* Remove border radius */
    overflow: visible; /* Change from hidden to visible */
    border: none !important; /* Remove border */
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 80px; /* Add space for caption */
}

.lg-gallery-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-item {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Custom gallery display styling - Remove container backgrounds */
.custom-gallery-display {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important; /* Remove black background */
    position: relative !important;
    border-radius: 0 !important; /* Remove border radius */
    overflow: visible !important; /* Change from hidden to visible */
}

.custom-gallery-display .gallery-content {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Center images and videos */
.custom-gallery-display .gallery-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    margin: 0 auto; /* Center horizontally */
}

.custom-gallery-display .gallery-content iframe {
    max-width: 100%;
    max-height: 100%;
    display: block;
    margin: 0 auto; /* Center horizontally */
    border: none;
    border-radius: 8px;
}

/* Hide counter */
.custom-gallery-display .gallery-counter {
    display: none !important;
}

/* Ensure LightGallery videos display properly in the main area */
.portfolio-lightgallery .lg-video-cont {
    width: 100% !important;
    height: 100% !important;
    background: transparent !important; /* Remove black background */
    border-radius: 0 !important;
    overflow: visible !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.portfolio-lightgallery .lg-video-object {
    width: 100% !important;
    height: 100% !important;
    border: none;
    border-radius: 8px;
}

/* Hide any video controls that appear in thumbnails */
.portfolio-gallery-thumbs .lg-video-cont,
.portfolio-gallery-thumbs iframe {
    display: none !important;
}

/* Thumbnail Carousel */
.portfolio-gallery-thumbs {
    padding: 20px 0;
    gap: 16px;
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Hide scrollbar for Firefox */
    -ms-overflow-style: none; /* Hide scrollbar for IE/Edge */
}

/* Hide scrollbar for WebKit browsers */
.portfolio-gallery-thumbs::-webkit-scrollbar {
    display: none;
}

/* Individual Thumbnails - Larger Size */
.gallery-thumb {
    flex-shrink: 0;
    cursor: pointer;
    border-radius: 0; /* Remove rounded borders */
    overflow: hidden;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none; /* Remove border */
    width: 160px;
    height: 120px;
}

.gallery-thumb-img {
    display: block;
    width: 160px !important;
    height: 120px !important;
    object-fit: cover;
    border-radius: 0; /* Remove rounded borders */
    transition: all 0.3s ease;
}

.gallery-thumb:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

/* Add white overlay for hover and active states */
.gallery-thumb:hover::after,
.gallery-thumb.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.5); /* 50% white overlay */
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.gallery-thumb.active {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.gallery-thumb.active .gallery-thumb-img {
    opacity: 1;
}

/* Video Thumbnail Styling */
.video-thumb-container {
    position: relative;
    display: inline-block;
    width: 160px;
    height: 120px;
}

.video-thumb-container .play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    opacity: 0.9;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
    transition: all 0.3s ease;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.gallery-thumb:hover .play-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
}

/* Scroll Buttons */
.thumbnail-scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.thumbnail-scroll-left {
    left: 8px;
}

.thumbnail-scroll-right {
    right: 8px;
}

.portfolio-gallery-container:hover .thumbnail-scroll-btn {
    opacity: 0.7;
}

.thumbnail-scroll-btn:hover {
    opacity: 1 !important;
    background: rgba(0, 0, 0, 0.95);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.thumbnail-scroll-btn:active {
    transform: translateY(-50%) scale(0.95);
}

/* LightGallery Custom Theme */
.portfolio-lightgallery.lg-container {
    background: var(--content-bg, #1a1a1a);
    font-family: var(--font-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
}

.portfolio-lightgallery .lg-backdrop {
    background: var(--content-bg, #1a1a1a);
}

.portfolio-lightgallery .lg-toolbar {
    background: linear-gradient(
        to bottom, 
        rgba(0, 0, 0, 0.8) 0%, 
        rgba(0, 0, 0, 0.4) 50%,
        transparent 100%
    );
    border-bottom: none;
    padding: 20px;
}

.portfolio-lightgallery .lg-icon {
    color: var(--text-light, #f0f0f0);
    font-size: 18px;
    transition: all 0.3s ease;
}

.portfolio-lightgallery .lg-icon:hover {
    color: var(--accent-color, #01554E);
    transform: scale(1.1);
}

.portfolio-lightgallery .lg-counter {
    color: var(--text-light, #f0f0f0);
    font-size: 14px;
    font-weight: 500;
}

.portfolio-lightgallery .lg-prev,
.portfolio-lightgallery .lg-next {
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    margin-top: -25px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.portfolio-lightgallery .lg-prev:hover,
.portfolio-lightgallery .lg-next:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.portfolio-lightgallery .lg-prev {
    left: 20px;
}

.portfolio-lightgallery .lg-next {
    right: 20px;
}

/* Thumbnail strip in LightGallery */
.portfolio-lightgallery .lg-thumb-outer {
    background: rgba(0, 0, 0, 0.9);
    border-top: 1px solid var(--border-color, #2e2e2e);
}

.portfolio-lightgallery .lg-thumb-item {
    border: 2px solid transparent;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.portfolio-lightgallery .lg-thumb-item.active {
    border-color: var(--accent-color, #01554E);
}

.portfolio-lightgallery .lg-thumb-item:hover {
    border-color: rgba(1, 85, 78, 0.6);
}

/* Video Player Styling */
.portfolio-lightgallery .lg-video-cont {
    background: transparent !important; /* Remove background */
    border-radius: 8px;
    overflow: hidden;
}

.portfolio-lightgallery .lg-video-object {
    border: none;
    border-radius: 8px;
}

/* Sub HTML (Captions) */
.portfolio-lightgallery .lg-sub-html {
    background: linear-gradient(
        to top, 
        rgba(0, 0, 0, 0.9) 0%, 
        rgba(0, 0, 0, 0.6) 50%,
        transparent 100%
    );
    color: var(--text-light, #f0f0f0);
    padding: 30px 20px 20px;
    border-radius: 0 0 8px 8px;
}

.portfolio-lightgallery .lg-sub-html h4 {
    font-family: var(--font-heading, 'Quantico', sans-serif);
    font-size: 18px;
    font-weight: 400;
    margin: 0 0 8px 0;
    color: var(--accent-color, #01554E);
}

.portfolio-lightgallery .lg-sub-html p {
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    opacity: 0.9;
}

/* Loading Animation */
.portfolio-lightgallery .lg-loading {
    background: var(--card-bg, #1b1b1b);
}

.portfolio-lightgallery .lg-loading:after {
    border-color: var(--accent-color, #01554E) transparent transparent transparent;
}

/* Responsive Design */
@media (max-width: 768px) {
    .portfolio-gallery-main {
        height: 50vh;
        min-height: 300px;
    }
    
    .portfolio-gallery-thumbs {
        padding: 15px 50px 15px 50px;
        gap: 12px;
    }
    
    .gallery-thumb {
        width: 120px;
        height: 90px;
    }
    
    .gallery-thumb-img {
        width: 120px !important;
        height: 90px !important;
    }
    
    .video-thumb-container {
        width: 120px;
        height: 90px;
    }
    
    .thumbnail-scroll-btn {
        width: 36px;
        height: 36px;
    }
    
    .thumbnail-scroll-left {
        left: 5px;
    }
    
    .thumbnail-scroll-right {
        right: 5px;
    }
}

@media (max-width: 480px) {
    .portfolio-gallery-main {
        height: 40vh;
        min-height: 250px;
        border-radius: 0;
    }
    
    .gallery-thumb {
        width: 100px;
        height: 75px;
    }
    
    .gallery-thumb-img {
        width: 100px !important;
        height: 75px !important;
    }
    
    .video-thumb-container {
        width: 100px;
        height: 75px;
    }
    
    .video-thumb-container .play-icon {
        transform: translate(-50%, -50%) scale(0.8);
    }
    
    .portfolio-gallery-thumbs {
        gap: 8px;
    }
}

/* High-density displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .gallery-thumb img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    .portfolio-gallery-main {
        background: transparent !important; /* Keep transparent */
        border-color: transparent !important;
    }
    
    .thumbnail-scroll-btn {
        background: rgba(255, 255, 255, 0.1);
        color: var(--text-light, #f0f0f0);
        backdrop-filter: blur(10px);
    }
    
    .thumbnail-scroll-btn:hover {
        background: rgba(255, 255, 255, 0.2);
    }
}

/* Focus states for accessibility */
.gallery-thumb:focus,
.thumbnail-scroll-btn:focus {
    outline: 2px solid var(--accent-color, #01554E);
    outline-offset: 2px;
}

.portfolio-lightgallery .lg-icon:focus {
    outline: 2px solid var(--accent-color, #01554E);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .gallery-thumb,
    .gallery-thumb img,
    .play-icon,
    .thumbnail-scroll-btn,
    .portfolio-lightgallery .lg-icon,
    .portfolio-lightgallery .lg-prev,
    .portfolio-lightgallery .lg-next {
        transition: none;
    }
    
    .portfolio-gallery-thumbs {
        scroll-behavior: auto;
    }
}

/* Print styles */
@media print {
    .portfolio-gallery-container {
        display: none;
    }
}