/* ════════════════════════════════════════════════════════════════════════
   WIDGET D'ACCESSIBILITÉ — PARTIE 2 : CSS
   Sans dépendance. Deux familles de règles :
     A. le widget lui-même (bouton flottant + fenêtre)
     B. les classes posées sur <body> qui modifient tout le site :
        .a11y-text-lg   → texte +25 %
        .a11y-text-xl   → texte +50 %
        .a11y-contrast  → mode sombre à contraste élevé
   Les mêmes classes sont aussi posées sur <html> pour les sites en rem.
   ════════════════════════════════════════════════════════════════════════ */

/* ── Variables du widget (surchargées en mode sombre plus bas) ──────────── */
.a11y-widget {
  --a11y-bg: #ffffff;
  --a11y-fg: #14161a;
  --a11y-muted: #4a4f57;          /* 8,6:1 sur blanc */
  --a11y-line: #d5d8de;
  --a11y-soft: #f2f4f7;
  --a11y-accent: #1846c7;         /* 7,1:1 sur blanc */
  --a11y-accent-fg: #ffffff;
  --a11y-focus: #1846c7;
  --a11y-trigger-bg: #14161a;
  --a11y-trigger-fg: #ffffff;
  --a11y-radius: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Texte réservé aux lecteurs d'écran */
.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;
}

/* ── A1. Bouton flottant ─────────────────────────────────────────────────── */
.a11y-trigger {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 2147483000;
  width: 56px; height: 56px;                     /* cible tactile > 44 px (WCAG 2.5.5) */
  display: grid; place-items: center;
  border: 2px solid var(--a11y-trigger-fg);
  border-radius: 50%;
  background: var(--a11y-trigger-bg);
  color: var(--a11y-trigger-fg);
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .45);
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
}
.a11y-trigger:hover { transform: scale(1.06); box-shadow: 0 14px 34px -8px rgba(0, 0, 0, .55); }
.a11y-trigger:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 4px; }
.a11y-trigger__icon { width: 28px; height: 28px; }
.a11y-trigger[aria-expanded="true"] { transform: scale(.94); }

/* ── A2. Fenêtre (élément <dialog> natif) ────────────────────────────────── */
.a11y-dialog {
  /* Ancrée au-dessus du bouton sur ordinateur */
  position: fixed;
  inset: auto auto calc(max(16px, env(safe-area-inset-bottom)) + 70px) max(16px, env(safe-area-inset-left));
  margin: 0; padding: 0;
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100dvh - 110px);
  overflow: auto;
  border: 1px solid var(--a11y-line);
  border-radius: var(--a11y-radius);
  background: var(--a11y-bg);
  color: var(--a11y-fg);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45);
  font: 400 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Neutralise les réglages du site (le widget garde sa propre échelle) */
  letter-spacing: normal; text-transform: none; text-align: left;
}
.a11y-dialog::backdrop { background: rgba(10, 12, 16, .45); }
.a11y-dialog[open] { animation: a11y-in .28s cubic-bezier(.2, .8, .2, 1); }
.a11y-dialog[open]::backdrop { animation: a11y-fade .28s ease; }
@keyframes a11y-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes a11y-fade { from { opacity: 0; } }

.a11y-panel { padding: 20px 20px 18px; display: grid; gap: 16px; }
/* Isole le widget des styles génériques du site (header, footer, button…) */
.a11y-head, .a11y-foot { background: none; border: 0; position: static; color: inherit; }
.a11y-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.a11y-title { margin: 0; font: 700 20px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--a11y-fg); letter-spacing: -.01em; text-transform: none; }
.a11y-desc { margin: -8px 0 0; font-size: 14px; color: var(--a11y-muted); }

.a11y-close {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--a11y-line); border-radius: 50%;
  background: transparent; color: var(--a11y-fg); cursor: pointer;
}
.a11y-close svg { width: 20px; height: 20px; }
.a11y-close:hover { background: var(--a11y-soft); }

.a11y-group { margin: 0; padding: 0; border: 0; min-width: 0; }
.a11y-legend { padding: 0; margin-bottom: 8px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--a11y-muted); }
.a11y-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.a11y-options--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Option = vrai bouton radio (natif, donc navigable aux flèches) masqué visuellement */
.a11y-opt { position: relative; display: block; cursor: pointer; }
.a11y-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.a11y-opt__box {
  min-height: 76px; height: 100%;
  display: grid; justify-items: center; align-content: center; gap: 4px;
  padding: 10px 6px; text-align: center;
  border: 2px solid var(--a11y-line); border-radius: 12px;
  background: var(--a11y-bg); color: var(--a11y-fg);
  font-size: 14px; font-weight: 600; line-height: 1.2;
  transition: border-color .2s, background .2s;
}
.a11y-opt__box small { display: block; font-size: 12px; font-weight: 500; color: var(--a11y-muted); }
.a11y-opt__demo { font-family: Georgia, serif; font-weight: 700; line-height: 1; }
.a11y-opt:hover .a11y-opt__box { border-color: var(--a11y-muted); }
.a11y-opt input:checked + .a11y-opt__box { border-color: var(--a11y-accent); background: var(--a11y-soft); box-shadow: inset 0 0 0 1px var(--a11y-accent); }
.a11y-opt input:checked + .a11y-opt__box::after { content: "✓"; position: absolute; top: 6px; right: 8px; font-size: 13px; color: var(--a11y-accent); }
.a11y-opt input:focus-visible + .a11y-opt__box { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }

.a11y-swatch { width: 34px; height: 22px; border-radius: 6px; border: 1px solid var(--a11y-line); }
.a11y-swatch--light { background: linear-gradient(135deg, #ffffff 50%, #1b1d22 50%); }
.a11y-swatch--dark  { background: linear-gradient(135deg, #000000 50%, #ffd23f 50%); }

.a11y-foot { display: flex; justify-content: space-between; gap: 10px; padding-top: 4px; }
.a11y-reset, .a11y-done {
  min-height: 44px; padding: 10px 18px; border-radius: 999px; cursor: pointer;
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.a11y-reset { background: transparent; color: var(--a11y-fg); border: 1px solid var(--a11y-line); }
.a11y-reset:hover { background: var(--a11y-soft); }
.a11y-done { background: var(--a11y-accent); color: var(--a11y-accent-fg); border: 2px solid var(--a11y-accent); }
.a11y-close:focus-visible, .a11y-reset:focus-visible, .a11y-done:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }

/* Mobile : la fenêtre devient une feuille ancrée en bas de l'écran */
@media (max-width: 560px) {
  .a11y-dialog {
    inset: auto 0 0 0; width: 100%; max-width: 100%;
    max-height: 88dvh; border-radius: 20px 20px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .a11y-dialog[open] { animation-name: a11y-up; }
  @keyframes a11y-up { from { transform: translateY(100%); } }
  .a11y-trigger { width: 52px; height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .a11y-trigger, .a11y-opt__box { transition: none; }
  .a11y-dialog[open], .a11y-dialog[open]::backdrop { animation: none; }
}
@media print { .a11y-widget { display: none !important; } }

/* ════════════════════════════════════════════════════════════════════════
   B1. TAILLE DU TEXTE
   Deux mécanismes complémentaires :
   1) --a11y-fs / --a11y-fh : multiplicateurs utilisés par les templates du
      CMS (toutes les tailles y sont écrites calc(… * var(--a11y-fs, 1))).
      Les titres grossissent moins (+12 % / +25 %) pour ne pas déborder.
   2) font-size en % sur <html> : pour tout site dont les tailles sont en rem.
   La mise en page (largeurs, grilles, espacements) n'est PAS agrandie :
   seul le texte change, le responsive reste intact.
   ════════════════════════════════════════════════════════════════════════ */
body.a11y-text-lg { --a11y-fs: 1.25; --a11y-fh: 1.12; }
body.a11y-text-xl { --a11y-fs: 1.5;  --a11y-fh: 1.25; }
html.a11y-text-lg { font-size: 125%; }
html.a11y-text-xl { font-size: 150%; }

/* Garde-fous anti-débordement lorsque le texte est agrandi */
body.a11y-text-lg :where(h1, h2, h3, h4, p, li, a, dd, figcaption, summary),
body.a11y-text-xl :where(h1, h2, h3, h4, p, li, a, dd, figcaption, summary) { overflow-wrap: break-word; }
body.a11y-text-lg :where(.btn, .nl, .chip, .credit),
body.a11y-text-xl :where(.btn, .nl, .chip, .credit) { white-space: normal; }

/* Spécifique aux templates du CMS : barre supérieure et menu */
body.a11y-text-lg .site-head:not(.scrolled) .topbar,
body.a11y-text-xl .site-head:not(.scrolled) .topbar { max-height: 160px; }
body.a11y-text-lg .topbar .wrap,
body.a11y-text-xl .topbar .wrap { height: auto; min-height: 44px; flex-wrap: wrap; padding-block: 6px; }
/* Le menu complet bascule plus tôt en menu « burger » pour ne jamais se chevaucher */
@media (max-width: 1320px) {
  body.a11y-text-lg .nav { display: none; }
  body.a11y-text-lg .burger { display: grid; }
  body.a11y-text-lg [data-layout=centered] .bar { display: flex; }
  body.a11y-text-lg [data-layout=centered] .brand { flex-direction: row; text-align: left; }
}
@media (max-width: 1560px) {
  body.a11y-text-xl .nav { display: none; }
  body.a11y-text-xl .burger { display: grid; }
  body.a11y-text-xl [data-layout=centered] .bar { display: flex; }
  body.a11y-text-xl [data-layout=centered] .brand { flex-direction: row; text-align: left; }
}
body.a11y-text-xl .bar { height: auto; min-height: var(--head-h); }

/* ════════════════════════════════════════════════════════════════════════
   B2. MODE SOMBRE À CONTRASTE ÉLEVÉ
   Fond quasi noir, texte blanc, liens et accents jaunes (13:1 sur noir).
   Les variables de thème des templates sont redéfinies sur <body>, ce qui
   l'emporte sur celles de <html> pour tous les descendants.
   ════════════════════════════════════════════════════════════════════════ */
body.a11y-contrast {
  --bg: #0a0a0a;
  --surface: #171717;
  --ink: #ffffff;
  --muted: #e6e6e6;
  --accent: #ffd23f;
  --accent-ink: #000000;
  --head-bg: #0a0a0a;
  --head-ink: #ffffff;
  --line: rgba(255, 255, 255, .28);
  --line-strong: rgba(255, 255, 255, .5);
  --dark: #000000;
  color-scheme: dark;
  background: #0a0a0a !important;
  color: #ffffff !important;
}
html.a11y-contrast { background: #0a0a0a; color-scheme: dark; }

/* Règles génériques (tout site) – faible spécificité grâce à :where() */
body.a11y-contrast :where(p, li, dd, dt, span, small, label, figcaption, blockquote, cite, td, th, h1, h2, h3, h4, h5, h6) { color: inherit; }
body.a11y-contrast :where(a:not(.btn):not(.a11y-trigger)) { color: #ffd23f; text-decoration: underline; text-underline-offset: 3px; }
body.a11y-contrast :where(a:not(.btn)):hover { color: #ffffff; }
body.a11y-contrast :where(input, select, textarea) { background: #000; color: #fff; border: 1px solid #fff; }
body.a11y-contrast :focus-visible { outline: 3px solid #ffd23f !important; outline-offset: 3px; }
body.a11y-contrast :where(hr) { border-color: rgba(255, 255, 255, .5); }

/* Ajustements des templates du CMS (couleurs calculées à partir du thème) */
body.a11y-contrast :where(.nav a, .brand, .more, .card, .icard, .lrow, .post, .ev, .f-legal a, .mega-links a, .sub.drop a, .chip, .back, .cat, .f-links a, .info a, .socials a, .tb-items a, .credit) { text-decoration: none; }
/* Liens « blocs » (cartes, menu, pied de page) : texte blanc, l'accent jaune reste sur « En savoir plus » */
body.a11y-contrast :where(.nav a, .brand, .card, .icard, .lrow, .post, .ev, .f-legal a, .f-legal button, .mega-links a, .sub.drop a, .chip, .back, .f-links a, .socials a, .tb-items a, .credit, .mnav a) { color: #ffffff; }
body.a11y-contrast :where(.nav a, .mega-links a, .sub.drop a, .f-links a, .back):hover { color: #ffd23f; }
body.a11y-contrast .sub.drop, body.a11y-contrast .sub.mega { background: #0a0a0a; border-color: rgba(255, 255, 255, .5); }
body.a11y-contrast .chip.on { background: #ffd23f; color: #000; }
body.a11y-contrast .top { background: #0a0a0a !important; border-color: rgba(255, 255, 255, .28) !important; }
body.a11y-contrast .site-head, body.a11y-contrast .site-head.over { color: #ffffff; }
body.a11y-contrast .topbar,
body.a11y-contrast .topbar[data-style] { background: #000 !important; color: #fff !important; border-color: rgba(255, 255, 255, .28); }
body.a11y-contrast .contact { background: #171717; color: #fff; }
body.a11y-contrast .contact :where(.txt, .info dt, .info dd) { color: #fff; }
body.a11y-contrast .contact .eyebrow { color: #ffd23f; }
body.a11y-contrast .info a { color: #ffd23f; }
body.a11y-contrast .contact .btn { background: #ffd23f; color: #000; }
body.a11y-contrast .mnav { background: #000; color: #fff; }
body.a11y-contrast .mnav :where(a.big, summary, .kids a, .foot, .foot a) { color: #fff; }
body.a11y-contrast.menu-open .site-head { color: #fff !important; }
body.a11y-contrast .btn { color: #000; }
/* Bouton de l'en-tête transparent au-dessus d'un hero plein écran */
body.a11y-contrast .site-head .top .btn,
body.a11y-contrast .site-head .top .btn:hover { background: #ffd23f !important; color: #000 !important; }
body.a11y-contrast .btn:hover { color: #000; }
body.a11y-contrast .btn.outline { color: #fff; box-shadow: inset 0 0 0 2px #fff; }
body.a11y-contrast .btn.outline:hover { color: #000; }
body.a11y-contrast .btn.link, body.a11y-contrast .btn.link:hover { color: #ffd23f; }
body.a11y-contrast footer { background: #000; color: #e6e6e6; border-top: 1px solid rgba(255, 255, 255, .28); }
body.a11y-contrast .stars { color: #ffd23f; }
body.a11y-contrast .shade { --o: .62; }
body.a11y-contrast .media.empty { color: #fff; }

/* Le widget lui-même passe en mode sombre */
body.a11y-contrast .a11y-widget {
  --a11y-bg: #0a0a0a;
  --a11y-fg: #ffffff;
  --a11y-muted: #e0e0e0;
  --a11y-line: #8a8a8a;
  --a11y-soft: #1f1f1f;
  --a11y-accent: #ffd23f;
  --a11y-accent-fg: #000000;
  --a11y-focus: #ffd23f;
  --a11y-trigger-bg: #ffd23f;
  --a11y-trigger-fg: #000000;
}
body.a11y-contrast .a11y-dialog { box-shadow: 0 0 0 2px #fff, 0 30px 80px -20px rgba(0, 0, 0, .8); }
body.a11y-contrast .a11y-dialog::backdrop { background: rgba(0, 0, 0, .7); }

body.a11y-contrast .ev-date{background:#ffd23f;color:#000}
body.a11y-contrast .badge{background:#2a2a2a;color:#fff}
body.a11y-contrast .badge.full{background:#fff;color:#000}
body.a11y-contrast .ck{background:#0a0a0a;color:#fff;border-color:#fff}
body.a11y-contrast .ck-b{background:#ffd23f;color:#000}
body.a11y-contrast .ck-b.ck-link{background:none;color:#ffd23f}
body.a11y-contrast .side-box{background:#0a0a0a;border-color:rgba(255,255,255,.5)}
body.a11y-contrast .side-promo,body.a11y-contrast .art-cta{background:#171717;color:#fff}
body.a11y-contrast .side-promo-t,body.a11y-contrast .side-promo p,body.a11y-contrast .art-cta-in p{color:#fff}
body.a11y-contrast :where(.toc a,.toc-m a,.side-posts a){color:#fff;text-decoration:none}
body.a11y-contrast .toc a.on,body.a11y-contrast .toc a:hover{color:#ffd23f;border-left-color:#ffd23f}
