/* ==========================================================================
   ESV — Barre d'outils d'accessibilité (composant maison)
   Remplace le plugin "One Click Accessibility" (pojo-accessibility).
   Design : Figma "Espace Sentein - POC Client" > Access_menu_V2.0 (node 2017:134)
   Markup : functions.php > esv_a11y_toolbar_markup()
   JS     : js/a11y-toolbar.js
   ========================================================================== */

/* ---------- Conteneur ---------- */
#tool-menu.esv-a11y {
    position: fixed;
    z-index: 50000;
    right: 0;
    top: 175px;
    font-family: "Roboto Condensed", Helvetica, Arial, sans-serif;
    transition: top .3s;
}

/* Panneau ouvert : au-dessus du bouton "retour en haut" (#button-top-div, z-index 500000) */
#tool-menu.esv-a11y.is-open {
    z-index: 500001;
}

/* Conservé : position compacte quand le header sticky est réduit */
#tool-menu.esv-a11y.tool-menu-scroll {
    top: 75px;
}

#tool-menu .esv-a11y__sr {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Bouton déclencheur (48x48) ---------- */
#tool-menu .esv-a11y__toggle {
    position: absolute;
    top: -48px;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 10px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #2a4062;
    box-shadow: 0 0 5px rgba(0, 0, 0, .2);
    cursor: pointer;
}

#tool-menu .esv-a11y__toggle img {
    display: block;
    width: 28px;
    height: 28px;
}

#tool-menu .esv-a11y__toggle:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -5px;
}

/* ---------- Panneau ---------- */
#tool-menu .esv-a11y__panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 227px;
    box-sizing: border-box;
    background: #fff;
    border: 1px solid #1d3557;
    box-shadow: 0 0 5px rgba(0, 0, 0, .2);
    /* Écrans peu hauts (mobile paysage) : le panneau défile au lieu d'être coupé.
       Valeur de repli ; le JS l'ajuste à la place réellement disponible. */
    max-height: calc(100vh - 185px);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(calc(100% + 10px));
    visibility: hidden;
    transition: transform .3s ease, visibility 0s linear .3s;
}

#tool-menu.is-open .esv-a11y__panel {
    transform: none;
    visibility: visible;
    transition: transform .3s ease, visibility 0s;
}

#tool-menu .esv-a11y__title {
    margin: 0;
    padding: 0;
    height: 40px;
    line-height: 40px;
    background: #2a4062;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    border-bottom: 1px solid #1d3557;
    box-sizing: border-box;
}

#tool-menu .esv-a11y__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

#tool-menu .esv-a11y__list > li {
    margin: 0;
    padding: 0;
    list-style: none;
    background: #fff;
}

#tool-menu .esv-a11y__list > li:nth-child(even) {
    background: #efefef;
}

/* ---------- Ligne / bouton ---------- */
#tool-menu .esv-a11y__item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    height: 40px;
    margin: 0;
    padding: 0 12px 0 13px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #1d3557;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.1;
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    box-sizing: border-box;
}

/* Survol uniquement sur les appareils à pointeur (évite l'état "collé" après un tap sur mobile) */
@media (hover: hover) {
    #tool-menu .esv-a11y__item:hover {
        background: rgba(29, 53, 87, .06);
    }
}

#tool-menu .esv-a11y__item,
#tool-menu .esv-a11y__toggle {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation; /* pas de délai / zoom au double-tap sur +/- */
}

#tool-menu .esv-a11y__item:focus-visible {
    outline: 2px solid #1d3557;
    outline-offset: -3px;
}

#tool-menu .esv-a11y__item[aria-disabled="true"] {
    opacity: .45;
    cursor: not-allowed;
}

#tool-menu .esv-a11y__icon {
    flex: 0 0 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
}

#tool-menu .esv-a11y__icon img {
    display: block;
    max-width: 17px;
    max-height: 17px;
    width: auto;
    height: auto;
}

#tool-menu .esv-a11y__icon--listen img {
    width: 16px;
    height: 16px;
}

#tool-menu .esv-a11y__label {
    flex: 1 1 auto;
    color: #1d3557;
}

/* Pastille ronde + / - */
#tool-menu .esv-a11y__round {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    border-radius: 19px;
    background: rgba(29, 53, 87, .1);
    color: #666;
    font-size: 12px;
    line-height: 14px;
    text-align: center;
}

/* Pastille Réinitialiser */
#tool-menu .esv-a11y__round--reset {
    flex: 0 0 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 16px;
    border-radius: 11px;
}

#tool-menu .esv-a11y__round--reset img {
    display: block;
    width: 10px;
    height: auto;
}

/* Interrupteur on/off (29x15) */
#tool-menu .esv-a11y__switch {
    position: relative;
    flex: 0 0 29px;
    width: 29px;
    height: 15px;
    border-radius: 20px;
    background: rgba(29, 53, 87, .1);
    transition: background-color .2s;
}

#tool-menu .esv-a11y__switch::after {
    content: "";
    position: absolute;
    top: 1.5px;
    left: 1px;
    width: 12px;
    height: 12px;
    box-sizing: border-box;
    border: 1px solid #fff;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 0 4px rgba(0, 0, 0, .25);
    transition: left .2s;
}

#tool-menu .esv-a11y__item[aria-checked="true"] .esv-a11y__switch {
    background: #1d3557;
}

#tool-menu .esv-a11y__item[aria-checked="true"] .esv-a11y__switch::after {
    left: 16px;
}

@media (prefers-reduced-motion: reduce) {
    #tool-menu .esv-a11y__panel,
    #tool-menu .esv-a11y__switch,
    #tool-menu .esv-a11y__switch::after {
        transition: none !important;
    }
}

/* Ancienne barre du plugin : masquée tant que le plugin n'est pas désactivé */
#pojo-a11y-toolbar {
    display: none !important;
}

/* ==========================================================================
   EFFETS APPLIQUÉS AU SITE
   Classes posées sur <html> (pas sur <body> : un filter sur body casserait
   les éléments en position:fixed, dont cette barre et le header sticky).
   La barre elle-même (#tool-menu) est toujours exclue.
   ========================================================================== */

/* Niveau de gris */
html.esv-a11y-grayscale {
    filter: grayscale(100%);
}

/* Affichage confort = mode contrasté (fond noir, texte blanc, liens jaunes) */
html.esv-a11y-contrast body,
html.esv-a11y-contrast body *:not(#tool-menu):not(#tool-menu *) {
    background-color: #000 !important;
    background-image: none !important;
    color: #fff !important;
    text-shadow: none !important;
    box-shadow: none !important;
}

html.esv-a11y-contrast body a:not(#tool-menu *),
html.esv-a11y-contrast body a:not(#tool-menu *) *,
html.esv-a11y-contrast body strong:not(#tool-menu *),
html.esv-a11y-contrast body b:not(#tool-menu *) {
    color: #ff0 !important;
}

html.esv-a11y-contrast body button:not(#tool-menu *),
html.esv-a11y-contrast body input:not(#tool-menu *),
html.esv-a11y-contrast body select:not(#tool-menu *),
html.esv-a11y-contrast body textarea:not(#tool-menu *),
html.esv-a11y-contrast body table:not(#tool-menu *),
html.esv-a11y-contrast body td:not(#tool-menu *),
html.esv-a11y-contrast body th:not(#tool-menu *) {
    border: 1px solid #fff !important;
}

/* Arrière-plan clair */
html.esv-a11y-light-bg body,
html.esv-a11y-light-bg body *:not(#tool-menu):not(#tool-menu *) {
    background-color: #fff !important;
    background-image: none !important;
    color: #000 !important;
    text-shadow: none !important;
}

html.esv-a11y-light-bg body a:not(#tool-menu *),
html.esv-a11y-light-bg body a:not(#tool-menu *) * {
    color: #1d3557 !important;
}

/* Liens soulignés */
html.esv-a11y-underline body a:not(#tool-menu *) {
    text-decoration: underline !important;
}

/* Police lisible (les polices d'icônes Divi / FontAwesome sont préservées) */
html.esv-a11y-readable body,
html.esv-a11y-readable body *:not(#tool-menu):not(#tool-menu *):not(.et-pb-icon):not(.et_pb_font_icon):not([class*="et-icon"]):not(.fa):not([class^="fa-"]):not([class*=" fa-"]) {
    font-family: Verdana, Arial, Helvetica, sans-serif !important;
}
