/* ============================================================
   Accessibility Widget — a11y-wgt
   IS 5568 / WCAG 2.1 AA compliant
   Prefix: a11y-wgt- (no conflicts with host site)
   Body-level classes: a11y-* on <html>

   THEMING: override 3 variables in your project CSS:
     --a11y-bg      panel and modal background
     --a11y-bg-btn  trigger button background
     --a11y-accent  accent color (borders, active states)
   ============================================================ */

:root {
  --a11y-bg:     #0d1e35;
  --a11y-bg-btn: #0a1223;
  --a11y-accent: #c9b99a;
}

/* ── Skip to content link ─────────────────────────────────── */
.a11y-skip-link {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999999;
  padding: 12px 24px;
  background: var(--a11y-bg-btn);
  color: var(--a11y-accent);
  font-family: Arial, sans-serif;
  font-size: 15px;
  font-weight: 600;
  border: 2px solid var(--a11y-accent);
  border-radius: 4px;
  text-decoration: none;
  white-space: nowrap;
  transition: top 0.2s;
}
.a11y-skip-link:focus {
  top: 12px;
  outline: 3px solid var(--a11y-accent);
  outline-offset: 2px;
}

/* ── Trigger button ───────────────────────────────────────── */
.a11y-wgt-btn {
  position: fixed;
  bottom: 24px;
  z-index: 99998;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--a11y-bg-btn);
  border: 2px solid var(--a11y-accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px color-mix(in srgb, var(--a11y-bg-btn) 45%, transparent);
  transition: transform 0.2s, box-shadow 0.2s;
  padding: 0;
  outline: none;
}
.a11y-wgt-btn:hover,
.a11y-wgt-btn:focus-visible {
  transform: scale(1.08);
  box-shadow: 0 6px 24px color-mix(in srgb, var(--a11y-bg-btn) 55%, transparent);
  outline: 3px solid var(--a11y-accent);
  outline-offset: 2px;
}
.a11y-wgt-btn--right { right: 24px; }
.a11y-wgt-btn--left  { left: 24px; }
.a11y-wgt-btn svg    { width: 28px; height: 28px; }

/* ── Panel ────────────────────────────────────────────────── */
.a11y-wgt-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 300px;
  max-width: 100vw;
  z-index: 99997;
  background: var(--a11y-bg);
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.35s cubic-bezier(.4,0,.2,1);
  font-family: Arial, Helvetica, sans-serif;
}
.a11y-wgt-panel--right {
  right: 0;
  transform: translateX(100%);
}
.a11y-wgt-panel--left {
  left: 0;
  transform: translateX(-100%);
}
.a11y-wgt-panel--open {
  transform: translateX(0) !important;
  z-index: 99999;
}

/* ── Panel header ─────────────────────────────────────────── */
.a11y-wgt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid color-mix(in srgb, var(--a11y-accent) 20%, transparent);
  flex-shrink: 0;
}
.a11y-wgt-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--a11y-accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0;
}
.a11y-wgt-close {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.6);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s;
}
.a11y-wgt-close:hover,
.a11y-wgt-close:focus-visible {
  color: var(--a11y-accent);
  outline: 2px solid var(--a11y-accent);
}
.a11y-wgt-close svg { width: 20px; height: 20px; }

/* ── Panel scroll area ────────────────────────────────────── */
.a11y-wgt-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0 16px;
  scrollbar-width: none;
}
.a11y-wgt-body::-webkit-scrollbar { display: none; }

/* ── Sections ─────────────────────────────────────────────── */
.a11y-wgt-section {
  padding: 12px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--a11y-accent) 10%, transparent);
}
.a11y-wgt-section:last-child { border-bottom: none; }

.a11y-wgt-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  margin-bottom: 10px;
  display: block;
}

/* ── Control grid ─────────────────────────────────────────── */
.a11y-wgt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.a11y-wgt-grid--3 {
  grid-template-columns: 1fr 1fr 1fr;
}
.a11y-wgt-grid--1 {
  grid-template-columns: 1fr;
}

/* ── Control button ───────────────────────────────────────── */
.a11y-wgt-ctrl {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid color-mix(in srgb, var(--a11y-accent) 15%, transparent);
  border-radius: 6px;
  color: rgba(255,255,255,0.7);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 62px;
}
.a11y-wgt-ctrl:hover,
.a11y-wgt-ctrl:focus-visible {
  background: color-mix(in srgb, var(--a11y-accent) 12%, transparent);
  color: #fff;
  border-color: color-mix(in srgb, var(--a11y-accent) 40%, transparent);
  outline: none;
}
.a11y-wgt-ctrl:focus-visible {
  outline: 2px solid var(--a11y-accent);
  outline-offset: 1px;
}
.a11y-wgt-ctrl--active {
  background: color-mix(in srgb, var(--a11y-accent) 20%, transparent);
  border-color: var(--a11y-accent);
  color: var(--a11y-accent);
}
.a11y-wgt-ctrl-icon {
  display: block;
  font-size: 20px;
  line-height: 1;
  margin-bottom: 4px;
  font-style: normal;
}

/* ── Font size row ────────────────────────────────────────── */
.a11y-wgt-fs-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.a11y-wgt-fs-btn {
  flex: 0 0 38px;
  height: 38px;
  background: rgba(255,255,255,0.05);
  border: 1px solid color-mix(in srgb, var(--a11y-accent) 20%, transparent);
  border-radius: 6px;
  color: rgba(255,255,255,0.7);
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  line-height: 1;
  padding: 0;
}
.a11y-wgt-fs-btn:hover,
.a11y-wgt-fs-btn:focus-visible {
  background: color-mix(in srgb, var(--a11y-accent) 15%, transparent);
  color: var(--a11y-accent);
  outline: 2px solid var(--a11y-accent);
}
.a11y-wgt-fs-val {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: var(--a11y-accent);
  font-weight: 700;
}

/* ── Footer links ─────────────────────────────────────────── */
.a11y-wgt-footer {
  padding: 12px 16px;
  border-top: 1px solid color-mix(in srgb, var(--a11y-accent) 15%, transparent);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.a11y-wgt-statement-link {
  display: block;
  font-size: 12px;
  color: var(--a11y-accent);
  text-decoration: underline;
  text-align: center;
  transition: color 0.15s;
}
.a11y-wgt-statement-link:hover { color: #fff; }
.a11y-wgt-statement-link:focus-visible { outline: 2px solid var(--a11y-accent); outline-offset: 2px; }

.a11y-wgt-reset {
  width: 100%;
  padding: 10px;
  background: none;
  border: 1px solid color-mix(in srgb, var(--a11y-accent) 25%, transparent);
  border-radius: 6px;
  color: rgba(255,255,255,0.5);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  letter-spacing: 0.06em;
}
.a11y-wgt-reset:hover,
.a11y-wgt-reset:focus-visible {
  border-color: var(--a11y-accent);
  color: var(--a11y-accent);
  outline: none;
}

/* ── Overlay (mobile) ─────────────────────────────────────── */
.a11y-wgt-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99996;
}
@media (max-width: 360px) {
  .a11y-wgt-overlay--visible { display: block; }
  .a11y-wgt-panel { width: 100vw; }
}

/* ── RTL panel adjustments ────────────────────────────────── */
[dir="rtl"] .a11y-wgt-header { flex-direction: row-reverse; }

/* ============================================================
   BODY-LEVEL MODIFICATIONS (applied via <html> classes by JS)
   All selectors scoped to html.a11y-* for easy override
   ============================================================ */

/* High contrast: yellow on black */
html.a11y-high-contrast,
html.a11y-high-contrast body {
  background: #000 !important;
  color: #ff0 !important;
}
html.a11y-high-contrast *:not(.a11y-wgt-panel):not(.a11y-wgt-btn):not(.a11y-wgt-overlay):not(.a11y-skip-link):not([class^="a11y-wgt"]) {
  background-color: #000 !important;
  color: #ff0 !important;
  border-color: #ff0 !important;
}
html.a11y-high-contrast img { filter: contrast(1.5) brightness(0.9); }

/* Invert colors — overlay approach (avoids breaking position:fixed) */
/* Injected by JS as a DOM element with mix-blend-mode */
#a11y-invert-overlay {
  position: fixed;
  inset: 0;
  z-index: 99990;
  pointer-events: none;
  mix-blend-mode: difference;
  background: #fff;
}

/* Grayscale — backdrop-filter overlay approach */
#a11y-mono-overlay {
  position: fixed;
  inset: 0;
  z-index: 99990;
  pointer-events: none;
  backdrop-filter: grayscale(1);
  -webkit-backdrop-filter: grayscale(1);
}

/* Highlight all links */
html.a11y-links a {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 3px !important;
  outline: 1px dashed currentColor !important;
  outline-offset: 2px !important;
}

/* Highlight headings */
html.a11y-headings h1,
html.a11y-headings h2,
html.a11y-headings h3,
html.a11y-headings h4,
html.a11y-headings h5,
html.a11y-headings h6 {
  outline: 2px solid var(--a11y-accent) !important;
  outline-offset: 4px !important;
}

/* Keyboard focus always visible */
html.a11y-focus *:focus {
  outline: 3px solid #f5a623 !important;
  outline-offset: 3px !important;
}

/* Stop all animations */
html.a11y-no-anim *,
html.a11y-no-anim *::before,
html.a11y-no-anim *::after {
  animation: none !important;
  transition: none !important;
}

/* Line height — medium */
html.a11y-lh-medium p,
html.a11y-lh-medium li,
html.a11y-lh-medium span,
html.a11y-lh-medium a,
html.a11y-lh-medium label,
html.a11y-lh-medium td {
  line-height: 1.9 !important;
}

/* Line height — large */
html.a11y-lh-large p,
html.a11y-lh-large li,
html.a11y-lh-large span,
html.a11y-lh-large a,
html.a11y-lh-large label,
html.a11y-lh-large td {
  line-height: 2.4 !important;
}

/* Font — sans-serif */
html.a11y-font-sans,
html.a11y-font-sans * {
  font-family: Arial, Helvetica, sans-serif !important;
}

/* Font — dyslexia friendly (OpenDyslexic via CDN) */
@font-face {
  font-family: 'OpenDyslexic';
  src: url('https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@master/compiled/OpenDyslexic-Regular.woff2') format('woff2'),
       url('https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@master/compiled/OpenDyslexic-Regular.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
html.a11y-font-dyslexia {
  font-family: 'OpenDyslexic', Arial, sans-serif !important;
}
html.a11y-font-dyslexia body,
html.a11y-font-dyslexia p,
html.a11y-font-dyslexia h1,
html.a11y-font-dyslexia h2,
html.a11y-font-dyslexia h3,
html.a11y-font-dyslexia h4,
html.a11y-font-dyslexia h5,
html.a11y-font-dyslexia h6,
html.a11y-font-dyslexia li,
html.a11y-font-dyslexia a,
html.a11y-font-dyslexia span,
html.a11y-font-dyslexia button,
html.a11y-font-dyslexia input,
html.a11y-font-dyslexia label,
html.a11y-font-dyslexia td,
html.a11y-font-dyslexia div {
  font-family: 'OpenDyslexic', Arial, sans-serif !important;
  letter-spacing: 0.05em !important;
  word-spacing: 0.1em !important;
}

/* ============================================================
   ACCESSIBILITY STATEMENT MODAL
   ============================================================ */
.a11y-stmt-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}
.a11y-stmt-overlay--open {
  opacity: 1;
  visibility: visible;
}
.a11y-stmt-modal {
  background: var(--a11y-bg);
  border: 1px solid color-mix(in srgb, var(--a11y-accent) 20%, transparent);
  border-radius: 8px;
  width: 100%;
  max-width: 660px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
  font-family: Arial, Helvetica, sans-serif;
  transform: translateY(12px);
  transition: transform 0.25s;
}
.a11y-stmt-overlay--open .a11y-stmt-modal {
  transform: translateY(0);
}

/* Header */
.a11y-stmt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid color-mix(in srgb, var(--a11y-accent) 18%, transparent);
  flex-shrink: 0;
}
.a11y-stmt-title {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--a11y-accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0;
}
.a11y-stmt-close {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.5);
  padding: 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.a11y-stmt-close:hover,
.a11y-stmt-close:focus-visible { color: var(--a11y-accent); outline: 2px solid var(--a11y-accent); }
.a11y-stmt-close svg { width: 20px; height: 20px; }

/* Body */
.a11y-stmt-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--a11y-accent) var(--a11y-bg);
}
.a11y-stmt-body::-webkit-scrollbar { width: 4px; }
.a11y-stmt-body::-webkit-scrollbar-thumb { background: var(--a11y-accent); border-radius: 4px; }

/* Test notice banner */
.a11y-stmt-notice {
  background: rgba(245,166,35,0.15);
  border: 1px solid rgba(245,166,35,0.4);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 13px;
  color: #f5a623;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* Content typography */
.a11y-stmt-subtitle {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--a11y-accent) 60%, transparent);
  margin-bottom: 24px;
}
.a11y-stmt-sec-title {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--a11y-accent);
  margin: 24px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid color-mix(in srgb, var(--a11y-accent) 12%, transparent);
}
.a11y-stmt-sec-title:first-of-type { margin-top: 0; }
.a11y-stmt-para {
  font-size: 14px;
  line-height: 1.8;
  color: rgba(255,255,255,0.72);
  margin-bottom: 12px;
}
.a11y-stmt-list {
  padding-left: 18px;
  margin-bottom: 12px;
}
.a11y-stmt-list li {
  font-size: 14px;
  line-height: 1.75;
  color: rgba(255,255,255,0.65);
  margin-bottom: 4px;
}
.a11y-stmt-date {
  font-size: 12px;
  color: rgba(255,255,255,0.3);
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid color-mix(in srgb, var(--a11y-accent) 10%, transparent);
}

/* RTL modal */
[dir="rtl"] .a11y-stmt-header { flex-direction: row-reverse; }
[dir="rtl"] .a11y-stmt-list { padding-left: 0; padding-right: 18px; }
