/* Единая шапка и меню для МерчКиров — подключается последней на всех страницах.
   Раньше стили меню были скопированы в каждую страницу и расходились:
   где-то в пунктах стояли иконки-точки, из-за них меню становилось шире
   и уезжало (заметно на «Доставке» и «FAQ»). Здесь геометрия зафиксирована. */

:root {
  --header-h: 76px;
  --mk-menu-font: 12.5px;
}

/* ── Шапка: одна высота на всех страницах ───────────────────── */
header {
  height: auto;
  min-height: var(--header-h);
  max-height: none;
  background: #fff;
  box-shadow: var(--shadow, 0 2px 15px rgba(0, 0, 0, .1));
  position: sticky;
  top: 0;
  z-index: 1000;
  overflow: visible;
}

header .header-content {
  max-width: 1360px;
  height: 100%;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

header .logo-link {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  text-decoration: none;
}

header .logo {
  height: 42px;
  width: auto;
  max-width: 210px;
  object-fit: contain;
  display: block;
}

/* ── Навигация: занимает свободное место и не вылезает за край ─ */
header nav {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

header .menu {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  margin: 0;
  padding: 5px;
  list-style: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary, #fdb913), var(--secondary, #f5a623));
  box-shadow: 0 4px 15px rgba(253, 185, 19, .28);
  max-width: 100%;
  overflow: visible;
}

header .menu > li {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

header .menu > li > a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  height: 36px;
  padding: 0 11px;
  margin: 0;
  border-radius: 999px;
  color: #fff;
  font-size: var(--mk-menu-font);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
  transition: background .2s ease, color .2s ease;
}

/* Иконки-точки в пунктах верхнего меню давали разную ширину — убираем */
header .menu > li > a svg,
header .menu > li > a img,
header .menu > li > a i {
  display: none !important;
}

header .menu > li > a:hover,
header .menu > li.open > a,
header .menu > li.active > a,
header .menu > li.current > a {
  background: rgba(255, 255, 255, .26);
  color: #fff;
  padding: 0 11px;
}

header .menu > li.has-submenu > a::after {
  content: '▾';
  display: inline-block;
  margin-left: 5px;
  font-size: 10px;
  line-height: 1;
  transition: transform .22s ease;
}

header .menu > li.has-submenu.open > a::after { transform: rotate(180deg); }

/* ── Подменю ─────────────────────────────────────────────────── */
header .menu .submenu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translate(-50%, -6px);
  min-width: 220px;
  max-width: 320px;
  margin: 0;
  padding: 8px 0;
  list-style: none;
  background: #fff;
  border-radius: var(--radius, 12px);
  box-shadow: var(--shadow-hover, 0 8px 28px rgba(0, 0, 0, .16));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
  z-index: 500;
}

header .menu li.has-submenu.open > .submenu,
header .menu li.has-submenu:hover > .submenu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

header .menu .submenu li { display: block; }

header .menu .submenu li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  color: #333;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
}

header .menu .submenu li a svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: currentColor;
  opacity: .6;
}

header .menu .submenu li a:hover,
header .menu .submenu li a.current {
  background: rgba(253, 185, 19, .12);
  color: var(--primary, #fdb913);
}

/* ── Кнопки справа: не сжимаются и не прыгают ────────────────── */
header .header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
}

header .header-btn,
header .burger-menu {
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

/* ── Планшет: пункты мельче, шапка ниже ──────────────────────── */
@media (max-width: 1200px) {
  :root { --mk-menu-font: 12.5px; }
  header .menu > li > a { padding: 0 10px; }
  header .logo { max-width: 170px; height: 38px; }
}

@media (max-width: 1024px) {
  :root { --header-h: 68px; --mk-menu-font: 12px; }
  header .menu { gap: 1px; padding: 4px; }
  header .menu > li > a { padding: 0 8px; height: 34px; }
  header .logo { height: 34px; max-width: 150px; }
}

/* Мобильные: меню переносится строками (без прокрутки — она обрезала подменю).
   Прячем его только там, где есть бургер, иначе страница осталась бы без навигации. */
@media (max-width: 900px) {
  :root { --mk-menu-font: 12px; }
  header { height: auto; min-height: 64px; max-height: none; }
  header .header-content { gap: 10px; padding: 6px 12px; flex-wrap: wrap; }
  header .burger-menu { display: flex; }
  header .logo { height: 32px; max-width: 130px; }
  header nav { display: flex; min-width: 0; flex: 1 1 100%; order: 3; }
  header .menu { padding: 4px; gap: 3px; flex-wrap: wrap; justify-content: center; border-radius: 18px; width: 100%; }
  header .menu > li > a { height: 32px; padding: 0 9px; }
  header:has(.burger-menu) nav { display: none; }
}

@media (max-width: 620px) {
  header nav { display: flex; }
  header .menu > li > a { padding: 0 8px; font-size: 11.5px; }
  header:has(.burger-menu) nav { display: none; }
}

/* Боковое меню: пункты одной высоты, без скачков */
.mobile-menu-item > a,
.mobile-menu-items li a {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 12px 20px;
  font-size: 15px;
  line-height: 1.25;
  text-decoration: none;
}

.mobile-menu-item a svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: currentColor;
  opacity: .55;
}
/* ── Мобильный пункт с подпунктами: ссылка + стрелка ─────────── */
.mobile-menu-item .m-row {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.mobile-menu-item .m-row .m-link {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-height: 48px;
  padding: 13px 20px;
  color: #333;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none;
}

.mobile-menu-item .m-row .m-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 54px;
  min-height: 48px;
  padding: 0;
  background: transparent;
  border: 0;
  border-left: 1px solid #f0f0f0;
  color: #777;
  cursor: pointer;
}

.mobile-menu-item .m-row .m-link:hover { background: rgba(253, 185, 19, .1); color: var(--primary, #fdb913); }
.mobile-menu-item .m-row .m-toggle.open .m-arrow { transform: rotate(180deg); }

/* Бургер — только там, где меню убрано в выпадашку (≤900px) */
header .burger-menu {
  display: none;
  cursor: pointer;
  border: 0;
  background: transparent;
  padding: 0 6px;
}

@media (max-width: 900px) {
  header .burger-menu { display: inline-flex; }
  /* на телефоне меню живёт в боковой панели */
  header nav { display: none; }
}

/* ── Боковое меню (телефон): закрыто по умолчанию на всех страницах ── */
.mobile-menu {
  position: fixed;
  top: 0;
  left: -100%;
  width: min(320px, 85vw);
  height: 100dvh;
  background: #fff;
  box-shadow: 3px 0 20px rgba(0, 0, 0, .15);
  z-index: 9999;
  transition: left .3s cubic-bezier(.4, 0, .2, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mobile-menu.active { left: 0; }

.mobile-menu-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  background: linear-gradient(135deg, var(--primary, #fdb913), var(--secondary, #f5a623));
  color: #fff;
}

.mobile-menu-header h3 { margin: 0; font-size: 18px; }

.mobile-menu-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.mobile-menu-items { padding: 10px 0 40px; }
.mobile-menu-item { border-bottom: 1px solid #f0f0f0; }
.mobile-menu-item > a,
.mobile-menu-item .m-link { color: #333; text-decoration: none; }
.mobile-menu-item > a.current { background: rgba(253, 185, 19, .12); font-weight: 600; }
.m-submenu { display: none; background: #f9f9f9; }
.m-submenu.open { display: block; }
.m-submenu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 12px 36px;
  color: #555;
  font-size: 14px;
  text-decoration: none;
  border-bottom: 1px solid #efefef;
}
.m-submenu a:hover { color: var(--primary, #fdb913); background: rgba(253, 185, 19, .07); }

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, .5);
}
.mobile-overlay.active { display: block; }