/**
 * TI A11y — herramientas editoriales útiles (discapacidad · lectura · contraste).
 * Reemplaza toolbar del tema sin CSS (botones eran no-op).
 */

/* ── Toolbar ── */
.ti-a11y-toolbar {
  position: fixed;
  z-index: 99990;
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-width: min(22rem, calc(100vw - 1.5rem));
  padding: 0.55rem 0.6rem;
  background: var(--ti-white, #fff);
  border: 1px solid rgba(29, 31, 69, 0.14);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(29, 31, 69, 0.14);
}

.ti-a11y-toolbar button {
  flex: 1 1 calc(50% - 0.25rem);
  min-height: 2.65rem;
  padding: 0.45rem 0.55rem;
  font: 600 0.78rem/1.2 Montserrat, system-ui, sans-serif;
  color: var(--ti-ink, #1d1f45);
  background: #fff;
  border: 1px solid rgba(82, 88, 202, 0.35);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ti-a11y-toolbar button:hover {
  background: var(--ti-surface, #f2f3fa);
}

.ti-a11y-toolbar button[aria-pressed="true"] {
  background: var(--ti-primary, #5258ca);
  border-color: var(--ti-primary, #5258ca);
  color: #fff;
}

.ti-a11y-toolbar button:focus-visible {
  outline: 2px solid var(--ti-focus, #2d6a8f);
  outline-offset: 2px;
}

@media (min-width: 768px) {
  .ti-a11y-toolbar {
    flex-wrap: nowrap;
    max-width: none;
  }

  .ti-a11y-toolbar button {
    flex: 0 1 auto;
    min-width: 7.5rem;
    font-size: 0.82rem;
  }
}

/* ── Texto grande (118% — alineado ti-nav-responsive) ── */
html.ti-large-text {
  font-size: 118%;
}

html.ti-large-text .ti-a11y-toolbar button {
  font-size: 0.85rem;
}

/* ── Lectura calmada — guías editoriales ── */
html.ti-calm-reading .entry-content,
html.ti-calm-reading .site-main,
html.ti-calm-reading .aurora-prose-section,
html.ti-calm-reading .aurora-article {
  max-width: 42rem;
  margin-inline: auto;
}

html.ti-calm-reading .entry-content p,
html.ti-calm-reading .aurora-prose-section p,
html.ti-calm-reading .site-main p {
  line-height: 1.85 !important;
  letter-spacing: 0.01em;
  word-spacing: 0.04em;
}

html.ti-calm-reading .entry-content h1,
html.ti-calm-reading .entry-content h2,
html.ti-calm-reading .entry-content h3,
html.ti-calm-reading .aurora-prose-section h2,
html.ti-calm-reading .aurora-prose-section h3 {
  line-height: 1.35 !important;
  margin-bottom: 0.65em !important;
}

/* ── Subrayar enlaces (utilidad real en contenido largo) ── */
html.ti-underline-links .entry-content a,
html.ti-underline-links .site-main a:not(.aurora-btn):not(.menu-link):not(.custom-logo-link),
html.ti-underline-links .aurora-prose-section a,
html.ti-underline-links .aurora-article a {
  text-decoration: underline !important;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 2px;
}

html.ti-underline-links .entry-content a:hover,
html.ti-underline-links .aurora-prose-section a:hover {
  text-decoration-thickness: 3px;
}

/* ── Alto contraste WCAG ── */
html.ti-high-contrast {
  --ti-ink: #000;
  --ti-body: #000;
  --ti-muted: #1a1a1a;
  --ti-primary: #0000ee;
  --ti-accent: #006600;
  --ti-surface: #fff;
  --ti-white: #fff;
  --aurora-bg: #fff !important;
  --aurora-ink: #000 !important;
  --aurora-primary: #0000ee !important;
  --aurora-muted: #1a1a1a !important;
}

html.ti-high-contrast,
html.ti-high-contrast body {
  background: #fff !important;
  color: #000 !important;
}

html.ti-high-contrast a {
  color: #0000ee !important;
}

html.ti-high-contrast a:visited {
  color: #551a8b !important;
}

html.ti-high-contrast .site-header,
html.ti-high-contrast #masthead,
html.ti-high-contrast .ti-a11y-toolbar {
  background: #fff !important;
  border-color: #000 !important;
}

html.ti-high-contrast .aurora-hero--mockup,
html.ti-high-contrast .aurora-page-hero,
html.ti-high-contrast .aurora-cta {
  background: #000 !important;
  color: #fff !important;
}

html.ti-high-contrast .aurora-hero--mockup h1,
html.ti-high-contrast .aurora-hero--mockup .aurora-hero__lead,
html.ti-high-contrast .aurora-page-hero h1,
html.ti-high-contrast .aurora-page-hero .aurora-hero__lead,
html.ti-high-contrast .aurora-cta h2,
html.ti-high-contrast .aurora-cta p {
  color: #fff !important;
}

html.ti-high-contrast .aurora-btn--hero,
html.ti-high-contrast .aurora-btn--primary,
html.ti-high-contrast .aurora-page-hero .aurora-btn--dark {
  background: #ff0 !important;
  color: #000 !important;
  border: 2px solid #000 !important;
}

html.ti-high-contrast .ti-a11y-toolbar button {
  border: 2px solid #000 !important;
  color: #000 !important;
}

html.ti-high-contrast .ti-a11y-toolbar button[aria-pressed="true"] {
  background: #000 !important;
  color: #fff !important;
}

html.ti-high-contrast img,
html.ti-high-contrast svg {
  filter: contrast(1.15);
}

/* Respeta prefers-reduced-motion globalmente cuando calm o HC activos */
html.ti-high-contrast *,
html.ti-calm-reading * {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

@media (prefers-reduced-motion: reduce) {
  .ti-a11y-toolbar button {
    transition: none;
  }
}
