/* Шапка сайта (блок header), меню разделов (блок menu, blocks/menu/menu.php) и мобильное меню (блок mobile-menu,
   blocks/mobileMenu) — design/2026-11-30-redizajn/verstka/header.css слияния 02.12 (канон мобильного меню —
   glavnaya/menyu.html). До 1001 px — шапка с «бургером», он открывает мобильное меню (mobileMenu/assets/menu.js);
   с 1002 px — полная шапка. Классы header__nav-item--*, header__search — хуки header.js и search.js: не переименовывать.
   Отличия от вёрстки — помечены «Тема:»: строка поиска (форма ActiveForm блока search, у вёрстки поле без обвязки),
   правила образца для всей страницы (фокус графитом, a{color:inherit}, шрифт кнопок, цвет текста) — только внутри
   шапки и меню (у страниц темы свои: оранжевый фокус, #333), перенос «Пополнить» под длинную сумму. */

/* Тема: база образца внутри шапки и меню. :where — без веса: классы блоков задают свой цвет поверх, как в образце */
:where(.header) a {
  color: inherit;
  text-decoration: none;
}

:where(.header) button {
  font: inherit;
  color: inherit;
}

:where(.header) :focus-visible,
:where(.mobile-menu) :focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* z-index 30: нижняя линия шапки видна над открытым мобильным меню (оно начинается с 60px, на линии шапки). */
.header {
  position: relative;
  z-index: 30;
  color: var(--ink);
  font-feature-settings: "tnum" 1; /* Тема: цифры моноширинные, как у body вёрстки (tokens.css) */
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.header__container {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  max-width: var(--container);
  height: 60px;
  padding: 0 var(--gutter);
  margin: 0 auto;
}

.header__logo {
  display: flex;
  margin-right: auto;
  color: var(--acc);
  text-decoration: none;
}

.header__logo-sub {
  fill: var(--ink2);
}

/* Разделы: на телефоне — в мобильном меню. */
.menu {
  display: none;
}

.menu__item {
  font-size: 0.9375rem;
  color: var(--ink2);
  text-decoration: none;
}

.menu__item--active {
  font-weight: 600;
  color: var(--ink);
}

.header__nav-items {
  display: flex;
  gap: 0.375rem;
  align-items: center;
}

/* Значок-кнопка: поиск, корзина, бургер. */
.header__icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: 0;
  border-radius: var(--rc);
}

.header__icon-image {
  width: 20px;
  height: 20px;
}

/* Счётчик корзины; число пишет header.js (.header__nav-item--cart-counter). */
.header__counter {
  position: absolute;
  top: 5px;
  right: 3px;
  min-width: 18px;
  height: 18px;
  padding: 0 0.3125rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 18px;
  color: var(--bg);
  text-align: center;
  background: var(--ink);
  border-radius: 9px;
}

/* Вход, регистрация, «Личный кабинет» — с 1002px; до этого они в мобильном меню и в плашке кредитов страницы. */
.header__account {
  display: none;
}

/* Бургер: значок «закрыть», пока меню открыто (класс ставит menu.js). */
.header__burger-close {
  display: none;
}

.header__burger--open .header__burger-open {
  display: none;
}

.header__burger--open .header__burger-close {
  display: block;
}

/* Поиск открыт (header.js) */
.header__nav-item--search-active {
  background: var(--surf);
}

/* Тема: поиск по каталогу — форма блока search (search.js даёт search--visible), строка под шапкой во всю ширину
   (в дизайне раскрытого поиска нет — вопрос дизайнеру открыт, по умолчанию строка).
   .header перед классом — сильнее общих правил блока search (search.css грузится после шапки) */
.header .header__search {
  top: 100%;
  right: 0;
  left: 0;
  z-index: 10;
  width: auto;
  max-width: none;
  padding: 0.75rem var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  box-shadow: none;
  opacity: 1;
}

.header .header__search:not(.search--visible) {
  opacity: 0;
}

.header__search .search__form {
  max-width: calc(var(--container) - 2 * var(--gutter-wide));
  margin: 0 auto;
}

.header__search .custom-input__field {
  min-height: 44px;
  padding: 0 84px 0 0.875rem;
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line2);
  border-radius: var(--rc);
}

.header__search .custom-input__field:focus {
  border-color: var(--ink);
}

/* Подпись поля стоит в нём, пока поле пустое: по середине поля высотой 44 px */
.header__search .custom-input__label {
  top: 11px;
  color: var(--mut);
}

/* Тема: подпись пустого поля не в фокусе — между левым краем и кнопками «Найти», «Очистить» (84 px, как у текста
   запроса), не влезает в строку — две строки по середине поля. На телефоне она шла под значки (сверка 03.12: на 390 «или ID»
   под лупой; поле пустое и не в фокусе — спрятали клавиатуру, нажали «Найти»). Поднятая подпись — как была.
   Середина — от поля высотой 44 px, не от обёртки: в обёртке под полем бывает сообщение проверки «Необходимо заполнить…». */
.header__search .custom-input__label:not(.custom-input__label--filled) {
  top: 22px;
  right: 84px;
  line-height: 1.15;
  overflow-wrap: anywhere;
  transform: translateY(-50%);
}

.header__search .custom-input__label--filled {
  top: -7px;
}

/* Тема: кнопки «Найти» и «Очистить» — по середине поля 44 px, не формы (search.css: top 50%): под полем бывает
   сообщение проверки «Необходимо заполнить…», и кнопки съезжали вниз на 8 px (ревью 03.12). */
.header__search .search__form-controls {
  top: 22px;
}

.header__search .search__form-icon {
  color: var(--mut);
}

@media (hover: hover) {
  .menu__item:hover {
    color: var(--ink);
  }

  .header__icon:hover {
    background: var(--surf);
  }

  /* Тема: кнопки строки поиска — как значки шапки: серый фон, значок не оранжевый (search.css красит его, вес 0,3,0) */
  .header__search .search__form-submit:hover,
  .header__search .search__form-close:hover {
    background: var(--surf);
  }

  .header__search .search__form-submit:hover .search__form-icon,
  .header__search .search__form-close:hover .search__form-icon {
    color: var(--ink);
  }
}

/* Поля страницы — с 901px, как у контента. */
/* stylelint-disable-next-line media-feature-range-notation -- правило темы: (width > N) не понимает Safari до 16.4 */
@media not screen and (max-width: 900px) {
  .header__container {
    padding: 0 var(--gutter-wide);
  }

  .header .header__search {
    padding: 0.75rem var(--gutter-wide);
  }
}

/* Полная шапка — с 1002px (Сева 02.12, «Всё по умолчанию»): гость с «Войти» и «Создать аккаунт» помещается с 1002px,
   вошедший — с 917px. До 1001px — шапка с бургером.
   Тема: границы шапки и мобильного меню — в em, от шрифта браузера, как rem-размеры шапки: 62.5625em и 74.9375em —
   1001 и 1199px при обычном шрифте 16px; при «Крупном» 20px — 1251,25 и 1498,75px. В px шапка вошедшего при
   шрифте 20px на 1200–1366px вылезала за правый край (ревью 02.12, [3/10 · вёрстка], стенд tests/js/header-wallet).
   Ширины в комментариях ниже — при шрифте 16px. */
/* stylelint-disable-next-line media-feature-range-notation -- правило темы: (width > N) не понимает Safari до 16.4 */
@media not screen and (max-width: 62.5625em) {
  .header__container {
    gap: 2.75rem;
    height: 72px;
  }

  .header__logo {
    margin-right: 0;
  }

  /* Тема: пункты разделов — во всю высоту шапки (72px), текст по середине, черта текущего — на нижней линии.
     В вёрстке — отступы 1.5rem: при шрифте браузера 20px пункт выше шапки на 18px, черта висела под ней над страницей
     (ревью 02.12, [2/10 · вёрстка], tests/js/header-wallet). При 16px раскладка та же. */
  .header__nav {
    display: flex;
    flex: 1;
    align-self: stretch;
  }

  .menu {
    display: flex;
    gap: 1.75rem;
  }

  .menu__item {
    display: flex;
    align-items: center;
    border-bottom: 2px solid transparent;
  }

  .menu__item--active {
    border-bottom-color: var(--ink);
  }

  .header__account {
    display: inline-flex;
  }

  .header__burger {
    display: none;
  }
}

/* ---------- Баланс вошедшего на ПК (вариант 1 «Плашка», Сева 02.12: «№1 Плашка»; образец shapka-balans/) ----------
   header__wallet--pill — одна ссылка на пополнение перед «Личный кабинет»: «1 250 кр | + Пополнить».
   Сумма — ThemeFunctions::formatCredits + « кр». До 1001px плашки нет — баланс в мобильном меню. */
.header__wallet {
  display: none;
}

.header__wallet-value {
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
}

.header__wallet-plus {
  flex: none;
  width: 12px;
  height: 12px;
}

/* stylelint-disable-next-line media-feature-range-notation -- правило темы: (width > N) не понимает Safari до 16.4 */
@media not screen and (max-width: 62.5625em) {
  .header__wallet {
    display: inline-flex;
    flex: none;
    align-items: center;
  }
}

.header__wallet--pill {
  gap: 0.625rem;
  min-height: 40px;
  padding: 0 0.875rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  background: var(--surf);
  border-radius: var(--rc);
  transition: background 0.15s;
}

.header__wallet-sep {
  width: 1px;
  height: 20px;
  background: var(--line2);
}

.header__wallet-action {
  display: inline-flex;
  gap: 0.375rem;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 600;
}

@media (hover: hover) {
  .header__wallet--pill:hover {
    background: var(--chip-hover);
  }
}

/* Узкий ПК, 1002–1199px: у вошедшего промежутки шапки 44 → 16px (группы), 28 → 16px (разделы); в плашке — сумма и «+»,
   слово «Пополнить» остаётся в имени ссылки для чтения с экрана и в title. Шапку гостя не меняет.
   Тема: в вёрстке — вложенный @media (not max-width 1001 → not min-width 1200), здесь — каскадом двух нижних границ
   not screen and (max-width: N) (правило темы, MediaWidthBoundaryTest): с 1002 — узкий режим, с 1200 — полный поверх.
   Обе границы — точное дополнение (max-width: N), в em: на дробной ширине (масштаб 110 %: 1001,82 и 1199,09px) щели нет. */
/* stylelint-disable-next-line media-feature-range-notation -- правило темы */
@media not screen and (max-width: 62.5625em) {
  .header--user .header__container {
    gap: 1rem;
  }

  .header--user .menu {
    gap: 1rem;
  }

  .header--user .header__wallet--pill {
    gap: 0.5rem;
    padding: 0 0.625rem 0 0.75rem;
  }

  .header__wallet--pill .header__wallet-word {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .header__wallet--pill .header__wallet-plus {
    width: 14px;
    height: 14px;
  }
}

/* Полный ПК вошедшего, с 1200px — как у гостя (44 и 28px, полная шапка выше), со словом «Пополнить» */
/* stylelint-disable-next-line media-feature-range-notation -- правило темы */
@media not screen and (max-width: 74.9375em) {
  .header--user .header__container {
    gap: 2.75rem;
  }

  .header--user .menu {
    gap: 1.75rem;
  }

  .header--user .header__wallet--pill {
    gap: 0.625rem;
    padding: 0 0.875rem;
  }

  .header__wallet--pill .header__wallet-word {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
  }

  .header__wallet--pill .header__wallet-plus {
    width: 12px;
    height: 12px;
  }
}

/* ---------- Мобильное меню (блок mobile-menu) ----------
   Под шапкой на всю ширину. Гость — подсказка про кредиты и две кнопки; вошедший — логин, «Выйти», баланс и «Пополнить»,
   разделы кабинета; «Админка» — только админу. Затем разделы сайта, текущий — полоса слева и полужирный. */
.mobile-menu {
  position: fixed;
  inset: 60px 0 0;
  z-index: 25;
  display: none;
  padding: 1rem 1rem 2rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--ink);
  font-feature-settings: "tnum" 1;
  background: var(--bg);
}

.mobile-menu__account {
  padding-bottom: 1rem;
}

.mobile-menu__note {
  margin: 0 0 0.875rem;
  font-size: 0.875rem;
  color: var(--ink2);
}

.mobile-menu__buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.mobile-menu__button {
  min-height: 48px;
  padding: 0 0.75rem;
}

.mobile-menu__card {
  padding: 1rem;
  background: var(--surf);
  border-radius: var(--r);
}

.mobile-menu__head {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.mobile-menu__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
}

.mobile-menu__logout {
  padding: 0.625rem 0 0.625rem 0.75rem;
  font-size: 0.875rem;
  color: var(--ink2);
  text-decoration: none;
}

/* Тема (27.11): сумма от 1 000 кр на узком телефоне — «Пополнить» уходит строкой ниже, а не наезжает на «кр» */
.mobile-menu__balance {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  margin-top: 0.625rem;
  border-top: 1px solid var(--line2);
}

.mobile-menu__balance-label {
  display: block;
  font-size: 0.8125rem;
  color: var(--mut);
}

.mobile-menu__balance-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.mobile-menu__topup {
  min-height: 44px;
  font-size: 0.9375rem;
}

.mobile-menu__list {
  display: flex;
  flex-direction: column;
  margin-top: 0.5rem;
}

.mobile-menu__list--site {
  padding-top: 0.25rem;
  border-top: 1px solid var(--line);
}

.mobile-menu__list--cabinet {
  margin-top: 0.25rem;
}

.mobile-menu__link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 0.25rem 0 0.875rem;
  font-size: 1rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.mobile-menu__link:last-child {
  border-bottom: 0;
}

/* Стрелка строки — декор. */
.mobile-menu__link::after {
  width: 7px;
  height: 7px;
  margin-right: 4px;
  content: "";
  border-right: 1.6px solid var(--mut);
  border-bottom: 1.6px solid var(--mut);
  transform: rotate(-45deg);
}

/* Текущий раздел: aria-current="page" и модификатор — полоса слева и полужирный. */
.mobile-menu__link--current {
  font-weight: 600;
}

.mobile-menu__link--current::before {
  position: absolute;
  left: 0;
  width: 3px;
  height: 24px;
  content: "";
  background: var(--ink);
  border-radius: 2px;
}

@media (hover: hover) {
  .mobile-menu__logout:hover {
    color: var(--ink);
    text-decoration: underline;
  }

  .mobile-menu__link:hover {
    background: var(--surf);
  }
}

/* Открыто — только пока виден бургер шапки (до 1001px, та же граница 62.5625em). Шире меню не показывается, даже если
   осталось открытым при повороте экрана. */
/* stylelint-disable-next-line media-feature-range-notation -- правило темы */
@media (max-width: 62.5625em) {
  .mobile-menu--open {
    display: block;
  }

  /* Тема: пока меню открыто, страница под ним не прокручивается (menu.js ставит класс на html) — шапка не уезжает
     из-под меню, над меню не появляется полоса страницы. Место под полосой прокрутки остаётся — на ПК в узком окне
     шапка не сдвигается вбок */
  .mobile-menu-lock {
    overflow: hidden;
    scrollbar-gutter: stable;
  }
}
