/* L'outil d'accessibilité : le bouton, le panneau, et ce que chaque réglage change.
   Moteur : js/accessibilite.js. Même matière que le reste du site : verre de nuit,
   trait de néon bleu et rose. Tout mouvement s'arrête en version calme. */

/* --- Le bouton -------------------------------------------------------------- */
.nfs-a11y__bouton {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 60;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--blanc-neon);
  background: color-mix(in srgb, var(--nuit-2) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.4), bottom 0.35s ease;
}
/* La lueur respire : une ombre fixe dont seule l'opacité change (rien à repeindre). */
.nfs-a11y__bouton::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow:
    0 0 16px color-mix(in srgb, var(--bleu) 60%, transparent),
    0 0 44px color-mix(in srgb, var(--rose-lueur) 55%, transparent);
  animation: nfs-a11y-respire 4.6s ease-in-out infinite;
  pointer-events: none;
}
/* L'anneau : un dégradé bleu et rose qui tourne lentement autour du pictogramme. */
.nfs-a11y__anneau {
  position: absolute;
  inset: 0;
  padding: 2px;
  border-radius: 50%;
  background: conic-gradient(var(--bleu), var(--rose), var(--bleu-lueur), var(--blanc-neon), var(--bleu));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: nfs-a11y-tourne 9s linear infinite;
}
.nfs-a11y__bouton svg { position: relative; transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.4); }
.nfs-a11y__bouton:hover { transform: scale(1.1); }
.nfs-a11y__bouton:hover svg { transform: scale(1.12) rotate(-6deg); }
.nfs-a11y__bouton:hover .nfs-a11y__anneau { animation-duration: 2.4s; }
.nfs-a11y__bouton:active { transform: scale(0.94); }
.nfs-a11y__bouton[aria-expanded="true"] { transform: scale(0.9); }

@keyframes nfs-a11y-tourne { to { transform: rotate(1turn); } }
@keyframes nfs-a11y-respire { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

/* --- Le voile et le panneau ------------------------------------------------- */
.nfs-a11y__voile {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: color-mix(in srgb, var(--nuit) 62%, transparent);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: nfs-a11y-voile 0.35s ease both;
}
.nfs-a11y__voile--sortie { animation: nfs-a11y-voile 0.22s ease reverse both; }
.nfs-a11y__voile[hidden],
.nfs-a11y__panneau[hidden] { display: none; }

.nfs-a11y__panneau {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 71;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(408px, calc(100vw - 24px));
  overflow: hidden;
  border: 1px solid var(--trait-fort);
  border-radius: 22px;
  color: var(--texte);
  font-family: var(--f-texte);
  background: linear-gradient(165deg, color-mix(in srgb, var(--nuit-3) 94%, transparent), color-mix(in srgb, var(--nuit) 97%, transparent) 70%);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    0 0 70px color-mix(in srgb, var(--bleu-lueur) 20%, transparent);
  animation: nfs-a11y-entree 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.nfs-a11y__panneau--sortie { animation: nfs-a11y-sortie 0.22s ease-in both; }

@keyframes nfs-a11y-voile { from { opacity: 0; } }
@keyframes nfs-a11y-entree { from { opacity: 0; transform: translateX(46px) scale(0.97); } }
@keyframes nfs-a11y-sortie { to { opacity: 0; transform: translateX(34px) scale(0.98); } }

/* Le bandeau du haut, souligné d'un trait de néon qui se trace à l'ouverture. */
.nfs-a11y__bandeau {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 16px 22px;
}
.nfs-a11y__bandeau::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--bleu), var(--blanc-neon) 45%, var(--rose));
  box-shadow: 0 0 12px var(--bleu), 0 0 26px color-mix(in srgb, var(--rose) 70%, transparent);
  transform-origin: left center;
  animation: nfs-a11y-trait 0.8s 0.18s cubic-bezier(0.65, 0, 0.35, 1) both;
}
@keyframes nfs-a11y-trait { from { transform: scaleX(0); } }

.nfs-a11y__titre {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 800 1.45rem/1 var(--f-titre);
  letter-spacing: -0.02em;
  color: var(--blanc-neon);
}
.nfs-a11y__titre-icone { display: grid; color: var(--bleu); }
.nfs-a11y__titre-icone svg { width: 20px; height: 25px; }
.nfs-a11y__bandeau-actions { display: flex; align-items: center; gap: 8px; }

.nfs-a11y__reinit,
.nfs-a11y__fermer {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  border: 1px solid var(--trait-fort);
  border-radius: 999px;
  color: var(--texte);
  background: transparent;
  font: 600 0.85rem/1 var(--f-titre);
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, background-color 0.25s;
}
.nfs-a11y__reinit { padding: 0 14px 0 12px; }
.nfs-a11y__fermer { justify-content: center; width: 38px; padding: 0; }
.nfs-a11y__reinit svg,
.nfs-a11y__fermer svg { transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
.nfs-a11y__reinit:hover,
.nfs-a11y__fermer:hover { color: var(--nuit); border-color: var(--blanc-neon); background: var(--blanc-neon); }
.nfs-a11y__reinit:hover svg { transform: rotate(-1turn); }
.nfs-a11y__fermer:hover svg { transform: rotate(90deg); }

.nfs-a11y__corps {
  padding: 6px 18px 22px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--trait-fort) transparent;
}
.nfs-a11y__categorie { margin-top: 20px; }
.nfs-a11y__categorie-titre {
  margin: 0 0 10px;
  font: 600 0.8rem/1 var(--f-titre);
  color: var(--rose);
}
.nfs-a11y__grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* Une tuile par réglage. Elles entrent l'une après l'autre (--rang, posé par le script). */
.nfs-a11y__outil {
  position: relative;
  display: grid;
  align-content: space-between;
  justify-items: start;
  gap: 12px;
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--trait);
  border-radius: 14px;
  color: var(--texte);
  background: color-mix(in srgb, var(--nuit) 55%, transparent);
  font: 600 0.9rem/1.25 var(--f-titre);
  text-align: left;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s, background-color 0.25s, box-shadow 0.3s, color 0.25s;
  animation: nfs-a11y-tuile 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(140ms + var(--rang, 0) * 38ms);
}
@keyframes nfs-a11y-tuile { from { opacity: 0; transform: translateY(16px); } }
.nfs-a11y__outil:hover { transform: translateY(-3px); border-color: var(--trait-fort); color: var(--blanc-neon); }
.nfs-a11y__outil:active { transform: translateY(0) scale(0.97); }

.nfs-a11y__outil-icone {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--trait-fort);
  border-radius: 50%;
  color: var(--bleu);
  transition: color 0.25s, background-color 0.25s, border-color 0.25s, box-shadow 0.3s;
}

/* Un réglage actif s'allume comme un tube : il hésite, puis tient. */
.nfs-a11y__outil[aria-pressed="true"] {
  border-color: var(--bleu);
  color: var(--blanc-neon);
  background: color-mix(in srgb, var(--bleu-lueur) 20%, var(--nuit));
  box-shadow: inset 0 0 0 1px var(--bleu), 0 0 26px color-mix(in srgb, var(--bleu) 34%, transparent);
}
.nfs-a11y__outil[aria-pressed="true"] .nfs-a11y__outil-icone {
  border-color: transparent;
  color: var(--nuit);
  background: var(--bleu);
  box-shadow: 0 0 16px var(--bleu);
  animation: nfs-a11y-allume 0.6s steps(1, end) both;
}
@keyframes nfs-a11y-allume {
  0% { opacity: 0.25; }
  18% { opacity: 1; }
  30% { opacity: 0.4; }
  46% { opacity: 1; }
  58% { opacity: 0.7; }
  70%, 100% { opacity: 1; }
}

.nfs-a11y__pastilles { position: absolute; top: 18px; right: 14px; display: flex; gap: 4px; }
.nfs-a11y__pastille {
  width: 12px;
  height: 4px;
  border-radius: 2px;
  background: var(--trait-fort);
  transition: background-color 0.25s, box-shadow 0.25s, transform 0.3s;
}
.nfs-a11y__pastille--pleine { background: var(--rose); box-shadow: 0 0 9px var(--rose); transform: scaleY(1.5); }

.nfs-a11y__outil--large {
  grid-template-columns: auto minmax(0, 1fr);
  align-content: center;
  align-items: center;
  width: 100%;
  min-height: 0;
}
.nfs-a11y__outil--large[aria-expanded="true"] { border-color: var(--bleu); color: var(--blanc-neon); }

.nfs-a11y__structure-liste { margin: 10px 0 0; padding: 0; list-style: none; border-left: 1px solid var(--trait-fort); }
.nfs-a11y__structure-liste[hidden] { display: none; }
.nfs-a11y__structure-item--h2 { padding-left: 12px; }
.nfs-a11y__structure-item--h3 { padding-left: 24px; }
.nfs-a11y__structure-item--h4 { padding-left: 36px; }
.nfs-a11y__structure-lien {
  display: block;
  width: 100%;
  padding: 7px 12px;
  border: 0;
  color: var(--texte);
  background: none;
  font: 500 0.9rem/1.3 var(--f-texte);
  text-align: left;
  cursor: pointer;
  transition: color 0.2s, padding-left 0.25s;
}
.nfs-a11y__structure-lien:hover { padding-left: 18px; color: var(--bleu); }
.nfs-a11y__structure-item--h1 .nfs-a11y__structure-lien { color: var(--blanc-neon); font-weight: 700; }
.nfs-a11y__structure-vide { padding: 8px 12px; color: var(--texte-doux); font-size: 0.9rem; }
.nfs-a11y__mention { margin: 22px 0 0; color: var(--texte-doux); font-size: 0.8rem; line-height: 1.45; }

.nfs-a11y__bouton:focus-visible,
.nfs-a11y__panneau :focus-visible { outline: 2px solid var(--blanc-neon); outline-offset: 3px; }

/* Téléphone : le panneau monte du bas de l'écran. */
@media (max-width: 560px) {
  .nfs-a11y__panneau {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 84svh;
    animation-name: nfs-a11y-entree-bas;
  }
  .nfs-a11y__panneau--sortie { animation-name: nfs-a11y-sortie-bas; }
  .nfs-a11y__bouton { width: 48px; height: 48px; }
}
@keyframes nfs-a11y-entree-bas { from { opacity: 0; transform: translateY(60px); } }
@keyframes nfs-a11y-sortie-bas { to { opacity: 0; transform: translateY(40px); } }

/* Version calme : tout est posé, rien ne bouge. */
html.calme .nfs-a11y__bouton,
html.calme .nfs-a11y__bouton *,
html.calme .nfs-a11y__bouton::after,
html.calme .nfs-a11y__voile,
html.calme .nfs-a11y__panneau,
html.calme .nfs-a11y__panneau *,
html.calme .nfs-a11y__panneau *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .nfs-a11y__bouton,
  .nfs-a11y__bouton *,
  .nfs-a11y__bouton::after,
  .nfs-a11y__voile,
  .nfs-a11y__panneau,
  .nfs-a11y__panneau *,
  .nfs-a11y__panneau *::after { animation: none !important; transition: none !important; }
}

/* --- Ce que chaque réglage change ------------------------------------------- */
/* Texte plus grand : tout ce qui est mesuré en rem suit. */
html.nfs-a11y-taille-1 { font-size: 112.5%; }
html.nfs-a11y-taille-2 { font-size: 125%; }
html.nfs-a11y-taille-3 { font-size: 137.5%; }
html.nfs-a11y-taille-4 { font-size: 150%; }

html.nfs-a11y-hauteur-1 :is(p, li, dd, dt, label, small, figcaption) { line-height: 1.8 !important; }
html.nfs-a11y-hauteur-2 :is(p, li, dd, dt, label, small, figcaption) { line-height: 2.1 !important; }
html.nfs-a11y-hauteur-3 :is(p, li, dd, dt, label, small, figcaption) { line-height: 2.4 !important; }

html.nfs-a11y-aligner :is(main, .pied) :is(h1, h2, h3, p, li, dd, dt, figcaption) { text-align: left !important; }

html.nfs-a11y-police body,
html.nfs-a11y-police body :is(h1, h2, h3, h4, p, a, li, span, label, input, select, textarea, button, small, dd, dt) {
  font-family: Verdana, Arial, Helvetica, sans-serif !important;
  letter-spacing: 0 !important;
}

/* Le filtre est posé sur chaque grand bloc, jamais sur la page entière : un filtre sur
   la racine décrocherait tout ce qui est fixé à l'écran (en-tête, ciel, panneau). */
html.nfs-a11y-gris :is(.ciel, .entete, main, .pied, .mesure, .nfs-a11y__bouton) { filter: grayscale(1); }

html.nfs-a11y-contraste {
  --nuit: #000;
  --nuit-2: #000;
  --nuit-3: #0B0B12;
  --texte: #FFF;
  --texte-doux: #F1F5FB;
  --trait: rgba(255, 255, 255, 0.55);
  --trait-fort: #FFF;
}
html.nfs-a11y-contraste body { background: #000; }
html.nfs-a11y-contraste .ciel { opacity: 0.2; }
html.nfs-a11y-contraste :is(p, li, dd, small, figcaption, label) { color: #FFF; }

html.nfs-a11y-images :is(main img, main picture, main video) { visibility: hidden !important; }

html.nfs-a11y-liens :is(main, .pied, .entete) a:not(.bouton) {
  color: #FFE45C !important;
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 4px !important;
  outline: 1px dashed #FFE45C;
  outline-offset: 3px;
}
html.nfs-a11y-liens a.bouton { outline: 3px solid #FFE45C; outline-offset: 3px; }

html.nfs-a11y-focus :focus { outline: 3px solid #FFD400 !important; outline-offset: 4px !important; box-shadow: 0 0 0 7px #000 !important; }

.nfs-a11y-masque-bande {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 80;
  background: rgba(0, 0, 4, 0.78);
  pointer-events: none;
}
.nfs-a11y-masque-bande--haut { top: 0; }
.nfs-a11y-masque-bande--bas { bottom: 0; }

/* --- Grandes polices sur petit écran ----------------------------------------
   Rien ne doit élargir la page : un mot trop long se coupe, le bandeau du panneau
   passe sur deux lignes et les tuiles se rangent sur une seule colonne. */
.nfs-a11y__bandeau { flex-wrap: wrap; }
.nfs-a11y__outil,
.nfs-a11y__titre { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) {
  html[class*="nfs-a11y-taille-"] .nfs-a11y__grille { grid-template-columns: minmax(0, 1fr); }
  html[class*="nfs-a11y-taille-"] .nfs-a11y__outil { min-height: 0; grid-auto-flow: column; justify-content: start; align-items: center; }
}
