/* ============================================================
   إمكانية الوصول — accessibility toolbar
   Self-contained, no external library. Settings are applied as
   data-a11y-* attributes on <html> and persisted in localStorage.
   The widget itself is appended to <html> (outside <body>) so page
   zoom / grayscale filters never touch its own controls.
   ============================================================ */

/* ---- page text/zoom scale (default 1 = no-op) ---- */
body { zoom: var(--ka-a11y-zoom, 1); }

/* ---- launcher button ---- */
.a11y-widget { direction: rtl; }
.a11y-fab {
  position: fixed; bottom: 18px; inset-inline-start: 18px; z-index: 2147483000;
  width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer;
  background: #1a4fd6; color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(26, 79, 214, .45); transition: transform .15s, background .15s;
}
.a11y-fab:hover { background: #1442b8; transform: scale(1.06); }
.a11y-fab:focus-visible { outline: 3px solid #ffd400; outline-offset: 2px; }
.a11y-fab svg { width: 26px; height: 26px; fill: currentColor; }

/* ---- panel ---- */
.a11y-panel {
  position: fixed; bottom: 74px; inset-inline-start: 18px; z-index: 2147483000;
  width: 300px; max-width: calc(100vw - 36px);
  background: #fff; color: #16181d; border: 1px solid #d8dae2; border-radius: 14px;
  box-shadow: 0 18px 50px rgba(10, 15, 40, .28); padding: 14px; font-family: inherit;
  max-height: calc(100vh - 100px); overflow: auto;
}
.a11y-panel[hidden] { display: none; }
@media (prefers-color-scheme: dark) {
  .a11y-panel { background: #1b1d24; color: #eef0f6; border-color: #333744; }
}
html[data-theme="dark"] .a11y-panel { background: #1b1d24; color: #eef0f6; border-color: #333744; }
html[data-theme="dark"] .a11y-size { border-color: #333744; }
html[data-theme="dark"] .a11y-stepper button { background: #262933; border-color: #3a3e4b; }
html[data-theme="dark"] .a11y-opt { background: #23262f; border-color: #333744; }
html[data-theme="dark"] .a11y-reset { background: #2b2f3b; color: #eef0f6; }

.a11y-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.a11y-head b { font-size: 15px; font-weight: 800; }
.a11y-close { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: inherit; padding: 2px 6px; border-radius: 6px; }
.a11y-close:hover { background: rgba(0, 0, 0, .08); }

.a11y-size { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 1px solid #e2e4ec; border-radius: 10px; margin-bottom: 12px; }
@media (prefers-color-scheme: dark) { .a11y-size { border-color: #333744; } }
.a11y-size > span { font-size: 13.5px; font-weight: 700; }
.a11y-stepper { display: flex; align-items: center; gap: 6px; }
.a11y-stepper button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid #cdd0da; background: #f4f5fa; color: inherit; cursor: pointer; font-weight: 800; }
.a11y-stepper button:hover { background: #e7e9f4; border-color: #1a4fd6; }
@media (prefers-color-scheme: dark) { .a11y-stepper button { background: #262933; border-color: #3a3e4b; } }
.a11y-size-val { min-width: 46px; text-align: center; font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; }

.a11y-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.a11y-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 12px 8px; border: 1px solid #e2e4ec; border-radius: 10px; background: #fafbfe;
  color: inherit; cursor: pointer; font-size: 12px; font-weight: 700; font-family: inherit; transition: .12s;
}
.a11y-opt svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.a11y-opt:hover { border-color: #1a4fd6; background: #eef2fd; }
.a11y-opt[aria-pressed="true"] { background: #1a4fd6; color: #fff; border-color: #1a4fd6; }
@media (prefers-color-scheme: dark) { .a11y-opt { background: #23262f; border-color: #333744; } .a11y-opt:hover { background: #2b2f3b; } }

.a11y-reset { width: 100%; margin-top: 12px; padding: 11px; border: 0; border-radius: 10px; background: #eceef4; color: #16181d; font-weight: 800; font-family: inherit; cursor: pointer; font-size: 13px; }
.a11y-reset:hover { background: #e0e3ec; }
@media (prefers-color-scheme: dark) { .a11y-reset { background: #2b2f3b; color: #eef0f6; } }

/* ============================================================
   Applied modes (on <html>)
   ============================================================ */

/* high contrast */
html[data-a11y-contrast="1"] body,
html[data-a11y-contrast="1"] .super,
html[data-a11y-contrast="1"] .masthead,
html[data-a11y-contrast="1"] section,
html[data-a11y-contrast="1"] article,
html[data-a11y-contrast="1"] aside,
html[data-a11y-contrast="1"] footer,
html[data-a11y-contrast="1"] .widget,
html[data-a11y-contrast="1"] header { background: #000 !important; color: #fff !important; }
html[data-a11y-contrast="1"] h1, html[data-a11y-contrast="1"] h2, html[data-a11y-contrast="1"] h3,
html[data-a11y-contrast="1"] p, html[data-a11y-contrast="1"] span, html[data-a11y-contrast="1"] b,
html[data-a11y-contrast="1"] time, html[data-a11y-contrast="1"] small, html[data-a11y-contrast="1"] li,
html[data-a11y-contrast="1"] td, html[data-a11y-contrast="1"] th { color: #fff !important; background: transparent !important; }
html[data-a11y-contrast="1"] a, html[data-a11y-contrast="1"] a * { color: #ffe600 !important; }
html[data-a11y-contrast="1"] .cat-tag, html[data-a11y-contrast="1"] .badge { background: #ffe600 !important; color: #000 !important; }
html[data-a11y-contrast="1"] img { filter: contrast(1.05); }

/* readable font */
html[data-a11y-readable="1"] body,
html[data-a11y-readable="1"] body * { font-family: Tahoma, "Segoe UI", Arial, sans-serif !important; }
html[data-a11y-readable="1"] p, html[data-a11y-readable="1"] li, html[data-a11y-readable="1"] .excerpt { font-weight: 500 !important; }

/* highlight links */
html[data-a11y-links="1"] a { text-decoration: underline !important; text-underline-offset: 2px; outline: 2px solid rgba(26, 79, 214, .55); outline-offset: 1px; border-radius: 2px; }

/* increased spacing */
html[data-a11y-spacing="1"] body { letter-spacing: .04em !important; word-spacing: .1em !important; }
html[data-a11y-spacing="1"] p, html[data-a11y-spacing="1"] li,
html[data-a11y-spacing="1"] h1, html[data-a11y-spacing="1"] h2, html[data-a11y-spacing="1"] h3 { line-height: 2 !important; }

/* grayscale (body only, so the widget keeps its colour) */
html[data-a11y-grayscale="1"] body { filter: grayscale(1); }

/* stop animations */
html[data-a11y-motion="1"] *, html[data-a11y-motion="1"] *::before, html[data-a11y-motion="1"] *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important;
  transition-duration: .001ms !important; scroll-behavior: auto !important;
}

/* big cursor */
html[data-a11y-cursor="1"] body,
html[data-a11y-cursor="1"] body * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 32 32'%3E%3Cpath d='M4 2l10 24 3.5-9.5L27 13z' fill='%23fff' stroke='%23000' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") 4 2, auto !important;
}

@media (max-width: 720px) {
  .a11y-fab { bottom: 14px; inset-inline-start: 14px; width: 42px; height: 42px; }
  .a11y-panel { bottom: 64px; inset-inline-start: 14px; }
}
