/* ========================================
   OPTIMISATIONS PERFORMANCE AVANCÉES
   ======================================== */

/* =====================================
   IMAGES OPTIMISÉES & WEBP
   ===================================== */

/* Support progressif WebP */
.webp-support {
    background-image: url('../assets/images/hero-bg.webp');
}

.no-webp-support {
    background-image: url('../assets/images/hero-bg.jpg');
}

/* Lazy loading avec placeholder progressif */
.progressive-image {
    position: relative;
    overflow: hidden;
    background-color: #f3f4f6;
}

.progressive-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.4), 
        transparent
    );
    transform: translateX(-100%);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

.progressive-image img {
    transition: opacity 0.3s ease;
    opacity: 0;
}

.progressive-image img.loaded {
    opacity: 1;
}

/* =====================================
   OPTIMISATIONS TYPOGRAPHIQUES
   ===================================== */

/* Préchargement des polices critiques */
@font-face {
    font-family: 'Inter';
    src: url('https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuLyfAZ9hiJ-Ek-_EeA.woff2') format('woff2');
    font-display: swap;
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Inter';
    src: url('https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuGKYAZ9hiJ-Ek-_EeA.woff2') format('woff2');
    font-display: swap;
    font-weight: 600;
    font-style: normal;
}

/* Optimisation du rendu des polices */
.font-optimized {
    font-display: swap;
    font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1, 'pnum' 1, 'tnum' 0, 'onum' 1, 'lnum' 0, 'dlig' 0;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =====================================
   OPTIMISATIONS CSS CRITIQUES
   ===================================== */

/* CSS critique pour le Above-the-fold */
.critical-css {
    /* Styles critiques pour le hero */
    background: linear-gradient(135deg, #1a2239 0%, #1a2239cc 100%);
    color: white;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.critical-text {
    font-family: 'Inter', sans-serif;
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

/* =====================================
   OPTIMISATIONS ANIMATIONS
   ===================================== */

/* Animations optimisées pour les performances */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* GPU acceleration pour les animations */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Réduction des animations sur connexions lentes */
@media (prefers-reduced-data: reduce) {
    .animate-fadeIn,
    .animate-slideUp,
    .animate-pulse-soft {
        animation: none !important;
    }
    
    .transition,
    .transition-colors {
        transition: none !important;
    }
}

/* =====================================
   OPTIMISATIONS LAYOUT
   ===================================== */

/* Containment pour optimiser les repaint */
.contain-layout {
    contain: layout;
}

.contain-paint {
    contain: paint;
}

.contain-size {
    contain: size;
}

/* Optimisation des grilles CSS */
.grid-optimized {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 2rem;
    contain: layout;
}

/* =====================================
   OPTIMISATIONS SCROLL
   ===================================== */

/* Smooth scrolling optimisé */
.smooth-scroll {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    .smooth-scroll {
        scroll-behavior: auto;
    }
}

/* Optimisation des zones de scroll */
.scroll-optimized {
    overflow: auto;
    overscroll-behavior: contain;
    scroll-snap-type: y mandatory;
}

.scroll-snap-item {
    scroll-snap-align: start;
}

/* =====================================
   OPTIMISATIONS INTERACTIVES
   ===================================== */

/* Optimisation des hovers sur tactile */
@media (hover: hover) {
    .hover-optimized:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    }
}

@media (hover: none) {
    .hover-optimized:active {
        transform: scale(0.98);
    }
}

/* Focus visible optimisé */
.focus-optimized:focus-visible {
    outline: 2px solid #1194e2;
    outline-offset: 2px;
    border-radius: 4px;
}

/* =====================================
   OPTIMISATIONS SPÉCIFIQUES MOBILE
   ===================================== */

/* Optimisation des touch targets */
@media (max-width: 768px) {
    .touch-optimized {
        min-height: 44px;
        min-width: 44px;
        padding: 12px;
        margin: 8px;
    }
    
    /* Optimisation des inputs sur mobile */
    .input-optimized {
        font-size: 16px; /* Évite le zoom sur iOS */
        padding: 12px 16px;
        border-radius: 8px;
        border: 2px solid #e5e7eb;
        background: white;
        transition: border-color 0.2s ease;
    }
    
    .input-optimized:focus {
        outline: none;
        border-color: #1194e2;
        box-shadow: 0 0 0 3px rgba(17, 148, 226, 0.1);
    }
}

/* =====================================
   OPTIMISATIONS PRINT
   ===================================== */

@media print {
    .no-print {
        display: none !important;
    }
    
    .print-optimized {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.4;
    }
    
    .print-break-before {
        page-break-before: always;
    }
    
    .print-break-after {
        page-break-after: always;
    }
    
    .print-break-inside-avoid {
        page-break-inside: avoid;
    }
}

/* =====================================
   OPTIMISATIONS DARK MODE
   ===================================== */

@media (prefers-color-scheme: dark) {
    .dark-mode-optimized {
        background: #1a1a1a;
        color: #ffffff;
    }
    
    .dark-mode-optimized .card {
        background: #2d2d2d;
        border-color: #404040;
    }
    
    .dark-mode-optimized .btn-primary {
        background: #1194e2;
        border-color: #1194e2;
    }
    
    .dark-mode-optimized .btn-secondary {
        background: #1ba3b8;
        border-color: #1ba3b8;
    }
}

/* =====================================
   OPTIMISATIONS HAUTE DENSITÉ
   ===================================== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .high-density-optimized {
        background-image: url('../assets/images/hero-bg@2x.jpg');
        background-size: cover;
    }
}

/* =====================================
   OPTIMISATIONS PRÉFÉRENCES UTILISATEUR
   ===================================== */

/* Respect des préférences de mouvement */
@media (prefers-reduced-motion: reduce) {
    .motion-optimized {
        animation: none !important;
        transition: none !important;
    }
    
    .motion-optimized:hover {
        transform: none !important;
    }
}

/* Respect des préférences de contraste */
@media (prefers-contrast: high) {
    .contrast-optimized {
        border: 2px solid currentColor;
        background: white;
        color: black;
    }
    
    .contrast-optimized .btn-primary {
        background: #000;
        color: #fff;
        border: 2px solid #000;
    }
}

/* =====================================
   OPTIMISATIONS PERFORMANCE GLOBALES
   ===================================== */

/* Optimisation des repaints */
.repaint-optimized {
    transform: translateZ(0);
    will-change: auto;
}

/* Optimisation des reflows */
.reflow-optimized {
    width: 100%;
    height: auto;
    contain: layout;
}

/* Optimisation des z-index */
.z-optimized {
    position: relative;
    z-index: 1;
    isolation: isolate;
}

/* =====================================
   UTILITAIRES PERFORMANCE
   ===================================== */

/* Masquer visuellement mais garder accessible */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Optimisation des images responsives */
.responsive-image {
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: cover;
    loading: lazy;
}

/* Optimisation des vidéos */
.responsive-video {
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: cover;
}

/* =====================================
   DEBUGGING PERFORMANCE
   ===================================== */

/* Utilitaires de debug (à retirer en production) */
.debug-performance {
    outline: 2px solid red;
    background: rgba(255, 0, 0, 0.1);
}

.debug-layout {
    outline: 2px solid blue;
    background: rgba(0, 0, 255, 0.1);
}

.debug-paint {
    outline: 2px solid green;
    background: rgba(0, 255, 0, 0.1);
} 