/* ==========================================================================
   Farmerim self-hosted accessibility widget
   Replaces the external negishim.com module. No external requests, no
   per-element DOM attributes. All state is held as classes on <html> plus a
   --a11y-zoom custom property; persisted in localStorage (see accessibility.js).
   ========================================================================== */

/* --- Page-level effects (applied to <html>) ------------------------------ */

/* Text/display size. zoom on <html> scales content uniformly while keeping
   viewport-anchored fixed elements (cookie bar, this widget) correct. */
html {
  zoom: var(--a11y-zoom, 1);
}

/* Grayscale / monochrome. filter must live on <html> (not <body>) so fixed
   descendants stay anchored to the viewport. */
html.a11y-grayscale {
  filter: grayscale(100%);
}

/* High contrast: black background, white text, yellow links. The widget
   itself is excluded so it stays usable. */
html.a11y-contrast body *:not(.a11y-root):not(.a11y-root *) {
  background-color: #000 !important;
  color: #fff !important;
  border-color: #fff !important;
  text-shadow: none !important;
  box-shadow: none !important;
}
html.a11y-contrast body {
  background: #000 !important;
}
html.a11y-contrast body a:not(.a11y-root *),
html.a11y-contrast body a:not(.a11y-root *) * {
  color: #ff0 !important;
}
html.a11y-contrast body input,
html.a11y-contrast body select,
html.a11y-contrast body textarea {
  background-color: #000 !important;
  color: #fff !important;
  border: 1px solid #fff !important;
}

/* Highlight links: force underline + clearer focus on every link. */
html.a11y-links body a:not(.a11y-root *) {
  text-decoration: underline !important;
}

/* Readable font: swap to a high-legibility sans and loosen spacing. */
html.a11y-readable body *:not(.a11y-root):not(.a11y-root *):not(i):not(.fa):not([class*="fa-"]) {
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif !important;
  letter-spacing: 0.02em !important;
  line-height: 1.7 !important;
}

/* Stop animations / transitions for vestibular comfort. */
html.a11y-no-anim *,
html.a11y-no-anim *::before,
html.a11y-no-anim *::after {
  animation-duration: 0s !important;
  animation-delay: 0s !important;
  transition-duration: 0s !important;
  transition-delay: 0s !important;
  scroll-behavior: auto !important;
}

/* Large cursor. */
html.a11y-big-cursor,
html.a11y-big-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' stroke='%23fff' stroke-width='1' d='M5 2l14 7-6 1.5L17 18l-3 1.5-3.5-7L5 16z'/%3E%3C/svg%3E") 4 2, auto !important;
}

/* --- The widget itself --------------------------------------------------- */

.a11y-root {
  position: fixed;
  top: 165px;
  /* RTL (Hebrew): top-left. LTR (English): mirrored to top-right (below). */
  left: 0;
  z-index: 2147483000;
  /* Counter the page zoom so the widget keeps a constant size. */
  zoom: var(--a11y-inv-zoom, 1);
  font-family: "Rubik", Arial, sans-serif;
  direction: rtl;
}
html[dir="ltr"] .a11y-root {
  left: auto;
  right: 0;
  direction: ltr;
}

.a11y-fab {
  appearance: none;
  border: 0;
  width: 48px;
  height: 48px;
  /* Flat side flush to the page edge, rounded corners facing into the page.
     RTL: flat-left. LTR override below: flat-right. */
  border-radius: 0 8px 8px 0;
  background: #1f5f2f;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: background 0.15s ease;
}
html[dir="ltr"] .a11y-fab {
  border-radius: 8px 0 0 8px;
}
.a11y-fab:hover,
.a11y-fab:focus-visible {
  background: #174722;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.a11y-panel {
  position: absolute;
  top: 0;
  left: 52px;
  width: 290px;
  /* LTR override (right edge) flips the panel to open leftwards — see below. */
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #d6e3d6;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  padding: 14px;
  display: none;
}
html[dir="ltr"] .a11y-panel {
  left: auto;
  right: 52px;
}
.a11y-root.is-open .a11y-panel {
  display: block;
}

.a11y-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.a11y-panel__title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: #1f5f2f;
}
.a11y-panel__close {
  appearance: none;
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #555;
  padding: 4px 8px;
  border-radius: 6px;
}
.a11y-panel__close:hover,
.a11y-panel__close:focus-visible {
  background: #f0f0f0;
  outline: 2px solid #1f5f2f;
}

.a11y-size {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.a11y-size__label {
  font-size: 13px;
  color: #555;
  flex: 1;
}
.a11y-size__val {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-width: 44px;
  text-align: center;
}
.a11y-size button {
  appearance: none;
  border: 1px solid #1f5f2f;
  background: #fff;
  color: #1f5f2f;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.a11y-size button:hover,
.a11y-size button:focus-visible {
  background: #1f5f2f;
  color: #fff;
  outline: none;
}

.a11y-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.a11y-toggle {
  appearance: none;
  border: 1px solid #d6e3d6;
  background: #f7fff4;
  color: #1a1a1a;
  border-radius: 8px;
  padding: 10px 8px;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 64px;
  justify-content: center;
}
.a11y-toggle i {
  font-size: 20px;
  color: #1f5f2f;
}
.a11y-toggle:hover,
.a11y-toggle:focus-visible {
  border-color: #1f5f2f;
  outline: none;
}
.a11y-toggle[aria-pressed="true"] {
  background: #1f5f2f;
  color: #fff;
  border-color: #1f5f2f;
}
.a11y-toggle[aria-pressed="true"] i {
  color: #fff;
}

.a11y-footer {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.a11y-reset {
  appearance: none;
  border: 1px solid #c0392b;
  background: #fff;
  color: #c0392b;
  border-radius: 8px;
  padding: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.a11y-reset:hover,
.a11y-reset:focus-visible {
  background: #c0392b;
  color: #fff;
  outline: none;
}
.a11y-statement {
  text-align: center;
  font-size: 13px;
  color: #1f5f2f;
  text-decoration: underline;
}

@media (max-width: 480px) {
  .a11y-panel {
    width: 84vw;
  }
  .a11y-root {
    top: 50px !important;
  }
}
