/*
  Шапка сайта документации. Одна на все страницы: Docusaurus (главная, гайды, Postman, Changelog,
  разметка в src/theme/Navbar/Content/index.js) и статические static/reference/ и static/swagger/.
  Разметку в этих трёх местах менять синхронно, стили только здесь: раньше у каждой страницы была
  своя шапка, и при переходах она прыгала.
  Стили повторяют шапку mailganer.com: шрифт RF Dewi 600 20px, ссылки чёрные, наведение #2b8ed9,
  кнопки «Вход» и «Регистрация» как на сайте. Шапка на всю ширину: лого над боковым меню гайдов и справочника.
*/
@font-face {
  font-family: 'RF Dewi';
  src: url('../fonts/RF-Dewi-Semibold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

.mg-header, .mg-header__mobile {
  --mgh-text: #000;
  --mgh-hover: #2b8ed9;
  --mgh-active: #0062ad;
}
.mg-header {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  /* Полоса по центру, как на mailganer.com: контейнер 1200px, лого и кнопки у его краёв. */
  width: 100%;
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  font-family: 'RF Dewi', Arial, sans-serif;
  font-weight: 600;
  /* Как в теле Docusaurus: без этого на статических страницах буквы ложатся чуть иначе. */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
[data-theme='dark'] .mg-header {
  --mgh-text: #e3e3e3;
  --mgh-active: #4c9fe6;
}

.mg-header__brand { display: flex; align-items: center; gap: 8px; flex: none; text-decoration: none; }
.mg-header__brand:hover { text-decoration: none; }
.mg-header__brand img { display: block; width: 140px; height: 30px; }
.mg-header__brand span { font-size: 20px; line-height: 1; color: #5c6574; font-weight: 500; }
/* «API» — название раздела, не часть бренда: серый на светлой (5.8:1), светлый серый на тёмной. */
[data-theme='dark'] .mg-header__brand span { color: #a8b3c1; }

.mg-header__links { display: flex; align-items: center; gap: 10px; min-width: 0; margin-left: 30px; }
.mg-header__link {
  font-size: 20px;
  line-height: 28px;
  color: var(--mgh-text);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.3s ease-in-out;
}
.mg-header__link:hover, .mg-header__link:focus-visible { color: var(--mgh-hover); text-decoration: none; }
.mg-header__link[aria-current='page'] { color: var(--mgh-active); }

.mg-header__right { display: flex; align-items: center; gap: 30px; margin-left: auto; flex: none; }
/* Переключатель темы: на Docusaurus штатный, на статических страницах .mg-theme-toggle того же вида.
   На главной Docusaurus кнопки нет, место остаётся, чтобы кнопки справа не сдвигались. */
.mg-header__theme { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; }
.mg-theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 50%; background: none; color: #1c1e21; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
}
.mg-theme-toggle:hover { background: #ebedf0; }
.mg-theme-toggle svg { display: none; }
[data-theme='light'] .mg-theme-toggle__light, [data-theme='dark'] .mg-theme-toggle__dark,
:root:not([data-theme]) .mg-theme-toggle__light { display: block; }
[data-theme='dark'] .mg-theme-toggle { color: #e3e3e3; }
[data-theme='dark'] .mg-theme-toggle:hover { background: #444950; }
.mg-header__buttons { display: flex; align-items: center; gap: 10px; }
.mg-header__btn {
  display: inline-block;
  padding: 2px 9px 4px;
  border-radius: 3px;
  font: 600 20px/28px 'RF Dewi', Arial, sans-serif;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}
.mg-header__btn:hover { text-decoration: none; }
.mg-header__btn--login { background: #f2eeeb; color: #000; }
.mg-header__btn--login:hover, .mg-header__btn--login:focus-visible { background: #e8d7ca; color: #000; }
.mg-header__btn--signup, .mg-header__btn--lk { background: #0062ad; color: #fff; }
.mg-header__btn--signup:hover, .mg-header__btn--signup:focus-visible,
.mg-header__btn--lk:hover, .mg-header__btn--lk:focus-visible { background: #2b8ed9; color: #fff; }

/* Кнопки входа по состоянию ЛК (data-mg-auth ставит ../js/mg-auth.js), как на mailganer.com:
   залогинен, значит только «В личный кабинет», иначе «Вход» и «Регистрация». Пока проверка не
   ответила и в кеше пусто, место под кнопки занято, но их не видно. */
.mg-header__btn--lk { display: none; }
html:not([data-mg-auth]) .mg-header__btn { visibility: hidden; }
html[data-mg-auth='user'] .mg-header__btn--login, html[data-mg-auth='user'] .mg-header__btn--signup { display: none; }
html[data-mg-auth='user'] .mg-header__btn--lk { display: inline-block; }
/* То же в выезжающем меню Docusaurus (пункты из themeConfig.navbar.items). */
html[data-mg-auth='user'] .navbar-sidebar .mg-nav-login, html[data-mg-auth='user'] .navbar-sidebar .mg-nav-signup,
html:not([data-mg-auth='user']) .navbar-sidebar .mg-nav-lk { display: none; }

/* Бургер статических страниц: размер и иконка как у .navbar__toggle Docusaurus, чтобы не сдвигался при переходе. */
.mg-header__burger {
  display: none;
  width: 30px; height: 30px; padding: 0;
  border: 0; background: none; color: var(--mgh-text); cursor: pointer;
}
.mg-header__burger svg { display: block; width: 30px; height: 30px; }
.mg-header__mobile { display: none; }

/* Полоса шапки на статических страницах. На Docusaurus её роль играет nav.navbar: та же высота
   вместе с нижней границей (border-box), иначе линия под шапкой при переходе прыгает на пиксель. */
.mg-header-bar {
  position: sticky; top: 0; z-index: 100;
  box-sizing: border-box;
  height: 80px;
  background: #fff;
  border-bottom: 1px solid #e6eaf0;
}
/* Тёмная полоса и мобильное меню: те же цвета, что у навбара Docusaurus в тёмной теме (src/css/custom.css). */
[data-theme='dark'] .mg-header-bar { background: #151a21; border-bottom-color: #232a34; }
[data-theme='dark'] .mg-header__mobile { --mgh-text: #e3e3e3; --mgh-active: #4c9fe6; }

@media (max-width: 1240px) {
  .mg-header { gap: 20px; }
  .mg-header__links { gap: 8px; }
  .mg-header__link, .mg-header__brand span { font-size: 17px; }
  .mg-header__btn { font-size: 17px; line-height: 24px; }
  .mg-header__right { gap: 16px; }
}

@media (max-width: 1100px) {
  .mg-header { gap: 16px; }
  .mg-header__links { gap: 6px; }
  .mg-header__brand img { width: 120px; height: 26px; }
  .mg-header__link, .mg-header__brand span { font-size: 16px; }
  .mg-header__btn { padding: 2px 8px 3px; font-size: 16px; line-height: 22px; }
  .mg-header__right { gap: 12px; }
}

/* Мобильная раскладка с той же границы, что у Docusaurus. */
@media (max-width: 996px) {
  .mg-header-bar { height: 64px; }
  .mg-header { padding: 0 16px; }
  .mg-header__brand img { width: 112px; height: 24px; }
  /* Переключатель темы на мобильной ширине живёт в выезжающем меню Docusaurus. */
  .mg-header__links, .mg-header__buttons, .mg-header__theme { display: none; }
  /* Значок уходит вправо к бургеру (меню скрыто): auto только у значка, правую группу не толкаем. */
  .mg-search-btn { margin-left: auto; margin-right: 6px; }
  .mg-header__right { margin-left: 0; }
  .mg-header__burger { display: block; }
  .mg-header__link, .mg-header__brand span { font-size: 18px; }

  .mg-header-bar.is-open .mg-header__mobile {
    display: flex; flex-direction: column; gap: 4px;
    position: absolute; top: 100%; left: 0; right: 0;
    max-height: calc(100vh - 64px); overflow-y: auto;
    padding: 12px 16px 20px;
    background: #fff; border-bottom: 1px solid #e6eaf0;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
  }
  [data-theme='dark'] .mg-header-bar.is-open .mg-header__mobile { background: #151a21; border-bottom-color: #232a34; }
  .mg-header__mobile .mg-header__link { padding: 8px 0; font-family: 'RF Dewi', Arial, sans-serif; font-weight: 600; }
  .mg-header__mobile .mg-header__mobile-buttons { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
  .mg-header__mobile .mg-theme-toggle { margin-left: auto; }
}
