/* ----------------------------------------------------------------
	Custom CSS - KaiStudio Theme
	Optimisations SEO, Performance et Responsive
-----------------------------------------------------------------*/

:root {
    /* Performance: Améliorer le rendu */
    --scroll-behavior: smooth;
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* Optimisation du rendu des polices */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Optimisation des images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

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

/* Optimisation des vidéos */
video {
    max-width: 100%;
    height: auto;
}

/* ========================================
   RESPONSIVE IMPROVEMENTS
   ======================================== */

/* Container fluide amélioré */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

/* Images responsive avec ratio */
.img-responsive-16-9 {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    overflow: hidden;
}

.img-responsive-16-9 img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */

/* Touch targets - minimum 44x44px pour mobile */
@media (max-width: 767.98px) {
    .btn,
    a.btn,
    button {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem;
    }

    /* Navigation mobile optimisée */
    .navbar-nav .nav-link {
        font-size: 1rem;
    }

    /* Formulaires optimisés pour mobile */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px; /* Évite le zoom automatique sur iOS */
        min-height: 44px;
    }

    /* Cards optimisées pour mobile */
    .card {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Typographie mobile */
    h1, .h1 {
        font-size: 1.75rem;
    }

    h2, .h2 {
        font-size: 1.5rem;
    }

    h3, .h3 {
        font-size: 1.25rem;
    }

    /* Espacements mobile */
    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    .my-5 {
        margin-top: 2rem !important;
        margin-bottom: 2rem !important;
    }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Focus visible amélioré */
*:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Skip link visible au focus */
.visually-hidden-focusable:focus {
    position: fixed !important;
    top: 10px !important;
    left: 10px !important;
    z-index: 9999 !important;
    width: auto !important;
    height: auto !important;
    clip: auto !important;
}

/* Amélioration des contrastes pour accessibilité */
.text-muted {
    color: #6c757d !important;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    /* Masquer les éléments non nécessaires à l'impression */
    header,
    footer,
    .fab,
    .floating-contact-wrap,
    #backToTop,
    .navbar,
    nav {
        display: none !important;
    }

    /* Optimiser pour l'impression */
    body {
        padding-top: 0;
        padding-bottom: 0;
    }

    /* Forcer les couleurs de fond et texte */
    * {
        background: white !important;
        color: black !important;
    }

    /* Éviter les coupures de page */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }

    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
}

/* ========================================
   PERFORMANCE: Reduce Motion
   ======================================== */

@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;
    }
}

/* ========================================
   MOBILE LANDSCAPE OPTIMIZATIONS
   ======================================== */

@media (max-width: 991.98px) and (orientation: landscape) {
    /* Optimisation du header en mode paysage */
    header.fixed-top {
        min-height: 56px;
    }

    body {
        padding-top: 56px;
    }

    /* Navigation compacte en mode paysage */
    .navbar-brand img {
        height: 32px;
    }
}

/* ========================================
   TABLET OPTIMIZATIONS
   ======================================== */

@media (min-width: 768px) and (max-width: 991.98px) {
    /* Container optimisé pour tablette */
    .container {
        max-width: 720px;
    }

    /* Grid optimisé pour tablette */
    .col-md-6 {
        flex: 0 0 auto;
        width: 50%;
    }

    /* Typographie tablette */
    h1, .h1 {
        font-size: 2.25rem;
    }

    h2, .h2 {
        font-size: 1.875rem;
    }
}

/* ========================================
   HIGH DPI / RETINA DISPLAYS
   ======================================== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimisations pour écrans haute résolution */
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* ========================================
   DARK MODE SUPPORT (Optionnel)
   ======================================== */

@media (prefers-color-scheme: dark) {
    /* Les variables sont déjà définies dans variables.css */
    /* Ajout d'optimisations spécifiques si nécessaire */

    /* Améliorer la lisibilité en mode sombre */
    body {
        background-color: var(--background);
        color: var(--text-dark);
    }

    /* Cards en mode sombre */
    .card {
        background-color: var(--background-light);
        border-color: var(--border-light);
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Classe pour images optimisées */
.img-optimized {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Aspect ratio helpers */
.aspect-ratio-16-9 {
    aspect-ratio: 16 / 9;
}

.aspect-ratio-4-3 {
    aspect-ratio: 4 / 3;
}

.aspect-ratio-1-1 {
    aspect-ratio: 1 / 1;
}

/* Text ellipsis */
.text-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-ellipsis-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-ellipsis-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
