/* ИПКСЗ — публичный сайт: ДОСТУПНОСТЬ (версия для слабовидящих, высококонтрастные темы, prefers-*). */

/* ===== Высококонтрастные темы «Версия для слабовидящих» =====
   Без filter/invert: тёмные схемы заданы честными переменными. Это важно —
   filter на корне создаёт containing block и ломает position: fixed
   (шторка, панель поиска, тулбар редактора). */
html.aa-theme-black {
  --c-white: #000;
  --c-surface: #000;
  --c-surface-alt: #141414;
  --c-soft: #141414;
  --c-text: #ffe94d;
  --c-dark: #ffe94d;
  --c-muted: #f0e07a;
  --c-border: #8f8a00;
  --c-link: #ffe94d;
  --c-link-hover: #fff6b0;
  --c-focus: #ffe94d;
  --c-blue-50: #141400;
  --c-blue-100: #2b2b00;
  /* Главное меню в этой теме — чёрное, текст темы (жёлтый), свечение — жёлтое */

  --c-nav-bg: #141414;
  --c-nav-fg: #ffe94d;
  --c-nav-fg-hover: #fff6b0;
  --c-nav-accent: #ffe94d;
  --c-nav-line: rgba(255, 233, 77, .35);
  --c-nav-glow: rgba(255, 233, 77, .18);
  --c-nav-glow-2: rgba(255, 233, 77, .12);
  --c-nav-glow-3: rgba(255, 233, 77, .07);
  background: #000;
  color: #ffe94d;
  color-scheme: dark;
}
html.aa-theme-black .footer { background: #000; }
html.aa-theme-black .footer a { color: #ffe94d; }
html.aa-theme-black .search-res__snip mark { color: #000; }
html.aa-theme-black :where(input, textarea, select) { background: #141400; color: var(--c-text); }
html.aa-theme-black .event__accr--ok a:hover,
html.aa-theme-black .ev-card__accr--ok a:hover { color: #8fe3c8; }

html.aa-theme-blue {
  --c-white: #0c1f36;
  --c-surface: #0c1f36;
  --c-surface-alt: #132a45;
  --c-soft: #132a45;
  --c-text: #e8f1fb;
  --c-dark: #ffffff;
  --c-muted: #b7c9de;
  --c-border: #3a5775;
  --c-link: #9cccff;
  --c-link-hover: #cde3ff;
  --c-focus: #9cccff;
  --c-blue-50: #132a45;
  --c-blue-100: #1a3552;
  /* Главное меню в этой теме — её же тёмно-синий, текст/акцент — светлые */
  --c-nav-bg: #132a45;
  --c-nav-fg: #e8f1fb;
  --c-nav-fg-hover: #fff;
  --c-nav-accent: #9cccff;
  --c-nav-line: rgba(156, 204, 255, .3);
  --c-nav-glow: rgba(30, 127, 140, .5);
  --c-nav-glow-2: rgba(109, 92, 160, .3);
  --c-nav-glow-3: rgba(21, 89, 143, .2);
  background: #0c1f36;
  color: #e8f1fb;
  color-scheme: dark;
}
html.aa-theme-blue .footer { background: #081726; }
html.aa-theme-blue .search-res__snip mark { color: #000; }
html.aa-theme-blue :where(input, textarea, select) { background: #132a45; color: var(--c-text); }

html.aa-no-img img,
html.aa-no-img picture { visibility: hidden; }

/* Шрифт с засечками — через переменные, поэтому переключаются и заголовки (--font-head) */
html.aa-font-serif {
  --font-main: Georgia, 'Times New Roman', 'Nimbus Roman', serif;
  --font-head: Georgia, 'Times New Roman', 'Nimbus Roman', serif;
}

/* Междустрочный интервал и разрядка (WCAG 1.4.12 Text Spacing):
   распространяем и на заголовки, ссылки, кнопки, подписи. */
html.aa-line-2 :where(p, li, dd, dt, blockquote, .content, h1, h2, h3, h4, h5, h6, a, button, label) {
  line-height: 1.7 !important;
}
html.aa-line-3 :where(p, li, dd, dt, blockquote, .content, h1, h2, h3, h4, h5, h6, a, button, label) {
  line-height: 2.1 !important;
}
html.aa-letter-2 :where(p, li, dd, dt, blockquote, .content, h1, h2, h3, h4, h5, h6, a, button, label) {
  letter-spacing: .08em !important;
}

.aa-toggle[aria-expanded="true"] { background: #fff; color: var(--c-blue); border-color: #fff; }

/* ===== Серверный рендер режима «Версия для слабовидящих» (?aa=1, без JS) =====
   Размер задаётся классом — не инлайн-стилем, чтобы работало и без JavaScript. */
html.aa-font-80 { font-size: 80%; }
html.aa-font-100 { font-size: 100%; }
html.aa-font-120 { font-size: 120%; }
html.aa-font-150 { font-size: 150%; }
html.aa-font-200 { font-size: 200%; }

/* Кнопка «Обычная версия» для режима без JS (сервер ставит ?aa=1). */
.aa-skip-back {
  display: block;
  background: #ffe94d;
  color: #1a1a00;
  font-weight: 700;
  text-align: center;
  padding: 12px 18px;
  text-decoration: none;
}
.aa-skip-back:hover { background: #fff6b0; color: #1a1a00; text-decoration: none; }
.aa-skip-back:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }

/* ===== Авто-тёмная тема по системной настройке (prefers-color-scheme: dark) =====
   Класс НАМЕРЕННО отдельный от тем панели (aa-theme-black/aa-theme-blue):
   это следование настройкам ОС, а не выбор пользователя в шторке. Как только
   пользователь выбирает тему в панели, класс снимается (см. site-main.js). */
html.aa-auto-dark {
  --c-white: #101720;
  --c-surface: #101720;
  --c-surface-alt: #18212c;
  --c-soft: #18212c;
  --c-text: #e6edf3;
  --c-dark: #ffffff;
  --c-muted: #b7c4d2;
  --c-border: #3a4b5e;
  --c-link: #8cc3ff;
  --c-link-hover: #bcdcff;
  --c-focus: #ffd54a;
  --c-blue-50: #18212c;
  --c-blue-100: #21303f;
  background: #101720;
  color: #e6edf3;
  color-scheme: dark;
}
html.aa-auto-dark .footer { background: #0b1118; }
html.aa-auto-dark .search-res__snip mark { color: #000; }
html.aa-auto-dark :where(input, textarea, select) { background: #18212c; color: var(--c-text); }

/* ===== prefers-reduced-motion: убираем плавную прокрутку и анимации =====
   (WCAG 2.3.3 Animation from Interactions / ГОСТ Р 52872). */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
}

/* ===== prefers-contrast: more: усиливаем контраст границ и мелкого текста ===== */
@media (prefers-contrast: more) {
  :root {
    --c-muted: #364654;
    --c-border: #7e94a8;
  }
  a { text-decoration: underline; }
  a:focus-visible,
  button:focus-visible,
  [tabindex]:focus-visible { outline-width: 4px; }
  .aa-panel__close,
  .aa-btn { border-width: 2px; }
}

/* ===== forced-colors (режим высокой контрастности Windows) =====
   Авторские цвета заменяются системными, поэтому важны границы/обводки,
   иначе кнопки и активное состояние исчезают. */
@media (forced-colors: active) {
  .aa-panel { border-left: 1px solid CanvasText; }
  .aa-panel__head { border-bottom-color: CanvasText; }
  .aa-panel__group--foot { border-top-color: CanvasText; }
  .aa-backdrop { background: Canvas; opacity: 0; }
  .aa-backdrop.is-open { opacity: .6; }
  .aa-panel__close,
  .aa-btn { border: 1px solid ButtonText; }
  .aa-btn.is-active {
    outline: 2px solid Highlight;
    outline-offset: -2px;
    color: HighlightText;
    background: Highlight;
  }
}

