/* Browser-Specific Fixes and Fallbacks for AZNerds Website */

/* ==========================================================================
   CSS Custom Properties Fallbacks
   ========================================================================== */

/* Fallbacks for browsers that don't support CSS custom properties */
.no-custom-properties {
    --primary-color: #d4af37;
    --secondary-color: #333;
    --text-color: #333;
    --light-text: #fff;
    --background-color: #fff;
    --light-background: #f5f5f5;
    --accent-color: #0078d4;
}

/* Internet Explorer 11 fallbacks */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    /* IE11 specific styles */
    .hero {
        display: block; /* Fallback for flexbox */
    }
    
    .hero-content {
        margin-top: 100px;
    }
    
    .services-grid {
        display: block; /* Fallback for CSS Grid */
    }
    
    .service-card {
        width: 30%;
        float: left;
        margin-right: 3.33%;
        margin-bottom: 2rem;
    }
    
    .service-card:nth-child(3n) {
        margin-right: 0;
    }
    
    .clearfix::after {
        content: "";
        display: table;
        clear: both;
    }
    
    /* IE11 flexbox fixes */
    .header-container {
        display: -ms-flexbox;
        -ms-flex-pack: justify;
        -ms-flex-align: center;
    }
    
    nav ul {
        display: -ms-flexbox;
    }
    
    .hero-buttons {
        display: -ms-flexbox;
        -ms-flex-pack: center;
    }
}

/* ==========================================================================
   Flexbox Fallbacks and Prefixes
   ========================================================================== */

.header-container {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}

nav ul {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
}

.hero {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}

.hero-buttons {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
}

.footer-bottom {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}

/* ==========================================================================
   CSS Grid Fallbacks
   ========================================================================== */

/* Feature query for CSS Grid support */
@supports not (display: grid) {
    .services-grid,
    .about-highlights,
    .team-grid,
    .portfolio-grid,
    .footer-grid {
        display: block;
    }
    
    .service-card,
    .highlight-item,
    .team-member,
    .portfolio-item,
    .footer-column {
        width: 100%;
        margin-bottom: 2rem;
    }
    
    /* Tablet and desktop layouts for non-grid browsers */
    @media (min-width: 768px) {
        .service-card,
        .highlight-item,
        .team-member {
            width: 48%;
            float: left;
            margin-right: 4%;
        }
        
        .service-card:nth-child(2n),
        .highlight-item:nth-child(2n),
        .team-member:nth-child(2n) {
            margin-right: 0;
        }
    }
    
    @media (min-width: 1024px) {
        .service-card,
        .team-member {
            width: 30%;
            margin-right: 5%;
        }
        
        .service-card:nth-child(2n),
        .team-member:nth-child(2n) {
            margin-right: 5%;
        }
        
        .service-card:nth-child(3n),
        .team-member:nth-child(3n) {
            margin-right: 0;
        }
        
        .footer-column {
            width: 23%;
            float: left;
            margin-right: 2.67%;
        }
        
        .footer-column:nth-child(4n) {
            margin-right: 0;
        }
    }
}

/* ==========================================================================
   Transform and Transition Prefixes
   ========================================================================== */

.service-card {
    -webkit-transition: -webkit-transform 0.3s ease, box-shadow 0.3s ease;
    transition: -webkit-transform 0.3s ease, box-shadow 0.3s ease;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    transition: transform 0.3s ease, box-shadow 0.3s ease, -webkit-transform 0.3s ease;
}

.service-card:hover {
    -webkit-transform: translateY(-5px);
    transform: translateY(-5px);
}

.btn {
    -webkit-transition: background-color 0.3s ease;
    transition: background-color 0.3s ease;
}

.social-icon {
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

.social-icon:hover {
    -webkit-transform: translateY(-3px);
    transform: translateY(-3px);
}

/* ==========================================================================
   Safari-Specific Fixes
   ========================================================================== */

/* Safari flexbox fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    .hero-buttons {
        -webkit-box-pack: center;
    }
    
    .header-container {
        -webkit-box-pack: justify;
    }
}

/* Safari input styling fixes */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
textarea,
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Safari button styling */
button,
.btn {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* ==========================================================================
   Firefox-Specific Fixes
   ========================================================================== */

/* Firefox button fixes */
@-moz-document url-prefix() {
    button::-moz-focus-inner,
    input[type="submit"]::-moz-focus-inner {
        border: 0;
        padding: 0;
    }
    
    /* Firefox flexbox fixes */
    .hero-buttons {
        -moz-box-pack: center;
    }
}

/* ==========================================================================
   Edge-Specific Fixes
   ========================================================================== */

/* Edge flexbox and grid fixes */
@supports (-ms-ime-align: auto) {
    .services-grid {
        display: -ms-grid;
        -ms-grid-columns: 1fr 2rem 1fr 2rem 1fr;
        -ms-grid-rows: auto;
    }
    
    .service-card:nth-child(1) {
        -ms-grid-column: 1;
    }
    
    .service-card:nth-child(2) {
        -ms-grid-column: 3;
    }
    
    .service-card:nth-child(3) {
        -ms-grid-column: 5;
    }
}

/* ==========================================================================
   Mobile Browser Fixes
   ========================================================================== */

/* iOS Safari fixes */
@supports (-webkit-overflow-scrolling: touch) {
    /* Fix for iOS Safari viewport units */
    .hero {
        min-height: 500px;
        min-height: calc(100vh - 80px);
    }
    
    /* iOS Safari input zoom fix */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    textarea {
        font-size: 16px; /* Prevents zoom on focus */
    }
    
    /* iOS Safari button styling */
    button,
    .btn {
        -webkit-appearance: none;
        border-radius: 4px;
    }
}

/* Android browser fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: 0.001dpcm) {
    /* Android Chrome specific fixes */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    textarea {
        background-color: transparent;
    }
}

/* ==========================================================================
   Print Styles Browser Compatibility
   ========================================================================== */

@media print {
    /* Ensure print styles work across browsers */
    * {
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    .hero-background {
        background: #333 !important;
    }
}

/* ==========================================================================
   High Contrast Mode Support
   ========================================================================== */

/* Windows High Contrast Mode */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid;
    }
    
    .service-card {
        border: 1px solid;
    }
    
    .hero-background {
        background: #000 !important;
    }
}

/* ==========================================================================
   Reduced Motion Support
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        -webkit-animation-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        -webkit-animation-iteration-count: 1 !important;
        animation-iteration-count: 1 !important;
        -webkit-transition-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Focus Visible Polyfill Support
   ========================================================================== */

/* Enhanced focus styles for better keyboard navigation */
.js-focus-visible :focus:not(.focus-visible) {
    outline: none;
}

.focus-visible {
    outline: 2px solid #0078d4;
    outline-offset: 2px;
}

/* ==========================================================================
   Legacy Browser Warnings
   ========================================================================== */

/* Show warning for very old browsers */
.browser-warning {
    display: none;
    background-color: #f8d7da;
    color: #721c24;
    padding: 1rem;
    text-align: center;
    border-bottom: 1px solid #f5c6cb;
}

/* Show warning for IE */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .browser-warning {
        display: block;
    }
}

/* ==========================================================================
   Polyfill Support Styles
   ========================================================================== */

/* Styles for when polyfills are loaded */
.polyfill-loaded .services-grid {
    display: grid;
}

.polyfill-loaded .hero {
    display: flex;
}

/* ==========================================================================
   Font Loading Fallbacks
   ========================================================================== */

/* System font fallbacks */
.fonts-loading body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.fonts-loading h1,
.fonts-loading h2,
.fonts-loading h3,
.fonts-loading h4,
.fonts-loading h5,
.fonts-loading h6 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Font display swap fallback */
@font-face {
    font-family: 'Montserrat Fallback';
    src: local('Arial'), local('Helvetica');
    font-display: swap;
}

@font-face {
    font-family: 'Open Sans Fallback';
    src: local('Arial'), local('Helvetica');
    font-display: swap;
}