/* ═══════════════════════════════════════════════════════════════════════
   ACCESIBILIDAD — Pinamar Datos
   Capa 1 (cimientos): saltar-al-contenido, foco visible, reducir movimiento.
   Capa 2 (barra propia ALT+A): tamaño de texto, color/contraste, fuente legible,
   resaltar enlaces, lectura en voz alta. Primera-parte, sin overlays de terceros.
   Objetivo: WCAG 2.1 AA · Ley 26.653 (accesibilidad web sector público AR).
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Saltar al contenido (primer foco de la página) ── */
.skip-link {
  position: fixed; top: -120px; left: 12px; z-index: 100000;
  background: #00351f; color: #ffffff; font-weight: 700;
  padding: 12px 20px; border-radius: 0 0 10px 10px; border: 2px solid #34d399;
  text-decoration: none; font-family: 'Inter', Arial, sans-serif;
  transition: top .15s ease;
}
.skip-link:focus { top: 0; outline: 3px solid #ffffff; outline-offset: 2px; }
/* Tema claro: el verde oscuro + contorno azul no llegaba a 3:1 — fondo claro para que el foco se vea (WCAG 2.4.7). */
[data-theme="light"] .skip-link { background: #ffffff; color: #064e3b; border-color: #0369a1; }
[data-theme="light"] .skip-link:focus { outline: 3px solid #0369a1; }

/* ── Foco visible y consistente al navegar con teclado (cimiento clave WCAG 2.4.7) ── */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible, [role="button"]:focus-visible,
summary:focus-visible {
  outline: 3px solid #22d3ee !important;
  outline-offset: 2px !important;
  border-radius: 4px;
}
[data-theme="light"] a:focus-visible, [data-theme="light"] button:focus-visible,
[data-theme="light"] input:focus-visible, [data-theme="light"] select:focus-visible,
[data-theme="light"] [tabindex]:focus-visible, [data-theme="light"] [role="button"]:focus-visible {
  outline-color: #0369a1 !important;
}
/* Sobre la barra superior verde (#007242), en los dos temas: el azul de arriba no se distingue del
   verde (1,1 a 1); el blanco, sí (6,3 a 1). */
.header a:focus-visible, .header button:focus-visible, .header input:focus-visible,
[data-theme="light"] .header a:focus-visible, [data-theme="light"] .header button:focus-visible,
[data-theme="light"] .header input:focus-visible {
  outline-color: #ffffff !important;
}

/* ── Reducir movimiento: preferencia del SO + interruptor de la barra ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
  #particleCanvas { display: none !important; }
}
html.a11y-reduce-motion *, html.a11y-reduce-motion *::before, html.a11y-reduce-motion *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important;
  transition-duration: .001ms !important; scroll-behavior: auto !important;
}
html.a11y-reduce-motion #particleCanvas { display: none !important; }

/* ── Tamaño de texto (escala la raíz; afecta todo lo definido en rem/em) ── */
html.a11y-fs-1 { font-size: 112.5%; }
html.a11y-fs-2 { font-size: 125%; }
html.a11y-fs-3 { font-size: 140%; }

/* ── Modos de color (filtro en la raíz; uno por vez) ──
   En invertido, re-invertimos imágenes/mapas/videos y la PROPIA barra para que
   sigan viéndose bien y operables. */
html.a11y-grayscale { filter: grayscale(1); }
html.a11y-contrast  { filter: contrast(1.35); }
html.a11y-invert    { filter: invert(1) hue-rotate(180deg); }
html.a11y-invert img, html.a11y-invert video, html.a11y-invert canvas,
html.a11y-invert .leaflet-container, html.a11y-invert [style*="background-image"],
html.a11y-invert .a11y-fab, html.a11y-invert .a11y-panel, html.a11y-invert .a11y-modal-ov {
  filter: invert(1) hue-rotate(180deg);
}
/* OJO: NO aplicar filter a .a11y-root (envoltorio) — un ancestro con filter rompe el
   position:fixed de sus hijos (FAB/panel se irían al fondo del documento y "desaparecen").
   Por eso se re-invierte cada pieza fija por separado, no el contenedor. */
/* En modo invertido el contorno de foco también se invierte y pierde contraste:
   lo forzamos a un azul oscuro de alto contraste (WCAG 2.4.7). */
html.a11y-invert :focus-visible { outline-color: #0369a1 !important; }

/* ── Fuente legible + espaciado (apoyo dislexia / baja visión) ── */
html.a11y-readable, html.a11y-readable * {
  font-family: Verdana, 'Segoe UI', Tahoma, Arial, sans-serif !important;
  letter-spacing: .03em !important;
  word-spacing: .12em !important;
  line-height: 1.7 !important;
}
html.a11y-readable .a11y-root, html.a11y-readable .a11y-root * { letter-spacing: normal !important; word-spacing: normal !important; }

/* ── Resaltar enlaces ── */
html.a11y-links a:not(.a11y-root a):not(.skip-link) {
  text-decoration: underline !important; text-underline-offset: 2px;
  outline: 1px dashed currentColor; outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   BARRA DE ACCESIBILIDAD (componente propio) — siempre legible y operable
   ═══════════════════════════════════════════════════════════════════════ */
.a11y-root { font-family: 'Inter', Arial, sans-serif; }

/* Botón flotante */
.a11y-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 99990;
  width: 56px; height: 56px; border-radius: 50%; cursor: pointer;
  background: #00351f; color: #ffffff; border: 2px solid #34d399;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
  transition: transform .15s ease, box-shadow .15s ease;
}
.a11y-fab:hover { transform: scale(1.06); box-shadow: 0 8px 26px rgba(52,211,153,.4); }
.a11y-fab svg { width: 30px; height: 30px; display: block; }

/* Panel */
.a11y-panel {
  position: fixed; right: 18px; bottom: 84px; z-index: 99991;
  width: 340px; max-width: calc(100vw - 36px); max-height: calc(100vh - 110px);
  overflow-y: auto; overscroll-behavior: contain;
  background: #0b1220; color: #f1f5f9; border: 1px solid #334155;
  border-radius: 16px; box-shadow: 0 18px 50px rgba(0,0,0,.55);
  padding: 0; font-size: 14px;
}
.a11y-panel[hidden] { display: none; }
.a11y-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  background: #00351f; color: #fff; padding: 14px 16px; border-radius: 15px 15px 0 0;
  position: sticky; top: 0;
}
.a11y-panel-head h2 { font-size: 16px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 8px; }
/* Ícono del header = símbolo UNIVERSAL de accesibilidad (persona con brazos/piernas extendidos,
   el mismo del botón), NO la silla de ruedas (que reduce la accesibilidad solo a movilidad). */
.a11y-title-ic { display: inline-flex; flex: none; }
.a11y-title-ic svg { width: 20px; height: 20px; display: block; }
.a11y-panel-head .a11y-kbd { font-size: 11px; opacity: .85; font-weight: 500; }
.a11y-x {
  background: transparent; border: 1px solid rgba(255,255,255,.4); color: #fff;
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 16px; line-height: 1;
}
.a11y-x:hover { background: rgba(255,255,255,.15); }
.a11y-body { padding: 14px 16px 18px; }

.a11y-group { margin-bottom: 16px; }
.a11y-group-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: #94a3b8; margin: 0 0 8px; font-weight: 700;
}
.a11y-segment { display: flex; gap: 6px; flex-wrap: wrap; }
.a11y-btn {
  flex: 1 1 auto; min-width: 64px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  background: #1e293b; color: #f1f5f9; border: 1px solid #334155;
  border-radius: 10px; padding: 10px 10px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .12s ease, border-color .12s ease;
  text-align: center;
}
.a11y-btn:hover { background: #273449; border-color: #475569; }
/* Estado activo: además del color, una pista NO-color (subrayado + negrita) para que
   se distinga en escala de grises o con daltonismo (WCAG 1.4.1 Uso del color). */
.a11y-btn[aria-pressed="true"], .a11y-btn.is-on {
  background: #064e3b; border-color: #34d399; color: #d1fae5;
  font-weight: 800; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px;
}
.a11y-segment .a11y-btn { min-width: 0; } /* permite achicar/envolver con texto grande (140%) sin clipping */
.a11y-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.a11y-btn-wide { width: 100%; }

.a11y-tts-row { display: flex; gap: 6px; }
.a11y-reset {
  width: 100%; margin-top: 4px; background: transparent; color: #fca5a5;
  border: 1px solid rgba(248,113,113,.4); border-radius: 10px; padding: 9px; font-weight: 600;
  font-size: 13px; cursor: pointer;
}
.a11y-reset:hover { background: rgba(248,113,113,.12); }
.a11y-foot { margin-top: 12px; font-size: 11.5px; color: #94a3b8; line-height: 1.5; text-align: center; }
.a11y-foot a { color: #67e8f9; }

/* Modo "leer lo que toco": resaltado del bloque + banner guía */
.a11y-reading { outline: 3px solid #22d3ee !important; outline-offset: 2px; background: rgba(34, 211, 238, 0.14) !important; border-radius: 4px; }
html.a11y-invert .a11y-reading { outline-color: #0369a1 !important; }
body.a11y-read-mode, body.a11y-read-mode a, body.a11y-read-mode button { cursor: help; }
.a11y-read-banner {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 99994;
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 24px);
  background: #00351f; color: #fff; border: 1px solid #34d399; border-radius: 999px;
  padding: 9px 10px 9px 18px; font-size: 13px; font-weight: 600;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .45); font-family: 'Inter', Arial, sans-serif;
}
.a11y-read-exit {
  background: rgba(255, 255, 255, .16); color: #fff; border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 999px; padding: 5px 14px; font-weight: 700; cursor: pointer; font-size: 12px; white-space: nowrap;
}
.a11y-read-exit:hover { background: rgba(255, 255, 255, .3); }
html.a11y-invert .a11y-read-banner { filter: invert(1) hue-rotate(180deg); }

/* La barra respeta SIEMPRE el foco visible aunque cambie el tema/modo */
.a11y-root :focus-visible { outline: 3px solid #22d3ee !important; outline-offset: 2px !important; }

/* Modal: declaración de accesibilidad */
.a11y-modal-ov {
  position: fixed; inset: 0; z-index: 99995; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.a11y-modal-ov[hidden] { display: none; }
.a11y-modal {
  background: #0b1220; color: #e2e8f0; border: 1px solid #334155; border-radius: 16px;
  max-width: 560px; width: 100%; max-height: 85vh; overflow-y: auto; padding: 0;
}
.a11y-modal-head { background: #00351f; color: #fff; padding: 16px 20px; border-radius: 15px 15px 0 0; display: flex; justify-content: space-between; align-items: center; }
.a11y-modal-head h2 { margin: 0; font-size: 18px; }
.a11y-modal-body { padding: 18px 20px 22px; line-height: 1.65; font-size: 14.5px; }
.a11y-modal-body h3 { font-size: 15px; margin: 16px 0 6px; color: #fff; }
.a11y-modal-body p { margin: 0 0 10px; color: #cbd5e1; }
.a11y-modal-body a { color: #67e8f9; }
.a11y-modal-body ul { margin: 4px 0 10px; padding-left: 20px; color: #cbd5e1; }

@media (max-width: 480px) {
  .a11y-panel { left: 12px; right: 12px; width: auto; max-width: none; }
  .a11y-fab { right: 12px; bottom: 12px; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Capa 3 — Operabilidad del flujo principal (auditoría 2026-07-16)
   Las tarjetas de módulo y los acordeones del drawer eran <div onclick>:
   inoperables por teclado. Ahora llevan role="button" + tabindex="0" (HTML)
   y Enter/Espacio delegado (pinamar_datos.js). El COLOR del anillo de foco
   lo gobierna la Capa 1 de arriba — acá solo se refuerza dónde hace falta.
   ═══════════════════════════════════════════════════════════════════════ */

/* El outline solo no se lee bien sobre una tarjeta con borde y fondo propios:
   se suma un halo para que el foco salte a la vista sin cambiar su color. */
.module-card:focus-visible,
.drawer-axis-header:focus-visible {
  outline-offset: 2px;
  box-shadow: 0 0 0 6px rgba(0, 200, 83, 0.20);
}
[data-theme="light"] .module-card:focus-visible,
[data-theme="light"] .drawer-axis-header:focus-visible {
  box-shadow: 0 0 0 6px rgba(3, 105, 161, 0.18); /* acompaña al azul de foco del tema claro */
}
/* El título del panel recibe el foco al abrirse (para que el lector anuncie el diálogo):
   es un destino programático, no un control → no dibuja anillo. */
/* !important OBLIGATORIO: la Capa 1 marca [tabindex]:focus-visible con !important, y este h2
   lleva tabindex="-1" para recibir el foco al abrir el diálogo → sin esto ganaba la Capa 1 y
   el anillo azul quedaba dibujado sobre el título CADA vez que se abría un panel, también con
   mouse (regresión detectada en el re-benchmark del 2026-07-23). Es un destino programático,
   no un control: el foco acá se anuncia por voz, no se dibuja. */
.panel-header h2:focus, .panel-header h2:focus-visible { outline: none !important; box-shadow: none !important; }
/* Lo mismo en el recorrido «Pinamar en números»: el título de cada pantalla recibe el foco para
   que el lector la anuncie, y al cerrarlo el foco vuelve al contenido de la portada. Ninguno de
   los dos es un control. */
.rec-tit:focus, .rec-tit:focus-visible, #contenido:focus, #contenido:focus-visible { outline: none !important; box-shadow: none !important; }
/* El recorrido es SIEMPRE oscuro, también con el tema claro elegido: el azul de foco del tema
   claro no se ve sobre la foto de noche. Adentro vale el aro del tema oscuro. */
[data-theme="light"] #recorrido a:focus-visible, [data-theme="light"] #recorrido button:focus-visible { outline-color: #22d3ee !important; }

/* 2.5.8 Target Size (mínimo 24×24 CSS px). Los enlaces sueltos del panel — ej.
   "Descargar PDF Original" — medían 14px de alto: imposibles de acertar en un celular. */
.panel-body a:not(.dc-btn):not(.action-btn),
.dc-btn, .panel-nav-btn { min-height: 24px; display: inline-flex; align-items: center; }

@media (max-width: 768px) {
  /* En táctil se va al objetivo cómodo de 44px donde el layout lo permite. */
  .dc-btn, .panel-nav-btn { min-height: 44px; }
  .panel-close { width: 44px; height: 44px; }
  /* Con un panel abierto, el botón flotante ALT+A tapaba "Siguiente" y valores de la torta. */
  body:has(.detail-panel.open) .a11y-fab { bottom: 84px; }
}
