/* Styles d'accessibilité pour le thème G2RD */

/* ─── Focus visible ──────────────────────────────────────────────────────────── */

:focus-visible {
  outline: 3px solid var(--wp--preset--color--primary);
  outline-offset: 3px;
}

.a11y-keyboard-nav :focus {
  outline: 3px solid var(--wp--preset--color--primary);
  outline-offset: 3px;
}

/* ─── Lecteurs d'écran ───────────────────────────────────────────────────────── */

.screen-reader-text,
.a11y-live {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}

.screen-reader-text:focus {
  clip: auto !important;
  clip-path: none;
  height: auto;
  width: auto;
  padding: var(--wp--preset--spacing--xs) var(--wp--preset--spacing--s);
  background: var(--wp--preset--color--white);
  border-radius: var(--wp--custom--radius--s);
  box-shadow: var(--wp--preset--shadow--light);
  z-index: 100000;
}

/* ─── Taille du texte ────────────────────────────────────────────────────────── */

.a11y-text-small body,
.a11y-text-small p,
.a11y-text-small li,
.a11y-text-small td {
  font-size: 0.875em !important;
}

.a11y-text-large body,
.a11y-text-large p,
.a11y-text-large li,
.a11y-text-large td {
  font-size: 1.125em !important;
}

.a11y-text-larger body,
.a11y-text-larger p,
.a11y-text-larger li,
.a11y-text-larger td {
  font-size: 1.25em !important;
}

/* ─── Police lisible ─────────────────────────────────────────────────────────── */

.a11y-readable-font,
.a11y-readable-font * {
  font-family: Arial, Verdana, sans-serif !important;
  letter-spacing: 0.06em;
  word-spacing: 0.1em;
}

/* ─── Interligne ─────────────────────────────────────────────────────────────── */

.a11y-line-height p,
.a11y-line-height li,
.a11y-line-height td,
.a11y-line-height blockquote {
  line-height: 2 !important;
}

/* ─── Alignement à gauche ────────────────────────────────────────────────────── */

.a11y-text-left p,
.a11y-text-left li,
.a11y-text-left td {
  text-align: left !important;
}

/* ─── Contraste élevé ────────────────────────────────────────────────────────── */

.a11y-high-contrast {
  background-color: #000 !important;
  color: #fff !important;
}

.a11y-high-contrast *:not(script):not(style):not(.a11y-widget):not(.a11y-panel):not(.a11y-panel *):not(.a11y-float-btn):not(.a11y-scroll-top) {
  background-color: #000 !important;
  color: #fff !important;
  border-color: #fff !important;
}

.a11y-high-contrast a,
.a11y-high-contrast a * {
  color: #ff0 !important;
  text-decoration: underline !important;
}

.a11y-high-contrast img {
  filter: brightness(0.9) contrast(1.2);
}

/* ─── Niveaux de gris ────────────────────────────────────────────────────────── */

.a11y-grayscale:not(.a11y-panel):not(.a11y-float-btn):not(.a11y-scroll-top) {
  filter: grayscale(1);
}

/* Appliqué sur html pour couvrir toute la page */
html:has(body.a11y-grayscale) {
  filter: grayscale(1);
}

/* ─── Réduction des animations ───────────────────────────────────────────────── */

.a11y-reduced-motion *,
.a11y-reduced-motion *::before,
.a11y-reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* ─── Pause des animations ───────────────────────────────────────────────────── */

.a11y-pause-anim *,
.a11y-pause-anim *::before,
.a11y-pause-anim *::after {
  animation-play-state: paused !important;
  transition: none !important;
}

/* ─── Masque de lecture ──────────────────────────────────────────────────────── */

.a11y-reading-mask::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 80px;
  top: var(--a11y-mask-top, 200px);
  background: color-mix(in srgb, var(--wp--preset--color--primary) 12%, transparent);
  border: 2px solid color-mix(in srgb, var(--wp--preset--color--primary) 30%, transparent);
  border-radius: 4px;
  pointer-events: none;
  z-index: 99998;
  transition: top 0.1s linear;
}

/* ─── Masquer les images ─────────────────────────────────────────────────────── */

.a11y-hide-images img,
.a11y-hide-images picture,
.a11y-hide-images svg:not(.a11y-btn__icon):not(.a11y-float-btn svg):not(.a11y-scroll-top svg) {
  opacity: 0 !important;
  pointer-events: none;
}

/* ─── Système : animations réduites ─────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── Formulaires accessibles ────────────────────────────────────────────────── */

.error-message {
  color: #b91c1c;
  font-size: var(--wp--preset--font-size--s);
  margin-top: var(--wp--preset--spacing--xs);
}

/* ─── Bouton flottant ────────────────────────────────────────────────────────── */

/* Conteneur fixe unique (bouton + panneau) — les deux restent solidaires même
   sous un ancêtre transformé (transform/filter/will-change capturent sinon le
   position:fixed du panneau et l'envoient en bas du document). */
.a11y-widget {
  position: fixed;
  bottom: 32px;
  left: 32px;
  z-index: 10000;
}

.a11y-float-btn {
  /* Couleur pilotée par les options du thème (slug de palette) → var CSS.
     Repli : couleur primaire du thème, puis navy neutre. */
  --_accent: var(--g2rd-a11y-accent, var(--wp--preset--color--primary, #0f172a));
  position: relative;
  background: var(--_accent);
  color: var(--wp--preset--color--white, #fff);
  border: none;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--_accent) 22%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  padding: 0;
}

.a11y-float-btn svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
  pointer-events: none;
}

.a11y-float-btn:hover,
.a11y-float-btn:focus-visible {
  background: color-mix(in srgb, var(--_accent) 85%, #000);
  box-shadow: 0 8px 32px color-mix(in srgb, var(--_accent) 28%, transparent);
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* ─── Scroll to top ──────────────────────────────────────────────────────────── */

.a11y-scroll-top {
  /* Couleur pilotée par les options du thème (slug de palette) → var CSS.
     Repli : couleur primaire du thème, puis navy neutre. */
  --_accent: var(--g2rd-top-accent, var(--wp--preset--color--primary, #0f172a));
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 10000;
  background: var(--_accent);
  color: var(--wp--preset--color--white, #fff);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 52px;
  height: 52px;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--_accent) 22%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, opacity 0.2s;
  padding: 0;
}

.a11y-scroll-top[hidden] {
  display: none;
}

.a11y-scroll-top svg {
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.a11y-scroll-top:hover,
.a11y-scroll-top:focus-visible {
  background: color-mix(in srgb, var(--_accent) 85%, #000);
  box-shadow: 0 8px 32px color-mix(in srgb, var(--_accent) 28%, transparent);
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* ─── Panneau d'accessibilité ────────────────────────────────────────────────── */

.a11y-panel {
  /* Ancré au-dessus du bouton, dans le wrapper .a11y-widget (position:fixed).
     Reste donc collé au bouton quel que soit le contexte de positionnement. */
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  z-index: 1;
  width: 300px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  background: var(--wp--preset--color--white, #fff);
  border-radius: 16px;
  box-shadow:
    0 8px 32px color-mix(in srgb, var(--wp--preset--color--primary) 18%, transparent),
    0 2px 6px color-mix(in srgb, var(--wp--preset--color--primary) 8%, transparent);
  font-family: var(--wp--preset--font-family--inter, system-ui, sans-serif);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px);
  transition: opacity 0.22s, transform 0.22s;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.a11y-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.a11y-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--wp--preset--color--primary) 10%, transparent);
  flex-shrink: 0;
}

.a11y-panel__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--wp--preset--color--primary, #0a0e27);
  line-height: 1.3;
}

.a11y-panel__close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--wp--preset--color--primary, #0a0e27);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  line-height: 1;
}

.a11y-panel__close svg {
  width: 18px;
  height: 18px;
}

.a11y-panel__close:hover,
.a11y-panel__close:focus-visible {
  background: color-mix(in srgb, var(--wp--preset--color--primary) 8%, transparent);
  outline: none;
}

.a11y-panel__body {
  overflow-y: auto;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}

/* ─── Sections du panneau ────────────────────────────────────────────────────── */

.a11y-section {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--wp--preset--color--primary) 8%, transparent);
}

.a11y-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
}

.a11y-section__title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: color-mix(in srgb, var(--wp--preset--color--primary) 50%, transparent);
  margin: 0 0 8px 2px;
  line-height: 1;
}

/* ─── Contrôle de taille du texte ────────────────────────────────────────────── */

.a11y-text-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.a11y-text-controls .a11y-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  justify-content: center;
  border-radius: 8px;
}

.a11y-text-controls .a11y-btn .a11y-btn__label {
  display: none;
}

.a11y-text-controls .a11y-btn .a11y-btn__icon {
  margin: 0;
}

.a11y-text-level {
  flex: 1;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--wp--preset--color--primary, #0a0e27);
}

/* ─── Boutons du panneau ─────────────────────────────────────────────────────── */

.a11y-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 4px;
  background: color-mix(in srgb, var(--wp--preset--color--primary) 4%, transparent);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--wp--preset--color--primary, #0a0e27);
  text-align: left;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.3;
}

.a11y-btn:last-child {
  margin-bottom: 0;
}

.a11y-btn:hover,
.a11y-btn:focus-visible {
  background: color-mix(in srgb, var(--wp--preset--color--primary) 10%, transparent);
  border-color: color-mix(in srgb, var(--wp--preset--color--primary) 20%, transparent);
  outline: none;
}

.a11y-btn.is-active {
  background: var(--wp--preset--color--primary, #0a0e27);
  color: var(--wp--preset--color--white, #fff);
  border-color: var(--wp--preset--color--primary, #0a0e27);
}

.a11y-btn.is-active:hover,
.a11y-btn.is-active:focus-visible {
  background: var(--wp--custom--color--primaryhover, #1e3a5f);
  border-color: var(--wp--custom--color--primaryhover, #1e3a5f);
}

.a11y-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.a11y-btn__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.a11y-btn__icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: none;
}

/* ─── Profils rapides ────────────────────────────────────────────────────────── */

.a11y-section--presets {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 10px;
}

.a11y-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.a11y-preset {
  flex: 1;
  min-width: 80px;
  padding: 7px 6px;
  background: color-mix(in srgb, var(--wp--preset--color--primary) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--wp--preset--color--primary) 12%, transparent);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--wp--preset--color--primary, #0a0e27);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.3;
}

.a11y-preset:hover,
.a11y-preset:focus-visible {
  background: color-mix(in srgb, var(--wp--preset--color--primary) 12%, transparent);
  border-color: color-mix(in srgb, var(--wp--preset--color--primary) 25%, transparent);
  outline: none;
}

/* ─── Réinitialiser ──────────────────────────────────────────────────────────── */

.a11y-reset {
  display: block;
  width: 100%;
  padding: 8px;
  background: none;
  border: 1px solid color-mix(in srgb, var(--wp--preset--color--primary) 20%, transparent);
  border-radius: 8px;
  font-size: 12px;
  color: color-mix(in srgb, var(--wp--preset--color--primary) 60%, transparent);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  margin-top: 4px;
  line-height: 1.3;
}

.a11y-reset:hover,
.a11y-reset:focus-visible {
  background: color-mix(in srgb, var(--wp--preset--color--primary) 6%, transparent);
  border-color: color-mix(in srgb, var(--wp--preset--color--primary) 35%, transparent);
  color: var(--wp--preset--color--primary, #0a0e27);
  outline: none;
}

/* ─── Mobile ─────────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .a11y-widget {
    bottom: 16px;
    left: 16px;
  }

  .a11y-panel {
    width: calc(100vw - 32px);
    max-width: none;
    max-height: calc(100vh - 100px);
  }

  .a11y-scroll-top {
    bottom: 16px;
    right: 16px;
  }
}

/* ─── Contraste élevé — panneau lui-même toujours lisible ────────────────────── */

.a11y-high-contrast .a11y-panel,
.a11y-high-contrast .a11y-float-btn,
.a11y-high-contrast .a11y-scroll-top {
  background: #111 !important;
  color: #fff !important;
  border: 2px solid #fff !important;
}

.a11y-high-contrast .a11y-btn {
  background: #222 !important;
  color: #fff !important;
  border-color: #555 !important;
}

.a11y-high-contrast .a11y-btn.is-active {
  background: #ff0 !important;
  color: #000 !important;
  border-color: #ff0 !important;
}

.a11y-high-contrast .a11y-panel__title,
.a11y-high-contrast .a11y-section__title {
  color: #fff !important;
}
