/* ===== STRUCTURE DU WIDGET ===== */
.accessibility-widget {
    position: fixed;
    bottom: var(--a11y-widget-bottom, 20px);
    right: 20px;
    transition: bottom 0.25s ease;
    z-index: 9999;
}

/* Fond legerement assombri (#7bba2d) : icone blanche a 3,4:1 (WCAG 1.4.11) */
.accessibility-toggle {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #5f9a20;
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Panneau compact : une ligne de reglage par option */
.accessibility-panel {
    display: none;
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 340px !important;
    /* Reflow (WCAG 1.4.10) : le panneau ne depasse jamais l'ecran */
    max-width: calc(100vw - 24px) !important;
    max-height: 80vh !important;
    background-color: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(15, 23, 42, 0.08);
    padding: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    color: #1f2937;
}

.accessibility-widget.open .accessibility-panel {
    display: block;
}

/* Le panneau recoit le focus a l'ouverture : pas de contour inutile,
   les controles qu'il contient affichent le leur */
.accessibility-isolated .accessibility-panel:focus,
.accessibility-isolated .accessibility-panel:focus-visible {
    outline: none !important;
}

/* Style pour la barre de défilement */
.accessibility-panel::-webkit-scrollbar {
    width: 8px !important;
}

.accessibility-panel::-webkit-scrollbar-thumb {
    background-color: #ccc !important;
    border-radius: 10px !important;
}

.accessibility-panel::-webkit-scrollbar-track {
    background-color: #f5f5f5 !important;
}

/* ===== ENTETE DU PANNEAU ===== */
.a11y-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    background: #fff;
    border-bottom: 1px solid #eef1f4;
}

.accessibility-panel h3 {
    font-size: 16px !important;
    font-weight: 700 !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: left;
    border: none !important;
    color: #1f2937 !important;
    letter-spacing: 0.01em;
}

.a11y-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.a11y-close:hover {
    background: #f1f3f5;
    color: #111827;
}

.a11y-close svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* ===== LIGNES DE REGLAGE ===== */
.a11y-body {
    padding: 4px 14px;
}

.a11y-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid #f1f4f7;
}

.a11y-body .a11y-row:last-child {
    border-bottom: none;
}

.a11y-row__icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #6b7280;
}

.a11y-row__icon svg {
    width: 17px;
    height: 17px;
    display: block;
}

.a11y-row__label {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13.5px;
    line-height: 1.3;
    color: #1f2937;
}

/* ===== STEPPER TAILLE DU TEXTE ===== */
.a11y-stepper {
    display: inline-flex;
    flex: 0 0 auto;
    border: 1px solid #d9dee3;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.a11y-stepper button {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: #fff;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.a11y-stepper button + button {
    border-left: 1px solid #e4e8ec;
}

.a11y-stepper button:hover:not(:disabled) {
    background: #f1f3f5;
}

.a11y-stepper .a11y-stepper__value {
    min-width: 58px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.a11y-stepper button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== BOUTON MODE (cycle : 1 bouton, plusieurs modes) ===== */
.a11y-mode {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    max-width: 155px;
    padding: 5px 8px 5px 10px;
    border: 1px solid #d9dee3;
    border-radius: 8px;
    background: #f8f9fb;
    color: #1f2937;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.a11y-mode:hover {
    background: #eef1f5;
    border-color: #c6ccd3;
}

.a11y-mode__value {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.a11y-mode__cycle {
    display: flex;
    flex: 0 0 auto;
    color: #9aa3ad;
}

.a11y-mode__cycle svg {
    width: 13px;
    height: 13px;
    display: block;
}

/* ===== BOUTON COMMANDE (lecture) ===== */
.a11y-command {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    padding: 6px 12px;
    border: 1px solid #d9dee3;
    border-radius: 8px;
    background: #fff;
    color: #1f2937;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.a11y-command:hover {
    background: #f1f3f5;
}

.a11y-command__icon {
    display: flex;
    color: #6b7280;
}

.a11y-command__icon svg {
    width: 14px;
    height: 14px;
    display: block;
}

.a11y-command__icon--stop {
    display: none;
}

.a11y-command.active {
    background: #f2f8ec;
    border-color: #b7d692;
    color: #3f6212;
}

.a11y-command.active .a11y-command__icon--play {
    display: none;
}

.a11y-command.active .a11y-command__icon--stop {
    display: flex;
    color: #3f6212;
}

/* ===== INTERRUPTEURS (on/off) ===== */
.a11y-switch {
    appearance: none;
    -webkit-appearance: none;
    flex: 0 0 auto;
    padding: 5px 0;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
}

.a11y-switch__track {
    position: relative;
    display: block;
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: #cbd1d8;
    border: 1px solid #b8bfc7;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.a11y-switch__thumb {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease;
}

.a11y-switch[aria-checked="true"] .a11y-switch__track {
    background: #5f9a20;
    border-color: #4d7f1a;
}

.a11y-switch[aria-checked="true"] .a11y-switch__thumb {
    transform: translateX(18px);
}

/* ===== PIED DU PANNEAU ===== */
.a11y-footer {
    padding: 10px 14px 12px;
    font-size: 11px;
    color: #9aa3ad;
    text-align: center;
    border-top: 1px solid #eef1f4;
}

/* ===== FOCUS VISIBLE ===== */
/* Contour net au clavier sur tous les controles du widget */
.accessibility-isolated .accessibility-toggle:focus-visible,
.accessibility-isolated .a11y-close:focus-visible,
.accessibility-isolated .a11y-mode:focus-visible,
.accessibility-isolated .a11y-command:focus-visible,
.accessibility-isolated .a11y-switch:focus-visible,
.accessibility-isolated .a11y-stepper button:focus-visible {
    outline: 3px solid #111 !important;
    outline-offset: 2px !important;
}

/* En mode sombre ou contraste eleve, le contour doit rester visible */
html.dark-mode :focus-visible {
    outline: 3px solid #fff !important;
    outline-offset: 2px !important;
}

html.high-contrast-mode :focus-visible {
    outline: 3px solid #000 !important;
    outline-offset: 2px !important;
}

/* ===== MODES D'ACCESSIBILITÉ ===== */
/* Mode sombre */
html.dark-mode *:not(.accessibility-isolated):not(.accessibility-isolated *) {
    background-color: #222 !important;
    color: #f5f5f5 !important;
    border-color: #555 !important;
}

/* Le mode sombre uniformise la couleur du texte : les liens sont
   soulignes pour rester identifiables (WCAG 1.4.1) */
html.dark-mode a {
    text-decoration: underline !important;
}

html.dark-mode input, 
html.dark-mode textarea {
    background-color: #333 !important;
}

/* Mode contraste élevé */
html.high-contrast-mode *:not(.accessibility-isolated):not(.accessibility-isolated *) {
    background-color: white !important;
    color: black !important;
    border-color: black !important;
}

/* Meme logique : liens soulignés en contraste élevé */
html.high-contrast-mode a {
    text-decoration: underline !important;
}

/* Mode daltonisme */
html.deuteranopia-mode {
    filter: grayscale(0.5) sepia(0.2) !important;
}

html.protanopia-mode {
    filter: hue-rotate(-30deg) saturate(0.8) !important;
}

html.tritanopia-mode {
    filter: hue-rotate(90deg) saturate(0.8) !important;
}

/* Mode texte large */
body.wide-text-spacing *:not(.accessibility-isolated):not(.accessibility-isolated *) {
    line-height: 1.8 !important;
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
}

body.wide-text-spacing p, 
body.wide-text-spacing li:not(.accessibility-isolated):not(.accessibility-isolated *) {
    margin-bottom: 1.5em !important;
}

/* Police lisible */
body.readable-font *:not(.fas):not(.fab):not(.far):not(.fa):not([class*="fa-"]):not(.accessibility-isolated):not(.accessibility-isolated *) {
    font-family: Verdana, sans-serif !important;
    text-transform: none !important;
}

/* Combinaison Police lisible + espacement large */
body.wide-text-spacing.readable-font *:not(.fas):not(.fab):not(.far):not(.fa):not([class*="fa-"]):not(.accessibility-isolated):not(.accessibility-isolated *) {
    font-family: Verdana, sans-serif !important;
    line-height: 1.8 !important;
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
}

/* Gestion des liens surlignés (le widget lui-meme est exclu) */
body.highlight-links a:not(.accessibility-isolated *),
body.highlight-links button:not(.accessibility-isolated *),
body.highlight-links input[type="button"]:not(.accessibility-isolated *),
body.highlight-links input[type="submit"]:not(.accessibility-isolated *),
body.highlight-links .btn {
    position: relative !important;
    background-color: #ffeb3ba1 !important;
    box-shadow: 0 0 0 2px #ff6b6b !important;
    z-index: 1 !important;
}

body.highlight-links a:not(.accessibility-isolated *)::after,
body.highlight-links button:not(.accessibility-isolated *)::after,
body.highlight-links input[type="button"]:not(.accessibility-isolated *)::after,
body.highlight-links input[type="submit"]:not(.accessibility-isolated *)::after,
body.highlight-links .btn::after {
    content: "" !important;
    position: absolute !important;
    top: -2px !important;
    left: -2px !important;
    right: -2px !important;
    bottom: -2px !important;
    background-color: #ffeb3ba1 !important;
    border: 1px solid #ff6b6b !important;
    border-radius: inherit !important;
    z-index: -1 !important;
    pointer-events: none !important;
}

body.highlight-links a:not(.accessibility-isolated *):hover,
body.highlight-links button:not(.accessibility-isolated *):hover,
body.highlight-links input[type="button"]:not(.accessibility-isolated *):hover,
body.highlight-links input[type="submit"]:not(.accessibility-isolated *):hover,
body.highlight-links .btn:hover {
    background-color: #ffeb3ba1 !important;
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.5) !important;
}

/* ===== GESTION DES ICÔNES EN MODE SOMBRE ===== */
/* Masquer/afficher les icônes adaptées au mode sombre */
img[src$="cart-shopping-white.svg"],
img[src$="user-alt-white.svg"] {
    display: none !important;
}

html.dark-mode img[src$="cart-shopping-svgrepo-com.svg"],
html.dark-mode img[src$="user-alt-1-svgrepo-com.svg"] {
    display: none !important;
}

html.dark-mode img[src$="cart-shopping-white.svg"],
html.dark-mode img[src$="user-alt-white.svg"] {
    display: inline-block !important;
}

/* Effets hover pour les icônes */
html.dark-mode img[src$="cart-shopping-white.svg"]:hover,
html.dark-mode img[src$="user-alt-white.svg"]:hover,
html.dark-mode img[src$="cart-shopping-svgrepo-com.svg"]:hover,
html.dark-mode img[src$="user-alt-1-svgrepo-com.svg"]:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

/* ===== NAVBAR ET LOGO EN MODE SOMBRE ET CONTRASTE ÉLEVÉ ===== */
/* Logo en mode sombre : affichage du logo officiel blanc sans filtre */
html.dark-mode .brand-logo--dark {
    display: none !important;
}

html.dark-mode .brand-logo--light {
    display: block !important;
}

html.dark-mode .brand,
html.dark-mode .brand img {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    filter: none !important;
}

/* Logo en mode contraste élevé */
html.high-contrast-mode .brand-logo--dark {
    display: block !important;
}

html.high-contrast-mode .brand-logo--light {
    display: none !important;
}

html.high-contrast-mode .brand,
html.high-contrast-mode .brand img {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Logos du footer en mode contraste élevé (sur fond devenu blanc).
   Spécificité >= à la règle générique html.high-contrast-mode *
   (les :not() comptent dans la spécificité) : sinon background-color:
   white reste appliqué à l'img et filter: brightness(0) la transforme
   en rectangle noir plein. */
html.high-contrast-mode .site-footer .footer-logo,
html.high-contrast-mode .site-footer .footer-group__logo img {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    filter: brightness(0) !important;
}

/* Menu burger en mode sombre */
html.dark-mode .menu-toggle {
    border: 1px solid rgba(255, 255, 255, 0.6) !important;
    background-color: rgba(255, 255, 255, 0.12) !important;
    border-radius: 4px;
}

html.dark-mode .menu-toggle:hover {
    background-color: rgba(255, 255, 255, 0.24) !important;
}

html.dark-mode .menu-toggle span:not(.sr-only) {
    background-color: #ffffff !important;
}

/* Menu burger en contraste élevé */
html.high-contrast-mode .menu-toggle {
    border: 2px solid #000000 !important;
    background-color: #ffffff !important;
    border-radius: 4px;
}

html.high-contrast-mode .menu-toggle:hover {
    background-color: #000000 !important;
}

html.high-contrast-mode .menu-toggle:hover span:not(.sr-only) {
    background-color: #ffffff !important;
}

html.high-contrast-mode .menu-toggle span:not(.sr-only) {
    background-color: #000000 !important;
}

/* Support rétrocompatible Bootstrap .navbar-toggler si présent */
html.dark-mode .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.5) !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
}

html.dark-mode .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

html.dark-mode .navbar-toggler:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

/* ===== GRAND CURSEUR PERSONNALISÉ ===== */
body.large-cursor,
body.large-cursor a,
body.large-cursor button,
body.large-cursor input,
body.large-cursor textarea,
body.large-cursor select,
body.large-cursor [role="button"],
body.large-cursor [tabindex],
body.large-cursor label,
body.large-cursor .btn,
body.large-cursor .clickable,
body.large-cursor *[onclick] {
    cursor: none !important;
}

.custom-cursor {
    position: fixed;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255,255,255,0.5);
    border: 2px solid #000;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    transition: transform 0.1s ease-out, width 0.2s, height 0.2s;
}

body.large-cursor:active .custom-cursor {
    transform: translate(-50%, -50%) scale(0.8);
    background-color: rgba(0,123,255,0.3);
    border-color: #0069d9;
}

body.large-cursor a:hover ~ .custom-cursor,
body.large-cursor button:hover ~ .custom-cursor,
body.large-cursor input:hover ~ .custom-cursor {
    width: 45px;
    height: 45px;
    border-color: #007bff;
}

.custom-cursor.clickable-target {
    background-color: rgba(0,123,255,0.2);
    border-color: #007bff;
    width: 45px;
    height: 45px;
}

.custom-cursor.clicking {
    transform: translate(-50%, -50%) scale(0.8);
    background-color: rgba(0,123,255,0.4);
    border-width: 3px;
}

/* ===== MODE LECTURE AU SURVOL ===== */
body.hover-reading-mode {
    cursor: help !important;
}

body.hover-reading-mode *:hover {
    outline: 2px dashed #ff6b6b !important;
}

/* Mode sans animation */
body.no-animations * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

/* Guide de lecture */
body.reading-guide {
    position: relative;
}

/* Masque supérieur avec bordure inférieure */
body.reading-guide::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--guide-position, 50vh) - 25px); 
    background-color: rgba(0, 0, 0, 0.7) !important;
    border-bottom: 2px solid #ffeb3b !important; /* Bordure inférieure */
    pointer-events: none;
    z-index: 9998;
    transition: height 0.1s ease;
}

/* Masque inférieur avec bordure supérieure */
body.reading-guide::after {
    content: "";
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(100vh - var(--guide-position, 50vh) - 25px);
    background-color: rgba(0, 0, 0, 0.7) !important;
    border-top: 2px solid #ffeb3b !important; /* Bordure supérieure */
    pointer-events: none;
    z-index: 9998;
    transition: height 0.1s ease;
}

/* Amélioration des performances */
.reading-highlight-borders {
    will-change: transform;
    position: fixed;
    left: 0;
    right: 0;
    height: 50px;
    z-index: 9999;
    pointer-events: none;
}

/* Règles spécifiques pour le mode contraste élevé */
html.high-contrast-mode body.reading-guide::before {
    background-color: rgba(0, 0, 0, 0.8) !important;
    border-bottom: 3px solid #ffeb3b !important; /* Bordure plus visible en contraste élevé */
}

html.high-contrast-mode body.reading-guide::after {
    background-color: rgba(0, 0, 0, 0.8) !important;
    border-top: 3px solid #ffeb3b !important; /* Bordure plus visible en contraste élevé */
}

/* Règles spécifiques pour le mode sombre */
html.dark-mode body.reading-guide::before {
    background-color: rgba(0, 0, 0, 0.8) !important;
    border-bottom: 2px solid #ffeb3b !important;
}

html.dark-mode body.reading-guide::after {
    background-color: rgba(0, 0, 0, 0.8) !important;
    border-top: 2px solid #ffeb3b !important;
}

/* Garantir que l'élément reading-highlight-borders reste transparent */
html.high-contrast-mode body.reading-guide .reading-highlight-borders,
html.dark-mode body.reading-guide .reading-highlight-borders {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    opacity: 0 !important;
}

/* Animation au survol du bouton d'accessibilité */
.accessibility-toggle {
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease !important;
}

.accessibility-toggle:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 4px 15px rgba(0, 255, 76, 0.4) !important;
    background-color: #4a7518 !important;
    animation: pulse 2s infinite !important;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0);
    }
}

/* Assurer que l'animation fonctionne en mode sombre et contraste élevé */
html.dark-mode .accessibility-toggle:hover,
html.high-contrast-mode .accessibility-toggle:hover {
    animation: pulse 2s infinite !important;
}

/* Mouvements reduits : aucune animation ni transition superflue */
@media (prefers-reduced-motion: reduce) {
    .accessibility-toggle,
    .accessibility-toggle:hover {
        transition: none !important;
        animation: none !important;
    }

    .accessibility-toggle:hover {
        transform: scale(1.05) !important;
    }

    .a11y-close,
    .a11y-mode,
    .a11y-command,
    .a11y-stepper button,
    .a11y-switch__track,
    .a11y-switch__thumb,
    .accessibility-widget,
    .custom-cursor {
        transition: none !important;
    }

    body.reading-guide::before,
    body.reading-guide::after {
        transition: none !important;
    }
}

/* Mode sans images */
html.no-background-images *:not(.accessibility-widget *) {
    background-image: none !important;
}

img.disabled-image {
    border: 1px dashed #999 !important;
    background-color: #f0f0f0 !important;
    padding: 8px !important;
    box-sizing: border-box !important;
    min-width: 24px !important;
    min-height: 24px !important;
    position: relative !important;
}

/* Pour compatibilité avec le mode sombre */
html.dark-mode img.disabled-image {
    background-color: #333 !important;
    border-color: #666 !important;
}
