/* KOSMOS header — визуал и типографика как на kosmosvpn.app */

.kosmos-header {
  --kh-bg: #070707;
  --kh-fg: #ffffff;
  --kh-muted: #8d8d8d;
  --kh-accent: #d0f8a0;
  --kh-border: rgba(255, 255, 255, 0.06);
  --kosmos-header-h: 72px;
  font-family: var(--kosmos-font, "Manrope", system-ui, sans-serif);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--kh-bg);
  color: var(--kh-fg);
  transition: transform 0.3s ease, background-color 0.2s ease, color 0.2s ease;
  padding-top: env(safe-area-inset-top);
  /* Сброс Reboot .site-header: inset-тень #f2f5f9 = белая полоса снизу */
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
  box-shadow: none !important;
  border: none !important;
  border-bottom: none !important;
}

html[data-theme="light"] .kosmos-header {
  --kh-bg: #ffffff;
  --kh-fg: #070707;
  --kh-muted: #8d8d8d;
  --kh-accent: #3b648c;
  --kh-border: rgba(7, 7, 7, 0.08);
  /* Без hairline — на лендинге её нет */
  box-shadow: none !important;
}

.kosmos-header.is-hidden {
  transform: translateY(-100%);
}

.kosmos-header.is-open {
  transform: none;
}

.kosmos-header a {
  color: var(--kh-muted);
  text-decoration: none;
  transition: color 0.2s ease;
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.2;
}

.kosmos-header a:hover,
.kosmos-header a:focus-visible {
  color: var(--kh-fg);
}

.kosmos-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--kosmos-header-h);
  padding: 16px 20px;
  box-sizing: border-box;
}

@media (min-width: 1024px) {
  .kosmos-header {
    --kosmos-header-h: 104px;
  }

  .kosmos-header__bar {
    padding: 24px 72px;
  }
}

.kosmos-header__brand {
  flex: 0 1 40%;
  display: flex;
  align-items: center;
  min-width: 0;
}

@media (min-width: 1024px) {
  .kosmos-header__brand {
    flex-basis: 18%;
  }
}

.kosmos-header__logo-link {
  display: inline-flex;
  align-items: center;
  color: var(--kh-fg) !important;
}

.kosmos-header__logo-img {
  display: block;
  height: 40px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  transition: filter 0.2s ease;
}

html[data-theme="light"] .kosmos-header__logo-img--default {
  filter: brightness(0);
}

@media (min-width: 1024px) {
  .kosmos-header__logo-img {
    height: 57px;
    max-width: 160px;
  }
}

.kosmos-header__nav {
  display: none;
  flex: 1 1 auto;
  justify-content: center;
}

@media (min-width: 1024px) {
  .kosmos-header__nav {
    display: flex;
  }
}

.kosmos-header__links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 40px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.kosmos-header__links li {
  margin: 0;
  padding: 0;
}

.kosmos-header__links a {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0;
  color: var(--kh-muted);
}

.kosmos-header__links a:hover,
.kosmos-header__links .current-menu-item > a,
.kosmos-header__links .current_page_item > a {
  color: var(--kh-fg);
}

.kosmos-header__actions {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  flex: 0 0 auto;
}

@media (min-width: 1024px) {
  .kosmos-header__actions {
    display: flex;
    flex-basis: 22%;
  }
}

.kosmos-header__mobile-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  .kosmos-header__mobile-tools {
    display: none;
  }
}

.kosmos-header__account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--kh-fg) !important;
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
}

.kosmos-header__account:hover {
  color: var(--kh-accent) !important;
}

.kosmos-header__account-arrow {
  font-size: 18px;
  line-height: 1;
}

/* Компактный поиск (триггер) — modal остаётся Reboot .js-search-screen */
.kosmos-header__search {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--kh-fg);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.kosmos-header__search:hover,
.kosmos-header__search:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: var(--kh-accent);
  outline: none;
}

html[data-theme="light"] .kosmos-header__search:hover,
html[data-theme="light"] .kosmos-header__search:focus-visible {
  background: rgba(7, 7, 7, 0.06);
}

.kosmos-header__burger {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.kosmos-header__burger-bar {
  display: block;
  width: 24px;
  height: 2px;
  border-radius: 2px;
  background: var(--kh-fg);
  transition: transform 0.25s ease, opacity 0.25s ease, background-color 0.2s ease;
}

.kosmos-header.is-open .kosmos-header__burger-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.kosmos-header.is-open .kosmos-header__burger-bar:nth-child(2) {
  opacity: 0;
}

.kosmos-header.is-open .kosmos-header__burger-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.kosmos-header__drawer {
  display: none;
  background: var(--kh-bg);
  padding: 8px 20px 32px;
  border-top: 1px solid var(--kh-border);
  max-height: calc(100dvh - var(--kosmos-header-offset, 104px));
  overflow-y: auto;
}

.kosmos-header.is-open .kosmos-header__drawer {
  display: block;
}

@media (min-width: 1024px) {
  .kosmos-header__drawer,
  .kosmos-header.is-open .kosmos-header__drawer {
    display: none !important;
  }
}

.kosmos-header__drawer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.kosmos-header__drawer-links a {
  font-size: 16px;
  font-weight: 400;
  color: var(--kh-muted);
}

.kosmos-header__drawer-links a:hover,
.kosmos-header__drawer-links .current-menu-item > a {
  color: var(--kh-fg);
}

.kosmos-header__drawer-account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 36px;
  color: var(--kh-fg) !important;
  font-size: 16px;
  font-weight: 500;
}

.kosmos-header__drawer-account:hover {
  color: var(--kh-accent) !important;
}

/* Реальная высота задаётся JS (--kosmos-header-offset) */
.kosmos-header-spacer {
  height: var(--kosmos-header-offset, 120px);
  flex-shrink: 0;
}

body.kosmos-has-header .header-separator,
body.kosmos-has-header .mobile-menu-placeholder,
body.kosmos-has-header .main-navigation {
  display: none !important;
}

body.kosmos-header-open {
  overflow: hidden;
}

/* Search overlay — ровный modal KOSMOS (без конфликта transform Reboot) */
.search-screen-overlay {
  background: rgba(7, 7, 7, 0.58) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.search-screen,
.search-screen.open {
  /* Reboot: translateY(-100px) / translateY(0) ломает наш translateX(-50%) */
  top: max(88px, 14vh) !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  width: min(560px, calc(100vw - 32px)) !important;
  max-width: 560px !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
  z-index: 1000000 !important;
}

.search-screen {
  transform: translate3d(-50%, -10px, 0) scale(0.98) !important;
  opacity: 0 !important;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease !important;
}

.search-screen.open {
  transform: translate3d(-50%, 0, 0) scale(1) !important;
  opacity: 1 !important;
  pointer-events: auto;
}

.kosmos-search-panel {
  padding: 18px 18px 16px;
  border-radius: 20px;
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 28px 64px -20px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

html[data-theme="light"] .kosmos-search-panel {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(7, 7, 7, 0.08);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 28px 64px -24px rgba(11, 37, 62, 0.28);
}

.kosmos-search-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 0 4px;
}

.kosmos-search-panel__title {
  font-family: var(--kosmos-font, Manrope, system-ui, sans-serif);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

html[data-theme="light"] .kosmos-search-panel__title {
  color: rgba(7, 7, 7, 0.45);
}

.kosmos-search-panel__hint {
  font-family: var(--kosmos-font, Manrope, system-ui, sans-serif);
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.35);
}

html[data-theme="light"] .kosmos-search-panel__hint {
  color: rgba(7, 7, 7, 0.35);
}

.search-screen .search-form {
  position: relative !important;
  display: flex !important;
  align-items: stretch !important;
  gap: 0 !important;
  margin: 0 !important;
  max-width: none !important;
  border-radius: 14px !important;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: none !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

html[data-theme="light"] .search-screen .search-form {
  background: #f4f5f7 !important;
  border-color: rgba(7, 7, 7, 0.1) !important;
}

.search-screen .search-form:focus-within {
  border-color: rgba(208, 248, 160, 0.65) !important;
  box-shadow: 0 0 0 3px rgba(208, 248, 160, 0.18) !important;
}

html[data-theme="light"] .search-screen .search-form:focus-within {
  border-color: rgba(59, 100, 140, 0.55) !important;
  box-shadow: 0 0 0 3px rgba(59, 100, 140, 0.15) !important;
}

.search-screen .search-form label {
  flex: 1 1 auto !important;
  display: block !important;
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  min-width: 0;
}

.search-screen .search-field {
  display: block !important;
  width: 100% !important;
  height: 56px !important;
  margin: 0 !important;
  padding: 0 18px !important;
  border: 0 !important;
  border-bottom: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: #f4f4f4 !important;
  font-family: var(--kosmos-font, Manrope, system-ui, sans-serif) !important;
  font-size: 17px !important;
  font-weight: 600 !important;
  letter-spacing: -0.02em;
  text-align: left !important;
  box-shadow: none !important;
  outline: none !important;
  -webkit-appearance: none;
  appearance: none;
}

html[data-theme="light"] .search-screen .search-field {
  color: #070707 !important;
}

.search-screen .search-field::placeholder {
  color: rgba(255, 255, 255, 0.38) !important;
  font-weight: 500 !important;
}

html[data-theme="light"] .search-screen .search-field::placeholder {
  color: rgba(7, 7, 7, 0.4) !important;
}

.search-screen .search-field::-webkit-search-decoration,
.search-screen .search-field::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-screen .search-submit {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  flex: 0 0 56px !important;
  width: 56px !important;
  height: 56px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: #d0f8a0
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='11' cy='11' r='6.5' stroke='%230b253e' stroke-width='2'/%3E%3Cpath d='M20 20l-3.5-3.5' stroke='%230b253e' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E")
    center / 22px 22px no-repeat !important;
  color: transparent !important;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease !important;
}

.search-screen .search-submit:hover,
.search-screen .search-submit:focus-visible {
  filter: brightness(1.06);
  outline: none;
}

.search-screen .search-submit:active {
  transform: scale(0.96);
}

html[data-theme="light"] .search-screen .search-submit {
  background: #0b253e
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='11' cy='11' r='6.5' stroke='%23d0f8a0' stroke-width='2'/%3E%3Cpath d='M20 20l-3.5-3.5' stroke='%23d0f8a0' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E")
    center / 22px 22px no-repeat !important;
  color: transparent !important;
}

.search-screen .search-submit:before {
  content: none !important;
  display: none !important;
}

@media (max-width: 640px) {
  .search-screen,
  .search-screen.open {
    top: max(72px, 10vh) !important;
    width: calc(100vw - 24px) !important;
  }

  .kosmos-search-panel {
    padding: 14px;
    border-radius: 16px;
  }

  .search-screen .search-field,
  .search-screen .search-submit {
    height: 52px !important;
  }

  .search-screen .search-submit {
    flex-basis: 52px !important;
    width: 52px !important;
  }
}

/* Language switcher — как на лендинге */
.kosmos-lang-switch {
  position: relative;
  flex-shrink: 0;
}

.kosmos-lang-switch__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--kh-fg);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.kosmos-lang-switch__btn:hover,
.kosmos-lang-switch__btn:focus-visible,
.kosmos-lang-switch.is-open .kosmos-lang-switch__btn {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  outline: none;
}

html[data-theme="light"] .kosmos-lang-switch__btn:hover,
html[data-theme="light"] .kosmos-lang-switch__btn:focus-visible,
html[data-theme="light"] .kosmos-lang-switch.is-open .kosmos-lang-switch__btn {
  background: rgba(7, 7, 7, 0.06);
  color: var(--kh-fg);
}

.kosmos-lang-switch__icon {
  width: 20px;
  height: 20px;
  display: block;
}

.kosmos-lang-switch__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 80;
  min-width: 200px;
  padding: 8px 0;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #111;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

html[data-theme="light"] .kosmos-lang-switch__panel {
  background: #fff;
  border-color: rgba(7, 7, 7, 0.1);
  box-shadow: 0 24px 48px rgba(11, 37, 62, 0.18);
}

.kosmos-rtl .kosmos-lang-switch__panel {
  right: auto;
  left: 0;
}

.kosmos-lang-switch__title {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8d8d8d;
}

.kosmos-lang-switch__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.kosmos-lang-switch__item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85) !important;
  text-decoration: none !important;
  transition: background 0.15s ease;
}

html[data-theme="light"] .kosmos-lang-switch__item {
  color: rgba(7, 7, 7, 0.85) !important;
}

.kosmos-lang-switch__item:hover {
  background: rgba(255, 255, 255, 0.08);
}

html[data-theme="light"] .kosmos-lang-switch__item:hover {
  background: rgba(7, 7, 7, 0.05);
}

.kosmos-lang-switch__item.is-active {
  background: #3b648c;
  color: #fff !important;
  font-weight: 700;
}
