/* =============================================
   Accessibility Widget — tzavaa-expert.com
   Israeli Standard 5568 / WCAG 2.1 AA
   ============================================= */

/* --- Floating Toggle Button --- */
.a11y-toggle-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 9998;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #2558B6;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  padding: 0;
  outline: none;
  font-size: 16px;
  line-height: 1;
}
.a11y-toggle-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 22px rgba(0,0,0,0.22);
}
.a11y-toggle-btn:focus-visible {
  outline: 3px solid #FFD700;
  outline-offset: 3px;
}
.a11y-toggle-btn svg {
  width: 28px;
  height: 28px;
  fill: #FFFFFF;
  pointer-events: none;
}

/* --- Panel Overlay (background dim) --- */
.a11y-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0,0,0,0.25);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.a11y-panel-overlay.a11y-open {
  opacity: 1;
  visibility: visible;
}

/* --- Panel --- */
.a11y-panel {
  position: fixed;
  bottom: 82px;
  left: 20px;
  z-index: 9999;
  width: 320px;
  max-height: 80vh;
  background: #FFFFFF;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
  overflow: hidden;
  direction: rtl;
  font-size: 16px;
  line-height: 1.5;
  color: #1A1A1A;
}
.a11y-panel.a11y-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* --- Panel Header --- */
.a11y-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid #E8E4D8;
  flex-shrink: 0;
}
.a11y-panel-title {
  font-family: 'Frank Ruhl Libre', Georgia, serif;
  font-size: 18px;
  font-weight: 500;
  color: #1A1A1A;
  letter-spacing: -0.01em;
}
.a11y-panel-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  padding: 0;
  flex-shrink: 0;
}
.a11y-panel-close:hover {
  background: #F0EDEA;
}
.a11y-panel-close:focus-visible {
  outline: 3px solid #2558B6;
  outline-offset: 1px;
}
.a11y-panel-close svg {
  width: 18px;
  height: 18px;
  stroke: #5B5B54;
  pointer-events: none;
}

/* --- Panel Body (scrollable) --- */
.a11y-panel-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
  flex: 1 1 auto;
}

/* --- Options Grid --- */
.a11y-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* --- Individual Option Button --- */
.a11y-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: #F5F3EF;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  text-align: center;
  min-height: 80px;
  font-size: 16px;
}
.a11y-option:hover {
  background: #ECEAE4;
}
.a11y-option:focus-visible {
  outline: 3px solid #2558B6;
  outline-offset: 1px;
}
.a11y-option[aria-pressed="true"] {
  background: #E1F5EE;
  border-color: #0F6E56;
}
.a11y-option[aria-pressed="true"]::after {
  content: '';
  position: absolute;
  top: 7px;
  left: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0F6E56;
}
.a11y-option svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.a11y-option-label {
  font-family: 'Heebo', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  color: #1A1A1A;
  line-height: 1.3;
}

/* --- Reset Button --- */
.a11y-reset {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: #FDE8E8;
  color: #B91C1C;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  font-family: 'Heebo', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  margin-top: 4px;
}
.a11y-reset:hover {
  background: #FCD5D5;
  border-color: #B91C1C;
}
.a11y-reset:focus-visible {
  outline: 3px solid #2558B6;
  outline-offset: 1px;
}
.a11y-reset svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* --- Panel Footer --- */
.a11y-panel-footer {
  border-top: 1px solid #E8E4D8;
  padding: 12px 18px;
  text-align: center;
  flex-shrink: 0;
}
.a11y-panel-footer a {
  font-family: 'Heebo', sans-serif;
  font-size: 13px;
  color: #5B5B54;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}
.a11y-panel-footer a:hover {
  color: #0F6E56;
}
.a11y-panel-footer a:focus-visible {
  outline: 3px solid #2558B6;
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Mobile --- */
@media (max-width: 640px) {
  .a11y-toggle-btn {
    width: 48px;
    height: 48px;
    bottom: 12px;
    left: 12px;
  }
  .a11y-toggle-btn svg {
    width: 24px;
    height: 24px;
  }
  .a11y-panel {
    width: min(280px, 90vw);
    bottom: 72px;
    left: 12px;
  }
  .a11y-grid {
    grid-template-columns: 1fr;
  }
}


/* =============================================
   Accessibility Mode Styles
   Applied to <body> via classes
   ============================================= */

/* --- Text Size --- handled via JavaScript (px override on each element) */

/* --- High Contrast --- */
body.a11y-high-contrast {
  background-color: #FFFFFF !important;
  color: #000000 !important;
  border-color: #000000 !important;
}
body.a11y-high-contrast * {
  background-color: #FFFFFF !important;
  color: #000000 !important;
  border-color: #000000 !important;
}
body.a11y-high-contrast a {
  color: #B8860B !important;
  text-decoration: underline !important;
}
body.a11y-high-contrast img {
  filter: contrast(1.2) !important;
}

/* --- Inverted Contrast --- */
body.a11y-inverted {
  background-color: #000000 !important;
  color: #FFFFFF !important;
  border-color: #555555 !important;
}
body.a11y-inverted * {
  background-color: #000000 !important;
  color: #FFFFFF !important;
  border-color: #555555 !important;
}
body.a11y-inverted a {
  color: #7CB9FF !important;
}
body.a11y-inverted img {
  filter: invert(1) hue-rotate(180deg) !important;
}

/* --- Grayscale ---
   Apply to direct children of body (NOT body itself)
   to avoid breaking position:fixed on the widget */
body.a11y-grayscale > *:not(.a11y-toggle-btn):not(.a11y-panel):not(.a11y-panel-overlay) {
  filter: grayscale(100%) !important;
}

/* --- Highlight Links --- */
body.a11y-highlight-links a {
  background-color: #FFFF00 !important;
  color: #000000 !important;
  text-decoration: underline !important;
  text-decoration-color: #000000 !important;
  outline: 2px solid #000000 !important;
  outline-offset: 2px;
  padding: 1px 3px;
}

/* --- Readable Font --- */
body.a11y-readable-font,
body.a11y-readable-font * {
  font-family: Arial, Helvetica, sans-serif !important;
}

/* --- Stop Animations --- */
body.a11y-stop-anim,
body.a11y-stop-anim * {
  animation-duration: 0s !important;
  animation-delay: 0s !important;
  transition-duration: 0s !important;
  transition-delay: 0s !important;
}

/* --- Large Cursor --- */
body.a11y-big-cursor,
body.a11y-big-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpath d='M8 4l22 16-10 2 6 14-5 2-6-14-7 8z' fill='%23FFD700' stroke='%23000' stroke-width='2'/%3E%3C/svg%3E") 4 4, auto !important;
}

/* --- Focus Highlight --- */
body.a11y-focus-highlight *:focus {
  outline: 3px solid #2558B6 !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 5px rgba(37,88,182,0.25) !important;
}


/* =============================================
   Widget Protection
   These rules prevent accessibility modes from
   breaking the widget's own appearance.
   Must come AFTER mode styles for correct cascade.
   ============================================= */

/* --- Toggle button --- */
body.a11y-high-contrast .a11y-toggle-btn,
body.a11y-inverted .a11y-toggle-btn,
body.a11y-highlight-links .a11y-toggle-btn {
  background: #2558B6 !important;
  background-color: #2558B6 !important;
  border: none !important;
  border-color: transparent !important;
  color: #FFFFFF !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15) !important;
  outline: none !important;
  padding: 0 !important;
  text-decoration: none !important;
}
body.a11y-high-contrast .a11y-toggle-btn svg,
body.a11y-inverted .a11y-toggle-btn svg {
  fill: #FFFFFF !important;
  color: #FFFFFF !important;
  filter: none !important;
}

/* --- Overlay --- */
body.a11y-high-contrast .a11y-panel-overlay,
body.a11y-inverted .a11y-panel-overlay {
  background: rgba(0,0,0,0.25) !important;
  background-color: rgba(0,0,0,0.25) !important;
}

/* --- Panel container --- */
body.a11y-high-contrast .a11y-panel,
body.a11y-inverted .a11y-panel {
  background: #FFFFFF !important;
  background-color: #FFFFFF !important;
  color: #1A1A1A !important;
  border-color: #E8E4D8 !important;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18) !important;
}

/* --- Panel header --- */
body.a11y-high-contrast .a11y-panel-header,
body.a11y-inverted .a11y-panel-header {
  background: #FFFFFF !important;
  background-color: #FFFFFF !important;
  border-color: #E8E4D8 !important;
}

/* --- Panel title --- */
body.a11y-high-contrast .a11y-panel-title,
body.a11y-inverted .a11y-panel-title {
  color: #1A1A1A !important;
}

/* --- Close button --- */
body.a11y-high-contrast .a11y-panel-close,
body.a11y-inverted .a11y-panel-close {
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  border-color: transparent !important;
}
body.a11y-high-contrast .a11y-panel-close svg,
body.a11y-inverted .a11y-panel-close svg {
  stroke: #5B5B54 !important;
  color: #5B5B54 !important;
  filter: none !important;
}

/* --- Panel body & grid --- */
body.a11y-high-contrast .a11y-panel-body,
body.a11y-inverted .a11y-panel-body,
body.a11y-high-contrast .a11y-grid,
body.a11y-inverted .a11y-grid {
  background: transparent !important;
  background-color: transparent !important;
  border-color: transparent !important;
}

/* --- Option buttons --- */
body.a11y-high-contrast .a11y-option,
body.a11y-inverted .a11y-option {
  background: #F5F3EF !important;
  background-color: #F5F3EF !important;
  border-color: transparent !important;
  color: #1A1A1A !important;
}
body.a11y-high-contrast .a11y-option:hover,
body.a11y-inverted .a11y-option:hover {
  background: #ECEAE4 !important;
  background-color: #ECEAE4 !important;
}
body.a11y-high-contrast .a11y-option[aria-pressed="true"],
body.a11y-inverted .a11y-option[aria-pressed="true"] {
  background: #E1F5EE !important;
  background-color: #E1F5EE !important;
  border-color: #0F6E56 !important;
}
body.a11y-high-contrast .a11y-option[aria-pressed="true"]::after,
body.a11y-inverted .a11y-option[aria-pressed="true"]::after {
  background: #0F6E56 !important;
  background-color: #0F6E56 !important;
}

/* --- Option inner spans (icon + label) --- */
body.a11y-high-contrast .a11y-option > span,
body.a11y-inverted .a11y-option > span {
  background: transparent !important;
  background-color: transparent !important;
  border-color: transparent !important;
}
body.a11y-high-contrast .a11y-option-label,
body.a11y-inverted .a11y-option-label {
  color: #1A1A1A !important;
}
body.a11y-high-contrast .a11y-option svg,
body.a11y-inverted .a11y-option svg {
  color: #1A1A1A !important;
  stroke: #1A1A1A !important;
  filter: none !important;
}

/* --- Reset button --- */
body.a11y-high-contrast .a11y-reset,
body.a11y-inverted .a11y-reset {
  background: #FDE8E8 !important;
  background-color: #FDE8E8 !important;
  border-color: transparent !important;
  color: #B91C1C !important;
}
body.a11y-high-contrast .a11y-reset:hover,
body.a11y-inverted .a11y-reset:hover {
  background: #FCD5D5 !important;
  background-color: #FCD5D5 !important;
  border-color: #B91C1C !important;
}
body.a11y-high-contrast .a11y-reset > *,
body.a11y-inverted .a11y-reset > * {
  background: transparent !important;
  background-color: transparent !important;
  border-color: transparent !important;
  color: inherit !important;
}
body.a11y-high-contrast .a11y-reset svg,
body.a11y-inverted .a11y-reset svg {
  stroke: #B91C1C !important;
  color: #B91C1C !important;
  filter: none !important;
}

/* --- Footer --- */
body.a11y-high-contrast .a11y-panel-footer,
body.a11y-inverted .a11y-panel-footer {
  background: #FFFFFF !important;
  background-color: #FFFFFF !important;
  border-color: #E8E4D8 !important;
}
body.a11y-high-contrast .a11y-panel-footer a,
body.a11y-inverted .a11y-panel-footer a {
  color: #5B5B54 !important;
}

/* --- Highlight links: protect widget links --- */
body.a11y-highlight-links .a11y-panel-footer a {
  background-color: transparent !important;
  color: #5B5B54 !important;
  outline: none !important;
  padding: 0 !important;
  text-decoration: underline !important;
  text-decoration-color: currentColor !important;
}

/* --- Readable font: protect widget fonts --- */
body.a11y-readable-font .a11y-panel-title {
  font-family: 'Frank Ruhl Libre', Georgia, serif !important;
}
body.a11y-readable-font .a11y-option-label,
body.a11y-readable-font .a11y-reset,
body.a11y-readable-font .a11y-reset span,
body.a11y-readable-font .a11y-panel-footer a {
  font-family: 'Heebo', sans-serif !important;
}

/* --- Text size: protect widget from body font-size changes --- */
body[class*="a11y-text-"] .a11y-panel {
  font-size: 16px !important;
}
body[class*="a11y-text-"] .a11y-toggle-btn {
  font-size: 16px !important;
}

/* --- Inverted: protect widget images/SVGs from invert filter --- */
body.a11y-inverted .a11y-panel img,
body.a11y-inverted .a11y-panel svg,
body.a11y-inverted .a11y-toggle-btn img,
body.a11y-inverted .a11y-toggle-btn svg {
  filter: none !important;
}


/* =============================================
   prefers-reduced-motion respect
   ============================================= */
@media (prefers-reduced-motion: reduce) {
  .a11y-toggle-btn,
  .a11y-panel,
  .a11y-panel-overlay,
  .a11y-option,
  .a11y-reset,
  .a11y-panel-close {
    transition-duration: 0s !important;
  }
}
