/* ══════════════════════════════════════════════════════════════════════════
   Accessibility panel (סרגל נגישות) — includes/partials/accessibility_panel.php
   + assets/js/a11y.js. Two halves: the panel UI (.a11yx) and the page-wide
   state rules (html.a11y-*), which head.php applies before first paint.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Openers ─────────────────────────────────────────────────────────────── */
.sp-a11y-btn,
.icon-btn--a11y {
  position: relative;
  width: 34px; height: 34px; padding: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 0;
  background: rgba(30,29,38,.72);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  backdrop-filter: blur(22px) saturate(140%);
  color: #fff;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 6px 16px rgba(0,0,0,.32);
  transition: transform .15s ease, border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.sp-a11y-btn svg,
.icon-btn--a11y svg { width: 17px; height: 17px; }
.sp-a11y-btn:hover,
.icon-btn--a11y:hover {
  transform: translateY(-1px);
  background: rgba(46,43,62,.85);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 0 0 4px rgba(184,102,205,.16), 0 6px 16px rgba(0,0,0,.34);
}
.sp-a11y-btn:active,
.icon-btn--a11y:active { transform: scale(.94); }
.sp-a11y-btn[aria-expanded="true"],
.icon-btn--a11y[aria-expanded="true"] {
  background: linear-gradient(135deg, #b866cd 0%, #8269df 100%);
  box-shadow: 0 0 0 4px rgba(184,102,205,.22), 0 6px 18px rgba(130,105,223,.4);
}
.sp-a11y-btn:focus-visible,
.icon-btn--a11y:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
/* phones reach the panel from the hamburger menu */
@media (max-width: 900px) { .icon-btn--a11y { display: none; } }

/* ── Panel ───────────────────────────────────────────────────────────────── */
.a11yx {
  --ax-tile: rgba(255,255,255,.07);
  --ax-tile-hover: rgba(255,255,255,.11);
  --ax-text: #fff;
  --ax-text-2: #b9b3c0;
  --ax-accent: #b866cd;
  --ax-accent-2: #8269df;
  --ax-grad: linear-gradient(135deg, #b866cd 0%, #8269df 100%);
  --ax-arrow: 40px;
  position: fixed;
  z-index: 100000;
  inset: auto 16px 16px auto;
  width: 392px;
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px;
  box-sizing: border-box;
  color: var(--ax-text);
  /* same smoked glass as the AI assistant panel (.aia-panel) */
  background:
    radial-gradient(120% 60% at 50% 22%, rgba(150,135,230,.14) 0, transparent 60%),
    linear-gradient(180deg, rgba(40,38,54,.58) 0%, rgba(24,23,32,.68) 55%, rgba(16,15,22,.76) 100%);
  -webkit-backdrop-filter: blur(36px) saturate(165%);
  backdrop-filter: blur(36px) saturate(165%);
  border: 0;
  border-radius: 30px;
  box-shadow: 0 40px 100px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.1), inset 0 0 0 1px rgba(255,255,255,.035);
  font: 500 14px/1.35 var(--sp-font, "Google Sans", "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif);
  text-align: start;
  animation: a11yx-in .22s cubic-bezier(.2,.9,.3,1.2);
  transform-origin: var(--ax-origin, 50% 100%);
}
.a11yx[hidden], .a11yx-backdrop[hidden] { display: none !important; }
.a11yx *, .a11yx *::before, .a11yx *::after { box-sizing: border-box; }
.a11yx button { font: inherit; color: inherit; margin: 0; -webkit-tap-highlight-color: transparent; }
.a11yx svg { display: block; }
.a11yx :focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@keyframes a11yx-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }

/* desktop: anchored under the topbar icon (JS sets top/left + arrow offset) */
.a11yx.is-anchored { inset: auto; --ax-origin: var(--ax-arrow) 0; }
.a11yx__arrow { display: none; }
.a11yx.is-anchored .a11yx__arrow {
  display: block;
  position: absolute; top: -7px; left: var(--ax-arrow);
  width: 14px; height: 14px; margin-left: -7px;
  background: rgba(46,43,62,.9);
  -webkit-backdrop-filter: blur(36px);
  backdrop-filter: blur(36px);
  transform: rotate(45deg);
  border-radius: 3px 0 0 0;
}

.a11yx__head { display: flex; align-items: center; gap: 12px; padding: 2px 2px 14px; }
.a11yx__badge {
  flex: 0 0 auto;
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--ax-grad);
  box-shadow: 0 8px 20px rgba(130,105,223,.35), inset 0 1px 0 rgba(255,255,255,.25);
}
.a11yx__badge svg { width: 21px; height: 21px; color: #fff; }
.a11yx__titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.a11yx__titles strong { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.a11yx__titles span { color: var(--ax-text-2); font-size: 12.5px; }
.a11yx__close {
  flex: 0 0 auto; width: 34px; height: 34px; padding: 0;
  display: grid; place-items: center; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.07); cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.a11yx__close:hover { background: rgba(255,255,255,.15); transform: rotate(90deg); }
.a11yx__close svg { width: 16px; height: 16px; }

/* text size */
.a11yx__size {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border-radius: 20px;
  background: var(--ax-tile);
}
.a11yx__size-label { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.a11yx__size-label svg { width: 20px; height: 20px; color: #d5b3f0; }
.a11yx__stepper {
  display: flex; align-items: center; gap: 2px; padding: 3px;
  border-radius: 999px; background: rgba(0,0,0,.28);
}
.a11yx__stepper button {
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: transparent; cursor: pointer;
  transition: background .15s ease;
}
.a11yx__stepper button:hover:not(:disabled) { background: rgba(255,255,255,.12); }
.a11yx__stepper button:disabled { opacity: .3; cursor: default; }
.a11yx__stepper button svg { width: 15px; height: 15px; }
.a11yx__stepper .a11yx__size-val { width: auto; min-width: 54px; padding: 0 6px; border-radius: 999px; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 13px; }
.a11yx__meter { grid-column: 1 / -1; display: flex; gap: 4px; }
.a11yx__meter i { flex: 1; height: 4px; border-radius: 4px; background: rgba(255,255,255,.1); transition: background .2s ease; }
.a11yx__meter i.is-on { background: var(--ax-grad); }

/* toggle tiles */
.a11yx__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.a11yx__tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 92px; padding: 12px 6px 10px;
  border-radius: 20px;
  border: 0;
  background: var(--ax-tile);
  cursor: pointer;
  text-align: center;
  transition: background .18s ease, border-color .18s ease, transform .12s ease;
}
/* an orphan in the last row becomes a full-width strip */
.a11yx__tile:last-child:nth-child(3n+1) { grid-column: 1 / -1; flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 58px; padding: 9px 12px; text-align: start; }
.a11yx__tile:last-child:nth-child(3n+1) .a11yx__check { top: 50%; margin-top: -9px; inset-inline-end: 14px; }
.a11yx__tile:hover { background: var(--ax-tile-hover); }
.a11yx__tile:active { transform: scale(.96); }
.a11yx__ic {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.08);
  color: #e9e4ee;
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}
.a11yx__ic svg { width: 21px; height: 21px; }
.a11yx__tl { font-size: 12.5px; font-weight: 700; line-height: 1.25; color: #ece8f0; }
.a11yx__check {
  position: absolute; top: 7px; inset-inline-end: 7px;
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  background: #fff; color: #6b3fa8;
  opacity: 0; transform: scale(.4);
  transition: opacity .18s ease, transform .22s cubic-bezier(.2,.9,.3,1.4);
}
.a11yx__check svg { width: 11px; height: 11px; }
.a11yx__tile[aria-pressed="true"] {
  background: linear-gradient(135deg, rgba(184,102,205,.26) 0%, rgba(130,105,223,.26) 100%);
}
.a11yx__tile[aria-pressed="true"] .a11yx__ic { background: var(--ax-grad); color: #fff; box-shadow: 0 6px 16px rgba(130,105,223,.38); }
.a11yx__tile[aria-pressed="true"] .a11yx__check { opacity: 1; transform: scale(1); }

.a11yx__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 2px 2px; }
.a11yx__reset {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; border-radius: 999px;
  border: 0; background: rgba(255,255,255,.08);
  font-weight: 800 !important; font-size: 13px !important; cursor: pointer;
  transition: background .15s ease;
}
.a11yx__reset:hover { background: rgba(255,255,255,.14); }
.a11yx__reset svg { width: 15px; height: 15px; }
.a11yx__statement { color: #d5b3f0 !important; font-size: 13px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.a11yx__statement:hover { color: #fff !important; }
.a11yx__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* phones: bottom sheet over a dimmed page */
.a11yx-backdrop { position: fixed; inset: 0; z-index: 99999; background: rgba(0,0,0,.5); animation: a11yx-fade .2s ease; }
@keyframes a11yx-fade { from { opacity: 0; } }
@media (max-width: 900px) {
  .a11yx {
    inset: auto 0 0 0; width: 100%; max-width: none;
    max-height: 88dvh;
    padding: 10px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    border-radius: 30px 30px 0 0;
    animation: a11yx-up .28s cubic-bezier(.2,.9,.3,1);
  }
  .a11yx::before { content: ""; display: block; width: 40px; height: 4px; margin: 0 auto 10px; border-radius: 4px; background: rgba(255,255,255,.22); }
  .a11yx__tile { min-height: 84px; }
  @keyframes a11yx-up { from { transform: translateY(100%); } }
}
@media (min-width: 901px) { .a11yx-backdrop { display: none !important; } }

/* ══ Page-wide states (classes on <html>) ═══════════════════════════════════ */

/* text size — zoom the content area so px-based layouts scale too */
html.a11y-fs .sp-content,
html.a11y-fs body:not(:has(.sp-content)) main { zoom: var(--a11y-zoom, 1); }

/* colour filters live on <html>: the root never becomes a containing block,
   so fixed bars and this panel stay pinned to the viewport */
html.a11y-contrast { --a11y-f-contrast: contrast(1.45) saturate(1.15); }
html.a11y-gray { --a11y-f-gray: grayscale(1); }
html.a11y-contrast,
html.a11y-gray { filter: var(--a11y-f-contrast,) var(--a11y-f-gray,); }
html.a11y-contrast :is(p, li, dd, span, small):not(.a11yx *) { text-shadow: none !important; }

html.a11y-links a:not(.a11yx *) {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 3px !important;
  outline: 2px solid #facc15 !important;
  outline-offset: 2px;
  border-radius: 3px;
}

html.a11y-headings :is(h1, h2, h3, h4, h5, h6):not(.a11yx *) {
  outline: 2px dashed #7dd3fc !important;
  outline-offset: 4px;
  background-color: rgba(125,211,252,.1) !important;
  border-radius: 4px;
}

html.a11y-readable body,
html.a11y-readable body *:not(svg, svg *, i, .fa, [class*="fa-"]) {
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif !important;
}

html.a11y-spacing :is(p, li, dd, dt, blockquote, td, th, label, h1, h2, h3, h4, h5, h6):not(.a11yx *) {
  line-height: 1.8 !important;
  letter-spacing: .04em !important;
  word-spacing: .14em !important;
}
html.a11y-spacing p:not(.a11yx *) { margin-bottom: 1.6em !important; }

html.a11y-cursor,
html.a11y-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'%3E%3Cpath d='M7 4l29 14.5-12.6 3.4L18 34z' fill='%23000' stroke='%23fff' stroke-width='2.6' stroke-linejoin='round'/%3E%3C/svg%3E") 7 4, auto !important;
}
html.a11y-cursor :is(a, button, [role="button"], label, select, summary),
html.a11y-cursor :is(a, button, [role="button"], label, select, summary) * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'%3E%3Cpath d='M7 4l29 14.5-12.6 3.4L18 34z' fill='%23facc15' stroke='%23000' stroke-width='2.6' stroke-linejoin='round'/%3E%3C/svg%3E") 7 4, pointer !important;
}

html.a11y-motion *,
html.a11y-motion *::before,
html.a11y-motion *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  scroll-behavior: auto !important;
}

html.a11y-focus :focus,
html.a11y-focus :focus-visible {
  outline: 3px solid #facc15 !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 7px rgba(0,0,0,.85) !important;
}

/* reading mask: a clear band follows the pointer, the rest of the page dims */
.a11yx-guide {
  position: fixed; left: 0; right: 0; top: 0;
  height: 120px; margin-top: -60px;
  z-index: 99998;
  pointer-events: none;
  border-block: 2px solid rgba(250,204,21,.85);
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.6);
  transform: translateY(var(--a11y-guide-y, 50vh));
  will-change: transform;
}
