/* =========================================================================
   ACCESSIBILITY TOGGLE WIDGET — accessibility-widget.css
   Drop-in, non-invasive accessibility toolbar.
   - Does NOT require any change to the host page's existing CSS/HTML/JS.
   - All override rules are scoped with :not(#a11y-widget):not(#a11y-widget *)
     so the widget itself is never affected by the modes it applies.
   - Overrides use !important + universal selectors so they win over
     external stylesheets AND pre-existing inline styles on the page.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. WIDGET CHROME (button + panel) — namespaced under #a11y-widget so it
      never collides with host page classes/ids.
   ------------------------------------------------------------------------- */
#a11y-widget, #a11y-widget * {
  box-sizing: border-box !important;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif !important;
}

#a11y-widget {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 2147483000; /* stay on top of virtually everything */
  display: block;
}

#a11y-toggle-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1a56db;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  transition: transform 0.2s ease, background 0.2s ease;
  padding: 0;
}
#a11y-toggle-btn:hover { background: #133e9e; transform: scale(1.06); }
#a11y-toggle-btn:focus-visible { outline: 3px solid #ffbf47; outline-offset: 2px; }
#a11y-toggle-btn svg { width: 30px; height: 30px; fill: #fff; }

#a11y-panel {
  position: absolute;
  left: 0;
  bottom: 66px;
  width: 300px;
  max-height: 70vh;
  overflow-y: auto;
  background: #ffffff;
  color: #1b1b1b;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
  padding: 14px;
  display: none;
  border: 1px solid #e2e2e2;
}
#a11y-panel.a11y-open { display: block; animation: a11yFadeIn .15s ease; }

@keyframes a11yFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

#a11y-panel h2 {
  font-size: 15px !important;
  margin: 0 0 10px 0 !important;
  padding: 0 0 8px 0 !important;
  border-bottom: 1px solid #eee !important;
  color: #1b1b1b !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
}

#a11y-panel .a11y-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#a11y-panel .a11y-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #f4f6fb;
  border: 1px solid #e1e5ee;
  border-radius: 10px;
  padding: 10px 6px;
  cursor: pointer;
  font-size: 11.5px !important;
  color: #1b1b1b !important;
  line-height: 1.15 !important;
  text-align: center !important;
  font-weight: 600 !important;
  transition: background 0.15s ease, border-color 0.15s ease;
}
#a11y-panel .a11y-btn svg { width: 20px; height: 20px; fill: #2545a0; }
#a11y-panel .a11y-btn:hover { background: #e8edfb; border-color: #c3cdea; }
#a11y-panel .a11y-btn.a11y-active { background: #2545a0; border-color: #2545a0; }
#a11y-panel .a11y-btn.a11y-active svg { fill: #fff; }
#a11y-panel .a11y-btn.a11y-active { color: #fff !important; }
#a11y-panel .a11y-btn:focus-visible { outline: 3px solid #ffbf47; outline-offset: 1px; }

#a11y-panel .a11y-btn.a11y-full {
  grid-column: 1 / -1;
  flex-direction: row;
}

#a11y-reset-btn {
  background: #fff0f0 !important;
  border-color: #f0c9c9 !important;
}
#a11y-reset-btn svg { fill: #c0392b !important; }
#a11y-reset-btn:hover { background: #ffe1e1 !important; }

#a11y-panel .a11y-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 24px;
  height: 24px;
  padding: 0;
}
#a11y-panel .a11y-close svg { width: 16px; height: 16px; fill: #888; }
#a11y-panel .a11y-close:hover svg { fill: #333; }

/* Live status text under Screen Reader button */
#a11y-sr-status {
  font-size: 10.5px !important;
  color: #666 !important;
  text-align: center !important;
  margin-top: 2px !important;
  grid-column: 1 / -1;
}

/* -------------------------------------------------------------------------
   2. DARK / LIGHT FORCED THEME
      Applied on <html> so it beats page-level styles regardless of where
      the host defines its own background/color rules.
   ------------------------------------------------------------------------- */
html.a11y-dark body,
html.a11y-dark body *:not(#a11y-widget):not(#a11y-widget *) {
  background-color: #0e0e0e !important;
  background-image: none !important;
  color: #f5f5f5 !important;
  border-color: #444 !important;
}
html.a11y-dark body { background-color: #0e0e0e !important; }

html.a11y-light body,
html.a11y-light body *:not(#a11y-widget):not(#a11y-widget *) {
  background-color: #ffffff !important;
  background-image: none !important;
  color: #111111 !important;
  border-color: #ccc !important;
}
html.a11y-light body { background-color: #ffffff !important; }

/* -------------------------------------------------------------------------
   3. TEXT SPACING (3 escalating levels)
   ------------------------------------------------------------------------- */
html.a11y-spacing-1 body *:not(#a11y-widget):not(#a11y-widget *) {
  letter-spacing: 0.06em !important;
  word-spacing: 0.12em !important;
  line-height: 1.6 !important;
}
html.a11y-spacing-2 body *:not(#a11y-widget):not(#a11y-widget *) {
  letter-spacing: 0.12em !important;
  word-spacing: 0.2em !important;
  line-height: 1.9 !important;
}
html.a11y-spacing-3 body *:not(#a11y-widget):not(#a11y-widget *) {
  letter-spacing: 0.2em !important;
  word-spacing: 0.3em !important;
  line-height: 2.2 !important;
}

/* -------------------------------------------------------------------------
   4/5. TEXT SIZE — handled via inline `zoom` set from JS (see .js file),
   because zoom scales every unit (px/em/rem/%) proportionally without
   needing to know the host's CSS. No CSS rule needed here.
   ------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
   6. HIGHLIGHT LINKS
   ------------------------------------------------------------------------- */
html.a11y-highlight-links body a:not(#a11y-widget *) {
  background-color: #ffe066 !important;
  color: #000000 !important;
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  outline: 2px solid #d4a800 !important;
  border-radius: 2px !important;
  padding: 0 2px !important;
}

/* -------------------------------------------------------------------------
   7. HIDE IMAGES
   ------------------------------------------------------------------------- */
html.a11y-hide-images body img:not(#a11y-widget *),
html.a11y-hide-images body picture:not(#a11y-widget *),
html.a11y-hide-images body video:not(#a11y-widget *),
html.a11y-hide-images body svg:not(#a11y-widget *):not(#a11y-widget),
html.a11y-hide-images body canvas:not(#a11y-widget *),
html.a11y-hide-images body iframe:not(#a11y-widget *) {
  display: none !important;
  visibility: hidden !important;
}
html.a11y-hide-images body *:not(#a11y-widget):not(#a11y-widget *) {
  background-image: none !important;
}

/* -------------------------------------------------------------------------
   8. BIG CURSOR
   ------------------------------------------------------------------------- */
html.a11y-big-cursor body,
html.a11y-big-cursor body *:not(#a11y-widget):not(#a11y-widget *) {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 32 32"><path d="M4 2 L4 28 L11 21 L15.5 30 L19 28.3 L14.5 19.5 L23 19.5 Z" fill="black" stroke="white" stroke-width="1.5"/></svg>') 4 4, auto !important;
}

/* Text selection reading highlight (used by Screen Reader mode) */
.a11y-reading-highlight {
  outline: 3px dashed #1a56db !important;
  outline-offset: 2px !important;
  border-radius: 3px !important;
}
html.a11y-sr-mode body *:not(#a11y-widget):not(#a11y-widget *) {
  cursor: pointer !important;
}

/* -------------------------------------------------------------------------
   9. TEXT ALIGN (cycled: left / center / right / justify)
   ------------------------------------------------------------------------- */
html.a11y-align-left body *:not(#a11y-widget):not(#a11y-widget *) { text-align: left !important; }
html.a11y-align-center body *:not(#a11y-widget):not(#a11y-widget *) { text-align: center !important; }
html.a11y-align-right body *:not(#a11y-widget):not(#a11y-widget *) { text-align: right !important; }
html.a11y-align-justify body *:not(#a11y-widget):not(#a11y-widget *) { text-align: justify !important; }

/* Small screens: keep panel usable */
@media (max-width: 420px) {
  #a11y-panel { width: 86vw; }
}
