/* =====================================================
   SITE HEADER
   Sticky, синий → белый при скролле (как kramz-trade.ru)
   ===================================================== */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: var(--header-z-index);
}
.site-header__bar {
  height: var(--header-height);
  background: var(--header-bg);
  color: #ffffff;
  transition: background-color 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    color 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  border-bottom: 1px solid transparent;
}

/* Главная и другие hero-страницы: прозрачная шапка поверх фона (Figma 1821-13925) */
.site-header.site-header--over-hero:not(.is-scrolled):not(:hover):not(.is-mega-open):not(.is-mega-closing):not(.is-menu-open) .site-header__bar {
  background: transparent;
  border-bottom-color: transparent;
}

/* При открытом mega/menu на hero — снова синий фон (включая анимацию закрытия) */
.site-header.site-header--over-hero.is-mega-open:not(.is-scrolled) .site-header__bar,
.site-header.site-header--over-hero.is-mega-closing:not(.is-scrolled) .site-header__bar,
.site-header.site-header--over-hero.is-menu-open:not(.is-scrolled) .site-header__bar {
  background: var(--header-bg);
  border-bottom-color: transparent;
}

/* При скролле / на страницах без hero → белая с нижней линией (Figma 377-1734, Primary-text) */
.site-header.is-scrolled .site-header__bar,
.site-header.site-header--always-light .site-header__bar {
  background: #ffffff;
  color: var(--color-text-primary);
  border-bottom-color: #c8cedf;
}

/* При наведении на белую шапку / при открытом меню → снова синяя */
.site-header.is-scrolled:hover .site-header__bar,
.site-header.is-scrolled.is-mega-open .site-header__bar,
.site-header.is-scrolled.is-mega-closing .site-header__bar,
.site-header.site-header--always-light:hover .site-header__bar,
.site-header.site-header--always-light.is-mega-open .site-header__bar,
.site-header.site-header--always-light.is-mega-closing .site-header__bar {
  background: var(--header-bg);
  color: #ffffff;
  border-bottom-color: transparent;
}

/* ——— Container inside header ——— */
.site-header .container {
  max-width: var(--container-width);
  height: 100%;
  padding-inline: var(--container-padding);
}

.site-header__inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 32px;
  height: var(--header-height);
}

/* ——— Logo ——— */
.site-header__logo {
  position: relative;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  text-decoration: none;
}

.site-header__logo-img {
  display: block;
  width: 117px;
  height: 33px;
  transition: opacity 0.3s ease;
}

/* Светлый логотип — виден на синем фоне; тёмный поверх него (opacity:0) */
.site-header__logo-img--light { opacity: 1; }
.site-header__logo-img--dark  {
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
}
.site-header__chevron--light  { opacity: 1; }
.site-header__chevron--dark   {
  opacity: 0;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

/* При белой шапке (scrolled / always-light, без hover и без открытого меню) → тёмный логотип */
.site-header.is-scrolled:not(:hover):not(.is-mega-open):not(.is-mega-closing) .site-header__logo-img--light,
.site-header.site-header--always-light:not(:hover):not(.is-mega-open):not(.is-mega-closing) .site-header__logo-img--light { opacity: 0; }
.site-header.is-scrolled:not(:hover):not(.is-mega-open):not(.is-mega-closing) .site-header__logo-img--dark,
.site-header.site-header--always-light:not(:hover):not(.is-mega-open):not(.is-mega-closing) .site-header__logo-img--dark  { opacity: 1; }
.site-header.is-scrolled:not(:hover):not(.is-mega-open):not(.is-mega-closing) .site-header__chevron--light,
.site-header.site-header--always-light:not(:hover):not(.is-mega-open):not(.is-mega-closing) .site-header__chevron--light  { opacity: 0; }
.site-header.is-scrolled:not(:hover):not(.is-mega-open):not(.is-mega-closing) .site-header__chevron--dark,
.site-header.site-header--always-light:not(:hover):not(.is-mega-open):not(.is-mega-closing) .site-header__chevron--dark   { opacity: 1; }

/* ——— Nav ——— */
.site-header__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  min-width: 0;
}

.site-header__nav-item {
  display: flex;
  align-items: center;
}

.site-header__nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  color: inherit;
  white-space: nowrap;
  text-decoration: none;
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.site-header__nav-link:hover {
  opacity: 0.85;
}

/* При открытом меню или ховере на «Примеры внедрений» / «Поддержка» — неактивные пункты полупрозрачные */
.site-header.is-mega-open .site-header__nav-item:not(.has-dropdown):not(:hover) .site-header__nav-link,
.site-header.is-mega-closing .site-header__nav-item:not(.has-dropdown):not(:hover) .site-header__nav-link,
.site-header.is-mega-open .site-header__nav-item.has-dropdown:not(.is-open) .site-header__nav-link,
.site-header.is-mega-closing .site-header__nav-item.has-dropdown:not(.is-open) .site-header__nav-link,
.site-header.is-plain-nav-hover .site-header__nav-item.has-dropdown .site-header__nav-link,
.site-header.is-plain-nav-hover .site-header__nav-item:not(.has-dropdown):not(:hover) .site-header__nav-link {
  opacity: 0.5;
}

.site-header.is-mega-open .site-header__nav-item.is-open .site-header__nav-link,
.site-header.is-mega-closing .site-header__nav-item.is-open .site-header__nav-link,
.site-header__nav-item.is-open .site-header__nav-link,
.site-header.is-plain-nav-hover .site-header__nav-item:not(.has-dropdown):hover .site-header__nav-link,
.site-header.is-plain-nav-hover .site-header__nav-item.has-dropdown.is-open .site-header__nav-link {
  opacity: 1;
}

/* При белой шапке — Primary-text #212123 */
.site-header.is-scrolled:not(:hover):not(.is-mega-open):not(.is-mega-closing) .site-header__nav-link,
.site-header.site-header--always-light:not(:hover):not(.is-mega-open):not(.is-mega-closing) .site-header__nav-link {
  color: var(--color-text-primary);
}

.site-header.is-scrolled:not(:hover):not(.is-mega-open):not(.is-mega-closing) .site-header__lang-text,
.site-header.site-header--always-light:not(:hover):not(.is-mega-open):not(.is-mega-closing) .site-header__lang-text {
  color: #5c6478;
}

.site-header__nav-link--active {
  opacity: 1;
}

.site-header__chevron {
  flex: none;
  display: block;
  width: 10px;
  height: 5px;
  transition: opacity 0.3s ease;
}

.site-header__nav-row {
  display: contents;
}

.site-header__nav-toggle {
  display: none;
}

/* ——— Подчёркивание + полный desktop-хедер (1025+ = как 1440) ——— */
@media (min-width: 1025px) {
  .site-header__inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 32px;
  }

  .site-header__nav {
    display: flex !important;
    position: relative;
    z-index: 2;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    align-items: center;
    justify-content: center;
    gap: 32px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    height: auto;
    padding: 0;
    overflow: visible;
    background: transparent;
  }

  .site-header__nav-item,
  .site-header__nav > .site-header__nav-link {
    flex-shrink: 0;
  }

  .site-header__nav-link {
    font-size: 16px;
    line-height: 1;
    padding: 0;
  }

  .site-header__actions {
    gap: 24px;
  }

  .site-header__actions .btn--header-cta {
    display: inline-flex;
  }

  .site-header__menu-toggle {
    display: none !important;
  }

  .site-header__nav-header,
  .site-header__nav-close,
  .site-header__nav-footer,
  .site-header__mobile-sub {
    display: none !important;
  }

  .site-header__nav-link::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 100%;
    height: 1px;
    background-color: currentColor;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .site-header__nav-item.is-open > .site-header__nav-link::after,
  .site-header__nav-link:hover::after {
    transform: scaleX(1);
  }

  /* Для пунктов с шевроном: полоска только под текстом, без иконки (4px gap + 10px chevron) */
  .site-header__nav-item.has-dropdown .site-header__nav-link::after {
    width: calc(100% - 14px);
  }

  /* Плашка — одна clip-path-анимация: текст на месте, обрезается вместе с фоном */
  .site-header__mega {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: calc(var(--header-z-index) + 1);
    display: block;
    overflow: hidden;
    clip-path: inset(0 0 100% 0);
    -webkit-clip-path: inset(0 0 100% 0);
    pointer-events: none;
    visibility: hidden;
    transition:
      clip-path 0.62s cubic-bezier(0.4, 0, 0.2, 1),
      -webkit-clip-path 0.62s cubic-bezier(0.4, 0, 0.2, 1),
      visibility 0s linear 0.62s;
  }

  .site-header.is-mega-open .site-header__mega {
    clip-path: inset(0 0 0 0);
    -webkit-clip-path: inset(0 0 0 0);
    pointer-events: auto;
    visibility: visible;
    transition:
      clip-path 0.62s cubic-bezier(0.4, 0, 0.2, 1),
      -webkit-clip-path 0.62s cubic-bezier(0.4, 0, 0.2, 1),
      height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
      visibility 0s linear 0s;
  }

  .site-header.is-mega-open .site-header__mega.is-closing {
    clip-path: inset(0 0 100% 0);
    -webkit-clip-path: inset(0 0 100% 0);
    pointer-events: none;
  }

  /* Неактивные колонки не влияют на высоту плашки */
  .site-header__mega-grid {
    position: relative;
  }

  .site-header__mega-col:not(.is-active) {
    display: none !important;
    position: absolute;
    top: 0;
    left: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .site-header__mega-col.is-active {
    display: block !important;
    position: relative;
  }

  /* Закрыто — пункты спрятаны */
  .site-header:not(.is-mega-open) .site-header__mega-col .site-header__mega-list li {
    opacity: 0;
    transform: translateY(14px);
    animation: none;
  }

  /* Открытие — каждый пункт снизу вверх, ровный каскад после раскрытия плашки */
  .site-header.is-mega-open .site-header__mega:not(.is-closing) .site-header__mega-col.is-active .site-header__mega-list li {
    opacity: 0;
    transform: translateY(14px);
    animation: siteHeaderMegaItemIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }

  .site-header.is-mega-open .site-header__mega:not(.is-closing) .site-header__mega-col.is-active .site-header__mega-list li:nth-child(1) {
    animation-delay: 0.22s;
  }

  .site-header.is-mega-open .site-header__mega:not(.is-closing) .site-header__mega-col.is-active .site-header__mega-list li:nth-child(2) {
    animation-delay: 0.28s;
  }

  .site-header.is-mega-open .site-header__mega:not(.is-closing) .site-header__mega-col.is-active .site-header__mega-list li:nth-child(3) {
    animation-delay: 0.34s;
  }

  .site-header.is-mega-open .site-header__mega:not(.is-closing) .site-header__mega-col.is-active .site-header__mega-list li:nth-child(4) {
    animation-delay: 0.4s;
  }

  .site-header.is-mega-open .site-header__mega:not(.is-closing) .site-header__mega-col.is-active .site-header__mega-list li:nth-child(5) {
    animation-delay: 0.46s;
  }

  .site-header.is-mega-open .site-header__mega:not(.is-closing) .site-header__mega-col.is-active .site-header__mega-list li:nth-child(6) {
    animation-delay: 0.52s;
  }

  .site-header.is-mega-open .site-header__mega:not(.is-closing) .site-header__mega-col.is-active .site-header__mega-list li:nth-child(7) {
    animation-delay: 0.58s;
  }

  .site-header.is-mega-open .site-header__mega:not(.is-closing) .site-header__mega-col.is-active .site-header__mega-list li:nth-child(8) {
    animation-delay: 0.64s;
  }

  /* Закрытие — пункты не двигаются, обрезаются clip-path плашки */
  .site-header.is-mega-open .site-header__mega.is-closing .site-header__mega-col.is-active .site-header__mega-list li {
    opacity: 1;
    transform: translateY(0);
    animation: none;
  }
}

/* 1025–1200: компактный desktop — влезает в строку, hover-зоны не слипаются */
@media (min-width: 1025px) and (max-width: 1200px) {
  .site-header__bar {
    position: relative;
    z-index: 2;
  }

  .site-header__inner {
    column-gap: clamp(12px, calc(12px + 6 * (100vw - 1024px) / 176), 18px);
  }

  .site-header__logo-img {
    width: clamp(100px, calc(100px + 10 * (100vw - 1024px) / 176), 110px);
    height: auto;
  }

  .site-header__nav {
    gap: clamp(12px, calc(12px + 4 * (100vw - 1024px) / 176), 16px);
  }

  .site-header__nav-link {
    font-size: 14px;
    gap: 4px;
  }

  .site-header__nav-item.has-dropdown .site-header__nav-link::after {
    width: calc(100% - 14px);
  }

  .site-header__actions {
    gap: 16px;
  }

  .site-header__lang-text {
    font-size: 15px;
  }

  .site-header__actions .btn--header-cta {
    height: 46px;
    padding-inline: 16px;
  }

  .site-header__actions .btn--header-cta .btn__text {
    font-size: 14px;
    line-height: 1;
  }

  .site-header__mega-inner {
    padding: 18px 0 36px;
  }

  .site-header__mega-inner--compact {
    padding-bottom: 40px;
  }

  .site-header__mega-link {
    font-size: 15px;
  }
}

/* ——— Actions: Ru + кнопка ——— */
.site-header__actions {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-shrink: 0;
}

.site-header__lang {
  position: relative;
  box-sizing: border-box;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.site-header__lang-text {
  position: absolute;
  left: 2.5px;
  top: 2px;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 400;
  line-height: 100%;
  color: #b2b9ce;
}

.site-header__lang:hover {
  opacity: 0.85;
}

.site-header__actions .btn--header-cta {
  order: 2;
}

/* Кнопка при белой шапке — прозрачный фон, тёмный контур и текст */
.site-header.is-scrolled:not(:hover):not(.is-mega-open):not(.is-mega-closing) .btn--header-cta,
.site-header.site-header--always-light:not(:hover):not(.is-mega-open):not(.is-mega-closing) .btn--header-cta {
  background-color: transparent;
  border: 1px solid var(--color-text-primary);
  color: var(--color-text-primary);
}

.site-header.is-scrolled:not(:hover):not(.is-mega-open):not(.is-mega-closing) .btn--header-cta .btn__text,
.site-header.site-header--always-light:not(:hover):not(.is-mega-open):not(.is-mega-closing) .btn--header-cta .btn__text {
  color: var(--color-text-primary);
}

.site-header.is-scrolled:not(:hover):not(.is-mega-open):not(.is-mega-closing) .btn--header-cta:hover,
.site-header.site-header--always-light:not(:hover):not(.is-mega-open):not(.is-mega-closing) .btn--header-cta:hover {
  background-color: #ffffff;
  border-color: var(--color-text-primary);
}

.site-header__actions .btn--header-cta.btn--outline-light:hover,
.site-header__nav-cta.btn--header-cta:hover {
  background-color: #ffffff;
  border-color: #ffffff;
}

.site-header__actions .btn--header-cta:hover .btn__text,
.site-header__nav-cta.btn--header-cta:hover .btn__text {
  color: var(--color-accent-card);
}

/* =====================================================
   MEGA MENU
   Абсолютная панель под хедером (Figma: 354-80=274px)
   ===================================================== */

/* Базовые стили плашки; display на desktop задаётся ниже в @media (min-width: 1025px) */
.site-header__mega {
  background: var(--header-bg);
  color: #ffffff;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

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

@keyframes siteHeaderMegaItemIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.site-header__mega-inner {
  /* padding-top: 20px — Figma: top=100px (80 header + 20 padding) */
  padding: 20px 0 48px;
  box-sizing: border-box;
}

/* Партнёрам / О компании — плашка по высоте списка + 40px снизу (Figma) */
@media (min-width: 1025px) {
  .site-header__mega-inner--compact {
    padding-bottom: 40px;
  }
}

/* Сдвиг контента под активный пункт меню — без transition, только вертикальная анимация пунктов */
.site-header__mega-grid {
  display: block;
  position: relative;
  padding-left: var(--mega-align, 0);
}

/* Колонки скрыты по умолчанию, JS переключает display */
.site-header__mega-col {
  display: none;
}

/* Активная колонка — Figma width: 233px */
.site-header__mega-col.is-active {
  display: block;
  width: 233px;
}

.site-header__mega-title {
  display: none;
  margin: 0 0 20px;
  font-family: var(--font-body);
  font-size: var(--text-s-size);
  font-weight: 400;
  line-height: var(--text-s-lh);
  color: rgba(255, 255, 255, 0.55);
}

/* Список ссылок — gap: 20px (Figma) */
.site-header__mega-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.site-header__mega-list li {
  list-style: none;
}

.site-header__mega-list li::marker {
  content: none;
}

/* Ссылка в меню */
.site-header__mega-link {
  position: relative;
  display: inline-block;
  max-width: 100%;
  font-family: var(--font-body), sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 100%;
  color: #ffffff;
  text-decoration: none;
}

/* Подчёркивание слева направо */
.site-header__mega-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 1px;
  background-color: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.site-header__mega-link:hover::after,
.site-header__mega-link:focus-visible::after {
  transform: scaleX(1);
}

/* Дубль-ссылки "Примеры внедрений" и "Поддержка" — скрыты на десктопе */
.site-header__mega-link--featured {
  display: none;
}

/* ——— Toggle label: open / close states ——— */
.site-header__menu-toggle-text {
  position: relative;
  display: inline-block;
}

.site-header__menu-toggle-label {
  display: block;
}

.site-header__menu-toggle-open,
.site-header__menu-toggle-close {
  transition: opacity 0.2s ease, transform 0.25s ease;
}

.site-header__menu-toggle-close {
  opacity: 0;
}

.site-header.is-menu-open .site-header__menu-toggle-close {
  opacity: 1;
}

/* ——— Mobile-only elements: скрыты на десктопе ——— */
.site-header__mobile-sub {
  display: none;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-header__nav-header {
  display: none;
}

.site-header__nav-logo {
  display: none;
}

.site-header__nav-close {
  display: none;
}

.site-header__nav-footer {
  display: none;
}

/* Шеврон поворачивается при раскрытом аккордеоне */
.site-header__nav-item.is-open > .site-header__nav-link .site-header__chevron {
  transform: rotate(180deg);
  transition: transform 0.2s ease;
}

/* =====================================================
   BURGER (mobile)
   ===================================================== */

.site-header__menu-toggle {
  display: none;
  order: 3;
}

@media (max-width: 687px) {
  .site-header__mega {
    display: none !important;
  }
}

@media (max-width: 1024px) {
  .site-header__menu-toggle {
    display: inline-flex;
    align-items: center;
    border: none;
    background: transparent;
    cursor: pointer;
    color: inherit;
  }
}
