/**
 * CPD Accesibilidad — estilos operativos WCAG 2.2 AA.
 * Foco visible, target size ≥ 24px, contraste, text spacing 1.4.12.
 */

:root {
  --cpd-a11y-primary: #103070;
  --cpd-a11y-surface: #ffffff;
  --cpd-a11y-text: #1a1a1a;
  --cpd-a11y-border: #c5d0dc;
  --cpd-a11y-focus: #f0d010;
  --cpd-a11y-muted: #4a5560;
  --cpd-a11y-z: 99990;
}

/* Ancla de skip / foco no oscurecido (2.4.11) */
.cpd-a11y-main-anchor,
#cpd-a11y-main-target {
  scroll-margin-top: 6rem;
}

body:has(#cpd-a11y-widget) a:focus-visible,
body:has(#cpd-a11y-widget) button:focus-visible,
body:has(#cpd-a11y-widget) input:focus-visible,
body:has(#cpd-a11y-widget) select:focus-visible,
body:has(#cpd-a11y-widget) textarea:focus-visible,
body:has(#cpd-a11y-widget) summary:focus-visible,
body:has(#cpd-a11y-widget) [tabindex]:focus-visible {
  outline: 3px solid var(--cpd-a11y-focus) !important;
  outline-offset: 2px !important;
  scroll-margin-top: 6rem;
}

/* Skip link */
.cpd-a11y-skip {
  position: absolute;
  left: 0.75rem;
  top: -100px;
  z-index: calc(var(--cpd-a11y-z) + 1);
  padding: 0.75rem 1rem;
  min-height: 44px;
  min-width: 44px;
  background: var(--cpd-a11y-primary);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  border-radius: 0 0 0.35rem 0.35rem;
}

.cpd-a11y-skip:focus {
  top: 0;
  outline: 3px solid var(--cpd-a11y-focus);
  outline-offset: 2px;
}

.cpd-a11y-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Widget: inmune a filtros del documento */
.cpd-a11y-widget {
  position: fixed;
  bottom: 1.25rem;
  z-index: var(--cpd-a11y-z);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  filter: none !important;
  -webkit-filter: none !important;
  isolation: isolate;
  color-scheme: light;
}

.cpd-a11y-widget--left {
  left: 1.25rem;
}

.cpd-a11y-widget--right {
  right: 1.25rem;
}

.cpd-a11y-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0.7rem 0.95rem;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--cpd-a11y-primary);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(16, 48, 112, 0.28);
}

.cpd-a11y-toggle__svg {
  display: block;
  flex-shrink: 0;
}

.cpd-a11y-toggle--icon_only {
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}

.cpd-a11y-toggle--icon_only .cpd-a11y-toggle__svg {
  width: 26px;
  height: 26px;
}

.cpd-a11y-toggle:focus-visible,
.cpd-a11y-panel button:focus-visible,
.cpd-a11y-panel a:focus-visible {
  outline: 3px solid var(--cpd-a11y-focus);
  outline-offset: 2px;
}

.cpd-a11y-panel {
  position: absolute;
  bottom: calc(100% + 0.65rem);
  width: min(20rem, calc(100vw - 2rem));
  max-height: min(70vh, 32rem);
  overflow: auto;
  padding: 0.85rem;
  border: 1px solid var(--cpd-a11y-border);
  border-radius: 0.75rem;
  background: var(--cpd-a11y-surface);
  color: var(--cpd-a11y-text);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.cpd-a11y-widget--left .cpd-a11y-panel {
  left: 0;
}

.cpd-a11y-widget--right .cpd-a11y-panel {
  right: 0;
}

.cpd-a11y-panel[hidden] {
  display: none !important;
}

.cpd-a11y-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.cpd-a11y-panel__title {
  margin: 0;
  font-size: 1.05rem;
  color: var(--cpd-a11y-text);
}

.cpd-a11y-panel__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--cpd-a11y-border);
  border-radius: 0.45rem;
  background: #f5f8fb;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--cpd-a11y-text);
}

.cpd-a11y-profiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.cpd-a11y-profiles button {
  min-height: 44px;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--cpd-a11y-primary);
  border-radius: 0.45rem;
  background: #eef4fa;
  color: var(--cpd-a11y-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.cpd-a11y-actions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.cpd-a11y-actions button {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--cpd-a11y-border);
  border-radius: 0.45rem;
  background: #f5f8fb;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
}

.cpd-a11y-actions button[aria-pressed="true"] {
  background: var(--cpd-a11y-primary);
  border-color: var(--cpd-a11y-primary);
  color: #fff;
}

.cpd-a11y-actions__font {
  display: grid;
  gap: 0.35rem;
}

.cpd-a11y-font-label {
  font-size: 0.8rem;
  color: var(--cpd-a11y-muted);
}

.cpd-a11y-actions__pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.cpd-a11y-voice {
  display: grid;
  gap: 0.35rem;
}

.cpd-a11y-voice__controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
}

.cpd-a11y-voice__controls.is-split {
  grid-template-columns: 1fr 1fr;
}

.cpd-a11y-voice__controls button {
  text-align: center;
}

.cpd-a11y-voice__controls button[hidden] {
  display: none !important;
}

.cpd-a11y-voice__status {
  margin: 0;
  min-height: 1.1em;
  font-size: 0.8rem;
  color: var(--cpd-a11y-muted);
}

.cpd-a11y-reset {
  font-weight: 700;
}

.cpd-a11y-panel__help {
  margin: 0.7rem 0 0;
  font-size: 0.85rem;
}

.cpd-a11y-panel__help a {
  color: var(--cpd-a11y-primary);
  font-weight: 600;
  text-decoration: underline;
}

.cpd-a11y-panel__note {
  margin: 0.7rem 0 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--cpd-a11y-muted);
}

/* Guía de lectura */
.cpd-a11y-reading-guide {
  position: fixed;
  left: 0;
  width: 100%;
  height: 2.75rem;
  pointer-events: none;
  z-index: calc(var(--cpd-a11y-z) - 1);
  background: rgba(255, 214, 70, 0.28);
  border-top: 2px solid #c79b00;
  border-bottom: 2px solid #c79b00;
}

.cpd-a11y-reading-guide[hidden] {
  display: none !important;
}

/* ——— Preferencias aplicadas al documento ——— */

/* Contraste alto: texto/UI ≥ 4.5:1 / 3:1 */
html.cpd-a11y-contrast,
html.cpd-a11y-contrast body {
  background: #000 !important;
  color: #fff !important;
}

html.cpd-a11y-contrast a {
  color: #ffff00 !important;
}

html.cpd-a11y-contrast body * {
  background-color: #000 !important;
  color: #fff !important;
  border-color: #fff !important;
}

html.cpd-a11y-contrast a {
  color: #ffff00 !important;
  background-color: transparent !important;
}

html.cpd-a11y-contrast button,
html.cpd-a11y-contrast input,
html.cpd-a11y-contrast select,
html.cpd-a11y-contrast textarea {
  border: 2px solid #fff !important;
}

/* El widget y el skip link conservan su UI institucional */
html.cpd-a11y-contrast #cpd-a11y-widget,
html.cpd-a11y-contrast #cpd-a11y-widget *,
html.cpd-a11y-contrast .cpd-a11y-skip,
html.cpd-a11y-contrast .cpd-a11y-reading-guide {
  filter: none !important;
}

html.cpd-a11y-contrast #cpd-a11y-widget {
  background: transparent !important;
  color: inherit !important;
  border-color: transparent !important;
}

html.cpd-a11y-contrast #cpd-a11y-widget .cpd-a11y-toggle {
  background: var(--cpd-a11y-primary) !important;
  color: #fff !important;
  border-color: transparent !important;
}

html.cpd-a11y-contrast #cpd-a11y-widget .cpd-a11y-panel {
  background: #fff !important;
  color: #1a1a1a !important;
  border-color: #c5d0dc !important;
}

html.cpd-a11y-contrast #cpd-a11y-widget .cpd-a11y-panel__title,
html.cpd-a11y-contrast #cpd-a11y-widget .cpd-a11y-panel__note,
html.cpd-a11y-contrast #cpd-a11y-widget .cpd-a11y-font-label {
  background: transparent !important;
  color: #1a1a1a !important;
  border-color: transparent !important;
}

html.cpd-a11y-contrast #cpd-a11y-widget .cpd-a11y-panel__note,
html.cpd-a11y-contrast #cpd-a11y-widget .cpd-a11y-font-label {
  color: #4a5560 !important;
}

html.cpd-a11y-contrast #cpd-a11y-widget .cpd-a11y-actions button,
html.cpd-a11y-contrast #cpd-a11y-widget .cpd-a11y-panel__close,
html.cpd-a11y-contrast #cpd-a11y-widget .cpd-a11y-profiles button {
  background: #f5f8fb !important;
  color: #1a1a1a !important;
  border-color: #c5d0dc !important;
}

html.cpd-a11y-contrast #cpd-a11y-widget .cpd-a11y-actions button[aria-pressed="true"] {
  background: var(--cpd-a11y-primary) !important;
  color: #fff !important;
  border-color: var(--cpd-a11y-primary) !important;
}

html.cpd-a11y-contrast #cpd-a11y-widget .cpd-a11y-profiles button {
  background: #eef4fa !important;
  color: var(--cpd-a11y-primary) !important;
  border-color: var(--cpd-a11y-primary) !important;
}

html.cpd-a11y-contrast #cpd-a11y-widget .cpd-a11y-panel__help a {
  background: transparent !important;
  color: var(--cpd-a11y-primary) !important;
}

html.cpd-a11y-contrast .cpd-a11y-skip {
  background: var(--cpd-a11y-primary) !important;
  color: #fff !important;
}

html.cpd-a11y-dark,
html.cpd-a11y-dark body {
  background: #121212 !important;
  color: #f2f2f2 !important;
}

html.cpd-a11y-dark a {
  color: #9ecbff !important;
}

html.cpd-a11y-dark input,
html.cpd-a11y-dark textarea,
html.cpd-a11y-dark select,
html.cpd-a11y-dark button {
  background-color: #1e1e1e;
  color: #f2f2f2;
  border-color: #666;
}

html.cpd-a11y-dark #cpd-a11y-widget .cpd-a11y-toggle {
  background: var(--cpd-a11y-primary);
  color: #fff;
  border-color: transparent;
}

html.cpd-a11y-dark #cpd-a11y-widget .cpd-a11y-panel {
  background: #fff;
  color: #1a1a1a;
}

html.cpd-a11y-dark #cpd-a11y-widget .cpd-a11y-actions button,
html.cpd-a11y-dark #cpd-a11y-widget .cpd-a11y-panel__close,
html.cpd-a11y-dark #cpd-a11y-widget .cpd-a11y-profiles button {
  background: #f5f8fb;
  color: #1a1a1a;
  border-color: #c5d0dc;
}

html.cpd-a11y-dark #cpd-a11y-widget .cpd-a11y-actions button[aria-pressed="true"] {
  background: var(--cpd-a11y-primary);
  color: #fff;
  border-color: var(--cpd-a11y-primary);
}

/* Monocromo: el widget queda fuera del filtro */
html.cpd-a11y-mono {
  filter: grayscale(1);
}

html.cpd-a11y-mono .cpd-a11y-widget {
  filter: grayscale(0) !important;
}

html.cpd-a11y-links a {
  text-decoration: underline !important;
  text-decoration-thickness: 0.15em !important;
  text-underline-offset: 0.2em !important;
  font-weight: 700 !important;
  background-image: linear-gradient(transparent 60%, rgba(255, 235, 59, 0.55) 60%) !important;
}

/* WCAG 1.4.12 Text Spacing */
html.cpd-a11y-spacing body,
html.cpd-a11y-spacing body * {
  letter-spacing: 0.12em !important;
  word-spacing: 0.16em !important;
  line-height: 1.5 !important;
}

html.cpd-a11y-spacing p,
html.cpd-a11y-spacing li,
html.cpd-a11y-spacing dd,
html.cpd-a11y-spacing figcaption,
html.cpd-a11y-spacing blockquote {
  margin-bottom: 2em !important;
}

html.cpd-a11y-spacing #cpd-a11y-widget,
html.cpd-a11y-spacing #cpd-a11y-widget * {
  letter-spacing: normal !important;
  word-spacing: normal !important;
  line-height: 1.4 !important;
  margin-bottom: 0 !important;
}

html.cpd-a11y-spacing #cpd-a11y-widget .cpd-a11y-panel__note {
  margin: 0.7rem 0 0 !important;
  line-height: 1.35 !important;
}

/* Fuente legible (dislexia): sans-serif espaciada, sin justificado */
html.cpd-a11y-dyslexia body,
html.cpd-a11y-dyslexia body * {
  font-family: "Comic Sans MS", "OpenDyslexic", "Segoe UI", Arial, sans-serif !important;
  letter-spacing: 0.05em !important;
  word-spacing: 0.1em !important;
  line-height: 1.6 !important;
  text-align: left !important;
  font-variant-ligatures: none !important;
}

html.cpd-a11y-dyslexia #cpd-a11y-widget,
html.cpd-a11y-dyslexia #cpd-a11y-widget * {
  font-family: "Segoe UI", system-ui, sans-serif !important;
  letter-spacing: normal !important;
  word-spacing: normal !important;
  line-height: 1.4 !important;
  text-align: left !important;
}

/* Cursor grande */
html.cpd-a11y-cursor,
html.cpd-a11y-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath fill='%23000' stroke='%23fff' stroke-width='2' d='M10 6v32l8-8h14z'/%3E%3C/svg%3E") 4 4, auto !important;
}

html.cpd-a11y-cursor a,
html.cpd-a11y-cursor button,
html.cpd-a11y-cursor [role="button"],
html.cpd-a11y-cursor input,
html.cpd-a11y-cursor select,
html.cpd-a11y-cursor textarea,
html.cpd-a11y-cursor label {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath fill='%231a3a5c' stroke='%23fff' stroke-width='2' d='M10 6v32l8-8h14z'/%3E%3C/svg%3E") 4 4, pointer !important;
}

/* Pausar animaciones / motion (2.3.3 / prefers-reduced-motion) */
html.cpd-a11y-reduce-motion *,
html.cpd-a11y-reduce-motion *::before,
html.cpd-a11y-reduce-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

html.cpd-a11y-hide-images img,
html.cpd-a11y-hide-images picture,
html.cpd-a11y-hide-images svg:not(.cpd-a11y-toggle__svg),
html.cpd-a11y-hide-images video {
  visibility: hidden !important;
}

html.cpd-a11y-hide-images .cpd-a11y-widget img,
html.cpd-a11y-hide-images .cpd-a11y-widget svg {
  visibility: visible !important;
}

@media (prefers-reduced-motion: reduce) {
  .cpd-a11y-toggle,
  .cpd-a11y-panel,
  .cpd-a11y-reading-guide {
    transition: none !important;
  }
}

@media (max-width: 480px) {
  .cpd-a11y-toggle__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }

  .cpd-a11y-toggle {
    border-radius: 50%;
    padding: 0.75rem;
  }

  .cpd-a11y-widget--left,
  .cpd-a11y-widget--right {
    left: 0.75rem;
    right: auto;
  }

  .cpd-a11y-widget--right {
    left: auto;
    right: 0.75rem;
  }
}

/* Por encima de Elementor, Astra y el CSS del prototipo. */
#cpd-a11y-widget.cpd-a11y-widget {
  position: fixed !important;
  z-index: 2147483000 !important;
  pointer-events: auto !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

#cpd-a11y-widget .cpd-a11y-toggle {
  pointer-events: auto !important;
  cursor: pointer !important;
}
