/**
 * Compatibility Mode Styles
 * Automatically applied for browsers with limited CSS support
 * Provides fallbacks for modern CSS features
 */

/* Base compatibility mode - applied when critical features are missing */
.ws-compatibility-mode {
    /* Disable complex animations and transitions */
    * {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }
    
    /* Ensure basic layout works */
    .ws-locations-row,
    .ws-suppliers-grid,
    .ws-product-cards,
    .ws-staff-gallery {
        display: block !important;
    }
    
    /* Fallback for grid layouts */
    .ws-locations-row .ws-location,
    .ws-suppliers-grid .ws-supplier,
    .ws-product-cards .ws-product-card {
        display: block !important;
        width: 100% !important;
        margin-bottom: 1rem !important;
        float: none !important;
    }
    
    /* Clear floats for older browsers */
    .ws-locations-row::after,
    .ws-suppliers-grid::after,
    .ws-product-cards::after {
        content: "";
        display: table;
        clear: both;
    }
}

/* Specific feature fallbacks */
.ws-no-grid .ws-locations-row,
.ws-no-grid .ws-suppliers-grid,
.ws-no-grid .ws-product-cards {
    display: block !important;
}

.ws-no-flexbox .ws-locations-row,
.ws-no-flexbox .ws-suppliers-grid,
.ws-no-flexbox .ws-product-cards {
    display: block !important;
}

.ws-no-transforms .ws-hero-img {
    /* Fallback for browsers without transforms */
    position: relative !important;
    top: auto !important;
    left: auto !important;
}

.ws-no-transitions .ws-product-card:hover,
.ws-no-transitions .ws-button:hover {
    /* Remove hover effects for browsers without transitions */
    transform: none !important;
    box-shadow: none !important;
}

.ws-no-animations .ws-staff-gallery img {
    /* Disable image rotation for browsers without animations */
    animation: none !important;
}

/* JavaScript capability fallbacks */
.ws-no-intersection-observer .ws-hero-img {
    /* Ensure images load without intersection observer */
    opacity: 1 !important;
}

.ws-no-geolocation .ws-location-recommended {
    /* Hide location recommendations if geolocation not supported */
    display: none !important;
}

.ws-no-local-storage .ws-location-recommended {
    /* Hide location recommendations if localStorage not supported */
    display: none !important;
}

/* Enhanced compatibility for very old browsers */
.ws-compatibility-mode .ws-modal {
    /* Fallback modal positioning for older browsers */
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    max-width: 90% !important;
    max-height: 90% !important;
}

.ws-compatibility-mode .ws-hero {
    /* Fallback hero sizing for older browsers */
    height: 300px !important;
    overflow: hidden !important;
}

.ws-compatibility-mode .ws-hero-img {
    /* Fallback hero image for older browsers */
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* Print and accessibility improvements for compatibility mode */
.ws-compatibility-mode @media print {
    .ws-modal,
    .ws-location-recommended {
        display: none !important;
    }
    
    .ws-locations-row,
    .ws-suppliers-grid,
    .ws-product-cards {
        display: block !important;
    }
}

/* High contrast mode support for older browsers */
.ws-compatibility-mode @media (prefers-contrast: high) {
    .ws-product-card,
    .ws-button,
    .ws-location {
        border: 2px solid #000 !important;
        background: #fff !important;
        color: #000 !important;
    }
}

/* Reduced motion support for older browsers */
.ws-compatibility-mode @media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Ensure compatibility mode works across all screen sizes */
.ws-compatibility-mode @media (max-width: 768px) {
    .ws-locations-row .ws-location,
    .ws-suppliers-grid .ws-supplier,
    .ws-product-cards .ws-product-card {
        width: 100% !important;
        margin-bottom: 1rem !important;
    }
}

.ws-compatibility-mode @media (max-width: 480px) {
    .ws-hero {
        height: 200px !important;
    }
    
    .ws-modal {
        width: 95% !important;
        margin: 0 auto !important;
    }
}

/* Navigation fallbacks for older browsers */
.ws-no-flexbox .ws-nav-list {
    display: block !important;
}

.ws-no-flexbox .ws-nav-list li {
    display: inline-block !important;
    float: left !important;
    margin-right: 1rem !important;
}

.ws-no-flexbox .ws-nav-list::after {
    content: "";
    display: table;
    clear: both;
}

/* Button and form fallbacks */
.ws-no-transitions .ws-button {
    border: 2px solid #8B4513 !important;
}

.ws-no-transitions .ws-button:hover {
    background: #8B4513 !important;
    color: white !important;
}

/* Card layout fallbacks */
.ws-no-grid .ws-menu-quicklinks ul {
    display: block !important;
}

.ws-no-grid .ws-menu-quicklinks ul li {
    display: inline-block !important;
    margin-right: 1rem !important;
    margin-bottom: 0.5rem !important;
}

/* Ensure text remains readable in all browsers */
.ws-compatibility-mode {
    font-family: Arial, Helvetica, sans-serif !important;
    line-height: 1.6 !important;
}

.ws-compatibility-mode h1,
.ws-compatibility-mode h2,
.ws-compatibility-mode h3,
.ws-compatibility-mode h4,
.ws-compatibility-mode h5,
.ws-compatibility-mode h6 {
    font-weight: bold !important;
    margin-bottom: 0.5rem !important;
}

.ws-compatibility-mode p {
    margin-bottom: 1rem !important;
}

/* Image fallbacks for older browsers */
.ws-compatibility-mode img {
    max-width: 100% !important;
    height: auto !important;
}

/* Ensure modals work in older browsers */
.ws-compatibility-mode .ws-modal-overlay {
    background: rgba(0, 0, 0, 0.7) !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1000 !important;
}
