/* ============================================================
   Accessibility Toolbar - self-hosted, no external vendor
   Built for funsiam.com

   HOW TO CUSTOMIZE:
   Change the values in :root below to match your brand colors
   and to move the button if it overlaps something else on the
   page (e.g. a WhatsApp floating button).
   ============================================================ */

:root {
  --a11y-accent: #2f6feb;        /* main button + active-state color   */
  --a11y-accent-dark: #1d4fb0;   /* hover color                        */
  --a11y-focus-ring: #ffbf47;    /* keyboard focus outline color       */
  --a11y-bg: #ffffff;
  --a11y-text: #1a1a1a;
  --a11y-border: #d8d8d8;
  --a11y-radius: 10px;
  --a11y-font: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --a11y-z: 999999;              /* trigger button stacking order      */

  /* Position of the floating trigger button.
     inset-inline-start = "left" in LTR, "right" in RTL (auto-mirrors
     for the Hebrew site, no extra work needed). */
  --a11y-offset-side: 16px;
  --a11y-offset-bottom: 16px;
}

/* ---------------- Trigger button ---------------- */

#a11y-toggle-btn {
  position: fixed;
  inset-inline-start: var(--a11y-offset-side);
  bottom: var(--a11y-offset-bottom);
  z-index: var(--a11y-z);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--a11y-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, background-color 0.15s ease;
  padding: 0;
}

#a11y-toggle-btn:hover {
  background: var(--a11y-accent-dark);
  transform: scale(1.05);
}

#a11y-toggle-btn:focus-visible {
  outline: 3px solid var(--a11y-focus-ring);
  outline-offset: 3px;
}

.a11y-toggle-icon {
  font-size: 26px;
  line-height: 1;
}

@media (prefers-reduced-motion: reduce) {
  #a11y-toggle-btn {
    transition: none;
  }
  #a11y-toggle-btn:hover {
    transform: none;
  }
}

/* ---------------- Panel (native <dialog>) ---------------- */

#a11y-panel {
  font-family: var(--a11y-font);
  color: var(--a11y-text);
  background: var(--a11y-bg);
  border: 1px solid var(--a11y-border);
  border-radius: var(--a11y-radius);
  padding: 0;
  width: min(360px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 32px));
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

#a11y-panel::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

#a11y-panel[open] {
  display: flex;
  flex-direction: column;
}

.a11y-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--a11y-border);
  flex-shrink: 0;
}

.a11y-panel-header h2 {
  font-size: 17px;
  margin: 0;
  font-weight: 700;
}

.a11y-close-btn {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--a11y-text);
  padding: 6px 10px;
  border-radius: 6px;
}

.a11y-close-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.a11y-close-btn:focus-visible {
  outline: 3px solid var(--a11y-accent);
  outline-offset: 2px;
}

.a11y-panel-body {
  padding: 12px 16px 16px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
}

.a11y-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--a11y-border);
  border-radius: 8px;
}

.a11y-row-label {
  font-size: 14px;
}

/* ---------------- Font-size stepper ---------------- */

.a11y-stepper {
  display: flex;
  gap: 4px;
}

.a11y-stepper button {
  min-width: 40px;
  height: 34px;
  border: 1px solid var(--a11y-border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--a11y-text);
}

.a11y-stepper button[aria-pressed="true"] {
  background: var(--a11y-accent);
  border-color: var(--a11y-accent);
  color: #fff;
}

.a11y-stepper button:focus-visible {
  outline: 3px solid var(--a11y-accent);
  outline-offset: 2px;
}

/* ---------------- Toggle switch ---------------- */

.a11y-switch {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--a11y-border);
  background: #e6e6e6;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.a11y-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: inset-inline-start 0.15s ease;
}

.a11y-switch[aria-checked="true"] {
  background: var(--a11y-accent);
  border-color: var(--a11y-accent);
}

.a11y-switch[aria-checked="true"]::after {
  inset-inline-start: 22px;
}

.a11y-switch:focus-visible {
  outline: 3px solid var(--a11y-focus-ring);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .a11y-switch::after {
    transition: none;
  }
}

.a11y-reset-btn {
  margin-top: 4px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--a11y-border);
  background: #f4f4f4;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--a11y-text);
}

.a11y-reset-btn:hover {
  background: #ebebeb;
}

.a11y-reset-btn:focus-visible {
  outline: 3px solid var(--a11y-accent);
  outline-offset: 2px;
}

/* ============================================================
   MODES applied to <html> - these affect the whole site, not
   just the panel. This is the part that does the actual work.
   ============================================================ */

html.a11y-fs-2 {
  --a11y-font-scale: 1.18;
}

html.a11y-fs-3 {
  --a11y-font-scale: 1.35;
}

html.a11y-contrast body {
  background: #000 !important;
  color: #fff !important;
}

html.a11y-contrast body * {
  background-color: #000 !important;
  color: #fff !important;
  border-color: #fff !important;
}

html.a11y-contrast a,
html.a11y-contrast a * {
  color: #ffe14d !important;
}

html.a11y-grayscale body {
  filter: grayscale(1);
}

html.a11y-invert body {
  filter: invert(1) hue-rotate(180deg);
}

/* re-invert media so photos/videos don't look like photo negatives */
html.a11y-invert img,
html.a11y-invert video,
html.a11y-invert picture {
  filter: invert(1) hue-rotate(180deg);
}

html.a11y-stop-anim *,
html.a11y-stop-anim *::before,
html.a11y-stop-anim *::after {
  animation-duration: 0s !important;
  animation-delay: 0s !important;
  transition-duration: 0s !important;
  transition-delay: 0s !important;
  scroll-behavior: auto !important;
}

html.a11y-readable-font body {
  font-family: Arial, Helvetica, sans-serif !important;
}

html.a11y-readable-font p,
html.a11y-readable-font span:not([class*="fa-"]):not([class^="fa"]):not([class*="eicon"]),
html.a11y-readable-font a,
html.a11y-readable-font li,
html.a11y-readable-font h1,
html.a11y-readable-font h2,
html.a11y-readable-font h3,
html.a11y-readable-font h4,
html.a11y-readable-font h5,
html.a11y-readable-font h6,
html.a11y-readable-font button,
html.a11y-readable-font input,
html.a11y-readable-font textarea,
html.a11y-readable-font select,
html.a11y-readable-font label {
  font-family: Arial, Helvetica, sans-serif !important;
  letter-spacing: 0.01em !important;
  line-height: 1.6 !important;
}

html.a11y-readable-font .fa,
html.a11y-readable-font .fas,
html.a11y-readable-font .far,
html.a11y-readable-font .fab,
html.a11y-readable-font [class*="fa-"],
html.a11y-readable-font [class*="eicon"] {
  letter-spacing: normal !important;
  line-height: 1 !important;
}

html.a11y-underline-links a {
  text-decoration: underline !important;
  text-underline-offset: 2px !important;
}

/* === Fun Siam accessibility fixes === */

/* High contrast: preserve media and accessibility UI */
html.a11y-contrast body {
  background: #000 !important;
  color: #fff !important;
}

html.a11y-contrast body *:not(#a11y-panel):not(#a11y-panel *):not(#a11y-toggle-btn):not(#a11y-toggle-btn *) {
  background-color: #000 !important;
  color: #fff !important;
  border-color: #fff !important;
}

html.a11y-contrast body a:not(#a11y-panel a),
html.a11y-contrast body a:not(#a11y-panel a) * {
  color: #ffe14d !important;
}

html.a11y-contrast img,
html.a11y-contrast picture,
html.a11y-contrast video,
html.a11y-contrast svg {
  background-color: transparent !important;
}

/* Underline mode: text links + visible outline for image links */
html.a11y-underline-links a {
  text-decoration: underline !important;
  text-underline-offset: 3px !important;
  text-decoration-thickness: 2px !important;
}

html.a11y-underline-links a img,
html.a11y-underline-links a picture {
  outline: 3px solid currentColor !important;
  outline-offset: 3px !important;
}

.a11y-statement-link {
  display: block;
  margin-top: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  text-align: center;
  color: var(--a11y-accent);
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.a11y-statement-link:hover {
  background: rgba(47, 111, 235, 0.08);
}

.a11y-statement-link:focus-visible {
  outline: 3px solid var(--a11y-focus-ring);
  outline-offset: 2px;
}

/* === Compact accessibility panel === */

#a11y-panel {
  max-height: calc(100vh - 24px);
}

.a11y-panel-header {
  padding: 10px 14px;
}

.a11y-panel-body {
  padding: 8px 12px 10px;
  gap: 6px;
  overflow-y: visible;
}

.a11y-row {
  padding: 7px 10px;
  min-height: 38px;
}

.a11y-row-label {
  font-size: 13.5px;
}

.a11y-stepper button {
  height: 32px;
  min-width: 38px;
}

.a11y-switch {
  width: 42px;
  height: 22px;
}

.a11y-switch::after {
  width: 16px;
  height: 16px;
}

.a11y-switch[aria-checked="true"]::after {
  inset-inline-start: 22px;
}

.a11y-reset-btn {
  padding: 8px 10px;
  margin-top: 2px;
}

.a11y-statement-link {
  padding: 7px 10px;
  margin-top: 0;
}

/* Safety fallback for very short screens */
@media (max-height: 590px) {
  .a11y-panel-body {
    overflow-y: auto;
  }

  #a11y-panel {
    max-height: calc(100vh - 16px);
  }
}

/* === Premium accessibility trigger === */

#a11y-toggle-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  background: linear-gradient(135deg, #087fbe 0%, #36a7ff 100%);
  box-shadow:
    0 8px 22px rgba(8, 128, 191, 0.28),
    0 2px 6px rgba(36, 55, 70, 0.15);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    filter 0.2s ease;
}

#a11y-toggle-btn:hover {
  background: linear-gradient(135deg, #087fbe 0%, #36a7ff 100%);
  transform: translateY(-2px) scale(1.03);
  box-shadow:
    0 12px 28px rgba(8, 128, 191, 0.34),
    0 3px 8px rgba(36, 55, 70, 0.18);
  filter: brightness(1.04);
}

#a11y-toggle-btn:active {
  transform: translateY(0) scale(0.97);
}

.a11y-toggle-icon {
  width: 27px;
  height: 27px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
}

.a11y-toggle-icon svg {
  display: block;
  width: 27px;
  height: 27px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 767px) {
  #a11y-toggle-btn {
    width: 46px;
    height: 46px;
    border-radius: 15px;
  }

  .a11y-toggle-icon,
  .a11y-toggle-icon svg {
    width: 25px;
    height: 25px;
  }
}
