/**
 * Performance Optimizations CSS
 * CSS Containment et optimisations de rendu
 */

/* ========== CSS CONTAINMENT ========== */
/* Isoler les sections pour améliorer les performances de peinture */

.hero-section,
.partenaires-section,
.tech-section,
.faq-section {
    contain: layout style paint;
    content-visibility: auto;
}

/* Container queries support */
.container {
    container-type: inline-size;
}

/* ========== OPTIMISATION RENDU ========== */
/* Forcer accélération GPU sur éléments animés */

.glass-card,
.feature-box,
.partner-logo-item,
.faq-item,
.tech-partner-card {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* ========== LAZY LOAD OPTIMIZATION ========== */
img[loading="lazy"] {
    content-visibility: auto;
}

/* ========== FONT RENDERING ========== */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ========== REDUCE LAYOUT SHIFTS ========== */
/* Réserver espace pour images */

img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Aspect ratios pour éviter layout shifts */
.tech-image {
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.partner-logo-item {
    aspect-ratio: 2 / 1;
}

.tech-partner-logo {
    aspect-ratio: 3 / 1;
}

/* ========== CRITICAL CSS INLINE (déjà dans index.html) ========== */
/* Above-the-fold content should have critical CSS inlined */

/* ========== WILL-CHANGE OPTIMIZATION ========== */
/* Ne pas surcharger will-change, seulement sur interactions actives */

.glass-button:hover,
.btn:hover,
.feature-box:hover,
.faq-item:hover {
    will-change: transform;
}

.glass-button:not(:hover),
.btn:not(:hover),
.feature-box:not(:hover),
.faq-item:not(:hover) {
    will-change: auto;
}

/* ========== SCROLL PERFORMANCE ========== */
/* Optimiser le scrolling avec passive listeners (géré en JS) */

#main-content {
    overflow-anchor: auto;
}

/* ========== COMPOSITE LAYERS ========== */
/* Créer des composite layers pour animations performantes */

.particles-bg,
.hero-section::before,
.visual-container {
    will-change: transform, opacity;
    transform: translateZ(0);
}

/* ========== GPU ACCELERATION ========== */
/* Forcer GPU sur éléments avec animations complexes */

@media (min-width: 768px) {
    .partners-carousel,
    .tech-features-grid,
    .faq-grid {
        transform: translateZ(0);
        will-change: transform;
    }
}

/* ========== REDUCE PAINT AREAS ========== */
/* Isoler les zones de peinture pour réduire les repaints */

.section-header,
.hero-content,
.tech-content-wrapper,
.partners-carousel-wrapper {
    contain: paint;
}

/* ========== INTERSECTION OBSERVER OPTIMIZATION ========== */
/* Optimiser le chargement conditionnel */

.scroll-reveal:not(.revealed) {
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
}

/* ========== HARDWARE ACCELERATION ========== */
/* Utiliser transform3d au lieu de translate2d */

@keyframes optimized-slide {
    from {
        transform: translate3d(0, 20px, 0);
        opacity: 0;
    }
    to {
        transform: translate3d(0, 0, 0);
        opacity: 1;
    }
}

/* ========== CRITICAL RENDERING PATH ========== */
/* Optimiser le chemin de rendu critique */

/* Prioriser le contenu above-the-fold */
.hero-section {
    contain: none; /* Ne pas contenir la section hero pour rendu rapide */
}

/* Différer le rendu des sections below-the-fold */
.partenaires-section,
.tech-section,
.faq-section {
    content-visibility: auto;
    contain-intrinsic-size: 0 800px;
}

/* ========== MOBILE OPTIMIZATIONS ========== */
@media (max-width: 768px) {
    /* Réduire complexité sur mobile */
    .glass-card {
        backdrop-filter: none;
        background: rgba(3, 11, 21, 0.9);
    }

    /* Simplifier animations sur mobile */
    .hover-lift:hover {
        transform: translateY(-4px);
    }

    /* Désactiver will-change sur mobile pour économiser mémoire */
    * {
        will-change: auto !important;
    }
}

/* ========== PRINT OPTIMIZATIONS ========== */
@media print {
    /* Désactiver animations pour impression */
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }

    /* Masquer éléments non essentiels */
    .particles-bg,
    .back-to-top,
    .hero-actions {
        display: none !important;
    }
}

/* ========== PREFERS REDUCED DATA ========== */
@media (prefers-reduced-data: reduce) {
    /* Désactiver animations coûteuses si économie données activée */
    .particles-bg,
    .visual-badge,
    .partners-carousel {
        animation: none !important;
    }

    /* Utiliser couleurs solides au lieu de dégradés */
    .glass-card {
        background: rgba(3, 11, 21, 0.95);
        backdrop-filter: none;
    }
}

/* ========== CONTRAST ENHANCEMENT ========== */
@media (prefers-contrast: high) {
    /* Augmenter contraste pour accessibilité */
    .hero-title,
    .section-title,
    .faq-question h3 {
        color: #ffffff;
        text-shadow: 0 0 1px rgba(0, 0, 0, 0.5);
    }

    .glass-card {
        border-width: 2px;
    }
}

/* ========== MONITOR PERFORMANCE ========== */
/* Ajouter des indicateurs visuels de performance en dev */

@media (max-width: 768px) {
    /* Indicateur de performance mobile */
    body::before {
        content: attr(data-perf);
        position: fixed;
        bottom: 10px;
        left: 10px;
        padding: 5px 10px;
        background: rgba(0, 168, 255, 0.8);
        color: white;
        font-size: 10px;
        z-index: 9999;
        border-radius: 4px;
        pointer-events: none;
        opacity: 0;
    }

    body[data-perf]::before {
        opacity: 1;
    }
}
