/* =========================================================================
   Двухуровневое меню: строка 1 (4 хаба) + строка 2 (подсекции) на десктопе,
   4 хаба-аккордеона на мобиле. Грузится ПОСЛЕ css/top_menu.css и переопределяет
   раскладку, сохраняя корневые классы-хуки (construction/installment/JS).
   ========================================================================= */

:root {
  --nav-row1-h: 60px;
  --nav-row2-h: 46px;
  --nav-desktop-gutter: 32px;
}

/* Акцент активного/наведённого раздела */
.site-top-menu[data-active-hub="realty"]   { --accent: #078537; --accent-soft: #eaf5ee; --subnav-text: #33414b; --subnav-border: rgba(0, 0, 0, 0.05); }
.site-top-menu[data-active-hub="build"]     { --accent: #6cb6e6; --accent-soft: #102a25; --subnav-text: #dbe8e3; --subnav-border: rgba(214, 233, 222, 0.1); }
.site-top-menu[data-active-hub="services"]  { --accent: #0f9b8e; --accent-soft: #e5f6f3; --subnav-text: #33414b; --subnav-border: rgba(0, 0, 0, 0.05); }
.site-top-menu[data-active-hub="info"]      { --accent: #5a6b76; --accent-soft: #eef1f4; --subnav-text: #33414b; --subnav-border: rgba(0, 0, 0, 0.05); }

/* Цвет подчёркивания каждого хаба */
.site-hubs__item--realty   { --hub: #078537; }
.site-hubs__item--build    { --hub: #2b7bbd; }
.site-hubs__item--services { --hub: #0f9b8e; }
.site-hubs__item--info     { --hub: #5a6b76; }

/* Отступ под фиксированную шапку из двух строк */
body { padding-top: calc(var(--nav-row1-h) + var(--nav-row2-h)); }

/* =========================== ДЕСКТОП =========================== */
.site-top-menu__bar {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "logo hubs phone search";
  min-height: var(--nav-row1-h);
}

@media (min-width: 992px) {
  .vd_container.site-top-menu__bar {
    padding-right: var(--nav-desktop-gutter);
    padding-left: var(--nav-desktop-gutter);
  }

  .vd_container.site-top-menu__row2-inner {
    padding-right: var(--nav-desktop-gutter);
    padding-left: var(--nav-desktop-gutter);
  }
}

.site-top-menu__hubs {
  grid-area: hubs;
  min-width: 0;
  margin: 0 10px;
}

.site-hubs {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-hubs__item {
  position: relative;
  margin: 0;
  padding: 0;
}

.site-hubs__link.site-menu__link {
  display: inline-flex;
  align-items: center;
  height: var(--nav-row1-h);
  min-height: var(--nav-row1-h);
  padding: 0 16px;
  font-size: 18px;
  font-weight: 400;
}

.site-hubs__link.site-menu__link::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: auto;
  bottom: 10px;
  height: 3px;
  border-radius: 3px;
  background: var(--hub);
  opacity: 0;
  transform: scaleX(0.3);
  transform-origin: center;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.site-hubs__link.site-menu__link:hover,
.site-hubs__link.site-menu__link:focus {
  color: var(--hub);
}

.site-hubs__link.site-menu__link:hover::after,
.site-hubs__link.site-menu__link:focus::after {
  opacity: 0.6;
  transform: scaleX(1);
}

/* Наведённый (предпросматриваемый) хаб остаётся подсвеченным, пока курсор в строке 2 */
.site-hubs__item.is-hover .site-hubs__link.site-menu__link {
  color: var(--hub);
}

.site-hubs__item.is-hover .site-hubs__link.site-menu__link::after {
  opacity: 0.6;
  transform: scaleX(1);
}

.site-hubs__item.is-current .site-hubs__link.site-menu__link {
  color: var(--hub);
  font-weight: 400;
}

.site-hubs__item.is-current .site-hubs__link.site-menu__link::after {
  opacity: 1;
  transform: scaleX(1);
}

/* Строка 2 */
.site-top-menu__row2 {
  background: var(--accent-soft, #eaf5ee);
  border-top: 1px solid var(--subnav-border, rgba(0, 0, 0, 0.05));
  overflow: hidden;
  max-height: 220px;
  opacity: 1;
  transition: max-height 0.3s ease, opacity 0.22s ease, transform 0.28s ease, background-color 0.2s ease;
}

.site-top-menu__row2-inner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  min-height: var(--nav-row2-h);
  /* Старт строки совпадает с горизонтальным отступом первой строки и логотипа. */
  padding: 2px 24px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--subnav-text, #33414b) 45%, transparent) transparent;
  -webkit-overflow-scrolling: touch;
}

.site-top-menu__row2-inner::-webkit-scrollbar {
  height: 5px;
}

.site-top-menu__row2-inner::-webkit-scrollbar-track {
  background: transparent;
}

.site-top-menu__row2-inner::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--subnav-text, #33414b) 45%, transparent);
  border-radius: 999px;
}

.site-subnav {
  display: none;
  flex: 0 0 max-content;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-subnav.is-shown {
  display: flex;
}

.site-subnav__item {
  margin: 0;
}

.site-subnav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: var(--nav-row2-h);
  padding: 0 12px;
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--subnav-text, #33414b);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.site-subnav__link::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 7px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0;
  transform: scaleX(0.3);
  transform-origin: center;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.site-subnav__item:first-child .site-subnav__link {
  padding-left: 0;
}

.site-subnav__item:first-child .site-subnav__link::after {
  left: 0;
}

.site-subnav__link:hover,
.site-subnav__link:focus {
  color: var(--accent);
  text-decoration: none;
}

.site-subnav__link:hover::after,
.site-subnav__link:focus::after {
  opacity: 1;
  transform: scaleX(1);
}

.site-subnav__link.is-current {
  color: var(--accent);
  font-weight: 400;
}

.site-subnav__link.is-current::after {
  opacity: 1;
  transform: scaleX(1);
}

/* Прокрутка: строка 2 уезжает под первую; наведение на шапку — снова показываем */
.site-top-menu.is-scrolled .site-top-menu__row2 {
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
}

.site-top-menu.is-scrolled.is-hover .site-top-menu__row2 {
  max-height: 220px;
  opacity: 1;
  transform: none;
}

/* Мобильный выезжающий drawer скрыт на десктопе */
.site-top-menu__drawer {
  display: none;
}

/* Служебные чекбоксы аккордеонов не показываем (управление — по отдельной стрелке). */
.site-drawer__accordion-state {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1450px) {
  :root { --nav-desktop-gutter: 18px; }
  .site-top-menu__row2-inner { padding-right: 18px; padding-left: 18px; }
}

@media (max-width: 1300px) {
  .site-top-menu__row2-inner { padding-right: 18px; padding-left: 18px; }
  .site-hubs__link.site-menu__link { padding: 0 12px; font-size: 16px; }
  .site-subnav__link { padding: 0 10px; font-size: 14px; }
}

/* =========================== МОБАЙЛ =========================== */
@media (max-width: 991px) {
  body { padding-top: 45px; }

  .site-top-menu__hubs,
  .site-top-menu__row2 {
    display: none;
  }

  .site-top-menu__bar {
    grid-template-columns: 68px minmax(0, 1fr) 56px;
    grid-template-areas: "burger center mobile-search";
    min-height: 45px;
    height: 45px;
  }

  .site-top-menu__drawer {
    display: block;
    position: fixed;
    top: -1px;
    left: 0;
    z-index: 1000000002;
    width: var(--site-menu-panel-width, min(320px, calc(100vw - 60px)));
    height: calc(100vh + 2px);
    height: calc(100dvh + 2px);
    padding-top: 1px;
    overflow-x: hidden;
    overflow-y: auto;
    background: linear-gradient(180deg, #13362c 0%, #184234 100%);
    border-right: 1px solid rgba(213, 230, 220, 0.12);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    -webkit-overflow-scrolling: touch;
  }

  .site-top-menu__state:checked ~ .site-top-menu__drawer {
    transform: translateX(0);
    box-shadow: 18px 0 40px rgba(7, 23, 17, 0.28);
  }

  /* Открытое меню: верхняя плашка не должна перехватывать тапы по первому пункту (она выше по z-index) */
  .site-top-menu__state:checked ~ .site-top-menu__bar {
    pointer-events: none;
  }

  .site-top-menu__state:checked ~ .site-top-menu__bar .site-top-menu__burger {
    pointer-events: auto;
  }

  .site-drawer {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .site-drawer__utility-item {
    margin: 0;
    border-bottom: 1px solid rgba(213, 230, 220, 0.12);
  }

  .site-drawer__utility-link,
  .site-drawer__head-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    font-family: Arial, sans-serif;
    color: #f4fbf6;
    text-decoration: none;
  }

  .site-drawer__utility-link {
    min-height: 54px;
    padding: 15px 18px;
    font-size: 16px;
  }

  .site-drawer__utility-link:hover,
  .site-drawer__utility-link:focus,
  .site-drawer__head-link:hover,
  .site-drawer__head-link:focus {
    color: #fff;
    background: rgba(214, 233, 222, 0.08);
    text-decoration: none;
  }

  .site-drawer__utility-link.is-current,
  .site-drawer__head-link.is-current {
    color: #fff;
    font-weight: 400;
  }

  .site-drawer__utility-link.is-current {
    box-shadow: inset 3px 0 0 #d7ef97;
  }

  .site-drawer__icon {
    display: block;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    margin: 0;
    object-fit: contain;
    opacity: 0.96;
  }

  .site-drawer__item {
    position: relative;
    border-bottom: 1px solid rgba(213, 230, 220, 0.12);
    --dot: #9fb3bf;
  }

  .site-drawer__item--realty   { --dot: #4fca82; }
  .site-drawer__item--build    { --dot: #6cb6e6; }
  .site-drawer__item--services { --dot: #43cbbc; }
  .site-drawer__item--info     { --dot: #aab6c2; }

  .site-drawer__head {
    display: flex;
    align-items: center;
    min-height: 54px;
    border-left: 3px solid transparent;
  }

  .site-drawer__head.is-current {
    border-left-color: var(--dot);
  }

  .site-drawer__head-link {
    flex: 1 1 auto;
    align-self: stretch;
    padding: 15px 8px 15px 15px;
    font-size: 16px;
  }

  .site-drawer__title {
    flex: 1 1 auto;
  }

  .site-drawer__toggle {
    display: flex;
    flex: 0 0 56px;
    align-self: stretch;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    color: #dcece3;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .site-drawer__toggle:hover {
    background: rgba(214, 233, 222, 0.08);
  }

  .site-drawer__arrow {
    flex: none;
    width: 14px;
    height: 10px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 10' fill='none'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%23DCECE3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center center / 14px 10px;
    transform: rotate(0deg);
    transform-origin: 50% 50%;
    opacity: 0.9;
    transition: transform 0.18s ease;
  }

  .site-drawer__sub {
    display: none;
    margin: 0;
    padding: 0 0 10px;
    list-style: none;
    background: #205542;
  }

  .site-drawer__state:checked ~ .site-drawer__head {
    background: rgba(214, 233, 222, 0.08);
  }

  .site-drawer__state:checked ~ .site-drawer__head .site-drawer__arrow {
    transform: rotate(180deg);
    opacity: 1;
  }

  .site-drawer__state:checked ~ .site-drawer__sub {
    display: block;
  }

  .site-drawer__child {
    position: relative;
    margin: 0;
  }

  .site-drawer__child-head {
    display: flex;
    align-items: stretch;
    min-height: 48px;
  }

  .site-drawer__link {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 10px;
    min-width: 0;
    min-height: 48px;
    padding: 11px 18px;
    font-family: Arial, sans-serif;
    font-size: 15px;
    color: #d7e7de;
    text-decoration: none;
  }

  .site-drawer__link .site-drawer__icon {
    flex-basis: 18px;
    width: 18px;
    height: 18px;
  }

  .site-drawer__link:hover,
  .site-drawer__link:focus {
    color: #fff;
    background: rgba(214, 233, 222, 0.06);
    text-decoration: none;
  }

  .site-drawer__link.is-current {
    color: #fff;
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--dot);
  }

  .site-drawer__nested-toggle {
    flex-basis: 52px;
    min-height: 48px;
  }

  .site-drawer__nested-toggle .site-drawer__arrow {
    position: relative;
    top: -2px;
  }

  .site-drawer__nested-sub {
    display: none;
    margin: 0;
    padding: 0 0 7px;
    list-style: none;
    background: #235240;
  }

  .site-drawer__nested-state:checked ~ .site-drawer__child-head {
    background: rgba(214, 233, 222, 0.05);
  }

  .site-drawer__nested-state:checked ~ .site-drawer__child-head .site-drawer__arrow {
    transform: rotate(180deg);
    opacity: 1;
  }

  .site-drawer__nested-state:checked ~ .site-drawer__nested-sub {
    display: block;
  }

  .site-drawer__village-link {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: 48px;
    padding: 9px 14px 9px 28px;
    font-family: Arial, sans-serif;
    color: #d7e7de;
    text-decoration: none;
  }

  .site-drawer__village-link:hover,
  .site-drawer__village-link:focus {
    color: #fff;
    background: rgba(214, 233, 222, 0.06);
    text-decoration: none;
  }

  .site-drawer__village-link.is-current {
    color: #fff;
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--dot);
  }

  .site-drawer__icon--village {
    flex-basis: 18px;
    width: 18px;
    height: 18px;
  }

  .site-drawer__village-copy {
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 8px;
    min-width: 0;
    padding-top: 1px;
  }

  .site-drawer__village-title {
    min-width: 0;
    font-size: 14px;
    line-height: 18px;
  }

  .site-drawer__village-copy .site-menu__type {
    float: none;
    align-self: start;
    min-width: 62px;
  }

  .site-drawer__village-note {
    grid-column: 1 / -1;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.3;
    color: #bfd7cb;
  }

  .site-drawer__state:focus-visible ~ .site-drawer__head .site-drawer__toggle,
  .site-drawer__nested-state:focus-visible ~ .site-drawer__child-head .site-drawer__toggle {
    outline: 2px solid rgba(222, 197, 150, 0.85);
    outline-offset: -6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-top-menu__row2,
  .site-hubs__link.site-menu__link::after,
  .site-subnav__link::after,
  .site-drawer__arrow,
  .site-top-menu__drawer {
    transition-duration: 0.01ms !important;
  }
}
