/*
 * CSS d'optimisation SEO et performances
 * Styles critiques pour améliorer le Core Web Vitals
 */

/* Optimisation du rendu critique */
.above-fold {
    display: block;
    visibility: visible;
}

/* Préchargement des polices pour éviter le FOUT */
@font-face {
    font-family: 'System';
    src: local('Apple SD Gothic Neo'), local('Segoe UI'), local('Roboto'), local('Oxygen'), local('Ubuntu'), local('Cantarell'), sans-serif;
    font-display: swap;
}

/* Optimisation des images - lazyload */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Optimisation CLS - réservation d'espace pour les images */
.image-container {
    position: relative;
    overflow: hidden;
}

.image-container::before {
    content: "";
    display: block;
    padding-top: 56.25%; /* 16:9 aspect ratio */
}

.image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Optimisation des animations pour réduire les reflows */
.optimized-animation {
    will-change: transform, opacity;
    transform: translateZ(0); /* Active l'accélération GPU */
}

/* Préchargement des ressources critiques */
.preload-hint {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Optimisation des boutons pour l'accessibilité et le SEO */
button, .btn {
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

button:focus-visible, .btn:focus-visible {
    outline: 2px solid #8b5cf6;
    outline-offset: 2px;
}

/* Optimisation du scroll et de la navigation */
html {
    scroll-behavior: smooth;
}

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

/* Styles critiques pour le header fixe */
.header-optimized {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background-color 0.3s ease;
}

/* Optimisation des cards pour les tutoriels */
.tutorial-card-optimized {
    contain: layout style paint;
    will-change: transform;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tutorial-card-optimized:hover {
    transform: translateY(-2px);
}

/* Optimisation pour les Core Web Vitals */
.web-vitals-optimized {
    /* LCP - Largest Contentful Paint */
    font-display: swap;
    
    /* FID - First Input Delay */
    pointer-events: auto;
    
    /* CLS - Cumulative Layout Shift */
    min-height: 1px;
}

/* Préchargement des ressources importantes */
.resource-hints {
    display: none;
}

/* Optimisation mobile-first */
@media (max-width: 768px) {
    .mobile-optimized {
        font-size: 16px; /* Évite le zoom sur iOS */
        -webkit-text-size-adjust: 100%;
        -webkit-tap-highlight-color: transparent;
    }
}

/* Optimisation pour les lecteurs d'écran */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip links pour l'accessibilité */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #8b5cf6;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
}

.skip-link:focus {
    top: 6px;
}

/* Optimisation des formulaires */
input, textarea, select {
    font-size: 16px; /* Évite le zoom sur mobile */
    border-radius: 4px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* Optimisation des icônes SVG */
.icon-optimized {
    width: 1em;
    height: 1em;
    fill: currentColor;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Optimisation du thème sombre */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }
}

/* Optimisation de l'impression */
@media print {
    .no-print {
        display: none !important;
    }
    
    a::after {
        content: " (" attr(href) ")";
    }
    
    .print-break {
        page-break-after: always;
    }
} 