:root {
    --a11y-focus: #70BD95;
    --a11y-border: #7d86a0;
    --a11y-on: #2c7a56;
}
[data-theme="light"] {
    --a11y-focus: #2a6e4e;
    --a11y-border: #7e8ba1;
}

/* AGRANDISSEMENT DU TEXTE · revu le 2026-08-27.
 *
 * Deux facteurs se MULTIPLIENT desormais, au lieu de s'ecraser :
 *
 *   --a11y-zoom : le reglage A / A+ / A++ de ce panneau ;
 *   --pref-zoom : la taille de police que le visiteur a choisie dans son
 *                 navigateur, posee par a11y.js (1 = 16 px, 1.25 = 20 px).
 *
 * Pourquoi passer par « zoom » plutot que par les rem : l'immense majorite
 * des tailles du site sont ecrites en pixels (frameworks tiers compris).
 * Les convertir une a une serait long et risque ; le facteur, lui, agrandit
 * TOUT, sur toutes les pages, y compris pe/, admin/ et les studios. */
:root                     { --a11y-zoom: 1; }
html[data-a11y-text="L"]  { --a11y-zoom: 1.15; }
html[data-a11y-text="XL"] { --a11y-zoom: 1.30; }

body { zoom: calc(var(--pref-zoom, 1) * var(--a11y-zoom, 1)); }

html[data-a11y-line="1"] body { line-height: 1.8; }
html[data-a11y-line="2"] body { line-height: 2.1; }
html[data-a11y-line="1"] :is(p, li, dd, .sec-desc, .lede, .note, .feature p, .step p, .callout p, td, .comp-card__desc) { line-height: 1.8; }
html[data-a11y-line="2"] :is(p, li, dd, .sec-desc, .lede, .note, .feature p, .step p, .callout p, td, .comp-card__desc) { line-height: 2.1; }

html[data-a11y-letter="1"] body { letter-spacing: 0.06em; word-spacing: 0.08em; }
html[data-a11y-letter="2"] body { letter-spacing: 0.12em; word-spacing: 0.16em; }

html[data-a11y-width="narrow"] :is(.content, .pe-main, .gallery-head, #skills, #projects, #composants) {
    max-width: 72ch;
    margin-left: auto;
    margin-right: auto;
}

/* Polices d'accessibilité auto-hébergées (woff2). Grâce à font-display:swap et au
   chargement paresseux des @font-face, seul le fichier de la police CHOISIE est
   téléchargé (rien par défaut). Licences : voir assets/fonts/LICENSES.md. */
@font-face { font-family: "Atkinson Hyperlegible"; src: url("../fonts/atkinson-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("../fonts/atkinson-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Lexend"; src: url("../fonts/lexend-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Lexend"; src: url("../fonts/lexend-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "OpenDyslexic"; src: url("../fonts/opendyslexic-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "OpenDyslexic"; src: url("../fonts/opendyslexic-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

/* Choix de police (data-a11y-font). "readable" reste un alias d'"atkinson"
   pour ne pas casser les préférences déjà enregistrées des visiteurs. */
html[data-a11y-font="atkinson"], html[data-a11y-font="readable"] { --a11y-font: "Atkinson Hyperlegible", Verdana, "Segoe UI", system-ui, sans-serif; }
html[data-a11y-font="lexend"]       { --a11y-font: "Lexend", "Segoe UI", system-ui, sans-serif; }
html[data-a11y-font="opendyslexic"] { --a11y-font: "OpenDyslexic", "Comic Sans MS", "Segoe UI", sans-serif; }
html[data-a11y-font] body,
html[data-a11y-font] button,
html[data-a11y-font] input,
html[data-a11y-font] select,
html[data-a11y-font] textarea {
    font-family: var(--a11y-font, inherit) !important;
}
html[data-a11y-font] :is(code, pre, .mono, .comp-card__title, .hero h1 .mono) {
    font-family: "Consolas", "SFMono-Regular", monospace !important;
}

html[data-a11y-contrast="more"] {
    --text-dim: #c2ccd8;
    --text-dim-strong: #d4dce6;
    --border: #5a6f8f;
    --border-light: #6f86a8;
    --ui-border: #93a1bb;
}
html[data-a11y-contrast="more"][data-theme="light"] {
    --text-dim: #303a47;
    --text-dim-strong: #2a333f;
    --border: #6b7c93;
    --border-light: #56677e;
    --ui-border: #5f7088;
}

@media (prefers-contrast: more) {
    html {
        --text-dim: #c2ccd8;
        --text-dim-strong: #d4dce6;
        --border: #5a6f8f;
        --border-light: #6f86a8;
        --ui-border: #93a1bb;
    }
    html[data-theme="light"] {
        --text-dim: #303a47;
        --text-dim-strong: #2a333f;
        --border: #6b7c93;
        --border-light: #56677e;
        --ui-border: #5f7088;
    }
}

html[data-a11y-underline="on"] :is(p, li, dd, .sec-desc, .lede, .note, .callout, .comp-card__desc, td) a {
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

html[data-a11y-underline="on"] :is(nav, .navbar, .toc, .crumb, .pe-header) a {
    text-decoration: none;
}

html[data-a11y-motion="off"] *,
html[data-a11y-motion="off"] *::before,
html[data-a11y-motion="off"] *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}
html[data-a11y-motion="off"] :is(.project-card, .skill-item, .composants-promo, .intro-image, .logo, .feature, .comp-card, .cal-mock):hover {
    transform: none;
}

/* Fond crème / sépia (repos visuel) · retinte tout le jeu de tokens en chaud. */
html[data-a11y-tint="cream"] {
    --bg-dark: #FDF6E3;
    --bg-sidebar: #FBF0D9;
    --bg-panel: #F5EAD0;
    --bg-canvas: #EFE3C6;
    --text-light: #3a332a;
    --text-dim: #6b6151;
    --border: #e0d3b0;
    --border-light: #d0c199;
}
html[data-a11y-justify="off"] :is(p, li, dd, .lede, .sec-desc, .note, .callout, .comp-card__desc, td) {
    text-align: left !important;
}

/* ===================================================================
   Panneau d'accessibilité · bouton dans #toolbar + menu déroulant
   =================================================================== */
.a11y-wrap { position: relative; display: inline-flex; }
.a11y-wrap--fixed { position: fixed; top: 12px; right: 12px; z-index: 3001; }

.a11y-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius, 6px);
    color: var(--text-dim);
    cursor: pointer;
}
.a11y-btn:hover { color: var(--text-light); background: var(--bg-panel); }
.a11y-btn:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }
.a11y-btn svg { width: 20px; height: 20px; display: block; }

.a11y-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 300px;
    max-width: calc(100vw - 24px);
    max-height: 82vh;
    overflow-y: auto;
    background: var(--bg-sidebar);
    color: var(--text-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 18px 44px -14px rgba(0, 0, 0, 0.55);
    padding: 16px;
    display: none;
    flex-direction: column;
    gap: 12px;
    z-index: 3001;
}
.a11y-panel.open { display: flex; }
.a11y-panel h2 { margin: 0 0 2px; font-size: 0.8312rem; color: var(--a11y-focus); }

/* Le panneau est une SURFACE DE CONTRÔLE : il ne doit pas être agrandi par le
   réglage "Taille du texte" (sinon il déborde de l'écran sans scroll possible),
   ni hériter de l'interlignage / interlettrage. On fige donc sa mise en forme,
   et on neutralise le zoom du body appliqué par data-a11y-text. */
.a11y-panel { line-height: 1.4; letter-spacing: normal; word-spacing: normal; }
html[data-a11y-text="L"]  .a11y-panel { zoom: 0.87; }   /* ~ 1 / 1.15 */
html[data-a11y-text="XL"] .a11y-panel { zoom: 0.77; }   /* ~ 1 / 1.30 */

.a11y-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.a11y-row > span,
.a11y-row > label { font-size: 0.7438rem; color: var(--text-light); }
.a11y-row > label { cursor: pointer; }

.a11y-seg {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 3px;
    background: var(--bg-panel);
    border: 1px solid var(--a11y-border);
    border-radius: 8px;
    padding: 3px;
}
.a11y-seg button {
    font: inherit;
    font-size: 0.6825rem;
    font-weight: 600;
    color: var(--text-dim);
    background: none;
    border: none;
    border-radius: 6px;
    padding: 5px 9px;
    min-width: 30px;
    cursor: pointer;
}
.a11y-seg button:hover { color: var(--text-light); }
.a11y-seg button[aria-pressed="true"] { background: var(--a11y-on); color: #fff; }
.a11y-seg button:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }

.a11y-select {
    max-width: 176px;
    background: var(--bg-panel);
    border: 1px solid var(--a11y-border);
    color: var(--text-light);
    border-radius: 7px;
    padding: 6px 8px;
    font: inherit;
    font-size: 0.6825rem;
    cursor: pointer;
}
.a11y-select:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }

.sw { position: relative; flex-shrink: 0; width: 38px; height: 22px; }
.sw input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.sw .tk {
    position: absolute; inset: 0; border-radius: 999px; pointer-events: none;
    background: var(--bg-panel); border: 1px solid var(--a11y-border);
}
.sw .tk::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
    border-radius: 50%; background: var(--text-dim); transition: transform 0.15s ease;
}
.sw input:checked + .tk { background: #3a9e6f; border-color: #3a9e6f; }
.sw input:checked + .tk::after { background: #fff; transform: translateX(16px); }
.sw input:focus-visible + .tk { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }

.a11y-reset {
    margin-top: 4px;
    font: inherit; font-size: 0.7175rem; font-weight: 600;
    color: var(--text-dim); background: none;
    border: 1px solid var(--a11y-border); border-radius: 7px;
    padding: 8px 12px; cursor: pointer;
}
.a11y-reset:hover { color: var(--text-light); border-color: var(--a11y-focus); }
.a11y-reset:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    .a11y-btn, .a11y-seg button, .sw .tk, .sw .tk::after, .a11y-reset, .a11y-select {
        transition-duration: 0.001ms;
    }
}

@media (forced-colors: active) {
    .a11y-seg button[aria-pressed="true"] {
        forced-color-adjust: none;
        background: Highlight;
        color: HighlightText;
    }
    .sw .tk { border-color: ButtonText; }
    .sw .tk::after { background: ButtonText; }
    .sw input:checked + .tk { background: Highlight; border-color: Highlight; }
    .sw input:checked + .tk::after { background: HighlightText; }
    .a11y-btn:focus-visible,
    .a11y-seg button:focus-visible,
    .a11y-select:focus-visible,
    .sw input:focus-visible + .tk,
    .a11y-reset:focus-visible { outline-color: Highlight; }
}
