/* Accessibility widget — IS 5568 AA */

/* Toggle button (always bottom-right, even in RTL) */
.a11y-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #0f2042;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 0 6px 20px rgba(15,32,66,0.35), 0 0 0 1px rgba(15,32,66,0.15);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 9998;
  padding: 0;
  font-family: inherit;
  transition: background 0.2s ease, transform 0.2s ease;
}
.a11y-toggle:hover { background: #1a2f5c; transform: scale(1.05); }
.a11y-toggle:focus-visible { outline: 3px solid #f27316; outline-offset: 3px; }

/* Panel */
.a11y-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 340px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  background: #fff;
  color: #0f2042;
  border-radius: 16px;
  box-shadow: 0 16px 50px rgba(15,32,66,0.25);
  border: 1px solid #e3e8f0;
  padding: 18px;
  z-index: 9999;
  display: none;
  font-family: Heebo, system-ui, -apple-system, sans-serif;
  direction: rtl;
  text-align: right;
}
.a11y-panel.open { display: block; }

.a11y-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; padding-bottom: 12px;
  border-bottom: 2px solid #ecf0f6;
}
.a11y-header strong { font-size: 18px; color: #0a1628; font-weight: 700; }
.a11y-close {
  background: #f7f9fc; border: 1px solid #e3e8f0;
  font-size: 22px; cursor: pointer; color: #2a3a52;
  line-height: 1; padding: 4px 12px;
  border-radius: 8px; font-family: inherit;
}
.a11y-close:hover { background: #ecf0f6; color: #0f2042; }
.a11y-close:focus-visible { outline: 2px solid #f27316; outline-offset: 2px; }

.a11y-section { margin-bottom: 16px; }
.a11y-section h4 {
  font-size: 12.5px; color: #5a6c85;
  margin: 0 0 8px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}

.a11y-row { display: flex; gap: 6px; }
.a11y-row button {
  flex: 1; padding: 10px 6px;
  border-radius: 8px;
  background: #f7f9fc;
  border: 1.5px solid #e3e8f0;
  color: #0a1628;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  font-family: inherit;
  min-height: 40px;
  transition: all 0.15s ease;
}
.a11y-row button:hover { background: #ecf0f6; border-color: #0f2042; }
.a11y-row button:focus-visible { outline: 2px solid #f27316; outline-offset: 2px; }
.a11y-row button[aria-pressed="true"] { background: #0f2042; color: #fff; border-color: #0f2042; }

.a11y-check {
  display: flex; align-items: center; gap: 10px;
  font-size: 14.5px; color: #2a3a52;
  padding: 8px 0;
  cursor: pointer;
  line-height: 1.4;
}
.a11y-check:hover { color: #0f2042; }
.a11y-check input {
  width: 20px; height: 20px;
  accent-color: #0f2042;
  cursor: pointer;
  flex-shrink: 0;
}
.a11y-check input:focus-visible { outline: 2px solid #f27316; outline-offset: 2px; }

.a11y-reset {
  width: 100%; padding: 11px;
  border-radius: 8px;
  background: #fff;
  border: 1.5px solid #d0d7e2;
  color: #2a3a52;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
}
.a11y-reset:hover { background: #f7f9fc; border-color: #0f2042; }
.a11y-reset:focus-visible { outline: 2px solid #f27316; outline-offset: 2px; }

.a11y-footer {
  padding-top: 12px;
  border-top: 1px solid #ecf0f6;
  text-align: center;
}
.a11y-footer a {
  color: #b8480c;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.a11y-footer a:hover { color: #8a3608; }

/* Live region for screen-reader announcements */
.a11y-live {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Reading guide bar */
.a11y-reading-guide-bar {
  position: fixed;
  left: 0; right: 0;
  height: 28px;
  background: rgba(255, 220, 0, 0.35);
  border-top: 2px solid rgba(0,0,0,0.4);
  border-bottom: 2px solid rgba(0,0,0,0.4);
  pointer-events: none;
  z-index: 9990;
  display: none;
}

/* ===== Applied accessibility modes ===== */

html.a11y-contrast-high { filter: contrast(1.4); }
html.a11y-contrast-dark { filter: invert(1) hue-rotate(180deg); background: #000; }
html.a11y-contrast-dark img,
html.a11y-contrast-dark video,
html.a11y-contrast-dark iframe { filter: invert(1) hue-rotate(180deg); }
html.a11y-grayscale { filter: grayscale(1); }
html.a11y-contrast-high.a11y-grayscale { filter: contrast(1.4) grayscale(1); }
html.a11y-contrast-dark.a11y-grayscale { filter: invert(1) hue-rotate(180deg) grayscale(1); }

/* Keep the a11y widget itself readable even when filters are applied */
html.a11y-contrast-dark .a11y-toggle,
html.a11y-contrast-dark .a11y-panel,
html.a11y-contrast-dark .a11y-reading-guide-bar { filter: invert(1) hue-rotate(180deg); }
html.a11y-grayscale .a11y-toggle,
html.a11y-grayscale .a11y-panel { filter: none; }

/* Link emphasis */
html.a11y-link-underline a:not(.btn):not(.nav-brand) {
  text-decoration: underline !important;
  text-underline-offset: 3px !important;
  text-decoration-thickness: 2px !important;
}

/* Strong focus indicator */
html.a11y-focus-strong *:focus-visible {
  outline: 4px solid #ff0 !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 0 8px #000 !important;
  border-radius: 4px;
}

/* Pause animations */
html.a11y-pause-anim *,
html.a11y-pause-anim *::before,
html.a11y-pause-anim *::after {
  animation-duration: 0.001s !important;
  animation-iteration-count: 1 !important;
  animation-delay: 0s !important;
  transition-duration: 0.001s !important;
  transition-delay: 0s !important;
  scroll-behavior: auto !important;
}

/* Highlight headings */
html.a11y-highlight-headings h1,
html.a11y-highlight-headings h2,
html.a11y-highlight-headings h3 {
  outline: 2px dashed #b8480c !important;
  outline-offset: 4px;
  background-color: rgba(255, 234, 215, 0.55) !important;
}

/* Big cursor */
html.a11y-big-cursor,
html.a11y-big-cursor * {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'><path d='M5 2v18l5-5h9z' fill='%23000' stroke='%23fff' stroke-width='1.5' stroke-linejoin='round'/></svg>") 0 0, auto !important;
}
html.a11y-big-cursor a,
html.a11y-big-cursor button,
html.a11y-big-cursor [role="button"],
html.a11y-big-cursor input,
html.a11y-big-cursor label {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'><path d='M9 1v8L5 5l1-2 4 4V1zm3 0v8l4-4-1-2-3 4V1zM2 9h8L6 5 4 6l4 3H2zm14 0h8l-4-4-2 1 4 3h-6zM5 12v9h14v-9H5zm2 2h10v5H7v-5z' fill='%23000' stroke='%23fff' stroke-width='0.8' stroke-linejoin='round'/></svg>") 12 12, pointer !important;
}

/* Letter spacing for dyslexia */
html.a11y-letter-spacing body,
html.a11y-letter-spacing body * {
  letter-spacing: 0.12em !important;
  word-spacing: 0.16em !important;
  line-height: 1.8 !important;
}

/* Readable font (sans-serif, larger weight) */
html.a11y-readable-font body,
html.a11y-readable-font body * {
  font-family: Heebo, Arial, sans-serif !important;
  font-weight: 500 !important;
}
html.a11y-readable-font h1,
html.a11y-readable-font h2,
html.a11y-readable-font h3,
html.a11y-readable-font h4,
html.a11y-readable-font strong,
html.a11y-readable-font b { font-weight: 800 !important; }

/* Skip link */
.skip-link {
  position: absolute;
  top: -100px;
  right: 16px;
  background: #0f2042;
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  z-index: 10000;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 16px; outline: 3px solid #f27316; outline-offset: 2px; }

/* Make sure panel is responsive on mobile */
@media (max-width: 480px) {
  .a11y-panel { width: calc(100vw - 32px); right: 16px; bottom: 86px; }
  .a11y-toggle { right: 16px; bottom: 16px; }
}
