/* ============================================================
   accessibility.css — תוסף נגישות תקן ישראלי 5568 / WCAG 2.1 AA
   ============================================================ */

/* --- CSS variables for font scaling --- */
:root { --a11y-font-add: 0px; }

/* Apply font scaling everywhere */
body   { font-size: calc(1rem    + var(--a11y-font-add)); }
p, li, td, th, label, input, textarea, select, button, a {
  font-size: calc(1em + var(--a11y-font-add));
}
h1 { font-size: calc(2rem    + var(--a11y-font-add)); }
h2 { font-size: calc(1.5rem  + var(--a11y-font-add)); }
h3 { font-size: calc(1.25rem + var(--a11y-font-add)); }

/* --- Contrast modes --- */
[data-a11y-contrast="high"] {
  filter: contrast(1.5);
  background: #fff !important;
  color: #000 !important;
}
[data-a11y-contrast="high"] * {
  background-color: transparent !important;
  color: #000 !important;
  border-color: #000 !important;
}
[data-a11y-contrast="high"] a { color: #00008b !important; text-decoration: underline !important; }
[data-a11y-contrast="high"] button { background: #000 !important; color: #fff !important; border: 2px solid #000 !important; }

[data-a11y-contrast="dark"] {
  background: #1a1a1a !important;
  color: #f0f0f0 !important;
}
[data-a11y-contrast="dark"] body,
[data-a11y-contrast="dark"] .navbar,
[data-a11y-contrast="dark"] .card,
[data-a11y-contrast="dark"] .admin-sidebar,
[data-a11y-contrast="dark"] .admin-main,
[data-a11y-contrast="dark"] .admin-topbar,
[data-a11y-contrast="dark"] main {
  background: #1a1a1a !important;
  color: #f0f0f0 !important;
}
[data-a11y-contrast="dark"] a       { color: #7eb8f7 !important; }
[data-a11y-contrast="dark"] button  { background: #2d2d2d !important; color: #f0f0f0 !important; border-color: #555 !important; }
[data-a11y-contrast="dark"] input,
[data-a11y-contrast="dark"] textarea,
[data-a11y-contrast="dark"] select  { background: #2d2d2d !important; color: #f0f0f0 !important; border-color: #555 !important; }

[data-a11y-contrast="inverted"] { filter: invert(1) hue-rotate(180deg); }
[data-a11y-contrast="inverted"] img,
[data-a11y-contrast="inverted"] video,
[data-a11y-contrast="inverted"] iframe { filter: invert(1) hue-rotate(180deg); }

/* --- Grayscale --- */
.a11y-grayscale { filter: grayscale(1); }

/* --- Links highlight --- */
.a11y-links a {
  text-decoration: underline !important;
  text-underline-offset: 3px !important;
  background: #ffff00 !important;
  color: #000 !important;
  padding: 0 2px !important;
  border-radius: 2px !important;
}

/* --- Headings highlight --- */
.a11y-headings h1,
.a11y-headings h2,
.a11y-headings h3,
.a11y-headings h4,
.a11y-headings h5,
.a11y-headings h6 {
  outline: 2px dashed #534AB7 !important;
  outline-offset: 2px !important;
}

/* --- Big cursor --- */
.a11y-cursor,
.a11y-cursor * { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M6 0l20 20-8-1-4 9-2-1 4-9-10 1z' fill='%23000' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E") 6 2, auto !important; }

/* --- Stop animations --- */
.a11y-no-anim *,
.a11y-no-anim *::before,
.a11y-no-anim *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* --- Dyslexia font (OpenDyslexic via system or fallback) --- */
.a11y-dyslexia,
.a11y-dyslexia * {
  font-family: 'OpenDyslexic', 'Comic Sans MS', 'Trebuchet MS', cursive !important;
  letter-spacing: 0.05em !important;
  word-spacing: 0.15em !important;
}

/* --- Text spacing --- */
.a11y-spacing p,
.a11y-spacing li,
.a11y-spacing td,
.a11y-spacing th {
  line-height: 2 !important;
  letter-spacing: 0.12em !important;
  word-spacing: 0.16em !important;
}

/* --- Focus outline --- */
.a11y-focus *:focus {
  outline: 3px solid #534AB7 !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 5px rgba(83, 74, 183, 0.25) !important;
}

/* --- Reading guide --- */
#a11y-guide {
  position: fixed;
  left: 0;
  right: 0;
  height: 28px;
  background: rgba(255, 220, 0, 0.25);
  border-top: 2px solid rgba(255, 180, 0, 0.6);
  border-bottom: 2px solid rgba(255, 180, 0, 0.6);
  pointer-events: none;
  z-index: 99998;
  transition: top 0.05s linear;
}

/* ============================================================
   Widget styles
   ============================================================ */

#a11y-widget { font-family: 'Noto Sans Hebrew', 'Noto Sans', 'Inter', sans-serif; }

/* Toggle button */
#a11y-toggle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #534AB7;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 0 2px 12px rgba(83,74,183,0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
  z-index: 99999;
  position: relative;
}
#a11y-toggle:hover  { background: #3C3489; transform: scale(1.08); }
#a11y-toggle:focus  { outline: 3px solid #fff; outline-offset: 2px; }

/* Panel */
#a11y-panel {
  position: absolute;
  bottom: 64px;
  width: 310px;
  background: #ffffff;
  border: 1px solid #d0cde8;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  overflow: hidden;
  max-height: 85vh;
  overflow-y: auto;
}

/* RTL panel position */
[dir="rtl"] #a11y-panel { left: 0; right: auto; }
[dir="ltr"] #a11y-panel { right: 0; left: auto; }

.a11y-header {
  background: #534AB7;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}
.a11y-title { font-size: 15px; font-weight: 600; }
.a11y-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.12s;
}
.a11y-close:hover { background: rgba(255,255,255,0.2); }
.a11y-close:focus { outline: 2px solid #fff; }

.a11y-body { padding: 14px 14px 10px; }

.a11y-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7c77a8;
  margin: 12px 0 6px;
}
.a11y-section-title:first-child { margin-top: 0; }

.a11y-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.a11y-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 4px;
}

/* Buttons */
.a11y-btn {
  padding: 7px 10px;
  border: 1.5px solid #d0cde8;
  border-radius: 7px;
  background: #f8f7fc;
  color: #3C3489;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: background 0.12s, border-color 0.12s, transform 0.1s;
  line-height: 1.3;
}
.a11y-btn:hover  { background: #EEEDFE; border-color: #534AB7; }
.a11y-btn:focus  { outline: 2px solid #534AB7; outline-offset: 2px; }
.a11y-btn:active { transform: scale(0.97); }
.a11y-btn.active,
.a11y-btn[aria-pressed="true"] {
  background: #534AB7;
  color: #fff;
  border-color: #534AB7;
}
.a11y-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.a11y-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #e8e6f0;
}
.a11y-reset {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
  font-size: 12px;
  padding: 6px 12px;
}
.a11y-reset:hover { background: #fecaca; border-color: #f87171; }

.a11y-stmt-link {
  font-size: 12px;
  color: #534AB7;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.a11y-stmt-link:focus { outline: 2px solid #534AB7; outline-offset: 2px; }

/* Skip link — חיוני לנגישות מקלדת */
.skip-link {
  position: absolute;
  top: -100px;
  right: 0;
  background: #534AB7;
  color: #fff;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 0 0 8px 0;
  text-decoration: none;
  z-index: 100000;
  transition: top 0.1s;
}
.skip-link:focus { top: 0; }

/* ============================================================
   prefers-reduced-motion — כיבוי אנימציות אוטומטי
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
   High contrast media query — תמיכה מובנית
   ============================================================ */
@media (forced-colors: active) {
  .a11y-btn { forced-color-adjust: none; }
  #a11y-toggle { forced-color-adjust: none; background: ButtonFace; color: ButtonText; border-color: ButtonText; }
}
