/* =========================================================
   IMPSR · Barra de accesibilidad
   Va junto con js/accesibilidad.js
   ========================================================= */

/* ---------- 1. Tamaño de letra (clases en <html>) ---------- */
html.a11y-f1 { font-size: 112.5% !important; }
html.a11y-f2 { font-size: 125%   !important; }
html.a11y-f3 { font-size: 137.5% !important; }
html.a11y-f4 { font-size: 150%   !important; }

/* Con letra grande, que los textos largos corten bien y no rompan la pantalla */
html.a11y-f2 body, html.a11y-f3 body, html.a11y-f4 body { overflow-wrap: break-word; }

/* ---------- 2. Bloque que se está leyendo en voz alta ---------- */
.a11y-leyendo {
  background-color: rgba(255, 214, 0, .32) !important;
  outline: 3px solid #f5a623 !important;
  outline-offset: 3px;
  border-radius: 4px;
  transition: background-color .2s ease;
}

/* ---------- 3. Alto contraste ---------- */
html.a11y-contraste,
html.a11y-contraste body {
  background: #000 !important;
  color: #fff !important;
}

/* Todo lo de la página (menos el propio widget) en negro / blanco */
html.a11y-contraste body *:not(.a11y-w):not(.a11y-w *) {
  background-color: #000 !important;
  color: #fff !important;
  border-color: #fff !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

/* Fondos con imagen o degradé (banners, cabeceras): se sacan para que el texto se lea.
   Se dejan los íconos de Bootstrap que usan imagen de fondo (se recolorean más abajo). */
html.a11y-contraste body *:not(.a11y-w):not(.a11y-w *):not(.navbar-toggler-icon):not(.btn-close):not(.form-select):not(.form-check-input):not(.carousel-control-prev-icon):not(.carousel-control-next-icon) {
  background-image: none !important;
}

/* Enlaces en amarillo y subrayados */
html.a11y-contraste body a:not(.a11y-w):not(.a11y-w *),
html.a11y-contraste body a:not(.a11y-w):not(.a11y-w *) * {
  color: #ffeb3b !important;
}
html.a11y-contraste body a:not(.a11y-w):not(.a11y-w *) {
  text-decoration: underline !important;
  text-underline-offset: 3px;
}

/* Botones con borde amarillo bien visible */
html.a11y-contraste body button:not(.a11y-w):not(.a11y-w *),
html.a11y-contraste body .btn:not(.a11y-w):not(.a11y-w *),
html.a11y-contraste body input[type="submit"]:not(.a11y-w):not(.a11y-w *),
html.a11y-contraste body input[type="button"]:not(.a11y-w):not(.a11y-w *) {
  color: #ffeb3b !important;
  border: 2px solid #ffeb3b !important;
}

/* Campos de formulario */
html.a11y-contraste body input:not(.a11y-w *),
html.a11y-contraste body select:not(.a11y-w *),
html.a11y-contraste body textarea:not(.a11y-w *) {
  border: 2px solid #fff !important;
}
html.a11y-contraste ::placeholder { color: #c8c8c8 !important; opacity: 1 !important; }

/* Íconos de Bootstrap redibujados en blanco */
html.a11y-contraste .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23fff' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2.5' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}
html.a11y-contraste .btn-close {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e") !important;
  filter: none !important;
  opacity: 1 !important;
}
html.a11y-contraste .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
}

/* Foco del teclado bien marcado */
html.a11y-contraste *:focus-visible {
  outline: 3px solid #ffeb3b !important;
  outline-offset: 2px !important;
}

/* Lo que se está leyendo, en contraste */
html.a11y-contraste body .a11y-leyendo:not(.a11y-w *) {
  outline: 4px solid #ffeb3b !important;
}

/* ---------- 4. El widget ---------- */
.a11y-w,
.a11y-w * {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: normal;
  text-transform: none;
  line-height: 1.3;
}

.a11y-w {
  --a11y-azul: #1565A0;
  --a11y-azul-osc: #0d4a7a;
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 1045;
  font-size: 16px;
}

.a11y-w svg { width: 22px; height: 22px; flex: 0 0 auto; display: block; }

/* Botón flotante */
.a11y-fab {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  min-width: 52px;
  padding: 0 18px 0 14px;
  border: 0;
  border-radius: 26px;
  background: var(--a11y-azul);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
  transition: background .15s ease, transform .15s ease;
}
.a11y-fab:hover { background: var(--a11y-azul-osc); }
.a11y-fab:active { transform: scale(.97); }
.a11y-fab:focus-visible { outline: 3px solid #f5a623; outline-offset: 3px; }
.a11y-fab svg { width: 26px; height: 26px; }

/* Aro que late mientras está leyendo */
.a11y-w.a11y-hablando .a11y-fab { animation: a11y-latido 1.6s ease-in-out infinite; }
@keyframes a11y-latido {
  0%, 100% { box-shadow: 0 4px 14px rgba(0, 0, 0, .28), 0 0 0 0 rgba(245, 166, 35, .7); }
  50%      { box-shadow: 0 4px 14px rgba(0, 0, 0, .28), 0 0 0 10px rgba(245, 166, 35, 0); }
}

/* Panel */
.a11y-panel {
  position: absolute;
  left: 0;
  bottom: 64px;
  width: 300px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: #fff;
  color: #1f2937;
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .25);
  border: 1px solid #e5e7eb;
  padding: 0 0 12px;
}
.a11y-panel[hidden] { display: none; }

.a11y-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 12px 16px;
  background: var(--a11y-azul);
  color: #fff;
  border-radius: 13px 13px 0 0;
}
.a11y-titulo { font-size: 17px; font-weight: 700; }
.a11y-x {
  width: 36px; height: 36px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 28px; line-height: 1;
  cursor: pointer;
}
.a11y-x:hover { background: rgba(255, 255, 255, .15); }

.a11y-sec { padding: 12px 16px 4px; }
.a11y-sec + .a11y-sec { border-top: 1px solid #eef0f3; }
.a11y-sub { font-size: 14px; font-weight: 600; color: #4b5563; margin: 0 0 8px; }

.a11y-fila { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

.a11y-btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 6px 10px;
  border: 2px solid #cfd8e3;
  border-radius: 10px;
  background: #f5f8fb;
  color: #0d4a7a;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.a11y-btn:hover:not([disabled]) { border-color: var(--a11y-azul); }
.a11y-btn[disabled] { opacity: .45; cursor: default; }
.a11y-btn:focus-visible,
.a11y-tog:focus-visible,
.a11y-reset:focus-visible,
.a11y-x:focus-visible { outline: 3px solid #f5a623; outline-offset: 2px; }

.a11y-prim { background: var(--a11y-azul); border-color: var(--a11y-azul); color: #fff; }
.a11y-prim:hover:not([disabled]) { background: var(--a11y-azul-osc); border-color: var(--a11y-azul-osc); }

.a11y-ancho { width: 100%; min-height: 52px; font-size: 18px; margin-bottom: 6px; }
.a11y-ancho[aria-pressed="true"] { background: #fff; color: #0d4a7a; border-color: var(--a11y-azul); }
.a11y-ancho[aria-pressed="true"]:hover:not([disabled]) { background: #eef5fb; color: #0d4a7a; }

/* "Leer toda la página" queda como opción secundaria, más chica */
.a11y-secund { margin-top: 2px; }
.a11y-secund .a11y-btn { min-height: 40px; font-size: 14px; font-weight: 600; background: #fff; }
.a11y-secund .a11y-btn svg { width: 18px; height: 18px; }

/* Puntito verde en el botón flotante cuando "Escuchar" está prendido */
.a11y-w.a11y-activo .a11y-fab { position: relative; }
.a11y-w.a11y-activo .a11y-fab::after {
  content: "";
  position: absolute;
  top: 2px; right: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
}

.a11y-letra .a11y-btn { flex: 0 0 64px; font-family: Georgia, "Times New Roman", serif; }
.a11y-chico { font-size: 18px !important; }
.a11y-grande { font-size: 26px !important; }
.a11y-letra sup { font-size: 60%; margin-left: 1px; }
.a11y-val { flex: 1 1 auto; text-align: center; font-size: 20px; font-weight: 700; color: #0d4a7a; }

/* Interruptores */
.a11y-tog {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 2px solid #cfd8e3;
  border-radius: 10px;
  background: #fff;
  color: #1f2937;
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.a11y-tog span:not(.a11y-sw) { flex: 1 1 auto; }
.a11y-tog svg { color: var(--a11y-azul); }
.a11y-sw {
  position: relative;
  flex: 0 0 44px;
  width: 44px; height: 24px;
  border-radius: 12px;
  background: #cbd2db;
  transition: background .15s ease;
}
.a11y-sw::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .15s ease;
}
.a11y-tog[aria-pressed="true"] { border-color: var(--a11y-azul); background: #eef5fb; }
.a11y-tog[aria-pressed="true"] .a11y-sw { background: var(--a11y-azul); }
.a11y-tog[aria-pressed="true"] .a11y-sw::after { transform: translateX(20px); }

.a11y-ayuda { margin: 2px 0 8px; font-size: 13.5px; color: #6b7280; }

.a11y-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  margin: 8px 16px 0;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #4b5563;
  font-size: 15px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.a11y-reset:hover { background: #f3f4f6; }

/* Cartel "hacé clic una vez" (Chrome no deja hablar sin un primer clic en la página) */
.a11y-cartel {
  position: absolute;
  left: 0;
  bottom: 64px;
  width: 280px;
  max-width: calc(100vw - 32px);
  padding: 12px 14px;
  border-radius: 12px;
  background: #1f2937;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.a11y-cartel[hidden] { display: none; }
.a11y-cartel::after {
  content: "";
  position: absolute;
  left: 22px; bottom: -8px;
  border: 8px solid transparent;
  border-bottom: 0;
  border-top-color: #1f2937;
}
html.a11y-contraste .a11y-cartel { background: #000; color: #ffeb3b; border: 2px solid #ffeb3b; }

.a11y-vivo {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* El widget también en alto contraste */
html.a11y-contraste .a11y-fab { background: #000; color: #ffeb3b; border: 3px solid #ffeb3b; }
html.a11y-contraste .a11y-panel { background: #000; color: #fff; border: 2px solid #ffeb3b; }
html.a11y-contraste .a11y-head { background: #000; border-bottom: 2px solid #ffeb3b; }
html.a11y-contraste .a11y-sub,
html.a11y-contraste .a11y-ayuda,
html.a11y-contraste .a11y-reset { color: #fff; }
html.a11y-contraste .a11y-sec + .a11y-sec { border-top-color: #555; }
html.a11y-contraste .a11y-btn,
html.a11y-contraste .a11y-tog { background: #000; color: #ffeb3b; border-color: #ffeb3b; }
html.a11y-contraste .a11y-tog svg { color: #ffeb3b; }
html.a11y-contraste .a11y-prim { background: #ffeb3b; color: #000; }
html.a11y-contraste .a11y-btn:hover:not([disabled]) { border-color: #fff; }
html.a11y-contraste .a11y-prim:hover:not([disabled]) { background: #fff; border-color: #fff; color: #000; }
html.a11y-contraste .a11y-fab:hover { background: #222; }
html.a11y-contraste .a11y-val { color: #fff; }
html.a11y-contraste .a11y-tog[aria-pressed="true"] { background: #222; }
html.a11y-contraste .a11y-tog[aria-pressed="true"] .a11y-sw { background: #ffeb3b; }
html.a11y-contraste .a11y-sw::after { background: #000; box-shadow: 0 0 0 2px #fff; }
html.a11y-contraste .a11y-reset:hover { background: #222; }

/* Celular: solo el ícono redondo, panel a lo ancho */
@media (max-width: 575.98px) {
  .a11y-w { left: 12px; bottom: 12px; }
  .a11y-fab { width: 52px; padding: 0; justify-content: center; }
  .a11y-fab-txt { display: none; }
  .a11y-panel { width: calc(100vw - 24px); max-width: none; }
}

/* Sin animaciones si la persona lo tiene configurado así */
@media (prefers-reduced-motion: reduce) {
  .a11y-w.a11y-hablando .a11y-fab { animation: none; outline: 3px solid #f5a623; }
}

/* No sale al imprimir */
@media print {
  .a11y-w { display: none !important; }
  .a11y-leyendo { background: none !important; outline: 0 !important; }
}
