/* 
 * Firefox-specific optimizations for Olivas Inquietas de Lucho
 * Author: GitHub Copilot
 * Date: March 2026
 */

/* Firefox-specific font smoothing and rendering optimizations */
@-moz-document url-prefix() {
    * {
        -moz-osx-font-smoothing: grayscale;
        -moz-font-smoothing: antialiased;
        /* Force better font rendering in Firefox */
    }
    
    img {
        -moz-force-broken-image-icons: 1;
        image-rendering: -moz-crisp-edges;
        image-rendering: crisp-edges;
        /* Better image rendering for product photos */
    }
    
    /* Firefox-specific performance optimizations */
    .site-section,
    .site-block-half,
    .portfolio-container,
    .program-body {
        will-change: transform;
        -moz-backface-visibility: hidden;
        backface-visibility: hidden;
        /* GPU acceleration for smooth animations */
    }
}

/* Firefox accessibility improvements using feature detection */
@supports (-moz-appearance: none) {
    
    /* Enhanced focus indicators for better accessibility */
    .btn:focus,
    button:focus {
        outline: 2px solid #5C6F2B;
        outline-offset: 2px;
        -moz-outline-radius: 2px;
    }
    
    .nav-link:focus,
    a:focus {
        outline: 2px solid #007bff;
        outline-offset: 2px;
        -moz-outline-radius: 2px;
    }
    
    /* Firefox native scrollbar styling */
    html,
    body,
    .portfolio-container {
        scrollbar-width: thin;
        scrollbar-color: #5C6F2B #f1f1f1;
        /* Thin scrollbars matching brand colors */
    }
    
    /* High contrast mode support for Firefox */
    @media (prefers-contrast: high) {
        .btn {
            border: 2px solid;
        }
        
        .nav-link {
            text-decoration: underline;
        }
    }
    
    /* Reduced motion support for Firefox users */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            -moz-animation-duration: 0.01ms !important;
            animation-duration: 0.01ms !important;
            -moz-animation-iteration-count: 1 !important;
            animation-iteration-count: 1 !important;
            -moz-transition-duration: 0.01ms !important;
            transition-duration: 0.01ms !important;
        }
    }
}

/* Firefox-specific CSS properties with vendor prefixes */
.portfolio-item,
.program,
.gallery-item {
    border-radius: 8px;
    -moz-border-radius: 8px;
    
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    -moz-box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    -moz-transition: -moz-transform 0.3s ease, -moz-box-shadow 0.3s ease;
}

.portfolio-item:hover,
.program:hover,
.gallery-item:hover {
    transform: translateY(-5px);
    -moz-transform: translateY(-5px);
    
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    -moz-box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}

/* Firefox-specific flexbox optimizations */
.portfolio .filters,
.navbar-nav,
.row {
    -moz-flex-wrap: wrap;
    flex-wrap: wrap;
    
    -moz-justify-content: center;
    justify-content: center;
}

/* Firefox button and form optimizations */
.btn {
    border-radius: 25px;
    -moz-border-radius: 25px;
    
    transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    -moz-transform: translateY(-2px);
}

/* Contact form and input optimizations for Firefox */
input[type="text"],
input[type="email"],
textarea {
    border-radius: 4px;
    -moz-border-radius: 4px;
    
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    -moz-transition: border-color 0.3s ease, -moz-box-shadow 0.3s ease;
    
    -moz-appearance: none;
    appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus {
    box-shadow: 0 0 0 2px rgba(92, 111, 43, 0.25);
    -moz-box-shadow: 0 0 0 2px rgba(92, 111, 43, 0.25);
}

/* Firefox-specific smooth scrolling enhancement */
html {
    scroll-behavior: smooth;
    -moz-scroll-behavior: smooth;
}

/* Firefox print optimizations */
@media print {
    @-moz-document url-prefix() {
        * {
            -moz-print-color-adjust: exact;
            color-adjust: exact;
        }
    }
}

/* Firefox-specific image lazy loading fallback */
@-moz-document url-prefix() {
    img[loading="lazy"] {
        /* Fallback for older Firefox versions */
        opacity: 1;
        transition: opacity 0.3s ease;
        -moz-transition: opacity 0.3s ease;
    }
}

/* Firefox-specific CSS Grid enhancements */
.portfolio-container {
    display: -moz-grid;
    display: grid;
    -moz-grid-gap: 10px;
    gap: 10px;
}

/* Firefox Android App Specific Optimizations */
@supports (-moz-appearance: none) {
    @media (max-width: 768px) {
        
        /* Firefox Android viewport optimizations */
        html {
            -webkit-text-size-adjust: 100%;
            -moz-text-size-adjust: 100%;
            text-size-adjust: 100%;
        }
        
        /* Firefox Android touch optimizations */
        .portfolio-item img,
        .program img {
            -moz-user-select: none;
            user-select: none;
            -moz-touch-callout: none;
            touch-action: manipulation;
            /* Prevent context menu on long press */
        }
        
        /* Enhanced touch targets for Firefox Android */
        .btn,
        .nav-link,
        .dropdown-toggle,
        .portfolio-item,
        .gallery-item {
            min-height: 48px; /* Google's recommended touch target */
            min-width: 48px;
            /* Larger touch area for easier tapping */
        }
        
        /* Firefox Android navigation improvements */
        .navbar-nav .nav-link {
            padding: 12px 16px;
            margin: 4px 0;
            /* More spacing for easier navigation */
        }
        
        /* Firefox Android form optimizations */
        input[type="text"],
        input[type="email"],
        input[type="tel"],
        textarea {
            font-size: 16px; /* Prevent zoom on focus in Firefox Android */
            padding: 12px;
            border-radius: 8px;
            -moz-border-radius: 8px;
        }
        
        /* Firefox Android keyboard optimizations */
        .contact-form {
            padding-bottom: 300px; /* Space for virtual keyboard */
        }
        
        /* Firefox Android scroll performance */
        .portfolio-container,
        .site-section {
            -webkit-overflow-scrolling: touch;
            overflow-scrolling: touch;
            /* Smooth scrolling on Firefox Android */
        }
        
        /* Firefox Android image loading optimization */
        img {
            loading: lazy;
            decoding: async;
            /* Better image performance on mobile */
        }
        
        /* Firefox Android button press effects */
        .btn:active,
        .portfolio-item:active {
            transform: scale(0.98);
            -moz-transform: scale(0.98);
            /* Visual feedback on touch */
        }
    }
}

/* Firefox Android landscape mode optimizations */
@media screen and (orientation: landscape) and (max-height: 500px) {
    @-moz-document url-prefix() {
        .navbar {
            min-height: auto;
            padding: 0.25rem 1rem;
            /* Compact navbar for landscape */
        }
        
        .hero-section {
            height: 70vh;
            /* Adjust hero height for landscape */
        }
        
        .site-section {
            padding: 2rem 0;
            /* Reduce padding in landscape */
        }
    }
}

/* Firefox Android PWA optimizations */
@media (display-mode: standalone) {
    @-moz-document url-prefix() {
        body {
            padding-top: env(safe-area-inset-top);
            padding-bottom: env(safe-area-inset-bottom);
            /* Handle notch and navigation bars */
        }
        
        .navbar {
            top: env(safe-area-inset-top);
            /* Position below status bar */
        }
        
        /* Hide browser UI elements when in PWA mode */
        .external-link::after {
            content: "";
            /* Don't show external link indicators in PWA */
        }
    }
}

/* Firefox Android performance hints */
@-moz-document url-prefix() {
    @media (max-width: 768px) {
        /* GPU acceleration for better performance */
        .portfolio-item,
        .program,
        .btn,
        .hero-section {
            -webkit-transform: translateZ(0);
            -moz-transform: translateZ(0);
            transform: translateZ(0);
            /* Force hardware acceleration */
        }
        
        /* Reduce repaints on scroll */
        .fixed-header {
            position: fixed;
            will-change: transform;
            backface-visibility: hidden;
            -moz-backface-visibility: hidden;
        }
        
        /* Optimize animations for 60fps */
        .portfolio-item:hover,
        .btn:hover {
            transition: transform 0.2s ease-out;
            -moz-transition: -moz-transform 0.2s ease-out;
            /* Faster transitions for mobile */
        }
    }
}

/* Firefox dark mode support */
@media (prefers-color-scheme: dark) {
    @supports (-moz-appearance: none) {
        html {
            scrollbar-color: #5C6F2B #2d3748;
        }
    }
}

/* Performance hint for Firefox layout engine */
.hero-section,
.site-section,
.portfolio-container {
    contain: layout style;
    /* Hint to Firefox to optimize rendering */
}

/* Firefox-specific font display optimizations */
@font-face {
    font-display: swap; /* Recommended for Firefox performance */
}