/* ========================================
   Gallery Page Styles
======================================== */

.gallery-nav-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.gallery-hero {
    padding: calc(var(--spacing-xl) + 60px) 0 var(--spacing-lg) 0;
    background: linear-gradient(180deg, var(--color-bg-primary) 0%, var(--color-bg-secondary) 100%);
    text-align: center;
}

.gallery-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 300;
    margin-bottom: var(--spacing-sm);
}

.gallery-subtitle {
    font-size: 1.5rem;
    color: var(--color-accent);
    margin-bottom: var(--spacing-sm);
}

.gallery-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
}

.meta-item {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

.meta-divider {
    color: var(--color-text-secondary);
}

.gallery-description {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--color-text-secondary);
}

.gallery-content {
    padding: var(--spacing-xl) 0;
    background-color: var(--color-bg-secondary);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    gap: var(--spacing-lg);
}

.gallery-item {
    background-color: var(--color-bg-tertiary);
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid var(--color-border);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.gallery-item:hover {
    border-color: var(--color-accent);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(-4px);
}

/* Expanded state - video takes full width */
.gallery-item.expanded {
    grid-column: 1 / -1;
    transform: none;
    cursor: default;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.7);
    border-color: var(--color-accent);
}

.gallery-item.expanded:hover {
    transform: none;
}

.gallery-item.expanded .video-wrapper {
    padding-top: 56.25%; /* Maintain 16:9 */
}

.gallery-item.expanded .video-wrapper iframe {
    pointer-events: auto; /* Enable controls when expanded */
}

.gallery-item.expanded .gallery-item-info {
    padding: 2rem;
}

/* Video Navigation Buttons */
.video-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 200;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.video-nav-btn:hover {
    background: var(--color-accent);
    border-color: var(--color-accent);
    transform: translateY(-50%) scale(1.1);
}

.video-nav-prev {
    left: 20px;
}

.video-nav-next {
    right: 20px;
}

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

.video-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background-color: #000;
}

.video-wrapper iframe {
    pointer-events: none; /* Prevent iframe from blocking clicks */
}

/* Image Wrapper - Same 16:9 aspect ratio as videos */
.image-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background-color: #000;
    overflow: hidden;
}

.image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

/* Hover effect for images */
.gallery-item-image:hover .image-wrapper img {
    transform: scale(1.05);
}

/* Expanded image state */
.gallery-item.expanded .image-wrapper {
    padding-top: 56.25%; /* Maintain 16:9 */
}

.gallery-item.expanded .image-wrapper img {
    object-fit: contain; /* Show full image when expanded */
    transform: none;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

/* Prevent images from scaling beyond their native resolution */
.gallery-item.expanded .image-wrapper img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Image Navigation Buttons (similar to video nav) */
.image-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 200;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.image-nav-btn:hover {
    background: var(--color-accent);
    border-color: var(--color-accent);
    transform: translateY(-50%) scale(1.1);
}

.image-nav-prev {
    left: 20px;
}

.image-nav-next {
    right: 20px;
}

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

.gallery-item-info {
    padding: var(--spacing-md);
}

.gallery-item-info h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--color-text-primary);
}

.gallery-item-info p {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    margin: 0;
}

/* Large video view option */
.gallery-item.full-width {
    grid-column: 1 / -1;
}

.gallery-item.full-width .video-wrapper {
    padding-top: 42%; /* Wider aspect ratio for featured videos */
}

/* ========================================
   Video Lightbox Modal
======================================== */
.video-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
}

.video-lightbox.active {
    display: flex;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
}

.lightbox-content {
    position: relative;
    width: 90%;
    max-width: 1400px;
    z-index: 3001;
    animation: lightboxZoomIn 0.3s ease-out;
}

@keyframes lightboxZoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: none;
    border: none;
    color: var(--color-text-primary);
    font-size: 3rem;
    cursor: pointer;
    z-index: 3002;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    line-height: 1;
}

.lightbox-close:hover {
    color: var(--color-accent);
    transform: rotate(90deg);
}

.lightbox-video-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background-color: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.lightbox-video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ========================================
   Flipbook Gallery Layout
======================================== */
.flipbook-gallery {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
}

.flipbook-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    align-items: start;
}

.flipbook-image {
    width: 100%;
    position: relative;
    background: #000;
    border-radius: var(--border-radius);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

/* Match the video aspect ratio exactly */
.flipbook-image::before {
    content: '';
    display: block;
    padding-top: 56.25%; /* 16:9 aspect ratio like videos */
}

.flipbook-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.flipbook-video {
    width: 100%;
}

.flipbook-video .gallery-item {
    margin: 0;
}

/* ========================================
   Responsive Design
======================================== */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .flipbook-pair {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
    
    .gallery-nav-title {
        display: none;
    }
    
    .gallery-hero {
        padding: calc(var(--spacing-lg) + 60px) 0 var(--spacing-md) 0;
    }
    
    .gallery-meta {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .gallery-title {
        font-size: 2rem;
    }
    
    .gallery-subtitle {
        font-size: 1.25rem;
    }
    
    .lightbox-close {
        top: 10px;
        right: 10px;
        font-size: 2.5rem;
    }
    
    .lightbox-content {
        width: 95%;
    }
}
