/* ==========================================================================
   Net/a11y.css - accessibility widget (IS 5568 / Reg. 35), copied from
   claude-guide.html. It only toggles a11y-* classes on <html>; prefs are shared
   with the rest of the site in localStorage['nafi-site:a11y'].
   ========================================================================== */

/* the panel keeps the site's dark gold look on every Net theme */
#a11y-root {
  --bg2: #0e0e0e;
  --bg3: #161616;
  --border: rgba(201, 169, 110, 0.22);
  --border-strong: rgba(201, 169, 110, 0.45);
  --gold: #c9a96e;
  --cream: #f5f0e8;
  --text: #d4cfc7;
  --text-dim: #b3ada4;
  --font-body: "Rubik", "Segoe UI", system-ui, sans-serif;
  --font-serif: "Rubik", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Fira Code", ui-monospace, monospace;
  direction: rtl;
  text-align: right;
}

/* Net's base stylesheet gives headings and paragraphs fit-content widths */
#a11y-root :is(h1, h2, p, ul, li, a) { width: auto; max-width: none; margin-left: 0; }

/* ═══ ACCESSIBILITY WIDGET (IS 5568 / תקנה 35) ═══════
   כלי נוחות אישי: מחליף מחלקות a11y-* על <html> בלבד,
   לא מריץ שכבת תיקון אוטומטית ולא נוגע בתוכן הדף. */
html.a11y-links a {
  text-decoration: underline !important;
  text-underline-offset: 2px;
}

html.a11y-headings :is(h1, h2, h3, h4) {
  outline: 2px solid var(--color-accent, var(--neon-blue, #4f46e5));
  outline-offset: 3px;
  border-radius: 4px;
}

html.a11y-readable,
html.a11y-readable :is(body, button, input, select, textarea, a) {
  font-family: Arial, 'Segoe UI', Tahoma, system-ui, -apple-system, sans-serif !important;
  letter-spacing: .01em;
}

html.a11y-text-115 { font-size: 115%; }
html.a11y-text-130 { font-size: 130%; }
html.a11y-text-150 { font-size: 150%; }

html.a11y-lines-16 body { line-height: 1.6 !important; }
html.a11y-lines-20 body { line-height: 2 !important; }

html.a11y-cursor-black,
html.a11y-cursor-black * {
  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 d='M5 2 5 25 11 19 15 28 19 26 15 17 24 17z' fill='%23000' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E") 5 2, auto !important;
}

html.a11y-cursor-large,
html.a11y-cursor-large * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='52' height='52' viewBox='0 0 32 32'%3E%3Cpath d='M5 2 5 25 11 19 15 28 19 26 15 17 24 17z' fill='%23000' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E") 8 3, auto !important;
}

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

html.a11y-contrast-high,
html.a11y-contrast-high[data-theme] {
  --color-bg: #000;
  --color-bg-2: #000;
  --color-bg-3: #161616;
  --color-text: #fff;
  --color-cream: #fff;
  --color-muted: #f2f2f2;
  --color-accent: #ffe600;
  --color-accent-hover: #ffe600;
  --color-border: #fff;
  --color-code-inline-bg: #161616;
  --color-code-inline-text: #ffe600;
}

/* the interactive guides use their own variable names */
html.a11y-contrast-high body {
  --bg-main: #000;
  --bg-card: #000;
  --bg-editor: #000;
  --bg-header: #000;
  --text-main: #fff;
  --text-muted: #f2f2f2;
  --border-color: #fff;
  --border-accent: #fff;
  --neon-blue: #ffe600;
  --neon-pink: #fff;
  --neon-green: #6cff9c;
}

html.a11y-contrast-invert body> :not(#a11y-root) {
  filter: invert(1) hue-rotate(180deg);
}

html.a11y-contrast-invert body> :not(#a11y-root) :is(img, video) {
  filter: invert(1) hue-rotate(180deg);
}

html.a11y-contrast-mono body> :not(#a11y-root) {
  filter: grayscale(1);
}

#a11y-root { cursor: auto; }

#a11y-trigger {
  position: fixed;
  bottom: 20px;
  inset-inline-end: 20px;
  z-index: 9990;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .85);
  background: #1452ff;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  display: grid;
  place-items: center;
  transition: transform .18s ease, box-shadow .18s ease;
}

#a11y-trigger:hover { transform: scale(1.06); }

#a11y-trigger:focus-visible {
  outline: 3px solid #ffe600;
  outline-offset: 3px;
}

#a11y-trigger svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#a11y-panel {
  position: fixed;
  bottom: 20px;
  inset-inline-end: 20px;
  z-index: 9991;
  width: min(360px, calc(100vw - 32px));
  max-height: min(80vh, 640px);
  overflow-y: auto;
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

#a11y-panel[hidden] { display: none; }

.a11y-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.a11y-head h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--cream);
}

.a11y-head .a11y-sub {
  font-size: .68rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  direction: ltr;
}

.a11y-close {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 9px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.a11y-close:focus-visible,
.a11y-card:focus-visible,
.a11y-reset:focus-visible,
.a11y-stmt-link:focus-visible,
.foot-a11y:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.a11y-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.a11y-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: .74rem;
  line-height: 1.35;
  min-height: 82px;
  transition: border-color .15s ease, background .15s ease;
}

.a11y-card svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.a11y-card svg .f { fill: currentColor; stroke: none; }

.a11y-card .a11y-val {
  font-size: .62rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  min-height: .8em;
  direction: ltr;
}

.a11y-card[aria-pressed="true"],
.a11y-card.is-on {
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 16%, var(--bg3));
}

.a11y-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.a11y-reset {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: .82rem;
}

.a11y-stmt-link {
  font-size: .78rem;
  color: var(--gold);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-body);
}

#a11y-statement {
  position: fixed;
  inset: 0;
  z-index: 9995;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .6);
  padding: 20px;
}

#a11y-statement[hidden] { display: none; }

.a11y-stmt-box {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 26px;
}

.a11y-stmt-box h1 {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 400;
  color: var(--cream);
  margin-bottom: 12px;
}

.a11y-stmt-box h2 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--cream);
  margin: 20px 0 8px;
}

.a11y-stmt-box p,
.a11y-stmt-box li {
  font-size: .88rem;
  line-height: 1.75;
  color: var(--text-dim);
}

.a11y-stmt-box ul {
  padding-inline-start: 20px;
  margin: 6px 0;
}

.a11y-stmt-box a { color: var(--gold); }
.a11y-stmt-box .a11y-stmt-close { margin-top: 20px; }

.foot-a11y {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  background: none;
  border: none;
  font: inherit;
  padding: 0;
}

.foot-a11y:hover { color: var(--gold); }

.a11y-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media print {
  html[class*="a11y-"] body,
  html[class*="a11y-"] body>* { filter: none !important; }
  html[class*="a11y-text-"] { font-size: 100% !important; }
  html[class*="a11y-lines-"] body { line-height: 1.5 !important; }
  #a11y-trigger,
  #a11y-panel,
  #a11y-statement { display: none !important; }
}
