/**
 * CSS Performance & Accessibilité - Chalet Toutblanc
 * Fichier: css/accessibility-performance.css
 * 
 * Optimisations:
 * - Amélioration du contraste des couleurs (WCAG 2.1)
 * - Tailles des cibles tactiles (48x48px minimum)
 * - Réduction du CLS (Cumulative Layout Shift)
 * - Focus visible pour l'accessibilité clavier
 * - Font fallback avec métriques ajustées pour éviter le CLS
 */

/* ==========================================================================
   0. FONT FALLBACK AVEC MÉTRIQUES AJUSTÉES POUR RÉDUIRE LE CLS
   Oswald est une police condensée - on ajuste les métriques système
   ========================================================================== */

/* Police fallback avec métriques similaires à Oswald pour éviter le reflow */
@font-face {
    font-family: 'Oswald-fallback';
    src: local('Arial Narrow'), local('Arial');
    size-adjust: 87%;
    ascent-override: 110%;
    descent-override: 25%;
    line-gap-override: 0%;
}

/* Appliquer le fallback sur les éléments utilisant Oswald */
html, body {
    font-family: 'Oswald', 'Oswald-fallback', sans-serif;
}

h1, h2, h3, h4, h5, h6,
.c-btn,
.c-site-header,
.u-brand,
.u-brand-face,
.u-accent,
.u-accent-face {
    font-family: 'Oswald', 'Oswald-fallback', sans-serif;
}

/* Contenu principal - dimensions réservées pour éviter le CLS */
.main.clr {
    min-height: 100vh;
}

/* Slideshow - réserver l'espace avant initialisation JS */
.owl-holder {
    min-height: 50vh;
    overflow: hidden;
}

/* Sections de contenu - réserver l'espace pour éviter le CLS */
.o-content {
    margin: 1em;
}

@media screen and (min-width: 840px) {
    .o-content {
        margin: 1em 4em 1em 220px;
    }
}

/* ==========================================================================
   1. AMÉLIORATION DU CONTRASTE DES COULEURS (WCAG 2.1 AA)
   ========================================================================== */

/* Texte principal - ratio minimum 4.5:1 */
body {
    color: #1a1a1a; /* Plus foncé que #222 pour meilleur contraste */
}

/* Liens - contraste amélioré */
a {
    color: #0056b3; /* Bleu accessible */
    text-decoration: underline;
}

a:hover,
a:focus {
    color: #003d80;
    text-decoration: underline;
}

/* Texte sur fond sombre */
.c-header,
.c-footer {
    color: #ffffff;
}

.c-header a,
.c-footer a {
    color: #ffffff;
}

/* Texte secondaire/gris - contraste minimum 4.5:1 */
.text-muted,
.numerical,
p.numerical {
    color: #595959; /* Ratio 7:1 sur fond blanc */
}

/* Boutons - contraste amélioré */
.btn,
button,
input[type="submit"],
input[type="button"] {
    background-color: #d4a800; /* Jaune plus foncé pour meilleur contraste */
    color: #000000;
    border: 2px solid #d4a800;
}

.btn:hover,
button:hover,
input[type="submit"]:hover {
    background-color: #b38f00;
    border-color: #b38f00;
    color: #000000;
}

/* Focus visible pour accessibilité clavier */
.btn:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
a:focus {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* ==========================================================================
   2. TAILLES DES CIBLES TACTILES (48x48px minimum - WCAG 2.5.5)
   ========================================================================== */

/* Liens et boutons du menu */
.c-nav a,
.c-header__nav a,
nav a {
    display: inline-block;
    min-height: 48px;
    min-width: 48px;
    padding: 12px 16px;
    line-height: 24px;
}

/* Boutons généraux */
.btn,
button,
input[type="submit"],
input[type="button"] {
    min-height: 48px;
    padding: 12px 24px;
    cursor: pointer;
}

/* Champs de formulaire */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
select,
textarea {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px; /* Évite le zoom automatique sur iOS */
}

/* Liens sociaux - Amélioration cibles tactiles */
.c-social a,
.o-social a,
.social-items a,
.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    min-width: 48px;
    padding: 8px;
}

/* Icônes sociales dans le footer */
.social-items a,
.c-footer .social-items a {
    font-size: 24px;
    margin: 0 4px;
}

/* Menu hamburger mobile */
.c-nav__toggle,
.menu-toggle,
.hamburger {
    min-height: 48px;
    min-width: 48px;
    padding: 12px;
}

/* ==========================================================================
   3. RÉDUCTION DU CLS (Cumulative Layout Shift)
   ========================================================================== */

/* Réserver l'espace pour les images du carousel */
.owl-carousel .owl-item img,
.owl-slideshow img,
.c-featured img,
.c-featured__img {
    aspect-ratio: 16 / 9;
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Images de contenu avec dimensions par défaut */
.o-content img {
    max-width: 100%;
    height: auto;
}


/* Logo avec dimensions fixes */
.logo img,
.c-header__logo img {
    width: 200px;
    height: auto;
    aspect-ratio: 3 / 1;
}

/* Séparateur flocon */
img[src*="hr-flake"] {
    width: 30px;
    height: 30px;
}

/* ==========================================================================
   4. POLICES - FONT-DISPLAY SWAP
   ========================================================================== */

/* Fallback système pour éviter FOIT (Flash of Invisible Text) */
body {
    font-family: 'Oswald', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* ==========================================================================
   5. SKIP LINK POUR ACCESSIBILITÉ
   ========================================================================== */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000000;
    color: #ffffff;
    padding: 12px 24px;
    z-index: 100000;
    text-decoration: none;
    font-weight: bold;
}

.skip-link:focus {
    top: 0;
}

/* ==========================================================================
   6. RÉDUCTION DU MOUVEMENT POUR ACCESSIBILITÉ
   ========================================================================== */

@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;
    }
    
    .owl-carousel {
        transition: none !important;
    }
}

/* ==========================================================================
   7. MODE SOMBRE (PRÉFÉRENCE SYSTÈME)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    /* Optionnel : support du mode sombre si souhaité */
}

/* ==========================================================================
   8. OPTIMISATIONS MOBILE
   ========================================================================== */

@media (max-width: 768px) {
    /* Augmenter encore les cibles tactiles sur mobile */
    .c-nav a,
    nav a {
        min-height: 56px;
        padding: 16px;
    }
    
    /* Taille de police minimale pour éviter le zoom iOS */
    input,
    select,
    textarea {
        font-size: 16px;
    }
    
    /* Espacement suffisant entre les éléments cliquables */
    .o-list-striped li {
        padding: 16px 0;
    }
    
    .o-list-striped a {
        display: block;
        padding: 12px 0;
    }
}

/* ==========================================================================
   9. CORRECTIONS LIGHTHOUSE - CONTRASTE AMÉLIORÉ
   ========================================================================== */

/* Textes gris/clairs - Ratio minimum 4.5:1 */
.c-featured__tagline,
.tagline,
.subtitle,
small,
.small {
    color: #545454; /* Ratio 7:1 sur fond blanc */
}

/* Liens dans le contenu - Plus de contraste */
.o-content a:not(.btn):not(.c-btn--primary) {
    color: #000;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.o-content a:not(.btn):not(.c-btn--primary):hover,
.o-content a:not(.btn):not(.c-btn--primary):focus {
    color: #003d80;
    text-decoration-thickness: 2px;
}

/* Footer links - Contraste amélioré */
.c-footer a,
footer a {
    color: #ffffff;
    text-decoration: underline;
}

.c-footer a:hover,
footer a:hover {
    color: #ffd700;
}

/* Texte placeholder - Contraste minimum */
::placeholder {
    color: #666666;
    opacity: 1;
}

/* ==========================================================================
   10. RATIO D'ASPECT IMAGES - ÉVITER DÉFORMATION
   ========================================================================== */

/* Forcer le ratio naturel des images */
img {
    max-width: 100%;
    height: auto;
}

/* Images de galerie */
.gallery img,
.photos img,
.c-gallery img {
    object-fit: cover;
    aspect-ratio: 4 / 3;
}

/* Images du carousel - Ratio 16:9 strict */
.owl-carousel img,
.owl-slideshow img {
    aspect-ratio: 16 / 9;
    object-fit: cover;
    width: 100%;
    height: auto;
}

/* ==========================================================================
   11. LODGIFY FACADE - OPTIMISATION LCP
   ========================================================================== */

/* Container Lodgify optimisé */
.lodgify-facade {
    min-height: 80px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.lodgify-facade:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.lodgify-facade:focus {
    outline: 3px solid #0056b3;
    outline-offset: 2px;
}

/* ==========================================================================
   12. IMAGE FLOCON - OPTIMISATION RETINA
   ========================================================================== */

/* Flocon décoratif - Image 265x563, affichée à 200px max */
.o-flake {
    max-width: 200px;
    height: auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Écrans Retina - utiliser image-set si supporté */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .o-flake {
        /* L'image 265x563 sera utilisée pour 200x425 (suffisant pour 1.3x) */
        /* Pour 2x complet, il faudrait une image 400x850 */
    }
}

/* ==========================================================================
   13. TOUCH TARGETS - ICÔNES SOCIALES HEADER
   ========================================================================== */

/* Icônes sociales dans le header (c-tools) */
.c-tools a,
.c-site-header .c-tools a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    margin: 0 2px;
}

.c-tools a i,
.c-site-header .c-tools a i {
    font-size: 18px;
}

/* Espacement suffisant entre les liens de langues */
.c-langs a {
    display: inline-block;
    min-height: 44px;
    min-width: 44px;
    line-height: 44px;
    text-align: center;
}
