/**
* UNIVERSAL BROWSER STYLES
* Styles for all major browsers including privacy-focused and niche browsers
*/

/* ====== CHROMIUM ENGINE (Chrome, Edge, Opera, Brave, Vivaldi, etc.) ====== */
.chromium-engine {
    /* Chromium browsers generally have excellent support */
}

.chromium-engine .sidebar {
    -webkit-transform: translateX(-100%);
    transform: translateX(-100%);
}

.chromium-engine .sidebar.active {
    -webkit-transform: translateX(0);
    transform: translateX(0);
}

/* ====== GECKO ENGINE (Firefox, Tor, LibreWolf, etc.) ====== */
.gecko-engine {
    /* Firefox-based browsers */
}

.gecko-engine .sidebar {
    -moz-transform: translateX(-100%);
    transform: translateX(-100%);
}

.gecko-engine .sidebar.active {
    -moz-transform: translateX(0);
    transform: translateX(0);
}

/* ====== WEBKIT ENGINE (Safari, DuckDuckGo, etc.) ====== */
.webkit-engine {
    /* Safari and WebKit-based browsers */
}

.webkit-engine .sidebar {
    -webkit-transform: translateX(-100%);
    transform: translateX(-100%);
}

.webkit-engine .sidebar.active {
    -webkit-transform: translateX(0);
    transform: translateX(0);
}

/* ====== PRIVACY-FOCUSED BROWSERS ====== */
.privacy-browser {
    /* Tor, DuckDuckGo, Brave, LibreWolf, etc. */
    /* These may block certain features - ensure graceful degradation */
}

.privacy-browser .analytics,
.privacy-browser .tracking {
    display: none !important;
}

/* ====== MOBILE BROWSERS ====== */
.mobile-device,
.device-mobile,
.device-tablet {
    /* All mobile browsers */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.mobile-device .sidebar,
.device-mobile .sidebar,
.device-tablet .sidebar {
    width: 100%;
    max-width: 320px;
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
}

/* iOS Safari specific */
.platform-ios .sidebar,
.ios-safari .sidebar {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
}

.platform-ios input,
.platform-ios textarea,
.platform-ios select,
.ios-safari input,
.ios-safari textarea,
.ios-safari select {
    font-size: 16px !important; /* Prevents zoom on focus */
    -webkit-appearance: none;
    appearance: none;
}

.platform-ios button,
.ios-safari button {
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

/* Android browsers */
.platform-android .sidebar,
.android-browser .sidebar {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
}

.platform-android input,
.platform-android textarea,
.platform-android select {
    font-size: 16px; /* Prevents zoom on focus */
}

/* Touch device optimizations */
.touch-device button,
.touch-device a,
.touch-device .btn {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 20px;
}

.touch-device input,
.touch-device textarea,
.touch-device select {
    min-height: 44px;
    padding: 12px;
}

/* ====== NO FLEXBOX SUPPORT ====== */
.no-flexbox .nav-container {
    display: block;
}

.no-flexbox .nav-links {
    display: block;
}

.no-flexbox .nav-links a {
    display: block;
    margin: 5px 0;
}

.no-flexbox .container {
    display: block;
}

.no-flexbox .hero-content {
    display: block;
    text-align: center;
}

/* ====== NO GRID SUPPORT ====== */
.no-grid .projects-container {
    display: block;
}

.no-grid .project-card-animated {
    display: block;
    width: 100%;
    margin-bottom: 20px;
    float: left;
}

.no-grid .stats-grid,
.no-grid .resources-container {
    display: block;
}

.no-grid .stats-grid > *,
.no-grid .resources-container > * {
    display: block;
    width: 100%;
    margin-bottom: 20px;
}

/* ====== NO CSS VARIABLES SUPPORT ====== */
.no-cssVariables :root {
    /* Fallback colors */
}

.no-cssVariables .btn-primary {
    background-color: #0d6efd;
    color: #ffffff;
}

.no-cssVariables body {
    color: #333333;
    background-color: #ffffff;
}

.no-cssVariables body.dark-mode {
    color: #eeeeee;
    background-color: #222222;
}

/* ====== TRIDENT ENGINE (IE) ====== */
.trident-engine .sidebar {
    left: -280px;
}

.trident-engine .sidebar.active {
    left: 0;
}

.trident-engine .btn {
    display: inline-block;
    padding: 10px 20px;
    background: #0d6efd;
    color: #fff;
    text-decoration: none;
}

/* ====== CLOUD RENDERING (Puffin) ====== */
.cloud-engine {
    /* Puffin uses cloud rendering */
    /* May need special handling for interactive elements */
}

/* ====== OPERA GX ====== */
/* Opera GX is Chromium-based, so it uses Chromium styles */

/* ====== SAMSUNG INTERNET ====== */
/* Samsung Internet is Chromium-based */

/* ====== UC BROWSER ====== */
/* UC Browser is Chromium-based */

/* ====== YANDEX BROWSER ====== */
/* Yandex is Chromium-based */

/* ====== ARC BROWSER ====== */
/* Arc is Chromium-based */

/* ====== VIVALDI ====== */
/* Vivaldi is Chromium-based */

/* ====== BRAVE ====== */
/* Brave is Chromium-based */

/* ====== TOR BROWSER ====== */
/* Tor is Firefox-based (Gecko) */

/* ====== DUCKDUCKGO ====== */
/* DuckDuckGo is WebKit-based */

/* ====== LIBREWOLF ====== */
/* LibreWolf is Firefox-based (Gecko) */

/* ====== WATERFOX ====== */
/* Waterfox is Firefox-based (Gecko) */

/* ====== FLOORP ====== */
/* Floorp is Firefox-based (Gecko) */

/* ====== ZEN BROWSER ====== */
/* Zen is Firefox-based (Gecko) */

/* ====== UNIVERSAL FIXES ====== */

/* Ensure smooth scrolling works everywhere */
html {
    scroll-behavior: smooth;
}

@supports not (scroll-behavior: smooth) {
    html {
        scroll-behavior: auto;
    }
}

/* Ensure transforms work everywhere */
.sidebar {
    -webkit-transform: translateX(-100%);
    -moz-transform: translateX(-100%);
    -ms-transform: translateX(-100%);
    -o-transform: translateX(0);
    transform: translateX(-100%);

    -webkit-transition: transform 0.3s ease;
    -moz-transition: transform 0.3s ease;
    -o-transition: transform 0.3s ease;
    transition: transform 0.3s ease;
}

.sidebar.active {
    -webkit-transform: translateX(0);
    -moz-transform: translateX(0);
    -ms-transform: translateX(0);
    -o-transform: translateX(0);
    transform: translateX(0);
}

/* Ensure transitions work everywhere */
* {
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

/* ====== PLATFORM-SPECIFIC OPTIMIZATIONS ====== */

/* Mac optimizations */
.platform-mac {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Windows optimizations */
.platform-windows {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Linux optimizations */
.platform-linux {
    font-family: 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', sans-serif;
}

/* ====== BROWSER-SPECIFIC FIXES ====== */

/* Safari flexbox gap fix (Safari < 14.1) */
.safari-no-gap .nav-links {
    gap: 0;
}

.safari-no-gap .nav-links > * {
    margin-right: 20px;
}

/* Legacy browser fixes */
.legacy-browser .sidebar {
    left: -280px;
    position: fixed;
}

.legacy-browser .sidebar.active {
    left: 0;
}

.legacy-browser .btn {
    display: inline-block;
    padding: 10px 20px;
    background: #0d6efd;
    color: #fff;
    text-decoration: none;
    border: none;
}

/* ====== RESPONSIVE FIXES FOR ALL BROWSERS ====== */

/* Small screens (all browsers) */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        max-width: 100%;
    }

    .nav-links {
        flex-direction: column;
    }

    .container {
        padding: 0 15px;
    }
}

/* Medium screens */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 960px;
    }
}

/* Large screens */
@media (min-width: 1025px) {
    .container {
        max-width: 1200px;
    }
}

/* ====== HIGH DPI DISPLAYS ====== */
@media (-webkit-min-device-pixel-ratio: 2),
      (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* ====== PRINT STYLES FOR ALL BROWSERS ====== */
@media print {
    .sidebar,
    .overlay,
    .btn,
    .navbar,
    .ai-agent-container,
    .ai-agent-system,
    .theme-toggle,
    .menu-btn {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
    }

    a {
        color: black !important;
        text-decoration: underline !important;
    }

    .container {
        max-width: 100% !important;
        padding: 0 !important;
    }
}

/* ====== ACCESSIBILITY FOR ALL BROWSERS ====== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ====== DARK MODE FOR ALL BROWSERS ====== */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }
}

/* ====== LANDSCAPE ORIENTATION FIXES ====== */
@media (orientation: landscape) and (max-height: 500px) {
    .mobile-device .sidebar,
    .device-mobile .sidebar {
        max-height: 100vh;
        overflow-y: auto;
    }
}

/* Focus styles for accessibility - Auto-added */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}
