/* ==========================================================
   faina.co.il — виджет доступности
   Израильский стандарт IS 5568 / WCAG 2.1 AA
   Порт канона magic-touch-clinic, токены заменены на brand-палитру faina.
   ========================================================== */

/* ── Ссылка «к основному содержимому» ────────────────────── */
.skip-link {
  position: absolute;
  inset-inline-start: 8px;
  top: -100px;
  z-index: 100;
  padding: 12px 20px;
  border-radius: 0 0 10px 10px;
  background: var(--navy-800);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: top 0.2s var(--ease);
}

.skip-link:focus {
  top: 0;
}

/* ── Плавающая кнопка вызова ─────────────────────────────── */
.a11y-trigger {
  position: fixed;
  inset-block-end: clamp(16px, 3vw, 28px);
  inset-inline-start: clamp(16px, 3vw, 28px);
  z-index: 55;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 52px;
  block-size: 52px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--navy-800);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(11, 35, 80, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  /* на нижней строке подвала кнопка приподнимается над текстом — величину
     подъёма считает initFabLift() в main.js, как и у кнопки WhatsApp */
  --fab-lift: 0px;
  transform: translateY(calc(var(--fab-lift) * -1));
  transition: background-color 0.22s var(--ease), transform 0.22s var(--ease), box-shadow 0.22s var(--ease);
}

.a11y-trigger:hover {
  background: var(--brass-600);
  transform: translateY(calc(var(--fab-lift) * -1)) scale(1.06);
}

.a11y-trigger:focus-visible {
  outline: 3px solid var(--brass-500);
  outline-offset: 3px;
}

.a11y-trigger svg {
  inline-size: 26px;
  block-size: 26px;
  fill: currentColor;
}

/* ── Затемнение ──────────────────────────────────────────── */
.a11y-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(9, 18, 38, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}

.a11y-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Панель ──────────────────────────────────────────────── */
.a11y-panel {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 71;
  display: flex;
  flex-direction: column;
  inline-size: min(348px, 92vw);
  background: #14171d;
  color: #e8eaee;
  box-shadow: 4px 0 40px rgba(0, 0, 0, 0.4);
  transform: translateX(-110%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

html[dir='rtl'] .a11y-panel {
  transform: translateX(110%);
  box-shadow: -4px 0 40px rgba(0, 0, 0, 0.4);
}

/* специфичность RTL-правила выше — дублируем селектор */
.a11y-panel.is-open,
html[dir='rtl'] .a11y-panel.is-open {
  transform: none;
}

.a11y-panel__head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding: 16px 20px;
  background: var(--navy-700);
  color: #fff;
}

.a11y-panel__head-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 36px;
  block-size: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.a11y-panel__head-icon svg {
  inline-size: 20px;
  block-size: 20px;
  fill: currentColor;
}

.a11y-panel__title {
  flex: 1;
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.a11y-panel__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 32px;
  block-size: 32px;
  flex-shrink: 0;
  padding: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: none;
  color: #fff;
  font-family: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}

.a11y-panel__close:hover {
  background: rgba(255, 255, 255, 0.18);
}

.a11y-panel__close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.a11y-panel__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #3a3f49 transparent;
}

.a11y-section__label {
  margin: 0 0 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #9aa1ad;
}

/* размер шрифта */
.a11y-font-btns,
.a11y-contrast-btns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.a11y-font-btn,
.a11y-contrast-btn,
.a11y-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px solid #333944;
  border-radius: 8px;
  background: #1c2029;
  color: #dfe3ea;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.a11y-font-btn {
  block-size: 60px;
  font-weight: 700;
}

.a11y-font-btn:hover,
.a11y-contrast-btn:hover,
.a11y-toggle:hover {
  border-color: #5a6270;
}

.a11y-font-btn.is-active,
.a11y-font-btn[aria-pressed='true'] {
  border-color: var(--brass-500);
  background: var(--brass-500);
  color: #14171d;
}

.a11y-font-btn:focus-visible,
.a11y-contrast-btn:focus-visible,
.a11y-toggle:focus-visible,
.a11y-stmt-link:focus-visible,
.a11y-reset-btn:focus-visible {
  outline: 2px solid var(--brass-500);
  outline-offset: 2px;
}

.a11y-font-glyph {
  line-height: 1;
}

.a11y-font-btn[data-a11y-val=''] .a11y-font-glyph {
  font-size: 15px;
}

.a11y-font-btn[data-a11y-val='lg'] .a11y-font-glyph {
  font-size: 20px;
}

.a11y-font-btn[data-a11y-val='xl'] .a11y-font-glyph {
  font-size: 25px;
}

.a11y-font-sublabel {
  font-size: 9px;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

/* контраст */
.a11y-contrast-btn {
  block-size: 64px;
  padding: 8px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
}

.a11y-contrast-btn.is-active,
.a11y-contrast-btn[aria-pressed='true'],
.a11y-toggle.is-active,
.a11y-toggle[aria-pressed='true'] {
  border-color: var(--brass-500);
  background: #2b2415;
  color: #e8cf9a;
}

.a11y-contrast-swatch {
  inline-size: 28px;
  block-size: 14px;
  flex-shrink: 0;
  border: 1px solid #59606c;
  border-radius: 4px;
}

.a11y-contrast-swatch--high {
  background: linear-gradient(90deg, #000 50%, #ff0 50%);
}

.a11y-contrast-swatch--invert {
  background: linear-gradient(90deg, #fff 50%, #000 50%);
}

.a11y-contrast-swatch--gray {
  background: linear-gradient(90deg, #444 50%, #bbb 50%);
}

/* переключатели */
.a11y-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.a11y-toggle {
  min-block-size: 60px;
  padding: 12px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}

/* низ панели */
.a11y-panel__foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  padding-block-start: 16px;
  border-block-start: 1px solid #262b34;
}

.a11y-stmt-link,
.a11y-reset-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.a11y-stmt-link {
  border: 1.5px solid #333944;
  background: #1c2029;
  color: #dfe3ea;
  font-weight: 500;
}

.a11y-stmt-link:hover {
  background: #232833;
  border-color: #5a6270;
}

.a11y-reset-btn {
  border: 1.5px solid var(--brass-600);
  background: none;
  color: var(--brass-200);
}

.a11y-reset-btn:hover {
  background: var(--brass-600);
  color: #fff;
}

/* ==========================================================
   Состояния, выставляемые виджетом на <html>
   ========================================================== */

html[data-a11y-font='lg'] {
  --fs-xs: 0.875rem;
  --fs-sm: 1rem;
  --fs-base: 1.125rem;
  --fs-md: 1.25rem;
  --fs-lg: 1.5rem;
  --fs-xl: 1.9rem;
  --fs-2xl: 2.5rem;
  --fs-3xl: 3.1rem;
  --fs-4xl: 3.8rem;
}

html[data-a11y-font='xl'] {
  --fs-xs: 1rem;
  --fs-sm: 1.125rem;
  --fs-base: 1.25rem;
  --fs-md: 1.4rem;
  --fs-lg: 1.65rem;
  --fs-xl: 2.1rem;
  --fs-2xl: 2.7rem;
  --fs-3xl: 3.3rem;
  --fs-4xl: 4rem;
}

/* инверсия */
html[data-a11y-contrast='invert'] {
  filter: invert(1) hue-rotate(180deg);
}

html[data-a11y-contrast='invert'] img,
html[data-a11y-contrast='invert'] video {
  filter: invert(1) hue-rotate(180deg);
}

/* оттенки серого */
html[data-a11y-contrast='gray'] {
  filter: grayscale(1);
}

/* высокий контраст: чёрный фон + жёлтый акцент */
html[data-a11y-contrast='high'] {
  --surface: #000 !important;
  --surface-2: #000 !important;
  --surface-3: #111 !important;
  --white: #000 !important;
  --navy-900: #000 !important;
  --navy-800: #000 !important;
  --navy-700: #ff0 !important;
  --navy-500: #ff0 !important;
  --navy-100: #222 !important;
  --ink: #fff !important;
  --ink-muted: #fff !important;
  --brass-600: #ff0 !important;
  --brass-500: #ff0 !important;
  --brass-200: #ff0 !important;
  --line: #666 !important;
  --line-strong: #888 !important;
  background-color: #000 !important;
  color: #fff !important;
}

html[data-a11y-contrast='high'] body,
html[data-a11y-contrast='high'] .hero__bg,
html[data-a11y-contrast='high'] .services,
html[data-a11y-contrast='high'] .reviews,
html[data-a11y-contrast='high'] .cta,
html[data-a11y-contrast='high'] .sitefooter,
html[data-a11y-contrast='high'] .topbar,
html[data-a11y-contrast='high'] .siteheader,
html[data-a11y-contrast='high'] .card,
html[data-a11y-contrast='high'] .qa,
html[data-a11y-contrast='high'] .embed-slot {
  background: #000 !important;
  background-image: none !important;
  color: #fff !important;
}

html[data-a11y-contrast='high'] a {
  color: #ff0 !important;
}

html[data-a11y-contrast='high'] .btn {
  background: #ff0 !important;
  border-color: #ff0 !important;
  color: #000 !important;
  box-shadow: none !important;
}

html[data-a11y-contrast='high'] .btn--ghost,
html[data-a11y-contrast='high'] .btn--ghost-light {
  background: #000 !important;
  border-color: #fff !important;
  color: #fff !important;
}

html[data-a11y-contrast='high'] .slide--empty,
html[data-a11y-contrast='high'] .card__badge {
  background: #000 !important;
  box-shadow: inset 0 0 0 1px #fff !important;
  color: #fff !important;
}

html[data-a11y-contrast='high'] .todo {
  background: #000 !important;
  box-shadow: inset 0 0 0 1px #ff0 !important;
  color: #ff0 !important;
}

html[data-a11y-contrast='high'] img {
  filter: contrast(1.15) brightness(0.92);
}

/* подсветка ссылок */
html[data-a11y-links='1'] a {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 3px !important;
  outline: 1px dashed currentColor !important;
  outline-offset: 2px !important;
  border-radius: 2px;
}

/* подсветка заголовков */
html[data-a11y-heads='1'] h1,
html[data-a11y-heads='1'] h2,
html[data-a11y-heads='1'] h3,
html[data-a11y-heads='1'] h4 {
  outline: 2px solid var(--brass-500) !important;
  outline-offset: 4px !important;
  border-radius: 2px;
}

/* остановка анимаций */
html[data-a11y-anim='1'] *,
html[data-a11y-anim='1'] *::before,
html[data-a11y-anim='1'] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* читаемый шрифт */
html[data-a11y-font-st='1'],
html[data-a11y-font-st='1'] * {
  font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif !important;
  font-style: normal !important;
  font-variation-settings: normal !important;
}

/* межбуквенный интервал */
html[data-a11y-spacing='1'] p,
html[data-a11y-spacing='1'] li,
html[data-a11y-spacing='1'] span,
html[data-a11y-spacing='1'] a,
html[data-a11y-spacing='1'] button,
html[data-a11y-spacing='1'] h1,
html[data-a11y-spacing='1'] h2,
html[data-a11y-spacing='1'] h3,
html[data-a11y-spacing='1'] h4 {
  letter-spacing: 0.1em !important;
  word-spacing: 0.16em !important;
}

/* межстрочный интервал */
html[data-a11y-lineh='1'] p,
html[data-a11y-lineh='1'] li,
html[data-a11y-lineh='1'] span,
html[data-a11y-lineh='1'] a,
html[data-a11y-lineh='1'] h1,
html[data-a11y-lineh='1'] h2,
html[data-a11y-lineh='1'] h3,
html[data-a11y-lineh='1'] h4 {
  line-height: 1.9 !important;
}

/* крупный курсор */
html[data-a11y-cursor='1'],
html[data-a11y-cursor='1'] * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Cpath d='M6 2v22l5-5 3 9 3-1-3-9h7z' fill='%23000' stroke='%23fff' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E") 6 2,
    auto !important;
}

/* усиленный фокус */
html[data-a11y-focus='1'] *:focus-visible {
  outline: 3px solid #fd0 !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 0 6px rgba(255, 221, 0, 0.28) !important;
  border-radius: 3px !important;
}

/* На узком экране настройки доступности живут пунктом в бургер-меню:
   в нижнем углу плавающая кнопка спорит за место с кнопкой WhatsApp. */
/* порог совпадает с мобильным меню в main.css: настройки доступности
   переезжают из плавающей кнопки в пункт меню */
@media (max-width: 1180px) {
  .a11y-trigger {
    display: none;
  }
}
