/* ─────────────────────────────────────────────────────────────────
   Pioneering Independence — accessibility layer
   Trigger + slide-in panel + data-attribute-driven theme overrides.
   ───────────────────────────────────────────────────────────────── */

/* ── Skip link — restyle the existing one from layouts/app.blade.php ── */
#app > a[href="#main"]:focus,
#app > a[href="#main"]:focus-visible {
  position: fixed !important;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10001;
  padding: 0.625rem 1rem;
  background: #1e1b4b;
  color: #fff !important;
  border-radius: 0.625rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,0.4);
  outline: 2px solid #fff;
  outline-offset: 2px;
  white-space: nowrap;
  clip: auto !important;
  clip-path: none !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  overflow: visible !important;
}

/* ── Floating trigger ──────────────────────────────────────────── */
.pi-a11y-trigger {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 9990;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem 0.625rem 0.75rem;
  background: linear-gradient(135deg, #6d28d9 0%, #4c1d95 100%);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 9999px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
  box-shadow:
    0 12px 30px -8px rgba(76, 29, 149, 0.5),
    0 6px 14px -6px rgba(0, 0, 0, 0.3);
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.18s, background 0.18s;
}
.pi-a11y-trigger:hover,
.pi-a11y-trigger:focus-visible {
  transform: translateY(-2px);
  box-shadow:
    0 18px 40px -8px rgba(76, 29, 149, 0.55),
    0 8px 18px -6px rgba(0, 0, 0, 0.35);
}
.pi-a11y-trigger:focus { outline: 0; }
.pi-a11y-trigger:focus-visible {
  outline: 3px solid #facc15;
  outline-offset: 3px;
}
.pi-a11y-trigger svg {
  width: 1.375rem;
  height: 1.375rem;
  flex-shrink: 0;
}
.pi-a11y-trigger__label {
  white-space: nowrap;
}

@media (max-width: 480px) {
  .pi-a11y-trigger {
    right: 0.75rem;
    bottom: 0.75rem;
    padding: 0.625rem;
    width: 3rem;
    height: 3rem;
    justify-content: center;
  }
  .pi-a11y-trigger__label { display: none; }
}

/* ── Panel ─────────────────────────────────────────────────────── */
.pi-a11y-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  z-index: 10000;
  background: #fff;
  color: #18181b;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0s linear 0.28s;
  box-shadow: -28px 0 80px -20px rgba(0, 0, 0, 0.45);
  outline: 0;
}
.pi-a11y-panel[data-open="true"] {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.pi-a11y-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, #4c1d95 0%, #6d28d9 60%, #7c3aed 100%);
  color: #fff;
}
.pi-a11y-panel__title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.pi-a11y-panel__sub {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.45;
}
.pi-a11y-panel__close {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.pi-a11y-panel__close:hover,
.pi-a11y-panel__close:focus-visible {
  background: rgba(255, 255, 255, 0.26);
  outline: 0;
}
.pi-a11y-panel__close svg { width: 1.125rem; height: 1.125rem; }

.pi-a11y-panel__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.25rem 1.5rem 1rem;
}
.pi-a11y-panel__body:focus { outline: 0; }

.pi-a11y-section + .pi-a11y-section { margin-top: 1.25rem; }
.pi-a11y-section__label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #71717a;
  margin-bottom: 0.625rem;
}

/* Pill group (text size) */
.pi-a11y-pillgroup {
  display: inline-flex;
  width: 100%;
  background: #f4f4f5;
  border-radius: 0.75rem;
  padding: 0.25rem;
  gap: 0.125rem;
}
.pi-a11y-pill {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 0.5rem 0.5rem;
  border-radius: 0.5rem;
  font-weight: 700;
  color: #52525b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.pi-a11y-pill:hover { color: #18181b; }
.pi-a11y-pill[aria-pressed="true"] {
  background: #fff;
  color: #4c1d95;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}
.pi-a11y-pill:focus-visible {
  outline: 2px solid #6d28d9;
  outline-offset: 2px;
}

/* Toggle row */
.pi-a11y-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.875rem;
  padding: 0.75rem 0;
  border-top: 1px solid #f4f4f5;
}
.pi-a11y-toggle:first-of-type { border-top: 0; }

.pi-a11y-toggle__label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #18181b;
  line-height: 1.3;
}
.pi-a11y-toggle__hint {
  display: block;
  margin-top: 0.125rem;
  font-size: 0.75rem;
  font-weight: 400;
  color: #71717a;
  line-height: 1.4;
}
.pi-a11y-switch {
  position: relative;
  flex-shrink: 0;
  width: 2.625rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: #d4d4d8;
  border: 0;
  cursor: pointer;
  transition: background 0.15s;
}
.pi-a11y-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.25rem;
  height: 1.25rem;
  background: #fff;
  border-radius: 9999px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.pi-a11y-switch[aria-pressed="true"] {
  background: #6d28d9;
}
.pi-a11y-switch[aria-pressed="true"]::after {
  transform: translateX(1.125rem);
}
.pi-a11y-switch:focus-visible {
  outline: 2px solid #6d28d9;
  outline-offset: 3px;
}

/* TTS row */
.pi-a11y-tts {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}
.pi-a11y-tts__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.625rem 0.5rem;
  background: #f4f4f5;
  color: #18181b;
  border: 0;
  border-radius: 0.625rem;
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.pi-a11y-tts__btn:hover { background: #e4e4e7; }
.pi-a11y-tts__btn[data-a11y-tts-play] { background: #6d28d9; color: #fff; }
.pi-a11y-tts__btn[data-a11y-tts-play]:hover { background: #5b21b6; }
.pi-a11y-tts__btn[data-a11y-tts-play][data-tts-active="true"] {
  background: #f59e0b;
}
.pi-a11y-tts__btn svg { width: 0.875rem; height: 0.875rem; flex-shrink: 0; }
.pi-a11y-tts__btn:focus-visible {
  outline: 2px solid #6d28d9;
  outline-offset: 2px;
}
.pi-a11y-tts__opts {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  margin-top: 0.625rem;
}
.pi-a11y-tts__opt {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #52525b;
  min-width: 0;
}
.pi-a11y-tts__opt select {
  width: 100%;
  min-width: 0;
  padding: 0.5rem 0.625rem;
  border: 1px solid #d4d4d8;
  border-radius: 0.625rem;
  background: #fff;
  color: #18181b;
  font-size: 0.875rem;
  font-weight: 500;
}
.pi-a11y-tts__opt select:focus-visible {
  outline: 2px solid #6d28d9;
  outline-offset: 2px;
}

/* Foot */
.pi-a11y-panel__foot {
  border-top: 1px solid #e4e4e7;
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #fafafa;
}
.pi-a11y-reset {
  background: #fff;
  border: 1px solid #d4d4d8;
  color: #18181b;
  padding: 0.5rem 0.875rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.pi-a11y-reset:hover { background: #f4f4f5; border-color: #a1a1aa; }
.pi-a11y-help {
  font-size: 0.75rem;
  color: #6d28d9;
  text-decoration: none;
  font-weight: 600;
}
.pi-a11y-help:hover { text-decoration: underline; }

/* Backdrop */
.pi-a11y-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 9995;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0s linear 0.2s;
  backdrop-filter: blur(2px);
}
.pi-a11y-backdrop[data-open="true"] {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s;
}

/* When panel is open, lock body scroll without losing scrollbar gutter */
html[data-a11y-panel-open="true"] body {
  overflow: hidden;
  padding-right: var(--pi-a11y-scrollbar, 0);
}

/* ─────────────────────────────────────────────────────────────────
   DATA-ATTRIBUTE-DRIVEN THEME OVERRIDES
   Applied by a11y.js setting attributes on <html>. CSS only — no
   element rewrites, so screen readers stay coherent.
   ───────────────────────────────────────────────────────────────── */

/* Text size scale — adjusts root rem, everything else scales */
html[data-a11y-text="lg"]  { font-size: 110%; }
html[data-a11y-text="xl"]  { font-size: 120%; }
html[data-a11y-text="xxl"] { font-size: 135%; }

/* Reduced motion — kill animations + auto-playing carousels */
html[data-a11y-motion="off"] *,
html[data-a11y-motion="off"] *::before,
html[data-a11y-motion="off"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  animation-delay: 0s !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}
/* The hero crossfade's last keyframe is invisible, so "run once instantly"
   left the hero blank. With motion off, show the first photo, still. */
html[data-a11y-motion="off"] .hero-carousel__img {
  animation: none !important;
  transform: none !important;
  opacity: 0 !important;
}
html[data-a11y-motion="off"] .hero-carousel__img:first-child {
  opacity: 1 !important;
}
html[data-a11y-motion="off"] .hero-carousel__dot {
  animation: none !important;
}

/* Underline all body links */
html[data-a11y-underline="on"] main a,
html[data-a11y-underline="on"] article a,
html[data-a11y-underline="on"] .content-info a {
  text-decoration: underline !important;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1.5px;
}

/* Enhanced focus ring */
html[data-a11y-focus="on"] :focus-visible {
  outline: 3px solid #facc15 !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px rgba(250, 204, 21, 0.32) !important;
  border-radius: 4px;
}

/* Dyslexia-friendly font — Atkinson Hyperlegible is the OS-wide
   choice for low-vision readability. Fall back to Lexend, then
   system. */
html[data-a11y-font="dys"] body,
html[data-a11y-font="dys"] h1,
html[data-a11y-font="dys"] h2,
html[data-a11y-font="dys"] h3,
html[data-a11y-font="dys"] h4,
html[data-a11y-font="dys"] h5,
html[data-a11y-font="dys"] h6,
html[data-a11y-font="dys"] p,
html[data-a11y-font="dys"] a,
html[data-a11y-font="dys"] li,
html[data-a11y-font="dys"] button,
html[data-a11y-font="dys"] input,
html[data-a11y-font="dys"] textarea,
html[data-a11y-font="dys"] label,
html[data-a11y-font="dys"] blockquote {
  font-family: 'Atkinson Hyperlegible', 'Lexend', 'OpenDyslexic',
               system-ui, -apple-system, BlinkMacSystemFont, sans-serif !important;
  letter-spacing: 0.015em !important;
  word-spacing: 0.04em;
}
html[data-a11y-font="dys"] p,
html[data-a11y-font="dys"] li { line-height: 1.7 !important; }

/* High contrast — bright background, black text, dark navigation
   bands invert. Aggressive enough to win against utility classes. */
html[data-a11y-contrast="high"] body {
  background: #ffffff !important;
  color: #000000 !important;
}
html[data-a11y-contrast="high"] p,
html[data-a11y-contrast="high"] li,
html[data-a11y-contrast="high"] span:not([class*="bg-"]),
html[data-a11y-contrast="high"] h1,
html[data-a11y-contrast="high"] h2,
html[data-a11y-contrast="high"] h3,
html[data-a11y-contrast="high"] h4,
html[data-a11y-contrast="high"] h5,
html[data-a11y-contrast="high"] h6 {
  color: #000000 !important;
  text-shadow: none !important;
}
html[data-a11y-contrast="high"] a {
  color: #0000ee !important;
  text-decoration: underline !important;
}
html[data-a11y-contrast="high"] a:visited { color: #551a8b !important; }
html[data-a11y-contrast="high"] [class*="bg-clip-text"] {
  -webkit-text-fill-color: currentColor !important;
  background: none !important;
}
/* Force-dark navigation/footers stay dark with white text for contrast */
html[data-a11y-contrast="high"] [class*="from-primary-9"],
html[data-a11y-contrast="high"] [class*="to-primary-9"],
html[data-a11y-contrast="high"] [class*="via-primary-9"],
html[data-a11y-contrast="high"] .content-info,
html[data-a11y-contrast="high"] [class*="bg-primary-9"] {
  background-image: none !important;
  background-color: #000000 !important;
}
html[data-a11y-contrast="high"] [class*="from-primary-9"] *,
html[data-a11y-contrast="high"] [class*="to-primary-9"] *,
html[data-a11y-contrast="high"] [class*="via-primary-9"] *,
html[data-a11y-contrast="high"] .content-info *,
html[data-a11y-contrast="high"] [class*="bg-primary-9"] * {
  color: #ffffff !important;
  border-color: #ffffff !important;
}
html[data-a11y-contrast="high"] .content-info a,
html[data-a11y-contrast="high"] [class*="from-primary-9"] a {
  color: #ffff00 !important;
}
/* Keep cards on a clean white plate with a black border so they
   pop out from the background */
html[data-a11y-contrast="high"] [class*="rounded-"][class*="bg-white"],
html[data-a11y-contrast="high"] [class*="rounded-"][class*="bg-zinc"],
html[data-a11y-contrast="high"] [class*="rounded-"][class*="border"] {
  background: #ffffff !important;
  color: #000000 !important;
  border: 2px solid #000000 !important;
  box-shadow: none !important;
}
/* But not the a11y panel itself */
html[data-a11y-contrast="high"] .pi-a11y-panel,
html[data-a11y-contrast="high"] .pi-a11y-trigger,
html[data-a11y-contrast="high"] .pi-a11y-panel * { /* let our own styling win */
  /* no overrides — handled by panel-scoped CSS above */
}

/* Larger cursor — high-contrast arrow + ring on interactive */
html[data-a11y-cursor="lg"] {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='34' height='34' viewBox='0 0 34 34'><path d='M3 3 L3 28 L10 21 L14 31 L19 29 L15 19 L25 19 Z' fill='black' stroke='white' stroke-width='2.5' stroke-linejoin='round'/></svg>") 2 2, default;
}
html[data-a11y-cursor="lg"] a,
html[data-a11y-cursor="lg"] button,
html[data-a11y-cursor="lg"] [role="button"],
html[data-a11y-cursor="lg"] input[type="submit"],
html[data-a11y-cursor="lg"] input[type="button"] {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='34' height='34' viewBox='0 0 34 34'><circle cx='17' cy='17' r='11' fill='black' stroke='white' stroke-width='3'/></svg>") 17 17, pointer;
}

/* Hide our own UI from print */
@media print {
  .pi-a11y-trigger,
  .pi-a11y-panel,
  .pi-a11y-backdrop,
  #app > a[href="#main"] { display: none !important; }
}
