/**
 * accessibility.css — Israeli-regulation-compliant accessibility widget
 * IS 5568 / WCAG 2.0 AA
 * Uses CSS logical properties for automatic RTL support.
 */

/* ══════════════════════════════════════════════════
   TOKENS
══════════════════════════════════════════════════ */
:root {
  --a11y-bg:        #001356;
  --a11y-accent:    #C4A866;
  --a11y-hover:     #183AAD;
  --a11y-white:     #ffffff;
  --a11y-panel-w:   300px;
  --a11y-radius:    8px;
  --a11y-z:         9999;
}

/* ══════════════════════════════════════════════════
   TRIGGER BUTTON — fixed to left edge, vertically centred
   Physical properties used here because writing-mode: vertical-rl
   changes how logical properties resolve (block axis becomes horizontal).
══════════════════════════════════════════════════ */
.a11y-trigger {
  position: fixed;
  bottom: 80px;
  left: 0;
  z-index: var(--a11y-z);

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;

  padding: 10px 8px;
  background: var(--a11y-bg);
  color: var(--a11y-white);
  border: none;
  border-radius: 0 var(--a11y-radius) var(--a11y-radius) 0;
  cursor: pointer;

  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.5px;
  line-height: 1;
  white-space: nowrap;
  writing-mode: vertical-rl;

  transition: background 0.2s ease, padding 0.2s ease;
}

.a11y-trigger:hover,
.a11y-trigger:focus-visible {
  background: var(--a11y-hover);
  padding-right: 12px;
  outline: none;
}

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

/* RTL: move to right edge, flip rounded corners and hover padding */
[dir="rtl"] .a11y-trigger {
  left: auto;
  right: 0;
  border-radius: var(--a11y-radius) 0 0 var(--a11y-radius);
  writing-mode: vertical-lr;
}

[dir="rtl"] .a11y-trigger:hover,
[dir="rtl"] .a11y-trigger:focus-visible {
  padding-right: 8px;
  padding-left: 12px;
}

.a11y-trigger__icon {
  width: 26px;
  height: 26px;
  writing-mode: horizontal-tb;
  flex-shrink: 0;
  margin-bottom: 4px;
}

.a11y-trigger__label {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ══════════════════════════════════════════════════
   BACKDROP
══════════════════════════════════════════════════ */
.a11y-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--a11y-z) + 1);
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.a11y-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ══════════════════════════════════════════════════
   PANEL
══════════════════════════════════════════════════ */
.a11y-panel {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--a11y-panel-w);
  max-width: 90vw;
  z-index: calc(var(--a11y-z) + 2);

  background: var(--a11y-bg);
  color: var(--a11y-white);
  overflow-y: auto;
  overflow-x: hidden;

  transform: translateX(-110%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  display: flex;
  flex-direction: column;
  padding: 0 0 24px;
}

/* RTL: base inset-inline-start:0 already resolves to right:0 in RTL.
   Only flip the off-screen translate direction. */
[dir="rtl"] .a11y-panel {
  transform: translateX(110%);
}

.a11y-panel.is-open {
  transform: translateX(0);
}

/* ── Panel header ── */
.a11y-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(196, 168, 102, 0.3);
  position: sticky;
  top: 0;
  background: var(--a11y-bg);
  z-index: 1;
}

.a11y-panel__title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--a11y-accent);
}

.a11y-panel__close {
  background: none;
  border: none;
  color: var(--a11y-white);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 10px 12px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.a11y-panel__close:hover {
  background: rgba(255, 255, 255, 0.12);
}

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

/* ── Sections inside panel ── */
.a11y-section {
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.a11y-section__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(196, 168, 102, 0.85);
  margin-bottom: 10px;
}

/* ── Font size row ── */
.a11y-font-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.a11y-font-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(196, 168, 102, 0.4);
  color: var(--a11y-white);
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.a11y-font-btn:hover {
  background: var(--a11y-hover);
  border-color: var(--a11y-accent);
}

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

.a11y-font-val {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: var(--a11y-white);
  min-width: 36px;
}

/* ── Tool toggle buttons ── */
.a11y-tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.a11y-tool {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--a11y-white);
  border-radius: 5px;
  padding: 9px 14px;
  font-size: 13px;
  font-family: inherit;
  text-align: start;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.a11y-tool::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1.5px solid rgba(196, 168, 102, 0.6);
  border-radius: 3px;
  flex-shrink: 0;
  background: transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.a11y-tool:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--a11y-accent);
}

.a11y-tool[aria-pressed="true"] {
  background: rgba(196, 168, 102, 0.18);
  border-color: var(--a11y-accent);
  color: var(--a11y-accent);
}

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

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

/* ── Reset button ── */
.a11y-reset {
  display: block;
  width: calc(100% - 40px);
  margin: 20px 20px 8px;
  padding: 11px 16px;
  background: rgba(196, 168, 102, 0.12);
  border: 1px solid var(--a11y-accent);
  color: var(--a11y-accent);
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}

.a11y-reset:hover {
  background: rgba(196, 168, 102, 0.25);
}

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

/* ── Statement link ── */
.a11y-stmt-link {
  display: block;
  text-align: center;
  margin: 4px 20px 0;
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  text-decoration: none;
  letter-spacing: 0.5px;
  transition: color 0.15s ease;
}

.a11y-stmt-link:hover {
  color: var(--a11y-white);
  text-decoration: underline;
}

.a11y-stmt-link:focus-visible {
  outline: 2px solid var(--a11y-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ══════════════════════════════════════════════════
   ACCESSIBILITY MODE CLASSES (applied to <html>)
══════════════════════════════════════════════════ */

/* ── Font size ── */
html.a11y-font-md { font-size: 18px; }
html.a11y-font-lg { font-size: 20px; }
html.a11y-font-xl { font-size: 24px; }

/* ── Visual filters — single ── */
html.a11y-contrast { filter: contrast(170%); }
html.a11y-invert   { filter: invert(100%) hue-rotate(180deg); }
html.a11y-grayscale { filter: grayscale(100%); }

/* ── Visual filters — combined (order matters: last definition wins) ── */
html.a11y-grayscale.a11y-contrast  { filter: grayscale(100%) contrast(170%); }
html.a11y-grayscale.a11y-invert    { filter: grayscale(100%) invert(100%) hue-rotate(180deg); }
html.a11y-contrast.a11y-invert     { filter: contrast(170%) invert(100%) hue-rotate(180deg); }
html.a11y-grayscale.a11y-contrast.a11y-invert {
  filter: grayscale(100%) contrast(170%) invert(100%) hue-rotate(180deg);
}

/* ── Link underlines ── */
html.a11y-underline-links a {
  text-decoration: underline !important;
}

/* ── Focus highlight ── */
html.a11y-highlight-focus :focus {
  outline: 3px solid #FFD700 !important;
  outline-offset: 3px !important;
}

/* ── Readable font ── */
html.a11y-readable * {
  font-family: Arial, Helvetica, sans-serif !important;
}

/* ── Highlight headings ── */
html.a11y-highlight-headings h1,
html.a11y-highlight-headings h2,
html.a11y-highlight-headings h3,
html.a11y-highlight-headings h4 {
  outline: 2px dashed rgba(255, 215, 0, 0.6) !important;
  outline-offset: 4px;
}

/* ── No animations ── */
html.a11y-no-anim *,
html.a11y-no-anim *::before,
html.a11y-no-anim *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

html.a11y-no-anim {
  scroll-behavior: auto !important;
}

/* ══════════════════════════════════════════════════
   GLOBAL FOCUS-VISIBLE (gold outline on all interactive elements)
══════════════════════════════════════════════════ */
.a11y-trigger:focus-visible,
.a11y-panel__close:focus-visible,
.a11y-font-btn:focus-visible,
.a11y-tool:focus-visible,
.a11y-reset:focus-visible,
.a11y-stmt-link:focus-visible {
  outline: 2px solid #C4A866;
  outline-offset: 2px;
}
