/* ============================================================
   SaudiOne Tourism Theme — Accessibility Toolbar
   Standards: WCAG 2.1/2.2, ADA, EAA, Section 508, RGAA,
   EN 301 549, UK EA, AODA, BITV, JIS X 8341, and more.

   All sizes driven by CSS custom properties set from admin:
   --so-a11y-font-size     (base font size, default 14px)
   --so-a11y-panel-width   (panel width, default 23rem)
   --so-a11y-trigger-size  (trigger button size, default 3.25rem)
   --so-a11y-accent        (accent color, inherits --so-primary)
   ============================================================ */

:root {
  --so-a11y-font-size: 14px;
  --so-a11y-panel-width: 23rem;
  --so-a11y-trigger-size: 3.25rem;
  --so-a11y-accent: var(--so-primary, #087F72);
}

/* ---- Accessibility Trigger Button ---- */
/* When inside .so-floating-actions, use flow layout instead of fixed positioning */
.so-floating-actions .so-a11y-trigger {
  position: static;
  width: var(--so-a11y-trigger-size);
  height: var(--so-a11y-trigger-size);
  border: 2px solid var(--so-a11y-accent);
  border-radius: 50%;
  background: var(--so-white, #fff);
  color: var(--so-a11y-accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

/* Fallback: standalone a11y trigger (if rendered outside floating-actions) */
.so-a11y-trigger:not(.so-floating-actions__btn) {
  position: fixed;
  bottom: 1.5rem;
  inset-inline-end: 1.5rem;
  z-index: 1001;
  width: var(--so-a11y-trigger-size);
  height: var(--so-a11y-trigger-size);
  border: 2px solid var(--so-a11y-accent);
  border-radius: 50%;
  background: var(--so-white, #fff);
  color: var(--so-a11y-accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.so-a11y-trigger:hover,
.so-a11y-trigger:focus-visible {
  background: var(--so-a11y-accent);
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(8,127,114, 0.35);
}
.so-a11y-trigger:focus-visible {
  outline: 3px solid var(--so-secondary, #FF725E);
  outline-offset: 2px;
}
.so-a11y-trigger svg {
  width: calc(var(--so-a11y-trigger-size) * 0.4);
  height: calc(var(--so-a11y-trigger-size) * 0.4);
}
.so-a11y-trigger--left {
  inset-inline-end: auto;
  inset-inline-start: 1.5rem;
}
@media (max-width: 640px) {
  .so-floating-actions .so-a11y-trigger {
    width: 2.75rem;
    height: 2.75rem;
  }
  .so-a11y-trigger:not(.so-floating-actions__btn) {
    bottom: 1rem;
    inset-inline-end: 1rem;
    width: 2.75rem;
    height: 2.75rem;
  }
}

/* Topbar accessibility link */
.so-topbar__a11y-link {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

/* Active state badge */
.so-a11y-trigger__badge {
  position: absolute;
  top: -4px;
  inset-inline-end: -4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--so-secondary, #FF725E);
  border: 2px solid var(--so-white, #fff);
  display: none;
}
.so-a11y-trigger__badge--active {
  display: block;
}

/* ---- Accessibility Panel ---- */
.so-a11y-panel {
  position: fixed;
  top: 0;
  inset-inline-end: 0;
  z-index: 10000;
  width: var(--so-a11y-panel-width);
  max-width: 100vw;
  font-size: var(--so-a11y-font-size);
  height: 100vh;
  height: 100dvh;
  background: var(--so-white, #fff);
  box-shadow: -8px 0 32px rgba(22,43,58, 0.15);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  /* Hidden once off-screen: no shadow at the page edge, no tab stops while closed. */
  visibility: hidden;
  transition: transform 0.3s ease, visibility 0s linear 0.3s;
  overflow: hidden;
}
[dir="rtl"] .so-a11y-panel {
  transform: translateX(-100%);
  box-shadow: 8px 0 32px rgba(22,43,58, 0.15);
}
.so-a11y-panel--open {
  transform: translateX(0) !important;
  visibility: visible;
  transition: transform 0.3s ease, visibility 0s;
}
.so-a11y-panel__backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(22,43,58, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.so-a11y-panel__backdrop--visible {
  opacity: 1;
  visibility: visible;
}

/* Panel Header */
.so-a11y-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.125rem;
  background: var(--so-a11y-accent);
  color: #fff;
  flex-shrink: 0;
}
.so-a11y-header__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--so-font-heading);
  font-size: 1.0625rem;
  font-weight: 600;
}
.so-a11y-header__title svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}
.so-a11y-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.so-a11y-header__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.125rem;
  height: 2.125rem;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 0.375rem;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.8125rem;
  font-weight: 600;
}
.so-a11y-header__btn:hover {
  background: rgba(255,255,255,0.25);
}
.so-a11y-header__btn svg {
  width: 1rem;
  height: 1rem;
}

/* Panel Body */
.so-a11y-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.875rem;
  overscroll-behavior: contain;
}
.so-a11y-body::-webkit-scrollbar {
  width: 4px;
}
.so-a11y-body::-webkit-scrollbar-thumb {
  background: var(--so-ash, #E8E6E1);
  border-radius: 2px;
}

/* ---- Compliance Banner ---- */
.so-a11y-compliance {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem;
  margin-bottom: 0.75rem;
  background: var(--so-pale-green, #E6F4F2);
  border-radius: var(--so-radius-md, 0.75rem);
  border: 1px solid rgba(8,127,114, 0.1);
}
.so-a11y-compliance__tag {
  font-size: 0.625rem;
  font-weight: 600;
  padding: 0.1875rem 0.4375rem;
  border-radius: var(--so-radius-full, 9999px);
  background: var(--so-white, #fff);
  color: var(--so-a11y-accent);
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid rgba(8,127,114, 0.12);
}

/* ---- Accessibility Profiles ---- */
.so-a11y-profiles {
  margin-bottom: 0.75rem;
}
.so-a11y-section-title {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--so-stone, #9B9689);
  margin-bottom: 0.5rem;
  padding-inline-start: 0.25rem;
}
.so-a11y-profiles__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.so-a11y-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  padding: 0.625rem 0.375rem;
  background: var(--so-cloud, #F8F9FA);
  border: 2px solid transparent;
  border-radius: var(--so-radius-md, 0.75rem);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  text-align: center;
}
.so-a11y-profile:hover {
  background: var(--so-pale-green, #E6F4F2);
  border-color: rgba(8,127,114, 0.2);
}
.so-a11y-profile:focus-visible {
  outline: 3px solid var(--so-secondary, #FF725E);
  outline-offset: 2px;
}
.so-a11y-profile--active {
  border-color: var(--so-a11y-accent);
  background: var(--so-pale-green, #E6F4F2);
  box-shadow: 0 0 0 1px var(--so-a11y-accent);
}
.so-a11y-profile__icon {
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--so-white, #fff);
  border-radius: 0.5rem;
  font-size: 1.125rem;
  box-shadow: var(--so-shadow-sm);
}
.so-a11y-profile--active .so-a11y-profile__icon {
  background: var(--so-a11y-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(8,127,114, 0.3);
}
.so-a11y-profile__label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--so-charcoal, #3A3A38);
  line-height: 1.2;
}

/* ---- Tool Sections ---- */
.so-a11y-section {
  margin-bottom: 0.75rem;
}
.so-a11y-section__tools {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

/* Single Tool Row */
.so-a11y-tool {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  background: var(--so-cloud, #F8F9FA);
  border: 1px solid transparent;
  border-radius: var(--so-radius-sm, 0.375rem);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.so-a11y-tool:hover {
  background: var(--so-pale-green, #E6F4F2);
}
.so-a11y-tool:focus-visible {
  outline: 3px solid var(--so-secondary, #FF725E);
  outline-offset: 1px;
}
.so-a11y-tool--active {
  border-color: var(--so-a11y-accent);
  background: var(--so-pale-green, #E6F4F2);
}
.so-a11y-tool__info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.so-a11y-tool__icon {
  width: 1.625rem;
  height: 1.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}
.so-a11y-tool__label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--so-charcoal, #3A3A38);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.so-a11y-tool__control {
  flex-shrink: 0;
}

/* Toggle Switch */
.so-a11y-toggle {
  position: relative;
  width: 2.5rem;
  height: 1.375rem;
  background: var(--so-ash, #E8E6E1);
  border-radius: var(--so-radius-full, 9999px);
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  padding: 0;
}
.so-a11y-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  background: var(--lbayk-theme-surface, #fff);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.2s;
}
.so-a11y-toggle--on {
  background: var(--so-a11y-accent);
}
.so-a11y-toggle--on::after {
  transform: translateX(1.125rem);
}
[dir="rtl"] .so-a11y-toggle--on::after {
  transform: translateX(-1.125rem);
}

/* Stepper (font size, spacing) */
.so-a11y-stepper {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.so-a11y-stepper__btn {
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--so-white, #fff);
  border: 1px solid var(--so-ash, #E8E6E1);
  border-radius: var(--so-radius-sm, 0.375rem);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  color: var(--so-charcoal, #3A3A38);
  transition: background 0.15s, border-color 0.15s;
  padding: 0;
  line-height: 1;
}
.so-a11y-stepper__btn:hover {
  background: var(--so-pale-green, #E6F4F2);
  border-color: var(--so-a11y-accent);
}
.so-a11y-stepper__value {
  min-width: 1.75rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--so-charcoal, #3A3A38);
}

/* Color blind selector */
.so-a11y-select {
  font-size: 0.8125rem;
  padding: 0.3125rem 0.5rem;
  border: 1px solid var(--so-ash, #E8E6E1);
  border-radius: var(--so-radius-sm, 0.375rem);
  background: var(--so-white, #fff);
  color: var(--so-charcoal, #3A3A38);
  cursor: pointer;
  max-width: 8rem;
}

/* ---- Panel Footer ---- */
.so-a11y-footer {
  flex-shrink: 0;
  padding: 0.75rem 0.875rem;
  border-top: 1px solid var(--so-ash, #E8E6E1);
  background: var(--so-cloud, #F8F9FA);
}
.so-a11y-footer__link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--so-a11y-accent);
  text-decoration: none;
}
.so-a11y-footer__link:hover {
  text-decoration: underline;
}
.so-a11y-footer__link svg {
  width: 0.875rem;
  height: 0.875rem;
}

/* ---- Reading Guide Overlay ---- */
.so-a11y-reading-guide {
  position: fixed;
  left: 0;
  width: 100%;
  height: 2.5rem;
  z-index: 100000;
  pointer-events: none;
  border-top: 2px solid var(--so-primary, #087F72);
  border-bottom: 2px solid var(--so-primary, #087F72);
  background: rgba(8,127,114, 0.06);
  display: none;
  transition: top 0.05s linear;
}
.so-a11y-reading-guide--active {
  display: block;
}

/* ---- Reading Mask Overlay ---- */
.so-a11y-reading-mask {
  position: fixed;
  inset: 0;
  z-index: 99999;
  pointer-events: none;
  display: none;
}
.so-a11y-reading-mask--active {
  display: block;
}
.so-a11y-reading-mask__top,
.so-a11y-reading-mask__bottom {
  position: absolute;
  left: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.65);
  transition: top 0.05s linear, height 0.05s linear;
}
.so-a11y-reading-mask__top {
  top: 0;
}
.so-a11y-reading-mask__bottom {
  bottom: 0;
}

/* ---- Global A11y CSS Filters / Overrides ---- */

/* High Contrast */
html.so-a11y-high-contrast {
  filter: contrast(1.5);
}
/* Dark Contrast */
html.so-a11y-dark-contrast {
  filter: invert(1) hue-rotate(180deg);
}
html.so-a11y-dark-contrast img,
html.so-a11y-dark-contrast video,
html.so-a11y-dark-contrast svg,
html.so-a11y-dark-contrast [style*="background-image"],
html.so-a11y-dark-contrast .so-a11y-panel {
  filter: invert(1) hue-rotate(180deg);
}
/* Light Contrast */
html.so-a11y-light-contrast {
  filter: contrast(1.75) brightness(1.2);
}
/* Monochrome / Grayscale */
html.so-a11y-monochrome {
  filter: grayscale(1);
}
/* High Saturation */
html.so-a11y-high-saturation {
  filter: saturate(2);
}
/* Low Saturation */
html.so-a11y-low-saturation {
  filter: saturate(0.5);
}
/* Invert Colors */
html.so-a11y-invert {
  filter: invert(1) hue-rotate(180deg);
}
html.so-a11y-invert img,
html.so-a11y-invert video,
html.so-a11y-invert svg {
  filter: invert(1) hue-rotate(180deg);
}

/* Color Blind Simulations */
html.so-a11y-cb-protanopia {
  filter: url('#so-a11y-protanopia');
}
html.so-a11y-cb-deuteranopia {
  filter: url('#so-a11y-deuteranopia');
}
html.so-a11y-cb-tritanopia {
  filter: url('#so-a11y-tritanopia');
}

/* Underline Links */
html.so-a11y-underline-links a {
  text-decoration: underline !important;
  text-underline-offset: 3px;
}
/* Highlight Links */
html.so-a11y-highlight-links a {
  outline: 2px solid var(--so-secondary, #FF725E) !important;
  outline-offset: 2px;
  border-radius: 2px;
}
/* Highlight Headings */
html.so-a11y-highlight-headings h1,
html.so-a11y-highlight-headings h2,
html.so-a11y-highlight-headings h3,
html.so-a11y-highlight-headings h4,
html.so-a11y-highlight-headings h5,
html.so-a11y-highlight-headings h6 {
  outline: 2px dashed var(--so-primary, #087F72) !important;
  outline-offset: 4px;
  border-radius: 2px;
}

/* Big Cursor */
html.so-a11y-big-cursor,
html.so-a11y-big-cursor * {
  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 2l20 14H14l7 13-4 2-7-13-5 8z' fill='%23000' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E") 4 2, auto !important;
}

/* Focus Highlight */
html.so-a11y-focus-highlight *:focus {
  outline: 3px solid var(--so-secondary, #FF725E) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px rgba(255,114,94, 0.25) !important;
}

/* Stop Animations */
html.so-a11y-stop-animations,
html.so-a11y-stop-animations * {
  animation-duration: 0s !important;
  animation-delay: 0s !important;
  transition-duration: 0s !important;
  transition-delay: 0s !important;
  scroll-behavior: auto !important;
}

/* Hide Images */
html.so-a11y-hide-images img,
html.so-a11y-hide-images svg:not(.so-a11y-panel svg):not(.so-a11y-trigger svg),
html.so-a11y-hide-images [style*="background-image"] {
  opacity: 0.05 !important;
}

/* Readable Font */
html.so-a11y-readable-font,
html.so-a11y-readable-font * {
  font-family: 'Atkinson Hyperlegible', Arial, Helvetica, sans-serif !important;
  letter-spacing: 0.03em;
}
[dir="rtl"] html.so-a11y-readable-font,
[dir="rtl"] html.so-a11y-readable-font * {
  font-family: 'Tajawal', 'Atkinson Hyperlegible', Arial, Helvetica, sans-serif !important;
}

/* Text Alignment */
html.so-a11y-align-left * {
  text-align: left !important;
}
html.so-a11y-align-center * {
  text-align: center !important;
}
html.so-a11y-align-right * {
  text-align: right !important;
}

/* Epilepsy Safe */
html.so-a11y-epilepsy-safe * {
  animation-duration: 0s !important;
  animation-delay: 0s !important;
  transition-duration: 0s !important;
}
html.so-a11y-epilepsy-safe img[src*=".gif"],
html.so-a11y-epilepsy-safe video {
  display: none !important;
}

/* Page Structure Overlay */
.so-a11y-structure-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: rgba(22,43,58, 0.85);
  overflow-y: auto;
  padding: 2rem;
  display: none;
}
.so-a11y-structure-overlay--active {
  display: block;
}
.so-a11y-structure__list {
  max-width: 40rem;
  margin: 0 auto;
  list-style: none;
  padding: 0;
}
.so-a11y-structure__item {
  padding: 0.625rem 0.875rem;
  margin-bottom: 0.375rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--so-radius-sm, 0.375rem);
  border-inline-start: 3px solid var(--so-primary, #087F72);
  transition: background 0.15s;
}
.so-a11y-structure__item:hover,
.so-a11y-structure__item:focus-within {
  background: rgba(255, 255, 255, 0.15);
}
.so-a11y-structure__link {
  color: #fff;
  text-decoration: none;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.so-a11y-structure__link:hover {
  color: var(--so-mint-glow, #BFE7E1);
}
.so-a11y-structure__tag {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  background: var(--so-primary, #087F72);
  color: #fff;
  letter-spacing: 0.04em;
}

/* Keyboard navigation indicator */
html.so-a11y-keyboard-nav *:focus {
  outline: 3px solid var(--so-primary, #087F72) !important;
  outline-offset: 2px !important;
}

/* ---- Reduced Motion Preference ---- */
@media (prefers-reduced-motion: reduce) {
  .so-a11y-panel {
    transition: none;
  }
  .so-a11y-panel__backdrop {
    transition: none;
  }
  .so-a11y-reading-guide {
    transition: none;
  }
}

/* ---- Mobile Panel Full Width ---- */
@media (max-width: 480px) {
  .so-a11y-panel {
    width: 100vw;
  }
  .so-a11y-profiles__grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.375rem;
  }
  .so-a11y-profile {
    padding: 0.5rem 0.25rem;
  }
}

/* ---- Print: hide toolbar ---- */
@media print {
  .so-a11y-trigger,
  .so-a11y-panel,
  .so-a11y-panel__backdrop,
  .so-a11y-reading-guide,
  .so-a11y-reading-mask,
  .so-a11y-structure-overlay {
    display: none !important;
  }
}
