/* Шапка: логотип, навигация и язык в одну строку — единая ширина на всех страницах */
.topbar:not(.menu-open) {
  width: min(1120px, calc(100% - 16px)) !important;
  max-width: 100% !important;
  box-sizing: border-box;
  flex-wrap: nowrap !important;
  gap: 8px;
}

.topbar.menu-open {
  width: auto !important;
  max-width: none !important;
  min-width: 0 !important;
  left: 0 !important;
  right: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  container-type: normal !important;
}

.topbar .menu {
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap !important;
  align-items: center;
  justify-content: flex-end;
}

.topbar .menu a {
  flex-shrink: 0;
  white-space: nowrap;
}

.topbar-lang {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  position: relative;
  z-index: 25;
  pointer-events: auto;
}

/* Фиксированный слот под переключатель — без скачка меню при загрузке и смене страниц */
@media (min-width: 1101px) {
  .topbar-lang {
    justify-content: flex-end;
    width: 118px;
    min-width: 118px;
    max-width: 118px;
  }

  .topbar-lang[data-lang-mode="collapsed"] {
    width: 76px;
    min-width: 76px;
    max-width: 76px;
  }

  .topbar-lang[data-lang-mode="dismissed"] {
    width: 36px;
    min-width: 36px;
    max-width: 36px;
  }
}

@media (min-width: 1101px) {
  .topbar:not(.menu-open) .menu {
    gap: 4px;
  }

  .topbar:not(.menu-open) .menu > a {
    padding: 6px 7px !important;
    font-size: 13px !important;
  }

  .topbar:not(.menu-open) .menu .menu-contact {
    padding: 6px 10px !important;
  }

  .topbar:not(.menu-open) .nav-icon-slot {
    flex: 0 0 22px !important;
    width: 22px !important;
    height: 22px !important;
    margin-right: 5px !important;
  }

  .topbar:not(.menu-open) .nav-icon-slot .nav-icon-img {
    width: 22px !important;
    height: 22px !important;
  }

  .topbar:not(.menu-open) .lang-switch {
    padding: 3px 3px 3px 6px;
  }

  .topbar:not(.menu-open) .lang-switch__flag {
    width: 32px;
    height: 24px;
  }

  .topbar:not(.menu-open) .lang-switch__flag img {
    width: 22px;
  }
}

/* Переключатель языка в шапке (справа от меню) */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.lang-switch__flags {
  display: flex;
  align-items: center;
  gap: 4px;
}

.lang-switch__flag {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 28px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.lang-switch__flag img {
  display: block;
  width: 26px;
  height: auto;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.lang-switch__flag:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.25);
}

.lang-switch__flag.is-active {
  border-color: rgba(145, 134, 224, 0.85);
  box-shadow: 0 0 0 1px rgba(145, 134, 224, 0.35);
}

.lang-switch__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: 2px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #b8bcc8;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.lang-switch__close:hover {
  background: rgba(255, 90, 90, 0.2);
  color: #ffb4b4;
}

/* Свернуто: оба флага видны, скрыт только крестик */
.lang-switch.is-collapsed .lang-switch__close {
  display: none;
}

.lang-switch.is-collapsed {
  padding: 4px;
}

.lang-switch.is-dismissed {
  display: none;
}

/* Мини-кнопка, если закрыли крестиком */
.lang-switch-mini {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  flex-shrink: 0;
}

.lang-switch-mini img {
  width: 22px;
  height: auto;
  border-radius: 2px;
}

.lang-switch-mini.is-visible {
  display: flex;
}

.menu .lang-switch,
.menu .lang-switch-mini {
  align-self: center;
}

@media (max-width: 1100px) {
  .topbar:not(.menu-open) .topbar-lang {
    display: flex !important;
    width: auto;
    min-width: 0;
    max-width: none;
    margin-left: auto;
    margin-right: 0;
  }

  .topbar.menu-open .topbar-lang {
    display: flex !important;
    width: auto;
    min-width: 0;
    max-width: none;
    justify-content: center;
    margin: clamp(4px, 1vh, 8px) auto 0;
    flex-shrink: 0;
  }

  .topbar.menu-open .menu .lang-switch,
  .topbar.menu-open .menu .lang-switch-mini {
    display: none;
  }
}

@media (max-width: 768px) {
  .topbar:not(.menu-open) {
    width: calc(100% - 16px) !important;
    max-width: calc(100% - 16px) !important;
  }
}

.i18n-blog-note {
  margin: 0 0 20px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(110, 159, 212, 0.35);
  background: rgba(110, 159, 212, 0.08);
  color: #c8d4ea;
  font-size: 14px;
  line-height: 1.5;
}

/* Иконка «Обо мне» в меню — на всех страницах, включая index без styles.css */
.menu a {
  display: inline-flex !important;
  align-items: center !important;
}

.nav-icon-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin-right: 10px;
  line-height: 0;
}

.nav-icon-slot .nav-icon-img {
  display: block;
  width: 28px;
  height: 28px;
  margin: 0;
  object-fit: contain;
  object-position: center;
}
