/* ═══════════════════════════════════════════════════════════════════════════
   ACCESSIBILITY WIDGET — Vanilla CSS
   Self-contained styles for the floating accessibility widget UI
   + all feature override rules (high contrast, dyslexia font, etc.)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Widget Button ────────────────────────────────────────────────────── */
#a11y-toggle-btn {
  position: fixed;
  bottom: 90px;
  left: 16px;
  z-index: 9000;
  width: 48px;
  height: 48px;
  background-color: #5b21b6;
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  transition: background-color 0.2s, transform 0.2s;
  outline: none;
}
#a11y-toggle-btn:hover {
  background-color: #7c3aed;
  transform: scale(1.1);
}
#a11y-toggle-btn:focus-visible {
  outline: 2px solid #f59e0b;
  outline-offset: 3px;
}
#a11y-toggle-btn svg {
  width: 22px;
  height: 22px;
  stroke: white;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Gold dot indicator when any pref is active */
#a11y-active-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: #f59e0b;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}
#a11y-active-dot.visible {
  display: block;
}

/* ─── Settings Panel ───────────────────────────────────────────────────── */
#a11y-panel {
  position: fixed;
  bottom: 148px;
  left: 16px;
  z-index: 9001;
  width: 320px;
  max-height: 80vh;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  overflow: hidden;
  display: none;
  flex-direction: column;
  animation: a11y-fade-in 0.18s ease;
}
#a11y-panel.open {
  display: flex;
}
@keyframes a11y-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Panel Header */
#a11y-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8f5ff;
}
#a11y-panel-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: #4c1d95;
  margin: 0;
}
#a11y-panel-title svg {
  width: 16px;
  height: 16px;
  stroke: #7c3aed;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#a11y-reset-btn {
  font-size: 11px;
  font-weight: 600;
  color: #7c3aed;
  background: transparent;
  border: 1px solid #ddd6fe;
  border-radius: 6px;
  padding: 4px 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
}
#a11y-reset-btn:hover {
  background: #ede9fe;
}
#a11y-reset-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
#a11y-reset-btn svg {
  width: 12px;
  height: 12px;
  stroke: #7c3aed;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Panel Grid */
#a11y-grid {
  padding: 10px;
  overflow-y: auto;
  max-height: calc(80vh - 52px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* Icon Tiles */
.a11y-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 6px;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  background: #fff;
  color: #6b7280;
  cursor: pointer;
  text-align: center;
  min-height: 78px;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  outline: none;
}
.a11y-tile:hover {
  border-color: #c4b5fd;
  background: #f5f3ff;
}
.a11y-tile:focus-visible {
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
}
.a11y-tile.active {
  background: #5b21b6;
  border-color: #5b21b6;
  color: #fff;
  box-shadow: 0 2px 8px rgba(91,33,182,0.25);
}
.a11y-tile svg {
  width: 22px;
  height: 22px;
  stroke: #a78bfa;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.15s;
}
.a11y-tile.active svg {
  stroke: #f59e0b;
}
.a11y-tile-label {
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
  color: inherit;
}
.a11y-tile-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 8.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 99px;
  line-height: 1.4;
}
.a11y-tile .a11y-tile-badge {
  background: #ede9fe;
  color: #5b21b6;
}
.a11y-tile.active .a11y-tile-badge {
  background: #f59e0b;
  color: #3b0764;
}

/* ─── Reading Guide ────────────────────────────────────────────────────── */
#a11y-reading-guide {
  pointer-events: none;
  position: fixed;
  left: 0;
  right: 0;
  z-index: 8999;
  height: 30px;
  top: -100px;
  background: linear-gradient(to bottom, transparent, rgba(234,179,8,0.30), transparent);
  box-shadow: 0 0 8px 2px rgba(234,179,8,0.12);
  display: none;
}
#a11y-reading-guide.active {
  display: block;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FEATURE OVERRIDES — applied via data-* attrs on <html>
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Font Size ────────────────────────────────────────────────────────── */
html[data-a11y-font-size="large"]   { font-size: 125% !important; }
html[data-a11y-font-size="x-large"] { font-size: 150% !important; }

/* ─── High Contrast ────────────────────────────────────────────────────── */
html[data-a11y-contrast="true"] #page-content {
  background-color: #000 !important;
  color: #fff !important;
}
html[data-a11y-contrast="true"] #page-content * {
  border-color: #666 !important;
}
html[data-a11y-contrast="true"] #page-content a {
  color: #ffd700 !important;
}
html[data-a11y-contrast="true"] #page-content h1,
html[data-a11y-contrast="true"] #page-content h2,
html[data-a11y-contrast="true"] #page-content h3,
html[data-a11y-contrast="true"] #page-content h4,
html[data-a11y-contrast="true"] #page-content h5,
html[data-a11y-contrast="true"] #page-content h6 {
  color: #fff !important;
}
html[data-a11y-contrast="true"] #page-content p,
html[data-a11y-contrast="true"] #page-content li,
html[data-a11y-contrast="true"] #page-content span,
html[data-a11y-contrast="true"] #page-content td,
html[data-a11y-contrast="true"] #page-content th {
  color: #fff !important;
}
html[data-a11y-contrast="true"] #page-content section,
html[data-a11y-contrast="true"] #page-content div,
html[data-a11y-contrast="true"] #page-content header,
html[data-a11y-contrast="true"] #page-content footer,
html[data-a11y-contrast="true"] #page-content nav {
  background-color: #000 !important;
  background-image: none !important;
}
html[data-a11y-contrast="true"] #page-content img {
  filter: contrast(1.2) brightness(0.95);
}
html[data-a11y-contrast="true"] #page-content input,
html[data-a11y-contrast="true"] #page-content textarea,
html[data-a11y-contrast="true"] #page-content select {
  background-color: #111 !important;
  color: #fff !important;
  border-color: #aaa !important;
}
html[data-a11y-contrast="true"] #page-content button,
html[data-a11y-contrast="true"] #page-content .btn {
  background-color: #000 !important;
  color: #ffd700 !important;
  border: 2px solid #ffd700 !important;
}
/* Remove backdrop blurs */
html[data-a11y-contrast="true"] #page-content [style*="backdrop-filter"] {
  backdrop-filter: none !important;
}

/* ─── Dyslexia-Friendly Font ───────────────────────────────────────────── */
/* Font is lazy-loaded via <link> in HTML head */
html[data-a11y-dyslexia="true"],
html[data-a11y-dyslexia="true"] * {
  font-family: 'OpenDyslexic', Arial, sans-serif !important;
}

/* ─── Highlight Links ──────────────────────────────────────────────────── */
html[data-a11y-links="true"] a {
  text-decoration: underline !important;
  outline: 2px solid #d97706 !important;
  outline-offset: 2px !important;
}

/* ─── Pause Animations ─────────────────────────────────────────────────── */
html[data-a11y-pause="true"] *,
html[data-a11y-pause="true"] *::before,
html[data-a11y-pause="true"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* ─── Big Cursor ───────────────────────────────────────────────────────── */
html[data-a11y-cursor="true"],
html[data-a11y-cursor="true"] * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Cpath d='M5 2 L5 28 L12 21 L20 28 L24 24 L16 17 L26 17 Z' fill='black' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E") 4 2, auto !important;
}

/* ─── Text Spacing ─────────────────────────────────────────────────────── */
html[data-a11y-spacing="true"] {
  letter-spacing: 0.05em;
  word-spacing: 0.12em;
}
html[data-a11y-spacing="true"] p,
html[data-a11y-spacing="true"] li,
html[data-a11y-spacing="true"] span,
html[data-a11y-spacing="true"] div,
html[data-a11y-spacing="true"] td {
  line-height: 1.85 !important;
}

/* ─── Saturation ───────────────────────────────────────────────────────── */
/* Applied to #page-content only — filter on body breaks position:fixed */
html[data-a11y-saturation="low"]  #page-content { filter: saturate(0.25); }
html[data-a11y-saturation="high"] #page-content { filter: saturate(1.9);  }

/* ─── OS Reduced Motion (automatic, no widget needed) ─────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
