/* Unified Gallery Styles - Works with image and video galleries */

/* Base styles */
.product-section {
    height: 600px;
}

.product-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    height: 100%;
}

.product-image {
    position: relative;
    overflow: hidden;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Image styles */
.product-image img {
    position: relative;
    z-index: 1;
    height: 100%;
    width: auto;
    max-height: 100%;
    object-fit: cover;
}

/* For right-side images */
.product-section:nth-child(even) .product-image img {
    position: absolute;
    right: 0;
}

/* For left-side images */
.product-section:nth-child(odd) .product-image img {
    position: absolute;
    left: 0;
}

/* Video styles */
.product-image video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    background-color: black;
}

/* Video specific section handling */
.product-image:has(video) {
    width: 600px;
    height: 600px;
}

/* Hide controls until user interacts */
.product-image video:not(.playing)::-webkit-media-controls,
.product-image video:not(.playing)::-webkit-media-controls-enclosure,
.product-image video:not(.playing)::-webkit-media-controls-panel {
    display: none !important;
}

/* Gallery overlay */
.gallery-overlay {
    position: absolute;
    z-index: 2;
    pointer-events: auto;
    cursor: pointer;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* Video play button */
.video-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background-color: rgba(228, 61, 18, 0.8);
    border-radius: 50%;
    z-index: 6;
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.3s, transform 0.3s;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Play button triangle */
.video-play-button::after {
    content: "";
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 10px 0 10px 16px;
    border-color: transparent transparent transparent white;
    margin-left: 3px;
}

/* Play button hover effect */
.video-play-button:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.product-image:hover .video-play-button {
    transform: translate(-50%, -50%) scale(1.1);
}

.product-image .video-play-button {
    transform: translate(-50%, -50%) scale(1);
}

/* Hide play button when video is playing */
.product-image video.playing + .video-play-button {
    display: none !important;
}

/* Show controls only when video is playing */
.product-image video.playing::-webkit-media-controls {
    display: flex !important;
}

/* Video indicator */
.video-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    opacity: 0.6;
}

/* Modal styles */
.gallery-modal {
    opacity: 0;
    animation: fadeIn 0.3s forwards;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Modal content */
.modal-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-y;
}

/* Modal media animations */
.modal-image,
.modal-video {
    opacity: 0;
    animation: zoomIn 0.3s forwards;
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

@keyframes zoomIn {
    from { 
        opacity: 0;
        transform: scale(0.95);
    }
    to { 
        opacity: 1;
        transform: scale(1);
    }
}

/* Video specific styles */
.modal-video {
    background-color: black;
}

/* Video controls customization */
video::-webkit-media-controls-panel {
    background-image: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
}

/* Navigation elements */
.modal-nav:hover, .modal-close:hover {
    transform: scale(1.1);
    transition: transform 0.2s;
}

.modal-nav {
    opacity: 0.8;
    transition: opacity 0.3s, transform 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.modal-nav:hover {
    opacity: 1;
}

/* Counter for modal */
.modal-counter {
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 14px;
}

/* Close button */
.modal-close {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.product-section:nth-child(2) .product-grid {
    display: grid;
    grid-template-columns: 1fr auto;
}

.product-section:nth-child(2) .product-image {
    width: 600px;
    height: 600px;
    justify-self: end;
    margin-right: 0;
    padding-right: 0;
}

.product-section .container {
    max-width: 100%;
    width: 100%;
    padding-right: 0;
}

/* Ensure video fills container */
.product-section:nth-child(2) .product-image video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    /* Override product section height restrictions */
    .product-section {
        height: auto !important;
        overflow: visible !important;
    }
    
    /* Make product grid single column */
    .product-grid {
        display: block !important;
        height: auto !important;
    }
    
    /* Ensure product image container has no height restrictions */
    .product-image {
        height: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
    }
    
    /* Fix image and video aspect ratio and prevent cropping */
    .product-image img,
    .product-image video {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        max-width: 100% !important;
    }
    
    /* Fix text section */
    .product-text {
        width: 100% !important;
        padding: 30px 20px !important;
    }
    
    /* Ensure overlay matches the media */
    .gallery-overlay {
        width: 100% !important;
        height: 100% !important;
        left: 0 !important;
        top: 0 !important;
    }
    
    /* Full-width modal for mobile */
    .gallery-modal {
        padding: 0 !important;
    }
    
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .modal-image,
    .modal-video {
        width: 100vw !important;
        max-width: 100vw !important;
        height: auto !important;
        max-height: 85vh !important;
        object-fit: contain !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Adjust navigation for full-width display */
    .modal-nav.prev {
        left: 10px !important;
        z-index: 1002 !important;
    }
    
    .modal-nav.next {
        right: 10px !important;
        z-index: 1002 !important;
    }
    
    /* Counter positioning */
    .modal-counter {
        bottom: 20px !important;
        z-index: 1002 !important;
        background-color: rgba(0, 0, 0, 0.6) !important;
    }
    
    /* Correct yellow/light section order on mobile */
    .yellow-bg .product-grid .product-image {
        order: -1 !important;
    }
}

/* Extra small screens adjustments */
@media (max-width: 480px) {
    /* Ensure proper padding on very small screens */
    .product-text {
        padding: 25px 15px !important;
    }
    
    .modal-nav.prev {
        left: 5px !important;
    }
    
    .modal-nav.next {
        right: 5px !important;
    }
    
    .modal-close {
        top: 5px !important;
        right: 5px !important;
    }
}