/* Mobile Gallery with Preserved Aspect Ratio */

/* Base styles */
.product-image {
    position: relative;
    overflow: hidden;
}

.product-image img {
    position: relative;
    z-index: 1;
}

.gallery-overlay {
    position: absolute;
    z-index: 2;
    pointer-events: auto;
    cursor: pointer;
}

.product-section:nth-child(even) .gallery-overlay {
    right: 0;
}

.gallery-nav {
    display: block;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.gallery-overlay:hover {
    background-color: rgba(0, 0, 0, 0.05);
    transition: background-color 0.2s;
}

/* Full window 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 image animations */
.modal-image {
    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);
    }
}

/* 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 mobile */
.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;
}

/* 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 aspect ratio and prevent cropping */
    .product-image img {
        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 image */
    .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 {
        width: auto !important;
        max-width: 100% !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;
    }
    
    /* Fix for right-side images */
    .product-section:nth-child(even) .product-image img {
        right: auto !important;
    }
    
    /* Fix for left-side images */
    .product-section:nth-child(odd) .product-image img {
        left: auto !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;
    }
}