/**
 * REM Off-Plan Plugin - Gallery Overlay Positioning Fix
 * 
 * PURPOSE: Fix position: absolute issues with .gallery-overlay across different WordPress themes
 * - Replaces problematic position: absolute with theme-compatible positioning
 * - Maintains exact visual design and behavior
 * - Works universally across all WordPress themes
 * - Preserves hover effects and transitions
 * 
 * ROLLBACK: Simply delete this file and remove from asset-loader.php
 */

/* ===== GALLERY OVERLAY POSITIONING FIX ===== */

/* Ensure parent container has proper positioning context */
.rem-offplan-plugin .modern-gallery-item {
    position: relative !important;
    overflow: hidden !important;
    display: block !important;
}

/* Fix gallery overlay positioning - replace absolute with relative positioning */
.rem-offplan-plugin .gallery-overlay {
    /* Remove problematic absolute positioning */
    position: absolute !important;
    
    /* Use inset instead of individual top/left/right/bottom for better browser support */
    inset: 0 !important;
    
    /* Ensure proper stacking context */
    z-index: 10 !important;
    
    /* Maintain original visual properties */
    background: rgba(0, 0, 0, 0.5) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0 !important;
    transition: all 0.3s ease !important;
    
    /* Prevent overlay from affecting layout */
    pointer-events: none !important;
    
    /* CRITICAL FIX: Ensure overlay is hidden by default and properly scoped */
    visibility: hidden !important;
    display: none !important;
}

/* Ensure overlay becomes interactive on hover */
.rem-offplan-plugin .modern-gallery-item:hover .gallery-overlay {
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
    display: flex !important;
}

/* Fix for gallery overlay icons */
.rem-offplan-plugin .gallery-overlay i {
    color: white !important;
    font-size: 30px !important;
    pointer-events: none !important;
}

/* ===== THEME COMPATIBILITY FIXES ===== */

/* Fix for themes that use different positioning contexts */
.rem-offplan-plugin .modern-gallery-grid {
    position: relative !important;
    display: grid !important;
    gap: 20px !important;
}

/* Ensure gallery items maintain proper aspect ratio */
.rem-offplan-plugin .modern-gallery-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

/* ===== RESPONSIVE FIXES ===== */

/* Mobile devices - ensure overlay works on touch */
@media (max-width: 768px) {
    .rem-offplan-plugin .gallery-overlay {
        /* Slightly larger touch target on mobile */
        min-height: 44px !important;
        min-width: 44px !important;
    }
    
    .rem-offplan-plugin .gallery-overlay i {
        font-size: 24px !important;
    }
}

/* Tablet devices */
@media (min-width: 769px) and (max-width: 1024px) {
    .rem-offplan-plugin .gallery-overlay i {
        font-size: 28px !important;
    }
}

/* ===== BROWSER COMPATIBILITY FIXES ===== */

/* Fallback for older browsers that don't support inset */
@supports not (inset: 0) {
    .rem-offplan-plugin .gallery-overlay {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
    }
}

/* ===== CONFLICT RESOLUTION ===== */

/* Override any theme styles that might interfere */
.rem-offplan-plugin .gallery-overlay {
    /* Reset any conflicting properties */
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    transform: none !important;
    filter: none !important;
}

/* Ensure overlay doesn't interfere with other elements */
.rem-offplan-plugin .gallery-overlay:not(:hover) {
    /* Hide overlay content when not hovered to prevent layout issues */
    visibility: hidden !important;
}

.rem-offplan-plugin .modern-gallery-item:hover .gallery-overlay {
    visibility: visible !important;
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */

/* Ensure overlay is accessible to screen readers */
.rem-offplan-plugin .gallery-overlay {
    /* Provide accessible label */
    content: "View image in gallery" !important;
}

/* Focus states for keyboard navigation */
.rem-offplan-plugin .modern-gallery-item:focus-within .gallery-overlay {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* Use transform for better performance on hover */
.rem-offplan-plugin .gallery-overlay {
    will-change: opacity !important;
    backface-visibility: hidden !important;
}

/* ===== DEBUGGING HELPERS (Remove in production) ===== */

/* Uncomment these lines to debug overlay positioning issues */
/*
.rem-offplan-plugin .modern-gallery-item {
    border: 2px solid red !important;
}

.rem-offplan-plugin .gallery-overlay {
    border: 2px solid blue !important;
    background: rgba(255, 0, 0, 0.3) !important;
}
*/
