/* ProsaMD — общая оболочка сайта: шапка, мобильное меню, оглавление лендинга, подвал.
   Один файл на все страницы (подключается после main.css / landing*.css).
   Решение владельца 2026-10-11 (★2, .zcode/design/site-nav): вариант A — панель под шапкой.
   Цвета — только существующие токены сайта (--paper, --ink*, --line*, --surface-sunken,
   --cinnabar*); палитру сайта меняет landing-rev6, не этот файл. */

:root {
  /* Акцент навигации: метка текущего раздела и CTA — чернила (решение владельца
     2026-10-11, схема Б палитры C): цвет в шапке — только у знака. */
  --nav-accent: var(--ink);
  --nav-cta-bg: var(--ink);
  --nav-cta-bg-hover: var(--ink-soft);
  --nav-scrim: rgba(29, 27, 38, 0.18);
}
:root[data-theme="dark"] {
  --nav-accent: var(--ink);
  --nav-scrim: rgba(0, 0, 0, 0.32);
}

/* ─────────── Шапка ─────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper); /* непрозрачный фолбэк без backdrop-filter */
  border-bottom: 1px solid var(--line);
}

/* «Стекло» (как было на /new): только там, где backdrop-filter поддерживается */
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-header {
    background: color-mix(in srgb, var(--paper) 72%, transparent);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
  }
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 64px;
}

.brand { display: inline-flex; align-items: center; flex: none; }
.brand-logo { height: 28px; width: auto; } /* ≈98px — минимум локапа 96px (kit/GUIDELINES.md) */

/* Пункты меню: список, новый пункт = одна строка <li> в разметке (лимит — 5 пунктов) */
.site-nav { margin-right: auto; min-width: 0; }
.nav-list {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.nav-list a {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 8px;
  white-space: nowrap;
  transition: color 0.15s;
}
/* Наведение — только цвет текста: одна индикация (плашки нет) */
.nav-list a:hover { color: var(--ink); }
.site-nav .nav-list a[aria-current] { color: var(--ink); }
/* Текущий раздел на десктопе — линия акцента под пунктом, на нижней границе шапки */
.site-nav .nav-list a[aria-current]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -13px;
  height: 2px;
  border-radius: 2px;
  background: var(--nav-accent);
}

/* Пометка «RU»: в EN-режиме у пунктов, ведущих на страницы только на русском */
.lang-tag {
  margin-left: 5px;
  padding: 0 3px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
}
:root:not([lang="en"]) .lang-tag { display: none; }
.site-footer .lang-tag { color: rgba(241, 239, 247, 0.7); border-color: rgba(241, 239, 247, 0.3); }

.shell-vh {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.header-actions { display: flex; align-items: center; gap: 4px; flex: none; margin-left: auto; }

/* CTA «Скачать» — на всех страницах; на телефоне остаётся в шапке рядом с бургером */
.nav-cta {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  margin-right: 6px;
  border-radius: 8px;
  background: var(--nav-cta-bg);
  color: var(--paper); /* чернила к бумаге ≥15:1 в обеих темах */
  font: 600 14.5px/1 "Noto Sans", ui-sans-serif, system-ui, sans-serif;
  text-decoration: none;
  white-space: nowrap;
  flex: none;
  transition: background 0.15s;
}
.nav-cta:hover { background: var(--nav-cta-bg-hover); }
.nav-cta:active { transform: translateY(1px); }

/* Иконки GitHub / язык / тема — одна разметка: .icon-btn (у кнопок type="button") */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font: 600 12.5px/1 "Noto Sans", sans-serif;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-sunken); }

:root:not([data-theme="dark"]) .ico-sun { display: none; }
:root[data-theme="dark"] .ico-moon { display: none; }

/* ─────────── Мобильное меню (вариант A) ─────────── */

/* Кнопка «Меню»: видна только ниже порога и только с JS (без JS у неё [hidden],
   а все пункты меню продублированы в подвале). Подпись постоянная, состояние —
   aria-expanded и иконка ☰ → ×. */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  height: 44px;
  padding: 0 12px 0 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: 500 14.5px/1 "Noto Sans", ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
  flex: none;
}
.nav-toggle:hover, .nav-toggle[aria-expanded="true"] { background: var(--surface-sunken); }
.nav-toggle svg { display: block; flex: none; }
.nav-toggle[aria-expanded="true"] .ico-burger,
.nav-toggle[aria-expanded="false"] .ico-close { display: none; }

/* Панель — под шапкой на всю ширину; непрозрачная, своя прокрутка на низких экранах */
.nav-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: calc(100vh - 64px);
  max-height: calc(100dvh - 64px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 0 12px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 16px 32px -16px rgba(29, 27, 38, 0.25);
}
.nav-panel[hidden] { display: none; }
.nav-panel .nav-list { display: block; }
.nav-panel .nav-list a {
  display: flex;
  height: 48px;
  padding: 0 20px;
  border-radius: 0;
  font-size: 17px;
  color: var(--ink);
}
/* Текущий раздел в панели — полоса акцента слева + полужирный */
.nav-panel .nav-list a[aria-current] { font-weight: 600; }
.nav-panel .nav-list a[aria-current]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--nav-accent);
}
.nav-panel .nav-list a:hover { background: var(--surface-sunken); }

.nav-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 12px 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.nav-tool {
  flex: 1 1 auto;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 6px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font: 500 14px/1.2 "Noto Sans", ui-sans-serif, system-ui, sans-serif;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.nav-tool:hover { color: var(--ink); background: var(--surface-sunken); }
.nav-tool svg { flex: none; }

/* Лёгкое затемнение страницы под панелью; тап по нему закрывает меню */
.nav-scrim {
  position: fixed;
  inset: 0;
  z-index: 49; /* под шапкой (50) */
  background: var(--nav-scrim);
}
.nav-scrim[hidden] { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .nav-panel:not([hidden]) { animation: nav-panel-in 0.14s ease-out; }
  .nav-scrim:not([hidden]) { animation: nav-scrim-in 0.14s ease-out; }
  @keyframes nav-panel-in { from { opacity: 0; transform: translateY(-6px); } }
  @keyframes nav-scrim-in { from { opacity: 0; } }
}

/* ПОРОГ БУРГЕРА: ≤767px сейчас (3 пункта, замер в proposal.md §4).
   Когда в меню станет 5 пунктов (Инструкция, Плагины) — поднять до 959px:
   это единственное место, JS берёт порог из видимости .nav-toggle. */
@media (max-width: 767px) {
  .header-inner { gap: 12px; }
  .site-nav { display: none; }
  .header-actions .icon-btn { display: none; } /* GitHub, язык, тема — в панели */
  .nav-toggle:not([hidden]) { display: inline-flex; }
  .nav-cta { margin-right: 2px; }
}
@media (min-width: 768px) {
  .nav-panel, .nav-scrim { display: none !important; }
}
/* Узкие телефоны: у бургера остаётся только иконка (подпись — для скринридера) */
@media (max-width: 359px) {
  .nav-toggle { padding: 0 10px; }
  .nav-toggle-label {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .nav-cta { padding: 0 12px; }
}

/* ─────────── Оглавление лендинга «На странице» (не липкое) ─────────── */

.page-toc { margin: 8px 0 0; }
.page-toc-row {
  display: flex;
  align-items: baseline;
  gap: 4px 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
  white-space: nowrap;
}
.page-toc-label { flex: none; font-weight: 600; color: var(--ink-muted); }
.page-toc ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.page-toc a {
  display: inline-block;
  padding: 4px 0;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
}
.page-toc a:hover { text-decoration-color: currentColor; }
/* Телефон: строка прокручивается вбок, правый край затухает */
@media (max-width: 767px) {
  .page-toc-row {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent);
    mask-image: linear-gradient(90deg, #000 82%, transparent);
  }
  .page-toc-row::-webkit-scrollbar { display: none; }
  .page-toc ul { flex-wrap: nowrap; padding-right: 48px; }
}

/* ─────────── Подвал ─────────── */

.site-footer {
  background: #1d1b26; /* чернила — константа бренда, не зависит от темы */
  color: #f1eff7;
  padding: 56px 0 40px;
}
:root[data-theme="dark"] .site-footer { border-top: 1px solid var(--line); }

.footer-top {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 3fr;
  gap: 32px;
  align-items: start;
}
.footer-logo { display: block; height: 28px; width: auto; }

.footer-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}
.footer-col-title {
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.4;
  color: rgba(241, 239, 247, 0.6);
}
.footer-col ul { margin: 0; padding: 0; list-style: none; }
.footer-col a {
  display: inline-flex;
  align-items: center;
  padding: 6px 0; /* тап-зона ≥ 32px */
  font-size: 14px;
  font-weight: 500;
  color: rgba(241, 239, 247, 0.88);
  text-decoration: underline;
  text-decoration-color: rgba(241, 239, 247, 0.3);
  text-underline-offset: 4px;
}
.footer-col a:hover { color: #fff; text-decoration-color: var(--cinnabar); }
.footer-col a:focus-visible { border-radius: 4px; }
.footer-ext { margin-left: 3px; font-size: 0.85em; opacity: 0.7; }
:root[lang="en"] .shell-ru-only { display: none; }

.footer-fine {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 0;
  margin: 40px 0 0;
  padding-top: 20px;
  border-top: 1px solid rgba(241, 239, 247, 0.12);
  font-size: 12.5px;
  color: rgba(241, 239, 247, 0.6);
}
.footer-slogan { color: rgba(241, 239, 247, 0.85); font-weight: 500; }
.footer-dot { margin: 0 8px; }

@media (max-width: 767px) {
  .footer-top { grid-template-columns: 1fr; gap: 24px; }
  .footer-nav { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 479px) {
  .footer-nav { gap: 20px 16px; }
  .footer-fine { flex-direction: column; gap: 6px; }
  .footer-fine .footer-dot { display: none; }
}
@media (max-width: 339px) {
  .footer-nav { grid-template-columns: 1fr; }
}
