/* Accessibility Widget - isolated, prefixed. Do not override site styles. */

/* ---- Widget container (floating button + panel) ---- */
/* z-index below loading screen (9999) so it doesn't appear on top of it */
.a11y-widget {
  position: fixed;
  inset: 0;
  z-index: 9990;
  pointer-events: none;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  direction: rtl;
}

.a11y-widget__trigger,
.a11y-widget__panel {
  pointer-events: auto;
}

/* Button: bottom-right (does not overlap phone/WhatsApp on the left) */
.a11y-widget__trigger {
  position: absolute;
  bottom: 44px;
  right: 20px;
  left: auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid #004a8f;
  background: #0052a3;
  box-shadow: 0 4px 20px rgba(0, 82, 163, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  color: #fff;
}
.a11y-widget__trigger:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(0, 82, 163, 0.45);
  background: #003d7a;
  color: #fff;
}
.a11y-widget__trigger:focus {
  outline: 2px solid #0052a3;
  outline-offset: 2px;
}
.a11y-widget__trigger[aria-pressed="true"] {
  background: #003d7a;
  color: #fff;
  border-color: #003d7a;
}
.a11y-widget__trigger svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

/* Panel (dialog) */
.a11y-widget__panel {
  position: absolute;
  bottom: calc(44px + 56px + 12px);
  right: 20px;
  left: auto;
  width: min(360px, calc(100vw - 40px));
  max-height: min(85vh, 560px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(22, 56, 43, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.a11y-widget__panel[hidden] {
  display: none !important;
}

.a11y-widget__panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(22, 56, 43, 0.1);
  font-weight: 600;
  color: #16382b;
  flex-shrink: 0;
}

.a11y-widget__panel-body {
  padding: 12px 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.a11y-widget__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(22, 56, 43, 0.06);
  min-height: 44px;
}
.a11y-widget__row:last-child {
  border-bottom: none;
}

.a11y-widget__label {
  flex: 1;
  text-align: right;
  color: #16382b;
  font-size: 15px;
}

/* Toggle switch */
.a11y-widget__toggle {
  width: 48px;
  height: 26px;
  border-radius: 13px;
  background: #ccc;
  border: none;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.a11y-widget__toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.2s ease;
}
.a11y-widget__toggle[aria-pressed="true"] {
  background: #16382b;
}
.a11y-widget__toggle[aria-pressed="true"]::after {
  transform: translateX(22px);
}
.a11y-widget__toggle:focus {
  outline: 2px solid #16382b;
  outline-offset: 2px;
}

/* Text size buttons (100, 110, 120, 130) */
.a11y-widget__size-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.a11y-widget__size-btn {
  min-width: 48px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(22, 56, 43, 0.25);
  background: #fff;
  color: #16382b;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s, border-color 0.2s;
}
.a11y-widget__size-btn:hover {
  background: rgba(22, 56, 43, 0.06);
}
.a11y-widget__size-btn[aria-pressed="true"] {
  background: #16382b;
  color: #fff;
  border-color: #16382b;
}
.a11y-widget__size-btn:focus {
  outline: 2px solid #16382b;
  outline-offset: 2px;
}

/* Reset button */
.a11y-widget__reset {
  width: 100%;
  margin-top: 8px;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid rgba(22, 56, 43, 0.3);
  background: #fff;
  color: #16382b;
  font-weight: 500;
  cursor: pointer;
  font-size: 15px;
  transition: background 0.2s;
}
.a11y-widget__reset:hover {
  background: rgba(22, 56, 43, 0.08);
}
.a11y-widget__reset:focus {
  outline: 2px solid #16382b;
  outline-offset: 2px;
}

/* Statement block */
.a11y-widget__statement {
  margin-top: 16px;
  padding: 14px;
  background: rgba(22, 56, 43, 0.06);
  border-radius: 8px;
  border: 1px solid rgba(22, 56, 43, 0.1);
  font-size: 13px;
  color: #16382b;
  line-height: 1.55;
  text-align: right;
}
.a11y-widget__statement h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
}
.a11y-widget__statement p {
  margin: 0 0 6px 0;
}
.a11y-widget__statement p:last-child {
  margin-bottom: 0;
}

/* Live region for announcements */
.a11y-widget__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Global effects (applied to body/html by widget) ---- */
/* Text size: set on html by JS: font-size: 110% etc. */

/* A) Text spacing */
body.a11y-text-spacing {
  letter-spacing: 0.12em;
  line-height: 1.8;
}

/* C) High contrast - body base; links and borders emphasized */
body.a11y-high-contrast {
  background: #fff !important;
  color: #000 !important;
}
body.a11y-high-contrast a {
  color: #0000ee !important;
  text-decoration: underline !important;
}
body.a11y-high-contrast button,
body.a11y-high-contrast input,
body.a11y-high-contrast select,
body.a11y-high-contrast textarea {
  border: 2px solid #000 !important;
  background: #fff !important;
  color: #000 !important;
}

/* D) Invert - on html, revert media */
html.a11y-invert {
  filter: invert(1);
}
html.a11y-invert img,
html.a11y-invert video,
html.a11y-invert iframe,
html.a11y-invert [style*="background-image"] {
  filter: invert(1);
}

/* E) Grayscale */
html.a11y-grayscale {
  filter: grayscale(1);
}
html.a11y-invert.html.a11y-grayscale img,
html.a11y-invert.html.a11y-grayscale video {
  filter: invert(1) grayscale(1);
}

/* F) Highlight links */
body.a11y-links-underline a[href] {
  text-decoration: underline !important;
  color: #0000aa !important;
  font-weight: 500;
}

/* G) Highlight headings */
body.a11y-headings-highlight h1,
body.a11y-headings-highlight h2,
body.a11y-headings-highlight h3,
body.a11y-headings-highlight h4,
body.a11y-headings-highlight h5,
body.a11y-headings-highlight h6 {
  outline: 2px solid rgba(22, 56, 43, 0.4);
  outline-offset: 2px;
  background: rgba(22, 56, 43, 0.06);
  padding: 0.15em 0.25em;
}

/* H) Readable font */
body.a11y-readable-font,
body.a11y-readable-font * {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

/* I) Big cursor + high contrast cursor - use CSS custom cursor (fallback to default if not set) */
body.a11y-big-cursor,
body.a11y-big-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 fill='%23000' stroke='%23fff' stroke-width='1.5' d='M4 4l8 20 4-6 6 2L4 4z'/%3E%3C/svg%3E") 4 4, auto !important;
}
body.a11y-cursor-contrast * {
  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 fill='%23fff' stroke='%23000' stroke-width='2' d='M4 4l8 20 4-6 6 2L4 4z'/%3E%3C/svg%3E") 4 4, auto !important;
}

/* J) Reduce motion */
body.a11y-reduce-motion,
body.a11y-reduce-motion *,
body.a11y-reduce-motion *::before,
body.a11y-reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* K) Reading mask - overlay with transparent horizontal band */
.a11y-reading-mask {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999998;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.4) 0%,
    rgba(0, 0, 0, 0.4) calc(50% - 50px),
    transparent calc(50% - 50px),
    transparent calc(50% + 50px),
    rgba(0, 0, 0, 0.4) calc(50% + 50px),
    rgba(0, 0, 0, 0.4) 100%
  );
}

/* L) Large click areas */
body.a11y-large-touch a[href],
body.a11y-large-touch button,
body.a11y-large-touch [role="button"] {
  min-height: 44px;
  min-width: 44px;
  padding: 0.4em 0.75em !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 480px) {
  .a11y-widget__trigger {
    width: 52px;
    height: 52px;
    bottom: 40px;
    right: 16px;
  }
  .a11y-widget__panel {
    right: 16px;
    bottom: calc(40px + 52px + 10px);
    max-height: 80vh;
  }
}
