/* Header */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  pointer-events: none;
}

.site-header__shell,
.mobile-header {
  pointer-events: auto;
}

.site-header__shell {
  display: block;
}

.site-header__top {
  position: relative;
  z-index: 40;
  max-height: var(--header-top-h);
  overflow: visible;
  opacity: 1;
  transform: translateY(0);
  transition:
    max-height var(--transition),
    opacity var(--transition),
    transform var(--transition);
  border-bottom: 1px solid var(--border-soft);
}

.site-header__top-inner {
  min-height: var(--header-top-h);
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.top-nav {
  justify-self: center;
  grid-column: 4;
}

.top-nav__list {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.top-nav__list a {
  font-size: calc(var(--fs-topnav) + 1px);
  font-weight: var(--fw-topnav);
  color: var(--text-primary);
  transition: opacity var(--transition-base), color var(--transition-base);
}

.top-nav__list a:hover {
  opacity: 0.82;
}

.top-contacts {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  grid-column: 5;
  gap: 8px;
  position: relative;
  z-index: 700;
}

.top-contacts__phone {
  font-size: var(--fs-phone);
  font-weight: var(--fw-phone);
  white-space: nowrap;
  margin-right: 8px;
}

.header-search {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  --search-max-width: 420px;
  justify-self: start;
  grid-column: 3;
  z-index: 710;
}

.header-search__toggle {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color var(--transition-base), background-color var(--transition-base);
  position: relative;
  z-index: 530;
}

.header-search__toggle:hover,
.header-search.is-open .header-search__toggle {
  border-color: var(--accent);
  background: rgba(255, 96, 0, 0.08);
}

.header-search__toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.header-search__icon {
  width: 15px;
  height: 15px;
  border: 1.8px solid currentColor;
  border-radius: 50%;
  position: relative;
}

.header-search__icon::after {
  content: "";
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 6px;
  height: 1.8px;
  background: currentColor;
  transform: rotate(45deg);
  border-radius: 2px;
}

.header-search__panel {
  position: absolute;
  top: 50%;
  left: calc(100% + 10px);
  transform: translateY(-50%);
  width: max(260px, var(--search-max-width));
  min-width: 260px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-base), visibility var(--transition-base);
  z-index: 720;
}

.header-search.is-open .header-search__panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.header-search__input {
  width: 95%;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #11161d;
  color: var(--text-primary);
  padding: 0 16px;
}

.header-search__input:focus-visible,
.mobile-header-search__input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.header-search__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  margin-top: 0;
  max-height: min(320px, calc(100vh - 140px));
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  background: #11161d;
  border-radius: 14px;
  box-shadow: var(--shadow-modal);
  overflow-x: hidden;
  z-index: 730;
}

.mobile-header-search__dropdown {
  margin-top: 8px;
  max-height: min(320px, calc(100vh - 140px));
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  background: var(--bg-mega);
  border-radius: 14px;
  box-shadow: var(--shadow-modal);
  overflow-x: hidden;
}

.header-search__result {
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-soft);
}

.header-search__result:first-child {
  border-top: 0;
}

.header-search__result:hover {
  background: var(--hover-bg);
}

.header-search__result-title {
  font-size: 14px;
  line-height: 1.35;
  color: var(--text-primary);
}

.header-search__result-meta {
  font-size: 12px;
  line-height: 1.25;
  color: var(--text-muted);
}

.header-search__empty {
  margin: 0;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--text-muted);
}

html[data-theme="light"] .header-search__input,
html[data-theme="light"] .header-search__dropdown {
  background: #ffffff;
}

.social-icon {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background-image: none;
}

.social-icon::before {
  content: "";
  width: 14px;
  height: 14px;
  display: inline-block;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: invert(1);
}

.social-icon--wa::before {
  background-image: url("../assets/img/icon-whatsapp.png");
}

.social-icon--tg::before {
  background-image: url("../assets/img/icon-telegram.png");
}

.social-icon--max::before {
  background-image: url("../assets/img/icon-max.png");
}

.social-icon--vk::before {
  background-image: url("../assets/img/icon-vk.png");
}

html[data-theme="light"] .social-icon {
  background-color: rgba(255, 255, 255, 0.78);
  border-color: rgba(17, 17, 17, 0.2);
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

html[data-theme="light"] .social-icon::before {
  filter: none;
}

html[data-theme="light"] .social-icon--wa:hover {
  background-color: rgba(255, 96, 0, 0.12);
  border-color: rgba(255, 96, 0, 0.45);
}

html[data-theme="light"] .social-icon--tg:hover {
  background-color: rgba(255, 96, 0, 0.12);
  border-color: rgba(255, 96, 0, 0.45);
}

html[data-theme="light"] .social-icon--max:hover {
  background-color: rgba(255, 96, 0, 0.12);
  border-color: rgba(255, 96, 0, 0.45);
}

.city-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  padding: 4px 8px;
  font-size: var(--fs-topnav);
  font-weight: var(--fw-topnav);
  justify-self: start;
}

.city-trigger__caret {
  width: 9px;
  height: 9px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
}

.site-header__bottom {
  position: relative;
  z-index: 20;
  transition: min-height var(--transition), background var(--transition);
}

.site-header__bottom-inner {
  min-height: var(--header-bottom-h);
  display: grid;
  grid-template-columns: 207px 1fr 207px;
  align-items: center;
  gap: 28px;
}

.site-header.is-scrolled .site-header__shell {
  background: var(--bg-header-scrolled);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.site-header.is-scrolled .site-header__top {
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px);
  overflow: hidden;
  border-bottom-color: transparent;
}

.site-header.is-scrolled .site-header__bottom-inner {
  min-height: var(--header-sticky-bottom-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  padding: 10px;
  margin: -10px;
}

.brand__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: min(100%, 110px);
  height: 56px;
}

.brand__logo-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
  transition: filter var(--transition-base);
}

.brand__text {
  min-width: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.theme-switcher-wrap--desktop {
  grid-column: 2;
  justify-self: start;
}

.theme-switch {
  border: none;
  background: transparent;
  color: var(--text-primary);
  border-radius: 12px;
  padding: 0;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  transition:
    background-color var(--transition-base),
    border-color var(--transition-base),
    box-shadow var(--transition-base);
}

.theme-switch__track {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  align-items: center;
  width: 72px;
  height: 36px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  position: relative;
  isolation: isolate;
  transition:
    background-color var(--transition-base),
    border-color var(--transition-base),
    box-shadow var(--transition-base);
}

.theme-switch__option {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.theme-switch__icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  opacity: 0.54;
  transition:
    opacity var(--transition-base),
    filter var(--transition-base),
    transform var(--transition-base);
  user-select: none;
  pointer-events: none;
}

.theme-switch__thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 8px 18px rgba(0, 0, 0, 0.22);
  transition:
    transform var(--transition-base),
    background-color var(--transition-base),
    box-shadow var(--transition-base);
}

.theme-switch.is-light .theme-switch__thumb {
  background: rgba(255, 255, 255, 0.96);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.88),
    0 10px 22px rgba(0, 0, 0, 0.18);
}

.theme-switch:not(.is-light) .theme-switch__thumb {
  transform: translateX(35px);
  background: rgba(58, 60, 66, 0.98);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 10px 22px rgba(0, 0, 0, 0.3);
}

.theme-switch.is-light .theme-switch__option--light .theme-switch__icon,
.theme-switch:not(.is-light) .theme-switch__option--dark .theme-switch__icon {
  opacity: 1;
  transform: scale(1.08);
}

.theme-switch.is-light .theme-switch__option--light .theme-switch__icon {
  filter: brightness(0);
}

.theme-switch:not(.is-light) .theme-switch__option--dark .theme-switch__icon {
  filter: invert(1);
}

.theme-switch:hover {
  filter: brightness(1.06);
}

html[data-theme="light"] .theme-switch__track {
  background: rgba(22, 26, 33, 0.06);
  border-color: rgba(22, 26, 33, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

html[data-theme="light"] .theme-switch__thumb {
  border: 1px solid rgba(22, 26, 33, 0.14);
}

.theme-switch:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.theme-switcher.is-theme-hint-active {
  position: relative;
  z-index: 130;
}

.theme-hint-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0, 0, 0, 0.36);
}

.theme-hint {
  position: fixed;
  z-index: 131;
  max-width: 280px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow-modal);
}

.theme-hint__title {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.25;
  color: var(--text-primary);
  font-weight: 600;
}

.theme-hint__text {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-primary);
}

.theme-hint__button {
  min-height: 38px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.theme-hint__button:hover {
  filter: brightness(1.05);
}

/* Mobile header */
.mobile-header {
  display: none;
  pointer-events: auto;
  background: transparent;
  transition: background var(--transition);
}

.mobile-header__inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: relative;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-burger {
  position: relative;
  width: 20px;
  height: 14px;
}

.icon-burger::before,
.icon-burger::after {
  content: "";
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.icon-burger::before {
  top: 1px;
}

.icon-burger::after {
  bottom: 1px;
}

.icon-phone {
  width: 20px;
  height: 20px;
  display: inline-block;
  background: currentColor;
  -webkit-mask: url("../assets/img/icon-phone.png") center / contain no-repeat;
  mask: url("../assets/img/icon-phone.png") center / contain no-repeat;
}

.brand--mobile {
  gap: 10px;
  font-size: 20px;
  padding: 0;
  margin: 0;
}

.brand--mobile .brand__logo {
  width: min(100%, 72px);
  height: 48px;
}

.mobile-header-search {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
}

.mobile-header-search__toggle {
  width: 40px;
  height: 40px;
}

.mobile-header-search__icon {
  width: 15px;
  height: 15px;
  border: 1.8px solid currentColor;
  border-radius: 50%;
  position: relative;
}

.mobile-header-search__icon::after {
  content: "";
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 6px;
  height: 1.8px;
  background: currentColor;
  transform: rotate(45deg);
}

.mobile-header-search__panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 14px;
  right: 14px;
  z-index: 9;
}

.mobile-header-search__row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.mobile-header-search__input {
  width: 100%;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-header-scrolled);
  color: var(--text-primary);
  padding: 0 14px;
}

.mobile-header-search__close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--text-primary);
  font-size: 0;
  line-height: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mobile-header-search__close::before {
  content: "";
  width: 14px;
  height: 14px;
  display: inline-block;
  background: currentColor;
  -webkit-mask: url("../assets/img/icon-close.png") center / contain no-repeat;
  mask: url("../assets/img/icon-close.png") center / contain no-repeat;
}

@media (max-width: 1199px) {
  .site-header__shell {
    display: none;
  }

  .mobile-header {
    display: block;
  }

  .site-header.is-scrolled .mobile-header {
    background: var(--bg-header-scrolled);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .theme-switcher-wrap--mobile .theme-switch {
    min-height: 34px;
  }

  .theme-switcher-wrap--mobile {
    width: auto;
    justify-content: flex-start;
    margin-top: 0;
  }

  .theme-switcher-wrap--mobile .theme-switcher {
    width: auto;
  }

  .theme-switcher-wrap--mobile .theme-switch__track {
    width: 68px;
    height: 34px;
  }

  .theme-switcher-wrap--mobile .theme-switch__thumb {
    width: 26px;
    height: 26px;
  }

  .theme-switcher-wrap--mobile .theme-switch.is-light .theme-switch__thumb {
    transform: translateX(0);
  }

  .theme-switcher-wrap--mobile .theme-switch:not(.is-light) .theme-switch__thumb {
    transform: translateX(34px);
  }
}

@media (max-width: 767px) {
  .mobile-header__inner {
    min-height: 68px;
  }

  .brand--mobile {
    font-size: 18px;
  }

  .brand--mobile .brand__logo {
    width: min(100%, 64px);
    height: 42px;
  }
}

/* Light theme: первый экран — читаемый хедер поверх hero */
html[data-theme="light"] .site-header:not(.is-scrolled) .site-header__shell {
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.9),
    rgba(255, 255, 255, 0.6),
    rgba(255, 255, 255, 0)
  );
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

html[data-theme="light"] .site-header:not(.is-scrolled) .mobile-header {
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.9),
    rgba(255, 255, 255, 0.6),
    rgba(255, 255, 255, 0)
  );
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

html[data-theme="light"] .site-header .brand,
html[data-theme="light"] .site-header .city-trigger,
html[data-theme="light"] .site-header .top-contacts__phone,
html[data-theme="light"] .site-header .top-nav__list a,
html[data-theme="light"] .site-header .main-nav__item,
html[data-theme="light"] .site-header .theme-switch,
html[data-theme="light"] .site-header .mobile-header .icon-btn,
html[data-theme="light"] .site-header .mobile-header .brand--mobile {
  color: #111111;
}

html[data-theme="light"] .site-header .brand__logo-image {
  filter: none;
}

html[data-theme="light"] .site-header .top-nav__list a:hover {
  opacity: 1;
  color: #ff6000;
}

html[data-theme="light"] .site-header .main-nav__item:hover,
html[data-theme="light"] .site-header .main-nav__item.is-active {
  color: #ff6000;
}
