/* ============================================================================
   Лайк Забор — каркас: шапка, меню, мобильное меню, подвал
   Шапка на десктопе строго в одну строку, высота основной панели 68px.
   Ниже 1400px навигация уходит в бургер — это гарантирует одну строку всегда.
   ========================================================================= */

/* --- Шапка --------------------------------------------------------------- */

.hdr {
  position: relative;
  z-index: var(--z-header);
  background: var(--green-700);
  color: var(--text-invert);
}

/* Утилитарная полоса: город, режим, почта, телефоны, мессенджеры */
.hdr__util {
  display: none;
  border-bottom: 1px solid var(--line-invert);
  background: var(--green-800);
  font-size: var(--t-xs);
}

@media (min-width: 1200px) {
  .hdr__util {
    display: block;
  }
}

.hdr__util-inner {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  height: 42px;
}

.hdr__util-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-invert-muted);
  white-space: nowrap;
}

.hdr__util-item svg {
  width: 15px;
  height: 15px;
  flex: none;
  opacity: 0.8;
}

.hdr__util-item a {
  color: var(--text-invert);
  transition: color var(--dur-2) var(--ease-out);
}

.hdr__util-item a:hover {
  color: var(--green-200);
}

.hdr__util-spacer {
  margin-left: auto;
}

.city-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  margin-left: -8px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text-invert);
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  transition: background-color var(--dur-2) var(--ease-out);
}

.city-btn:hover {
  background: rgba(244, 243, 238, 0.1);
}

.city-btn__name {
  border-bottom: 1px dashed rgba(244, 243, 238, 0.45);
}

.city-btn__caret {
  width: 9px;
  height: 6px;
  opacity: 0.7;
}

.hdr__socials {
  display: inline-flex;
  gap: 8px;
}

.hdr__socials a {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-invert);
  border-radius: var(--r-sm);
  transition: border-color var(--dur-2) var(--ease-out), background-color var(--dur-2) var(--ease-out);
}

.hdr__socials a:hover {
  border-color: var(--green-200);
  background: rgba(160, 199, 106, 0.16);
}

.hdr__socials svg {
  width: 15px;
  height: 15px;
}

/* Основная панель. Прилипает к верху, при скролле уплотняется. */
.hdr__main {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--green-700);
  border-bottom: 1px solid transparent;
  transition: box-shadow var(--dur-3) var(--ease-out), border-color var(--dur-3) var(--ease-out);
}

.hdr__main.is-stuck {
  border-bottom-color: var(--line-invert);
  box-shadow: 0 8px 28px rgba(23, 28, 18, 0.28);
}

.hdr__main-inner {
  position: relative; /* точка отсчёта для мега-меню */
  display: flex;
  align-items: center;
  gap: var(--s-5);
  height: 68px;
  transition: height var(--dur-3) var(--ease-out);
}

.hdr__main.is-stuck .hdr__main-inner {
  height: 60px;
}

/* Лого-блок: эмблема на светлой плашке + словесный знак.
   Плашка нужна потому, что фирменная эмблема выполнена в тёмных цветах и на
   зелёной шапке пропадает. Сам файл логотипа не изменялся. */
.hdr__logo {
  flex: none;
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.logo-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: var(--logo-size, 44px);
  height: var(--logo-size, 44px);
  padding: 5px;
  border-radius: var(--r-sm);
  background: #f4f3ee;
  transition: width var(--dur-3) var(--ease-out), height var(--dur-3) var(--ease-out);
}

.logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-word {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text-invert);
  white-space: nowrap;
}

.hdr__main.is-stuck .logo-mark {
  width: 38px;
  height: 38px;
}

/* На узких экранах словесный знак уступает место телефону и бургеру */
@media (max-width: 420px) {
  .logo-word {
    display: none;
  }
}

.hdr__actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-left: auto;
}

.hdr__phone {
  display: none;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-invert);
  white-space: nowrap;
  transition: color var(--dur-2) var(--ease-out);
}

.hdr__phone:hover {
  color: var(--green-200);
}

@media (min-width: 1200px) {
  .hdr__phone {
    display: none;
  }
  /* Телефон живёт в утилитарной полосе, в основной — только CTA */
}

@media (min-width: 560px) and (max-width: 1199px) {
  .hdr__phone {
    display: inline-block;
  }
}

.hdr__icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-invert);
  border-radius: var(--r-sm);
  background: none;
  color: var(--text-invert);
  cursor: pointer;
  transition: border-color var(--dur-2) var(--ease-out), background-color var(--dur-2) var(--ease-out);
}

.hdr__icon-btn:hover {
  border-color: rgba(244, 243, 238, 0.5);
  background: rgba(244, 243, 238, 0.08);
}

.hdr__icon-btn svg {
  width: 19px;
  height: 19px;
}

/* Кнопка звонка нужна там, где номер целиком не помещается: на узком экране
   звонок остаётся основным способом связи, прятать его за бургер нельзя. */
.hdr__call {
  display: grid;
}

@media (min-width: 560px) {
  .hdr__call {
    display: none;
  }
}

/* Селектор составной намеренно: у .hdr__cta есть класс .btn с
   display:inline-flex, а components.css подключается после layout.css.
   При одинаковой специфичности победило бы правило кнопки, и на мобильном
   CTA выталкивала бы бургер за пределы экрана. */
.hdr__actions .hdr__cta {
  display: none;
}

@media (min-width: 900px) {
  .hdr__actions .hdr__cta {
    display: inline-flex;
  }
}

/* --- Бургер -------------------------------------------------------------- */

.burger {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-invert);
  border-radius: var(--r-sm);
  background: none;
  cursor: pointer;
}

@media (min-width: 1400px) {
  .burger {
    display: none;
  }
}

.burger__box {
  position: relative;
  width: 20px;
  height: 14px;
}

.burger__line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--text-invert);
  border-radius: 2px;
  transition: transform var(--dur-2) var(--ease-out), opacity var(--dur-1) linear,
    top var(--dur-2) var(--ease-out);
}

.burger__line:nth-child(1) {
  top: 0;
}
.burger__line:nth-child(2) {
  top: 6px;
}
.burger__line:nth-child(3) {
  top: 12px;
}

.burger[aria-expanded='true'] .burger__line:nth-child(1) {
  top: 6px;
  transform: rotate(45deg);
}
.burger[aria-expanded='true'] .burger__line:nth-child(2) {
  opacity: 0;
}
.burger[aria-expanded='true'] .burger__line:nth-child(3) {
  top: 6px;
  transform: rotate(-45deg);
}

/* --- Главное меню (десктоп) ---------------------------------------------- */

.nav {
  display: none;
}

/* Меню целиком помещается в контейнер только с 1400 px: ниже показываем
   бургер, иначе шапка вылезала за контейнер и страница ехала вбок */
@media (min-width: 1400px) {
  .nav {
    display: block;
  }
}

.nav__list {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* 1200-1440: меню включается, но вместе с логотипом, поиском и кнопкой
   «Вызвать замерщика» не помещается в контейнер - страница получала
   горизонтальную прокрутку на самых частых ноутбучных ширинах.
   Уплотняем метрики шапки, пока места мало. */
@media (min-width: 1400px) and (max-width: 1600px) {
  .hdr__main-inner {
    gap: var(--s-4);
  }

  .nav__link {
    padding: 10px 7px;
    font-size: 0.875rem;
  }

  .hdr__actions .hdr__cta {
    padding: 12px 16px;
    font-size: 0.875rem;
  }
}

.nav__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-invert);
  white-space: nowrap;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}

.nav__link:hover,
.nav__item:focus-within > .nav__link {
  background: rgba(244, 243, 238, 0.1);
}

.nav__link[aria-current='page'] {
  color: var(--green-200);
}

.nav__item {
  position: relative;
}

/* Мега-меню тянется на ширину контейнера, а не пункта меню, поэтому пункт
   «Каталог» перестаёт быть точкой отсчёта: иначе панель шириной 1180px,
   отцентрованная по пункту у левого края, уезжает за границу экрана. */
.nav__item--mega {
  position: static;
}

.nav__item--current > .nav__link {
  color: var(--green-200);
  background: rgba(160, 199, 106, 0.12);
}

.nav__caret {
  width: 9px;
  height: 6px;
  opacity: 0.7;
  transition: transform var(--dur-2) var(--ease-out);
}

.nav__item.is-open .nav__caret {
  transform: rotate(180deg);
}

/* Выпадающий список */
.nav__drop {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 250px;
  padding: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out),
    visibility var(--dur-2);
}

.nav__item.is-open > .nav__drop {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav__drop a {
  display: block;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  color: var(--text);
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}

.nav__drop a:hover {
  background: var(--bg-sunken);
  color: var(--accent);
}

/* Мега-меню каталога. Отсчёт от .hdr__main-inner, а не от пункта меню. */
.nav__mega {
  position: absolute;
  top: calc(100% + 10px);
  left: var(--gutter);
  right: var(--gutter);
  transform: translateY(-8px);
  padding: var(--s-6);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out),
    visibility var(--dur-2);
}

.nav__item.is-open > .nav__mega {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.mega__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-6);
}

.mega__col-title {
  display: block;
  margin-bottom: var(--s-3);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--text);
  transition: color var(--dur-2) var(--ease-out);
}

.mega__col-title:hover {
  color: var(--accent);
}

.mega__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  margin-left: -8px;
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  color: var(--text-muted);
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}

.mega__link:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.mega__link img {
  width: 40px;
  height: 32px;
  object-fit: cover;
  border-radius: var(--r-xs);
  flex: none;
}

.mega__promo {
  grid-column: span 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  margin-top: var(--s-5);
  padding: var(--s-4) var(--s-5);
  background: var(--bg-sunken);
  border-radius: var(--r-md);
}

.mega__promo p {
  margin: 0;
  font-size: var(--t-sm);
  color: var(--text-muted);
}

/* --- Мобильное меню (drawer) --------------------------------------------- */

.mnav {
  position: fixed;
  inset: 0;
  z-index: var(--z-menu);
  display: none;
}

.mnav.is-open {
  display: block;
}

/* Открытое состояние задаёт CSS, а не JS. Раньше выезд панели делал GSAP,
   и если requestAnimationFrame тормозил, посетитель получал затемнённый
   экран без меню и с заблокированным скроллом. Теперь анимация - надстройка:
   даже без JS-библиотеки меню открывается. */
.mnav__scrim {
  position: absolute;
  inset: 0;
  background: rgba(23, 28, 18, 0.6);
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease-out);
}

.mnav.is-open .mnav__scrim {
  opacity: 1;
}

.mnav__panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(430px, 100%);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--dur-3) var(--ease);
}

.mnav.is-open .mnav__panel {
  transform: translateX(0);
}

.mnav__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: var(--green-700);
  color: var(--text-invert);
}

.mnav__head img {
  height: 30px;
  width: auto;
}

.mnav__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-5);
}

.mnav__search {
  display: flex;
  gap: var(--s-2);
  margin-bottom: var(--s-5);
}

.mnav__list > li {
  border-bottom: 1px solid var(--line);
}

.mnav__row {
  display: flex;
  align-items: stretch;
}

.mnav__link {
  flex: 1;
  padding: 14px 0;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--text);
}

.mnav__link[aria-current='page'] {
  color: var(--accent);
}

.mnav__toggle {
  flex: none;
  width: 48px;
  border: 0;
  border-left: 1px solid var(--line);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.mnav__toggle svg {
  width: 12px;
  height: 8px;
  margin-inline: auto;
  transition: transform var(--dur-2) var(--ease-out);
}

.mnav__toggle[aria-expanded='true'] svg {
  transform: rotate(180deg);
}

.mnav__sub {
  overflow: hidden;
  height: 0;
}

.mnav__sub-inner {
  padding: 0 0 var(--s-4) var(--s-4);
  border-left: 2px solid var(--brand-soft);
  margin-left: 2px;
}

.mnav__sub a {
  display: block;
  padding: 9px 0;
  font-size: var(--t-sm);
  color: var(--text-muted);
}

.mnav__sub a:hover {
  color: var(--accent);
}

.mnav__foot {
  padding: var(--s-5);
  border-top: 1px solid var(--line);
  background: var(--bg-sunken);
  display: grid;
  gap: var(--s-3);
}

.mnav__contacts {
  display: grid;
  gap: 6px;
  font-size: var(--t-sm);
}

.mnav__contacts a {
  font-family: var(--font-display);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* --- Подвал -------------------------------------------------------------- */

.ftr {
  background: var(--green-800);
  color: var(--text-invert);
  padding-top: clamp(48px, 6vw, 80px);
}

.ftr a {
  transition: color var(--dur-2) var(--ease-out);
}

.ftr__grid {
  display: grid;
  gap: var(--s-7) var(--s-6);
  grid-template-columns: 1fr;
  padding-bottom: clamp(40px, 5vw, 64px);
}

@media (min-width: 640px) {
  .ftr__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .ftr__grid {
    grid-template-columns: 1.6fr repeat(3, 1fr) 1.5fr;
  }
}

.ftr__logo {
  margin-bottom: var(--s-5);
}

.ftr__logo .logo-word {
  font-size: 1.25rem;
}

.ftr__legal {
  font-size: var(--t-xs);
  line-height: 1.6;
  color: var(--text-invert-muted);
  max-width: 34ch;
}

.ftr__legal-links {
  display: grid;
  gap: 6px;
  margin-top: var(--s-4);
  font-size: var(--t-xs);
}

.ftr__legal-links a {
  color: var(--text-invert-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(244, 243, 238, 0.3);
}

.ftr__legal-links a:hover {
  color: var(--green-200);
}

.ftr__title {
  margin-bottom: var(--s-4);
  font-family: var(--font-display);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green-200);
}

.ftr__links {
  display: grid;
  gap: 10px;
  font-size: var(--t-sm);
}

.ftr__links a {
  color: var(--text-invert-muted);
}

.ftr__links a:hover {
  color: var(--text-invert);
}

.ftr__contacts {
  display: grid;
  gap: var(--s-3);
  font-size: var(--t-sm);
  color: var(--text-invert-muted);
}

.ftr__phones {
  display: grid;
  gap: 4px;
}

.ftr__phones a {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-invert);
}

.ftr__phones a:hover {
  color: var(--green-200);
}

.ftr__cta {
  display: grid;
  gap: var(--s-2);
  margin-top: var(--s-4);
}

.ftr__bottom {
  border-top: 1px solid var(--line-invert);
  padding-block: var(--s-5);
}

.ftr__bottom-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-4) var(--s-5);
  font-size: var(--t-xs);
  color: var(--text-invert-muted);
}

.ftr__bottom-inner a {
  color: var(--text-invert-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ftr__bottom-inner a:hover {
  color: var(--green-200);
}

.ftr__bottom-spacer {
  margin-left: auto;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line-invert);
  border-radius: var(--r-sm);
  background: none;
  color: var(--text-invert-muted);
  font-family: inherit;
  font-size: var(--t-xs);
  cursor: pointer;
  transition: border-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}

.theme-toggle:hover {
  border-color: rgba(244, 243, 238, 0.45);
  color: var(--text-invert);
}

.theme-toggle svg {
  width: 15px;
  height: 15px;
}

/* В светлой теме предлагаем луну, в тёмной — солнце */
.theme-toggle__sun {
  display: none;
}
.theme-toggle__moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .theme-toggle__sun {
    display: block;
  }
  :root:not([data-theme='light']) .theme-toggle__moon {
    display: none;
  }
}

:root[data-theme='dark'] .theme-toggle__sun {
  display: block;
}
:root[data-theme='dark'] .theme-toggle__moon {
  display: none;
}
:root[data-theme='light'] .theme-toggle__sun {
  display: none;
}
:root[data-theme='light'] .theme-toggle__moon {
  display: block;
}
