/* ==========================================================================
   ACCESSIBILITY ENGINE (נגישות) - YESHURUN GROUP PRODUCTION STANDARD
   Pixel-perfect 1:1 Implementation of Custom Accessibility Widget
   ========================================================================== */

:root {
  --a11y-amber: #f3b43f;
  --a11y-amber-hover: #e2a532;
  --a11y-amber-light: #fef8eb;
  --a11y-dark: #111111;
  --a11y-bg: #f4f5f7;
  --a11y-card-bg: #ffffff;
  --a11y-btn-bg: #f3f4f6;
  --a11y-btn-hover: #eaedf0;
  --a11y-pill-inactive: #d1d5db;
  --a11y-pill-active: #4b5563;
  --a11y-radius-card: 20px;
  --a11y-radius-btn: 14px;
}

/* --------------------------------------------------------------------------
   1. Floating Trigger Button (כפתור פתיחת תפריט נגישות עגול)
   -------------------------------------------------------------------------- */
#a11y-trigger-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background-color: var(--a11y-amber);
  color: var(--a11y-dark);
  border: none;
  cursor: pointer;
  z-index: 999990;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#a11y-trigger-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

#a11y-trigger-btn:active {
  transform: scale(0.96);
}

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

.a11y-trigger-inner-ring {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--a11y-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.a11y-trigger-inner-ring svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* Floating Restore Tab (shown when user clicks "הסתר") */
#a11y-restore-tab {
  position: fixed;
  bottom: 24px;
  right: 0;
  background-color: var(--a11y-amber);
  color: var(--a11y-dark);
  padding: 8px 14px 8px 10px;
  border-radius: 20px 0 0 20px;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1.5px solid var(--a11y-dark);
  border-right: none;
  cursor: pointer;
  z-index: 999990;
  display: none;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease;
}

#a11y-restore-tab:hover {
  transform: translateX(-4px);
}

#a11y-restore-tab svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* --------------------------------------------------------------------------
   2. Main Accessibility Modal Dialog (חלון הנגישות הצף)
   -------------------------------------------------------------------------- */
#a11y-widget-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999995;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
  pointer-events: none;
}

#a11y-widget-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#a11y-widget-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 410px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 40px);
  background-color: var(--a11y-bg);
  border-radius: var(--a11y-radius-card);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.24);
  z-index: 999998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  direction: rtl;
  font-family: inherit;
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.26s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.26s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.26s;
}

#a11y-widget-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   3. Header (כותרת עליונה צהובה עם לשונית חיתוך מעוגלת)
   -------------------------------------------------------------------------- */
.a11y-header {
  position: relative;
  background-color: var(--a11y-amber);
  color: var(--a11y-dark);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 2;
}

/* Protruding tab cut in the bottom center of the header */
.a11y-header::after {
  content: "";
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  height: 9px;
  background-color: var(--a11y-amber);
  border-radius: 0 0 12px 12px;
  pointer-events: none;
}

.a11y-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.a11y-header-icon-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: #ffffff;
  color: var(--a11y-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.a11y-header-icon-badge svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.a11y-header-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--a11y-dark);
  margin: 0;
  letter-spacing: -0.2px;
}

.a11y-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.a11y-header-btn {
  background: transparent;
  border: none;
  color: var(--a11y-dark);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.18s ease, transform 0.18s ease;
}

.a11y-header-btn:hover {
  background-color: rgba(0, 0, 0, 0.08);
  transform: scale(1.08);
}

.a11y-header-btn:active {
  transform: scale(0.92);
}

.a11y-header-btn svg {
  width: 19px;
  height: 19px;
}

.a11y-header-divider {
  width: 1px;
  height: 18px;
  background-color: rgba(0, 0, 0, 0.18);
  margin: 0 2px;
}

/* --------------------------------------------------------------------------
   4. Scrollable Body & Category Cards (גוף התפריט וכרטיסיות)
   -------------------------------------------------------------------------- */
.a11y-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.a11y-body::-webkit-scrollbar {
  width: 6px;
}

.a11y-body::-webkit-scrollbar-track {
  background: transparent;
}

.a11y-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.a11y-category-card {
  background-color: var(--a11y-card-bg);
  border-radius: var(--a11y-radius-card);
  padding: 14px 14px 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.a11y-category-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 12px;
  text-align: right;
  padding-right: 4px;
}

/* Grid of 2 columns */
.a11y-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* Button Item: In RTL, icon on right, label & pills to its left! */
.a11y-item-btn {
  background-color: var(--a11y-btn-bg);
  border: 2px solid transparent;
  border-radius: var(--a11y-radius-btn);
  padding: 12px 10px 12px 12px;
  min-height: 72px;
  cursor: pointer;
  display: flex;
  flex-direction: row; /* in RTL, first DOM child is on the right! */
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  text-align: right;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.a11y-item-btn:hover {
  background-color: var(--a11y-btn-hover);
  transform: translateY(-1px);
}

.a11y-item-btn:active {
  transform: translateY(1px);
}

/* Active State: Solid black border exactly as in screenshot 0! */
.a11y-item-btn.is-active {
  border-color: var(--a11y-dark);
  background-color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* White Circle Icon Container (on the RIGHT in RTL) */
.a11y-item-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--a11y-dark);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.a11y-item-btn:hover .a11y-item-icon-wrap {
  transform: scale(1.05);
}

.a11y-item-icon-wrap svg {
  width: 22px;
  height: 22px;
}

/* Content Container: Label on top, Pills below */
.a11y-item-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.a11y-item-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--a11y-dark);
  line-height: 1.25;
  white-space: normal;
}

/* Step Indicator Pills (bars) */
.a11y-indicators-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.a11y-indicator-pill {
  width: 16px;
  height: 6px;
  border-radius: 3px;
  background-color: var(--a11y-pill-inactive);
  transition: background-color 0.2s ease, width 0.2s ease;
}

.a11y-indicator-pill.is-active {
  background-color: var(--a11y-pill-active);
}

/* Single-toggle indicator badge */
.a11y-single-toggle-pill {
  width: 20px;
  height: 6px;
  border-radius: 3px;
  background-color: var(--a11y-pill-inactive);
  transition: background-color 0.2s ease;
}

.a11y-single-toggle-pill.is-active {
  background-color: var(--a11y-pill-active);
}

/* --------------------------------------------------------------------------
   5. Footer (חלק תחתון צהוב עם לשונית מעוגלת כלפי מעלה)
   -------------------------------------------------------------------------- */
.a11y-footer {
  position: relative;
  background-color: var(--a11y-amber);
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

/* Upward protruding tab in the center of the footer */
.a11y-footer::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  height: 9px;
  background-color: var(--a11y-amber);
  border-radius: 12px 12px 0 0;
  pointer-events: none;
}

/* Mobile Quick Floating Actions (shown inside/above bottom bar on mobile) */
.a11y-mobile-actions-bar {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 14px;
  background-color: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  position: relative;
  z-index: 3;
}

.a11y-mobile-pill-btn {
  background-color: #ffffff;
  color: var(--a11y-dark);
  border: 1.5px solid rgba(0, 0, 0, 0.15);
  border-radius: 9999px;
  padding: 8px 22px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  transition: all 0.18s ease;
}

.a11y-mobile-pill-btn:hover {
  background-color: #f8fafc;
  border-color: var(--a11y-dark);
}

.a11y-mobile-pill-btn:active {
  transform: scale(0.96);
}

.a11y-mobile-pill-btn svg {
  width: 17px;
  height: 17px;
}

/* --------------------------------------------------------------------------
   6. Page Structure / Sitemap Modal (מבנה עמוד)
   -------------------------------------------------------------------------- */
#a11y-sitemap-modal {
  position: absolute;
  inset: 0;
  background-color: var(--a11y-bg);
  z-index: 10;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateX(100%);
  visibility: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

#a11y-sitemap-modal.is-open {
  opacity: 1;
  transform: translateX(0);
  visibility: visible;
}

.a11y-sitemap-header {
  background-color: var(--a11y-amber);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.a11y-sitemap-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  list-style: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.a11y-sitemap-item {
  background-color: #ffffff;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.a11y-sitemap-item:hover {
  border-color: var(--a11y-dark);
  background-color: var(--a11y-amber-light);
  transform: translateX(-3px);
}

.a11y-sitemap-tag {
  font-size: 0.72rem;
  font-weight: 800;
  background-color: var(--a11y-amber);
  color: var(--a11y-dark);
  padding: 2px 6px;
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   7. Live Interactive Features Styles
   (Applied to page content, strictly isolating #a11y-widget-root)
   -------------------------------------------------------------------------- */

/* Text sizing steps */
html.a11y-text-1 body {
  font-size: 112% !important;
}

html.a11y-text-2 body {
  font-size: 124% !important;
}

html.a11y-text-3 body {
  font-size: 136% !important;
}

/* Line Height */
html.a11y-lh-1 body *:not(#a11y-widget-root *) {
  line-height: 1.85 !important;
}

html.a11y-lh-2 body *:not(#a11y-widget-root *) {
  line-height: 2.2 !important;
}

/* Text Alignment */
html.a11y-align-center body *:not(#a11y-widget-root *) {
  text-align: center !important;
}

html.a11y-align-left body *:not(#a11y-widget-root *) {
  text-align: left !important;
}

/* Readable Font */
html.a11y-readable-font body *:not(#a11y-widget-root *) {
  font-family: Arial, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif !important;
  letter-spacing: 0.02em !important;
}

/* High Contrast (Dark) */
html.a11y-contrast-dark {
  background-color: #000000 !important;
  color: #ffffff !important;
}

html.a11y-contrast-dark body > *:not(#a11y-widget-root):not(#a11y-reading-mask-top):not(#a11y-reading-mask-bottom) {
  background-color: #0d0d0d !important;
  color: #ffffff !important;
  border-color: #333333 !important;
}

html.a11y-contrast-dark h1:not(#a11y-widget-root *),
html.a11y-contrast-dark h2:not(#a11y-widget-root *),
html.a11y-contrast-dark h3:not(#a11y-widget-root *),
html.a11y-contrast-dark h4:not(#a11y-widget-root *) {
  color: #f3b43f !important;
}

html.a11y-contrast-dark a:not(#a11y-widget-root *) {
  color: #38bdf8 !important;
  text-decoration: underline !important;
}

html.a11y-contrast-dark button:not(#a11y-widget-root *) {
  border: 1.5px solid #f3b43f !important;
  color: #f3b43f !important;
}

/* Invert Contrast (strictly isolated from widget) */
html.a11y-contrast-invert body > *:not(#a11y-widget-root):not(#a11y-reading-mask-top):not(#a11y-reading-mask-bottom) {
  filter: invert(100%) hue-rotate(180deg) !important;
}

/* Grayscale (strictly isolated from widget so amber header stays colorful!) */
html.a11y-grayscale body > *:not(#a11y-widget-root):not(#a11y-reading-mask-top):not(#a11y-reading-mask-bottom) {
  filter: grayscale(100%) !important;
}

/* Hide Images */
html.a11y-hide-images img:not(#a11y-widget-root *),
html.a11y-hide-images picture:not(#a11y-widget-root *),
html.a11y-hide-images video:not(#a11y-widget-root *),
html.a11y-hide-images [style*="background-image"]:not(#a11y-widget-root *) {
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Pause Animations */
html.a11y-pause-animations body *:not(#a11y-widget-root *),
html.a11y-pause-animations body *::before,
html.a11y-pause-animations body *::after {
  animation-play-state: paused !important;
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* Highlight Links */
html.a11y-highlight-links a:not(#a11y-widget-root *) {
  background-color: #fef08a !important;
  color: #0f172a !important;
  text-decoration: underline !important;
  font-weight: 800 !important;
  outline: 2px solid #000000 !important;
  border-radius: 4px !important;
  padding: 1px 4px !important;
}

/* Focus Outline */
html.a11y-focus-outline *:focus:not(#a11y-widget-root *),
html.a11y-focus-outline *:focus-visible:not(#a11y-widget-root *) {
  outline: 4px solid var(--a11y-amber) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px #000000 !important;
}

/* Reading Mask Visor Overlays */
#a11y-reading-mask-top,
#a11y-reading-mask-bottom {
  position: fixed;
  left: 0;
  right: 0;
  background-color: rgba(0, 0, 0, 0.65);
  pointer-events: none;
  z-index: 999991;
  display: none;
  transition: height 0.05s ease-out, top 0.05s ease-out;
}

#a11y-reading-mask-top {
  top: 0;
  height: 0;
}

#a11y-reading-mask-bottom {
  bottom: 0;
  top: 100px;
}

/* Highlight target flash on jumping from structure list */
.a11y-highlight-target {
  animation: a11yPulse 1.5s ease-out;
}

@keyframes a11yPulse {
  0% { outline: 4px solid var(--a11y-amber); background-color: rgba(243, 180, 63, 0.35); }
  100% { outline: 4px solid transparent; background-color: transparent; }
}

/* --------------------------------------------------------------------------
   8. Mobile Specific Adjustments (Screenshot 4 & 5 Exact Match)
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
  #a11y-trigger-btn {
    bottom: 20px;
    right: 16px;
    width: 48px;
    height: 48px;
  }

  .a11y-trigger-inner-ring {
    width: 38px;
    height: 38px;
  }

  .a11y-trigger-inner-ring svg {
    width: 20px;
    height: 20px;
  }

  #a11y-widget-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    max-height: 86vh;
    border-radius: 22px 22px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.28);
  }

  #a11y-widget-panel.is-open {
    transform: translateY(0);
  }

  .a11y-header {
    padding: 12px 18px;
    border-radius: 22px 22px 0 0;
  }

  /* On mobile header, keep only the Close 'X' button! */
  .a11y-header #a11y-btn-reset,
  .a11y-header #a11y-btn-hide,
  .a11y-header .a11y-header-divider {
    display: none !important;
  }

  .a11y-header-title {
    font-size: 1.15rem;
  }

  /* In mobile: 1 column full-width horizontal rows matching Screenshot 4! */
  .a11y-buttons-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .a11y-item-btn {
    min-height: 58px;
    padding: 10px 14px;
    display: flex;
    flex-direction: row; /* In RTL: icon & label right, pills on far left! */
    justify-content: space-between;
    align-items: center;
  }

  .a11y-item-content {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .a11y-item-label {
    font-size: 0.94rem;
  }

  .a11y-item-icon-wrap {
    width: 38px;
    height: 38px;
  }

  .a11y-indicator-pill {
    width: 24px;
    height: 8px;
    border-radius: 4px;
  }

  .a11y-single-toggle-pill {
    width: 24px;
    height: 8px;
    border-radius: 4px;
  }

  /* Show floating quick buttons on mobile (Screenshot 4) */
  .a11y-mobile-actions-bar {
    display: flex;
  }

  .a11y-footer {
    height: calc(26px + env(safe-area-inset-bottom, 0px));
  }
}
