/* ===== NEGISHUT / ACCESSIBILITE =====
 * Widget d'accessibilite AUTO-HEBERGE (aucune dependance externe, aucun CDN tiers).
 * Cible : t"i 5568 / niveau AA.
 *
 * Les modes sont poses en classe sur <html> par js/accessibility.js :
 *   a11y-contrast   contraste eleve (fond noir / texte jaune)
 *   a11y-light      contraste clair (fond blanc / texte noir)
 *   a11y-grayscale  niveaux de gris
 *   a11y-invert     couleurs inversees
 *   a11y-links      liens soulignes et encadres
 *   a11y-readable   police lisible
 *   a11y-spacing    interlignage et espacement augmentes
 *   a11y-bigcursor  gros curseur
 *   a11y-noanim     animations stoppees
 *
 * Le widget lui-meme (#a11y-root) est TOUJOURS exclu des modes : ses regles
 * portent un #id (specificite superieure a "body *"), donc elles gagnent.
 */

/* ---------- 1. Bases toujours actives (ameliorent la ligne de base) ---------- */

/* Focus clavier visible partout : exigence de base du niveau AA. */
body *:focus-visible {
    outline: 3px solid #1a56db !important;
    outline-offset: 2px !important;
}

/* Texte lu par les lecteurs d'ecran mais invisible a l'ecran.
   ⛔ Ne PAS utiliser display:none ni visibility:hidden : ils retirent aussi le texte
   de l'arbre d'accessibilite, donc il ne serait lu par personne. */
.a11y-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Lien d'evitement : premier tabulable de la page, cache jusqu'au focus. */
.a11y-skip-link {
    position: fixed;
    top: -200px;
    inset-inline-start: 12px;
    z-index: 2147483001;
    background: #1a2332;
    color: #FFD700;
    font: 600 16px/1.4 'Inter', Arial, sans-serif;
    padding: 14px 22px;
    border-radius: 0 0 10px 10px;
    text-decoration: none;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
    transition: top .15s ease;
}

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

/* ---------- 2. Bouton flottant ---------- */

#a11y-root {
    font-family: 'Inter', Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

#a11y-toggle {
    position: fixed;
    bottom: 22px;
    inset-inline-start: 22px;
    z-index: 2147483000;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 3px solid #ffffff;
    border-radius: 50%;
    background: #1a56db;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .18s ease, background-color .18s ease;
}

#a11y-toggle:hover,
#a11y-toggle:focus-visible {
    background: #1447b8;
    transform: scale(1.07);
}

#a11y-toggle svg {
    width: 32px;
    height: 32px;
    display: block;
    fill: currentColor;
}

/* ---------- 3. Panneau ---------- */

#a11y-panel {
    position: fixed;
    bottom: 90px;
    inset-inline-start: 22px;
    z-index: 2147483000;
    width: 320px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: #ffffff;
    color: #1a2332;
    border: 2px solid #1a2332;
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .32);
    padding: 0;
}

#a11y-panel[hidden] {
    display: none;
}

.a11y-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #1a2332;
    color: #ffffff;
    padding: 12px 14px;
    border-radius: 10px 10px 0 0;
}

.a11y-head h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #FFD700;
}

.a11y-close {
    background: transparent;
    border: 2px solid transparent;
    color: #ffffff;
    font-size: 24px;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
}

.a11y-close:hover,
.a11y-close:focus-visible {
    border-color: #FFD700;
}

.a11y-body {
    padding: 12px 14px 16px;
}

.a11y-group-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #55617a;
    margin: 12px 0 6px;
}

.a11y-group-title:first-child {
    margin-top: 0;
}

/* Taille du texte */
.a11y-font-row {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Force LTR meme en hebreu : sinon "A-" s'affiche "-A" et le bouton
       d'agrandissement passe a gauche du bouton de reduction. */
    direction: ltr;
}

.a11y-font-row button {
    flex: 1 1 0;
    min-height: 44px;
    font-size: 19px;
    font-weight: 700;
    background: #eef2fb;
    color: #1a2332;
    border: 2px solid #c9d4ea;
    border-radius: 10px;
    cursor: pointer;
}

.a11y-font-row button:hover,
.a11y-font-row button:focus-visible {
    background: #dde5f7;
    border-color: #1a56db;
}

.a11y-font-value {
    flex: 1 1 0;
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Boutons bascule */
.a11y-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.a11y-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 62px;
    padding: 8px 6px;
    text-align: center;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.25;
    background: #f6f8fd;
    color: #1a2332;
    border: 2px solid #c9d4ea;
    border-radius: 10px;
    cursor: pointer;
}

.a11y-opt:hover,
.a11y-opt:focus-visible {
    background: #e7edfa;
    border-color: #1a56db;
}

.a11y-opt[aria-pressed="true"] {
    background: #1a56db;
    border-color: #1a56db;
    color: #ffffff;
}

.a11y-opt .a11y-ico {
    font-size: 20px;
    line-height: 1;
}

/* Pied du panneau */
.a11y-foot {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.a11y-reset {
    min-height: 44px;
    font-size: 14px;
    font-weight: 700;
    background: #fff1f1;
    color: #a11212;
    border: 2px solid #e8b4b4;
    border-radius: 10px;
    cursor: pointer;
}

.a11y-reset:hover,
.a11y-reset:focus-visible {
    background: #ffe0e0;
    border-color: #a11212;
}

.a11y-statement {
    display: block;
    text-align: center;
    font-size: 13.5px;
    font-weight: 600;
    color: #1a56db;
    text-decoration: underline;
    padding: 8px 4px;
    border-radius: 8px;
}

.a11y-statement:hover,
.a11y-statement:focus-visible {
    background: #eef2fb;
}

@media (max-width: 420px) {
    #a11y-panel {
        inset-inline-start: 8px;
        inset-inline-end: 8px;
        width: auto;
    }
}

/* ---------- 4. Modes d'affichage ---------- */
/* On applique les filtres aux ENFANTS DIRECTS de body (pas a body) : un filtre
 * sur body ferait de lui le bloc conteneur des elements position:fixed et
 * decalerait le widget. */

html.a11y-grayscale body > *:not(#a11y-root) {
    filter: grayscale(100%);
}

html.a11y-invert body > *:not(#a11y-root) {
    filter: invert(100%) hue-rotate(180deg);
}

html.a11y-invert body > *:not(#a11y-root) img,
html.a11y-invert body > *:not(#a11y-root) video {
    filter: invert(100%) hue-rotate(180deg);
}

/* Contraste eleve : jaune sur noir */
html.a11y-contrast body,
html.a11y-contrast body * {
    background-image: none !important;
    background-color: #000000 !important;
    color: #FFFF00 !important;
    border-color: #FFFF00 !important;
    text-shadow: none !important;
    box-shadow: none !important;
}

html.a11y-contrast body a,
html.a11y-contrast body a * {
    color: #00E5FF !important;
    text-decoration: underline !important;
}

html.a11y-contrast body button,
html.a11y-contrast body input,
html.a11y-contrast body select,
html.a11y-contrast body textarea {
    border: 2px solid #FFFF00 !important;
}

html.a11y-contrast body img {
    filter: grayscale(30%) contrast(1.15);
}

/* Contraste clair : noir sur blanc */
html.a11y-light body,
html.a11y-light body * {
    background-image: none !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    border-color: #000000 !important;
    text-shadow: none !important;
}

html.a11y-light body a,
html.a11y-light body a * {
    color: #00309e !important;
    text-decoration: underline !important;
}

/* Liens mis en evidence */
html.a11y-links body a {
    text-decoration: underline !important;
    text-underline-offset: 3px !important;
    outline: 1px dashed currentColor !important;
    outline-offset: 2px !important;
}

/* Police lisible */
html.a11y-readable body * {
    font-family: Arial, 'Segoe UI', Tahoma, sans-serif !important;
    letter-spacing: .01em !important;
}

/* Espacement augmente */
html.a11y-spacing body * {
    line-height: 1.9 !important;
    letter-spacing: .06em !important;
    word-spacing: .16em !important;
}

/* Gros curseur */
html.a11y-bigcursor body,
html.a11y-bigcursor body * {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'><path d='M5 2l14 9-6.2 1.3L16 20l-3 1.3-3.2-7.4L5 18z' fill='%23000' stroke='%23fff' stroke-width='1.4'/></svg>") 4 2, auto !important;
}

/* Animations stoppees */
html.a11y-noanim body * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

/* ---------- 4bis. Le widget echappe TOUJOURS aux modes ----------
 * Un selecteur porte par #a11y-root a une specificite ID : il bat les regles
 * ci-dessus, qui sont portees par une CLASSE. Sans ce bloc, le panneau
 * deviendrait jaune-sur-noir et ses boutons illisibles en mode contraste.
 * (⛔ ne PAS remplacer par des :not(#a11y-root *) : un :not() complexe rend
 * la regle entiere invalide sur un navigateur qui ne le comprend pas, et le
 * mode ne s'applique alors plus du tout.) */
html #a11y-root,
html #a11y-root * {
    background-image: none !important;
    text-shadow: none !important;
    cursor: auto !important;
    letter-spacing: normal !important;
    word-spacing: normal !important;
    line-height: 1.5 !important;
    font-family: 'Inter', Arial, Helvetica, sans-serif !important;
    background-color: transparent !important;
    color: #1a2332 !important;
    border-color: #c9d4ea !important;
    filter: none !important;
}

html #a11y-root button,
html #a11y-root a {
    cursor: pointer !important;
}

html #a11y-panel {
    background-color: #ffffff !important;
    border-color: #1a2332 !important;
}

html #a11y-panel .a11y-head {
    background-color: #1a2332 !important;
}

html #a11y-panel .a11y-head h2 {
    color: #FFD700 !important;
}

html #a11y-panel .a11y-close {
    color: #ffffff !important;
    border-color: transparent !important;
}

html #a11y-toggle {
    background-color: #1a56db !important;
    color: #ffffff !important;
    border-color: #ffffff !important;
}

html #a11y-panel .a11y-font-row button {
    background-color: #eef2fb !important;
}

html #a11y-panel .a11y-opt {
    background-color: #f6f8fd !important;
}

html #a11y-panel .a11y-opt[aria-pressed="true"] {
    background-color: #1a56db !important;
    border-color: #1a56db !important;
    color: #ffffff !important;
}

html #a11y-panel .a11y-reset {
    background-color: #fff1f1 !important;
    color: #a11212 !important;
    border-color: #e8b4b4 !important;
}

html #a11y-panel .a11y-statement {
    color: #1a56db !important;
    text-decoration: underline !important;
}

html #a11y-panel .a11y-group-title {
    color: #55617a !important;
}

/* Respect de la preference systeme, independamment du widget */
@media (prefers-reduced-motion: reduce) {
    body *,
    body *::before,
    body *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- 5. Impression : ne pas imprimer le widget ---------- */
@media print {
    #a11y-root {
        display: none !important;
    }
}
