/* 
 * Utilitaires d'accessibilité
 * Classes pour améliorer l'expérience utilisateur et l'accessibilité
 */

/* ========== CLASSES UTILITAIRES D'ACCESSIBILITÉ ========== */

/* Screen readers only - Contenu visible uniquement aux 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;
}

/* Révéler le contenu sr-only au focus */
.sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: var(--spacing-sm);
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background: var(--bg-primary);
    border: 2px solid var(--border-focus);
    border-radius: var(--radius-md);
}

/* Skip links pour la navigation au clavier */
.skip-link {
    position: absolute;
    top: -40px;
    left: var(--spacing-md);
    background: var(--text-primary);
    color: var(--text-white);
    padding: var(--spacing-sm) var(--spacing-md);
    text-decoration: none;
    border-radius: var(--radius-md);
    z-index: var(--z-tooltip);
    font-weight: 600;
    transition: var(--transition-fast);
}

.skip-link:focus {
    top: var(--spacing-md);
}

/* Focus visible amélioré */
.focus-visible,
*:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Suppression de l'outline par défaut */
*:focus:not(:focus-visible) {
    outline: none;
}

/* États de focus pour les éléments interactifs */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.1);
}

/* ========== AMÉLIORATION DE LA LISIBILITÉ ========== */

/* Contraste amélioré pour les liens */
a {
    color: var(--primary-color);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: var(--transition-fast);
}

a:hover {
    color: var(--primary-hover);
    text-decoration-thickness: 2px;
}

a:focus {
    color: var(--primary-hover);
    background: rgba(29, 78, 216, 0.1);
    padding: 2px 4px;
    margin: -2px -4px;
    border-radius: var(--radius-sm);
}

/* Amélioration des boutons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-xl);
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: 600;
    line-height: 1.5;
    text-decoration: none;
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition-normal);
    min-height: 44px; /* Taille minimum recommandée WCAG */
    position: relative;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Bouton primaire avec contraste AAA */
.btn-primary {
    background: var(--primary-color);
    color: var(--text-white);
    border-color: var(--primary-color);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Bouton secondaire */
.btn-secondary {
    background: transparent;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--primary-color);
    color: var(--text-white);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ========== MOTION ET ANIMATIONS ACCESSIBLES ========== */

/* Respecter les préférences de motion réduite */
@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;
    }
}

/* Animations respectueuses */
.fade-in {
    animation: fadeIn var(--transition-slow) ease forwards;
}

.slide-up {
    animation: slideUp var(--transition-normal) ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== UTILITAIRES DE MISE EN PAGE ========== */

/* Container responsive */
.container {
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

/* Espacement vertical cohérent */
.section {
    padding: var(--spacing-3xl) 0;
}

.section-title {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xl);
    line-height: 1.2;
}

/* ========== AMÉLIORATION DE LA TYPOGRAPHIE ========== */

/* Hiérarchie typographique claire */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 var(--spacing-md) 0;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

/* Paragraphes avec espacement optimal */
p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0 0 var(--spacing-md) 0;
    max-width: 65ch; /* Largeur optimale pour la lecture */
}

/* Listes avec espacement amélioré */
ul, ol {
    margin: 0 0 var(--spacing-md) 0;
    padding-left: var(--spacing-xl);
}

li {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--spacing-sm);
}

/* ========== AMÉLIORATION DES FORMULAIRES ========== */

/* Labels accessibles */
label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

/* Champs de formulaire */
input, textarea, select {
    width: 100%;
    padding: var(--spacing-md);
    font-family: inherit;
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    min-height: 44px;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
    outline: none;
}

/* États d'erreur */
.field-error input,
.field-error textarea,
.field-error select {
    border-color: var(--error-color);
}

.error-message {
    color: var(--error-color);
    font-size: var(--text-sm);
    margin-top: var(--spacing-xs);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

/* ========== UTILITAIRES RESPONSIVE ========== */

/* Masquer sur mobile */
@media (max-width: 767px) {
    .hidden-mobile {
        display: none;
    }
}

/* Masquer sur desktop */
@media (min-width: 768px) {
    .hidden-desktop {
        display: none;
    }
}

/* Text sizes responsive */
@media (max-width: 767px) {
    .section-title {
        font-size: var(--text-2xl);
    }
    
    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }
    h3 { font-size: var(--text-xl); }
}

/* ========== INDICATEURS DE CHARGE ET D'ÉTAT ========== */

/* Loading spinner accessible */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* États visuels pour les éléments interactifs */
.interactive {
    transition: var(--transition-fast);
}

.interactive:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.interactive:active {
    transform: translateY(0);
}

/* ========== AMÉLIORATIONS PRINT ========== */

@media print {
    .no-print {
        display: none !important;
    }
    
    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    a, a:visited {
        text-decoration: underline;
    }
    
    .btn {
        border: 1px solid black;
        padding: 0.25rem 0.5rem;
    }
}
