/* ── נגישות ופרטיות — מצבי תצוגה, תפריט הנגישות והודעת הפרטיות ─────────────
 *
 * (מקור: geniza-explorer/assets/a11y.css, מותאם לפלטה של הדשבורד)
 * נטען בכל דף אחרי assets/theme.css, כדי שהדריסות כאן ינצחו.
 *
 * שלושה חלקים:
 *   1. מצבי התצוגה — מחלקות על <html> שהתפריט מדליק ומכבה.
 *   2. עיצוב כפתור הנגישות והתפריט.
 *   3. עיצוב הודעת הפרטיות.
 *
 * כלל אחד שקובע את כל השאר: מצבי הצבע מיושמים בדריסת משתני הפלטה של
 * :root (assets/theme.css), ולא ב-filter על <html>. filter על אלמנט השורש
 * הופך אותו ל-containing block, וכל position:fixed בדף — כפתור הנגישות
 * והודעת הפרטיות בכלל זה — מפסיק להיצמד למסך ומתחיל לגלול עם הדף.
 * ────────────────────────────────────────────────────────────────────────── */

/* ── 0. גודל טקסט ────────────────────────────────────────────────────────────
 * שלוש מדרגות ב-font-size של השורש, באחוזים ולא ב-px: אחוזים מכפילים את
 * גודל הבסיס שהמשתמש הגדיר בדפדפן שלו במקום לדרוס אותו. עובד רק על מידות
 * ב-rem/em — כל font-size שמוגדר ב-px מתעלם מהפקד הזה לחלוטין. */
html              { font-size: 100%; }
html[data-fs="m"] { font-size: 112.5%; }
html[data-fs="l"] { font-size: 125%; }

/* ── 1. מצבי תצוגה ──────────────────────────────────────────────────────── */

/* ---- ניגודיות גבוהה: שחור על לבן ---- */
html.a11y-contrast {
  --bg-1:          #ffffff;
  --bg-2:          #ffffff;
  --surface:       #ffffff;
  --surface-2:     #ffffff;
  --text:          #000000;
  --text-2:        #000000;
  --text-3:        #1c1c1c;
  --header-a:      #000000;
  --header-b:      #000000;
  --header-text:   #ffffff;
  --accent:        #00307a;
  --accent-light:  #00307a;
  --accent-dark:   #00307a;
  --accent-deep:   #00307a;
  --accent-soft-a: #ffffff;
  --accent-soft-b: #ffffff;
  --hot:           #a00000;
  --link:          #00307a;
  --link-hover:    #000000;
  --border:        #000000;
  --border-2:      #000000;
  --card-border:   #000000;
  --chip-text:     #000000;
  --chip-hover:    #000000;
  --shadow-page:   none;
  --shadow-card:   none;
  --shadow-hero:   none;
}

/* ---- ניגודיות הפוכה: לבן על שחור ---- */
html.a11y-invert {
  --bg-1:          #000000;
  --bg-2:          #000000;
  --surface:       #000000;
  --surface-2:     #121212;
  --text:          #ffffff;
  --text-2:        #e2e2e2;
  --text-3:        #c9c9c9;
  --header-a:      #121212;
  --header-b:      #121212;
  --header-text:   #ffffff;
  --accent:        #8fc6f2;
  --accent-light:  #c9e4fa;
  --accent-dark:   #8fc6f2;
  --accent-deep:   #c9e4fa;
  --accent-soft-a: #0b1a2a;
  --accent-soft-b: #0b1a2a;
  --hot:           #ff8a80;
  --link:          #8fc6f2;
  --link-hover:    #c9e4fa;
  --border:        #5a5a5a;
  --border-2:      #6e6e6e;
  --card-border:   #5a5a5a;
  --chip-text:     #e2e2e2;
  --chip-hover:    #8fc6f2;
  --shadow-page:   none;
  --shadow-card:   none;
  --shadow-hero:   none;
}
/* קישור הדילוג לבן על --accent-dark. בניגודיות הפוכה --accent-dark בהיר,
   ולבן עליו כמעט נעלם — הקישור הראשון בדף, בדיוק במצב שמשתמש לקוי ראייה
   מדליק. הצבע נקבע לפי הרקע של כל מצב. */
html.a11y-invert .skip-link,
html.a11y-invert .skip-link:focus { color: #000 !important; }
/* באותו אופן: תווית הכפתור בפס הפרטיות והעיגול של כפתור הנגישות */
html.a11y-invert .a11y-fab { color: #000; }

/* ---- גווני אפור ----
 * filter על ילדי body ולא על body או html עצמם — ראו הערת הפתיחה.
 * הרכיבים שלנו מוחרגים כדי שהתפריט יישאר קריא בזמן שמסתכלים בו. */
html.a11y-mono body > *:not(.a11y-panel):not(.a11y-fab):not(.consent) {
  filter: grayscale(1);
}

/* ---- הדגשת קישורים ---- */
html.a11y-links a {
  text-decoration: underline !important;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px !important;
  font-weight: 600;
}
html.a11y-links a:hover,
html.a11y-links a:focus-visible { background: #fff3a8; color: #000; }
html.a11y-invert.a11y-links a:hover,
html.a11y-invert.a11y-links a:focus-visible { background: #4a3d00; color: #fff; }

/* ---- פונט קריא ----
 * גופני תצוגה (משיכות משתנות, ליגטורות) קשים בדיסלקציה ובראייה ירודה.
 * כאן הפקד מחליף את גופן המערכת ב-Arial אחיד ומבטל ליגטורות. */
html.a11y-readable body,
html.a11y-readable body * {
  font-family: Arial, 'Segoe UI', system-ui, sans-serif !important;
  font-variant-ligatures: none !important;
}

/* ---- ריווח מוגדל — הערכים של קריטריון 1.4.12 ---- */
html.a11y-spacing body,
html.a11y-spacing p,
html.a11y-spacing li,
html.a11y-spacing dd,
html.a11y-spacing dt,
html.a11y-spacing td,
html.a11y-spacing blockquote {
  line-height: 1.9 !important;
  letter-spacing: .12em !important;
  word-spacing: .16em !important;
}
html.a11y-spacing p { margin-bottom: 2em !important; }
html.a11y-spacing .a11y-panel * { letter-spacing: normal !important; word-spacing: normal !important; }

/* ---- עצירת אנימציות ---- */
html.a11y-still *,
html.a11y-still *::before,
html.a11y-still *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

/* ---- סמן גדול (SVG מוטבע — עובד גם בלי רשת) ---- */
html.a11y-cursor,
html.a11y-cursor * {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 32 32'><path d='M6 2l0 24 6-6 4 9 5-2-4-9 9 0z' fill='%23fff' stroke='%23000' stroke-width='2' stroke-linejoin='round'/></svg>") 4 2, auto !important;
}
html.a11y-cursor a,
html.a11y-cursor button,
html.a11y-cursor summary,
html.a11y-cursor [role="button"] {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 32 32'><path d='M12 2c-1.7 0-3 1.3-3 3v11l-2-2c-1.2-1.2-3-1.2-4 0-1 1.2-1 2.8 0 4l7 10h14l2-13c.2-1.6-1-3-2.6-3-1 0-1.9.6-2.3 1.4-.2-1.3-1.3-2.4-2.7-2.4-1 0-1.9.6-2.4 1.4V5c0-1.7-1.3-3-3-3z' fill='%23fff' stroke='%23000' stroke-width='2' stroke-linejoin='round'/></svg>") 10 2, pointer !important;
}

/* ---- הדגשת מיקוד ----
 * טבעת כפולה, כתום על שחור: הכתום לבדו נותן 1.8:1 על לבן ואינו עומד
 * ב-1.4.11. הטבעת השחורה שסביבו היא שמבטיחה ניגודיות על כל רקע. */
html.a11y-focus :focus,
html.a11y-focus :focus-visible {
  outline: 4px solid #ffb300 !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 3px #000 !important;
  border-radius: 2px;
}

/* ── 2. כפתור הנגישות והתפריט ────────────────────────────────────────────
 * הצבעים נלקחים מהפלטה של האתר, עם ערכי גיבוי לכל משתנה — כך התפריט
 * מתחלף יחד עם מצבי התצוגה בלי כלל נפרד לכל מצב, וממשיך להיראות נכון
 * גם אם הקובץ הזה נטען בדף בלי style.css. */

:root { --a11y-consent-h: 0px; }

.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;
}

.a11y-fab {
  position: fixed; z-index: 2147483000;
  inset-inline-start: 12px;
  bottom: calc(var(--a11y-consent-h) + 12px);
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent-dark, #1565C0); color: #fff;
  border: 2px solid var(--surface, #fff);
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  padding: 0; cursor: pointer; transition: bottom var(--dur-fast, .15s) var(--ease, ease),
              background var(--dur-fast, .15s) var(--ease, ease);
}
.a11y-fab svg { width: 26px; height: 26px; fill: currentColor; }
.a11y-fab:hover, .a11y-fab[aria-expanded="true"] { background: var(--accent, #2196F3); }

.a11y-panel {
  position: fixed; z-index: 2147483001;
  inset-inline-start: 12px;
  bottom: calc(var(--a11y-consent-h) + 68px);
  width: min(21rem, calc(100vw - 24px));
  max-height: min(38rem, calc(100vh - var(--a11y-consent-h) - 96px));
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface, #fff); color: var(--text, #333);
  border: 1px solid var(--border-2, #cbd5e0); border-radius: 6px;
  box-shadow: 0 6px 28px rgba(0,0,0,.28);
  padding: 14px 15px 16px;
  font-family: var(--font-ui, system-ui), Arial, sans-serif;
  text-align: start;
}
.a11y-panel[hidden] { display: none; }

.a11y-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid var(--border, #eee); padding-bottom: 9px; margin-bottom: 11px;
}
.a11y-hd h2 { font-size: 1rem; line-height: 1.3; margin: 0; font-family: inherit; }
.a11y-x {
  background: none; border: 1px solid var(--border-2, #cbd5e0); border-radius: 3px;
  width: 30px; height: 30px; line-height: 1; font-size: 1.125rem; color: var(--text-2, #666);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto; cursor: pointer;
}
.a11y-x:hover { border-color: var(--text, #333); color: var(--text, #333); }

.a11y-grp { margin-bottom: 14px; }
.a11y-grp > h3 {
  font-size: .6875rem; letter-spacing: .14em;
  color: var(--text-3, #6b6b6b); font-weight: 500; margin: 0 0 7px;
}

.a11y-seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.a11y-seg.three { grid-template-columns: repeat(3, 1fr); }
.a11y-seg button {
  background: var(--surface-2, #f8f9ff); border: 1px solid var(--border-2, #cbd5e0); border-radius: 3px;
  padding: 9px 4px; font-weight: 500; color: var(--text-2, #666);
  min-height: 44px; line-height: 1.25; cursor: pointer; font-family: inherit;
  font-size: 12.5px;   /* a11y-allow-px — סרגל בחירת הגודל עצמו נשאר יציב */
}
.a11y-seg button[aria-pressed="true"] {
  background: var(--accent-dark, #1565C0); color: #fff;
  border-color: var(--accent-dark, #1565C0); font-weight: 700;
}
html.a11y-invert .a11y-seg button[aria-pressed="true"] { color: #000; }
.a11y-seg .sz-s { font-size: 12px; }    /* a11y-allow-px */
.a11y-seg .sz-m { font-size: 15px; }    /* a11y-allow-px */
.a11y-seg .sz-l { font-size: 18px; }    /* a11y-allow-px */

/* המתג חייב להיות ניתן לזיהוי גם כשהוא כבוי (1.4.11 — 3:1 לרכיבי ממשק),
 * ולכן המסגרת והידית כהות ולא בגוון בהיר. מלבד הצבע גם מיקום הידית
 * משתנה, כדי שהמצב לא ייקרא מהצבע לבדו (1.4.1). */
.a11y-tog {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; background: none; border: none;
  border-bottom: 1px solid var(--border, #eee);
  padding: 10px 2px; text-align: start; font-size: .84375rem; color: var(--text, #333);
  min-height: 44px; cursor: pointer; font-family: inherit;
}
.a11y-tog:last-child { border-bottom: none; }
.a11y-tog:hover { color: var(--link, #1565C0); }
.a11y-tog .sw {
  flex: 0 0 auto; width: 38px; height: 22px; border-radius: 11px;
  background: var(--surface-2, #f8f9ff); border: 1px solid var(--text-2, #666); position: relative;
  transition: background var(--dur-fast, .15s) var(--ease, ease);
}
.a11y-tog .sw::after {
  content: ''; position: absolute; top: 2px; inset-inline-start: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--text-2, #666);
  transition: transform var(--dur-fast, .15s) var(--ease, ease),
              background var(--dur-fast, .15s) var(--ease, ease);
}
.a11y-tog[aria-pressed="true"] .sw {
  background: var(--accent-dark, #1565C0); border-color: var(--accent-dark, #1565C0);
}
.a11y-tog[aria-pressed="true"] .sw::after {
  background: var(--surface, #fff); transform: translateX(-16px);
}
html[dir="ltr"] .a11y-tog[aria-pressed="true"] .sw::after { transform: translateX(16px); }

.a11y-foot { border-top: 1px solid var(--border, #eee); padding-top: 11px; margin-top: 4px; }
.a11y-reset {
  width: 100%; background: transparent; border: 1.5px solid var(--text, #333);
  border-radius: 3px; padding: 10px; font-size: .8125rem; font-weight: 700;
  color: var(--text, #333); min-height: 44px; cursor: pointer; font-family: inherit;
}
.a11y-reset:hover { background: var(--text, #333); color: var(--surface, #fff); }
.a11y-links-row { margin: 10px 0 0; font-size: .75rem; line-height: 1.7; color: var(--text-2, #666); }
.a11y-links-row a { color: var(--link, #1565C0); text-decoration: underline; text-underline-offset: 2px; }
.a11y-kbd { margin: 9px 0 0; font-size: .6875rem; color: var(--text-2, #666); line-height: 1.6; }

@media print { .a11y-fab, .a11y-panel, .consent { display: none !important; } }

/* ── 3. הודעת הפרטיות ──────────────────────────────────────────────────── */

.consent {
  position: fixed; z-index: 2147482999; inset-inline: 0; bottom: 0;
  background: #2D3748; color: #f7fafc;
  border-top: 3px solid var(--accent, #2196F3);
  padding: 14px 0;
  box-shadow: 0 -3px 18px rgba(0,0,0,.3);
  font-family: var(--font-ui, system-ui), Arial, sans-serif;
}
.consent[hidden] { display: none; }
.consent .wrap {
  max-width: 860px; margin: 0 auto; padding: 0 16px;
  display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap;
}
.consent-txt { flex: 1 1 15rem; min-width: 0; }
.consent-txt b { display: block; font-size: .875rem; margin-bottom: 4px; }
.consent-txt p { margin: 0; font-size: .78125rem; line-height: 1.65; color: #e2e8f0; }
.consent-txt a { color: #90CAF9; text-decoration: underline; text-underline-offset: 2px; }
.consent-act { display: flex; gap: 8px; flex: 0 0 auto; flex-wrap: wrap; align-items: center; }
.consent-act button {
  border-radius: 3px; padding: 10px 16px; font-size: .8125rem; font-weight: 700;
  min-height: 44px; border: 1.5px solid; cursor: pointer; font-family: inherit;
}
.consent-ok { background: #1565C0; border-color: #90CAF9; color: #fff; }
.consent-no { background: transparent; border-color: #a0aec0; color: #e2e8f0; }
.consent-no:hover { border-color: #fff; color: #fff; }
@media (max-width: 520px) {
  .consent-act { width: 100%; }
  .consent-act button { flex: 1 1 auto; }
}
