/**
 * ========================================
 * MOBILE FIX CSS - VERSION OPTIMISÉE 2.0
 * ========================================
 * Corrections spécifiques et optimisations mobile
 * Ce fichier complète le système responsive principal
 */

/* ========== FIXES CRITIQUES MOBILE ========== */

/* Empêcher le scroll horizontal sur tous les appareils */
@media screen and (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        position: relative !important;
    }
    
    /* Fix pour les éléments qui dépassent */
    * {
        box-sizing: border-box !important;
    }
    
    /* S'assurer que tous les containers respectent la largeur */
    .main-content,
    .section,
    .hero,
    nav,
    footer {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
    
    /* FIX SECTIONS VIDES - IMPORTANT */
    .main-content {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    
    /* Hero doit commencer directement après la nav */
    .hero {
        margin-top: 60px !important;
    }
}

/* ========== OPTIMISATIONS VIEWPORT (iOS Safari) ========== */

/* Fix pour la barre d'adresse qui disparaît sur iOS */
@media screen and (max-width: 768px) {
    .hero {
        /* Utilise la variable CSS personnalisée définie par JS */
        min-height: calc(var(--vh, 1vh) * 100) !important;
    }
}

/* ========== OPTIMISATIONS TOUCH ========== */

/* Améliorer le tap sur les éléments interactifs */
@media (hover: none) and (pointer: coarse) {
    /* Tous les éléments cliquables */
    button,
    a,
    input[type="submit"],
    input[type="button"],
    .cta-button,
    .card,
    .stat {
        -webkit-tap-highlight-color: rgba(0, 245, 255, 0.2);
        touch-action: manipulation;
    }
    
    /* Désactiver le zoom sur les inputs (iOS) */
    input,
    select,
    textarea {
        font-size: 16px !important; /* Empêche le zoom automatique sur iOS */
    }
    
    /* Améliorer la lisibilité du texte */
    body {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
}

/* ========== FIXES POUR iOS ========== */

/* Fix pour iPhone avec encoche (iPhone X et plus) */
@supports (padding: env(safe-area-inset-top)) {
    @media screen and (max-width: 768px) {
        body {
            padding-left: env(safe-area-inset-left);
            padding-right: env(safe-area-inset-right);
        }
        
        nav {
            padding-top: calc(0.5rem + env(safe-area-inset-top));
            padding-left: calc(1rem + env(safe-area-inset-left));
            padding-right: calc(1rem + env(safe-area-inset-right));
        }
        
        .hero {
            padding-top: calc(120px + env(safe-area-inset-top));
            padding-left: calc(20px + env(safe-area-inset-left));
            padding-right: calc(20px + env(safe-area-inset-right));
        }
        
        footer {
            padding-bottom: calc(2rem + env(safe-area-inset-bottom));
        }
    }
}

/* Fix pour le scroll élastique sur iOS */
@media screen and (max-width: 768px) {
    body {
        overscroll-behavior-y: contain;
    }
}

/* ========== OPTIMISATIONS PERFORMANCE MOBILE ========== */

/* Réduire les animations complexes sur mobile */
@media (max-width: 768px) {
    /* Simplifier l'animation du hero background */
    .hero::before {
        animation-duration: 60s !important; /* Plus lent = moins gourmand */
        will-change: auto; /* Désactiver will-change pour économiser la mémoire */
    }
    
    /* Optimiser les transitions */
    .card,
    .stat,
    .process-step {
        will-change: auto;
    }
    
    /* Désactiver les animations de hover sur touch devices */
    @media (hover: none) {
        .card:hover,
        .stat:hover,
        .cta-button:hover {
            transform: none !important;
        }
        
        /* Mais ajouter un feedback au tap */
        .card:active,
        .stat:active {
            opacity: 0.9;
            transform: scale(0.99) !important;
        }
        
        .cta-button:active {
            transform: scale(0.97) !important;
        }
    }
}

/* ========== FIXES TYPOGRAPHIE MOBILE ========== */

@media screen and (max-width: 768px) {
    /* Améliorer la lisibilité sur petits écrans */
    body {
        text-rendering: optimizeSpeed; /* Plus rapide sur mobile */
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* S'assurer que le texte ne dépasse pas */
    h1, h2, h3, h4, h5, h6, p, span, div, a {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    /* Améliorer le contraste sur petits écrans */
    .subtitle,
    .section-subtitle,
    .card-description,
    .step-description {
        color: #c0c0c0 !important; /* Légèrement plus clair pour mieux lire */
    }
}

/* ========== FIXES FORMULAIRE MOBILE ========== */

@media screen and (max-width: 768px) {
    /* S'assurer que les inputs sont bien visibles quand le clavier apparaît */
    input:focus,
    textarea:focus,
    select:focus {
        transform: translateZ(0); /* Force GPU pour smooth scroll */
    }
    
    /* Améliorer l'apparence des selects sur mobile */
    select {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300F5FF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 1rem center;
        background-size: 1em;
        padding-right: 3rem !important;
    }
}

/* ========== NAVIGATION MOBILE AMÉLIORÉE ========== */

@media screen and (max-width: 768px) {
    /* S'assurer que le menu est au-dessus de tout */
    .nav-links {
        z-index: 999 !important;
    }
    
    /* Overlay pour fermer le menu */
    .menu-overlay {
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
    }
    
    /* Animation des items du menu */
    .nav-links li {
        opacity: 0;
        transform: translateX(-20px);
        transition: all 0.3s ease;
    }
    
    .nav-links.active li {
        opacity: 1;
        transform: translateX(0);
    }
    
    /* Délai d'animation progressif */
    .nav-links.active li:nth-child(1) { transition-delay: 0.05s; }
    .nav-links.active li:nth-child(2) { transition-delay: 0.1s; }
    .nav-links.active li:nth-child(3) { transition-delay: 0.15s; }
    .nav-links.active li:nth-child(4) { transition-delay: 0.2s; }
    .nav-links.active li:nth-child(5) { transition-delay: 0.25s; }
}

/* ========== ORIENTATION LANDSCAPE SUR MOBILE ========== */

@media screen and (max-width: 768px) and (orientation: landscape) {
    /* Réduire les espaces verticaux en mode paysage */
    .hero {
        min-height: auto !important;
        padding-top: 80px !important;
        padding-bottom: 30px !important;
    }
    
    h1 {
        font-size: 2rem !important;
        margin-bottom: 1rem !important;
    }
    
    .subtitle {
        font-size: 0.95rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    .stats {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.75rem !important;
        margin-top: 1.5rem !important;
    }
    
    .section {
        padding: 3rem 1.25rem !important;
    }
}

/* ========== FIXES POUR TRÈS PETITS ÉCRANS (< 360px) ========== */

@media screen and (max-width: 360px) {
    /* Réduire encore plus les espacements */
    .hero {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    .section {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .card {
        padding: 1.25rem !important;
    }
    
    /* Réduire la taille des boutons */
    .cta-button {
        padding: 0.85rem 1.5rem !important;
        font-size: 0.9rem !important;
    }
}

/* ========== ANIMATIONS RÉDUITES POUR ACCESSIBILITÉ ========== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ========== MODE SOMBRE FORCÉ (Certains navigateurs) ========== */

@media (prefers-color-scheme: dark) {
    /* Le site est déjà dark, mais on s'assure de l'optimisation */
    body {
        color-scheme: dark;
    }
}

/* ========== PRINT STYLES (Bonus) ========== */

@media print {
    /* Masquer les éléments non nécessaires à l'impression */
    nav,
    .loading-screen,
    .scroll-indicator,
    .footer-social,
    .cta-container {
        display: none !important;
    }
    
    /* Optimiser pour l'impression */
    body {
        background: white !important;
        color: black !important;
    }
    
    .hero,
    .section {
        page-break-inside: avoid;
    }
}

/* ========== CORRECTIONS SPÉCIFIQUES NAVIGATEURS ========== */

/* Fix pour Chrome Android */
@supports (-webkit-touch-callout: none) {
    @media screen and (max-width: 768px) {
        input,
        textarea,
        select {
            -webkit-appearance: none;
            border-radius: 0;
        }
    }
}

/* Fix pour Firefox Mobile */
@-moz-document url-prefix() {
    @media screen and (max-width: 768px) {
        input,
        textarea,
        select {
            background-clip: padding-box;
        }
    }
}

/* ========== FIN DU FICHIER ========== */
