/* ===== TOP BAR (1:1 from prototype) ===== */
.top-bar {
  background: var(--brand-teal-light);
  border-bottom: 1px solid #d8e8eb;
  height: 40px;
  font-size: 13px;
  color: var(--brand-gray);
  overflow: hidden;
  position: relative;
}
.top-bar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}
.top-bar__left {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 0 0 auto;
}
.top-bar__center {
  position: relative;
  overflow: hidden;
  height: 40px;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.top-bar__slider {
  display: flex;
  align-items: center;
  animation: slideText 12s ease-in-out infinite;
  white-space: nowrap;
  width: 100%;
}
.top-bar__slide {
  min-width: 100%;
  text-align: center;
  font-weight: 700;
  color: var(--brand-dark);
  font-size: 13px;
}
@keyframes slideText {
  0%, 30%   { transform: translateX(0); }
  35%, 65%  { transform: translateX(-100%); }
  70%, 100% { transform: translateX(-200%); }
}
.top-bar__right {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 13px;
  flex: 0 0 auto;
}
.top-bar__phone {
  font-weight: 700;
  color: var(--brand-dark);
  white-space: nowrap;
}
.top-bar__phone a { color: var(--brand-dark); }
.top-bar__phone a:hover { color: var(--brand-teal); }

/* "Официальный дилер" badge */
.official-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--brand-teal);
  color: white;
  padding: 2px 10px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.official-badge svg { width: 12px; height: 12px; fill: white; }

/* ===== HEADER (1:1 from prototype) ===== */
.header {
  background: #fff;
  padding: 20px 0;
  border-bottom: 1px solid #eee;
}
.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.header__logo {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
}
.header__logo img {
  display: block;
  height: 42px;
  width: 274px;
  max-width: 100%;
}
.header__nav {
  display: flex;
  gap: 28px;
  flex: 0 1 auto;
  white-space: nowrap;
}
.header__nav a {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--brand-dark);
  letter-spacing: 0.5px;
  transition: color 0.2s;
  white-space: nowrap;
}
.header__nav a:hover { color: var(--brand-teal); }

/* Search */
.header__search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--brand-light-gray);
  border: 1px solid var(--brand-border);
  border-radius: 4px;
  padding: 8px 12px;
  width: 240px;
  flex: 0 0 auto;
}
.header__search svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  stroke: #999;
}
.header__search input {
  border: none;
  background: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  width: 100%;
  color: var(--brand-dark);
}
.header__search input::placeholder { color: #999; }

/* Header icons (compare / wishlist / cart / burger) */
.header__icons {
  display: flex;
  gap: 16px;
  align-items: center;
  flex: 0 0 auto;
}
.header__icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  color: var(--brand-dark);
  transition: opacity 0.2s;
}
.header__icon:hover { opacity: 0.6; }

/* Help icon dropdown — пункты «Доставка / Оплата / Возврат» при hover/focus.
   Pure CSS, без JS. :focus-within держит меню открытым при keyboard-навигации
   и tap на мобиле (после касания элемент получает фокус → меню остаётся открытым
   пока пользователь не тапнет вне). */
.header__help { position: relative; }
.header__help:hover,
.header__help:focus-within { opacity: 1; }
.header__help-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin: 6px 0 0;
  padding: 8px 0;
  list-style: none;
  min-width: 160px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 1000;
}
.header__help:hover .header__help-menu,
.header__help:focus-within .header__help-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.header__help-menu li { margin: 0; }
.header__help-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: var(--brand-dark);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}
.header__help-menu a::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-yellow);
  flex-shrink: 0;
}
.header__help-menu a:hover { background: rgba(0, 0, 0, 0.04); }
.header__icon svg {
  width: 22px;
  height: 22px;
  stroke: var(--brand-dark);
  fill: none;
}
.header__icon .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  background: var(--brand-yellow);
  color: var(--brand-dark);
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}
.header__cart-hidden { display: none !important; }

/* ===== CATEGORY NAV (1:1 from prototype) ===== */
.cat-nav {
  background: var(--brand-teal);
  padding: 0;
}
.cat-nav .container {
  display: flex;
  justify-content: center;
  gap: 0;
}
.cat-nav a {
  color: white;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 12px 20px;
  letter-spacing: 0.5px;
  transition: background 0.2s;
  white-space: nowrap;
}
.cat-nav a:hover { background: rgba(255,255,255,0.15); }
.cat-nav a.cat-nav--highlight {
  background: rgba(255,255,255,0.2);
  border-bottom: 2px solid var(--brand-yellow);
}
.cat-nav a.cat-nav--highlight:hover { background: rgba(255,255,255,0.25); }

/* ===== BURGER (mobile only) ===== */
/* 44×44 — ровно как соседние .header__icon; было 40×40, в одном ряду стояли
   иконки разного размера (и 40 < минимума 44 для пальца). */
.burger-btn {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  z-index: 1001;   /* above the open drawer (1000) so the X-icon stays clickable to close it */
}
.burger-btn span,
.burger-btn span::before,
.burger-btn span::after {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--brand-dark);
  border-radius: 2px;
  transition: all 0.3s;
}
.burger-btn span { position: relative; }
.burger-btn span::before,
.burger-btn span::after {
  content: '';
  position: absolute;
  left: 0;
}
.burger-btn span::before { top: -7px; }
.burger-btn span::after  { top:  7px; }
.burger-btn.active span { background: transparent; }
.burger-btn.active span::before { top: 0; transform: rotate(45deg); }
.burger-btn.active span::after  { top: 0; transform: rotate(-45deg); }
/* При открытой шторке бургер превращался в «×» и висел ПОВЕРХ панели в 50px от
   штатного крестика #drawerClose — два крестика подряд. Убираем дубль: закрывают
   шторку #drawerClose, тап по затемнению и Esc. pointer-events:none — чтобы тап в
   это место попал на оверлей и всё равно закрыл шторку. */
.burger-btn.active {
  opacity: 0;
  pointer-events: none;
}

/* ===== ПОИСК В ШАПКЕ НА МОБИЛЕ ===== */
/* На десктопе поле .header__search видно, иконка не нужна. Появляется там же,
   где .header__search прячется (≤768 и класс .vp-mobile). */
.header__icon--search { display: none; background: none; border: none; padding: 0; }
.header__icon--search svg { width: 22px; height: 22px; stroke: var(--brand-dark); fill: none; }

/* ===== ПОИСК ВНУТРИ БУРГЕР-ШТОРКИ ===== */
.drawer-search {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 0 52px 18px 0;   /* справа место под крестик */
  border: 1px solid var(--brand-border, #ddd);
  border-radius: 8px;
  overflow: hidden;
  background: var(--brand-light-gray, #f5f5f5);
}
.drawer-search__input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: none;
  outline: none;
  font-family: inherit;
  font-size: 16px;   /* ≥16px — иначе iOS зумит страницу при фокусе */
  line-height: 1.2;
  color: var(--brand-dark);
  padding: 0 12px;
  height: 46px;
  -webkit-appearance: none;
  appearance: none;
}
.drawer-search__input::placeholder { color: #999; }
.drawer-search__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.drawer-search__btn {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 0;
  cursor: pointer;
  background: var(--brand-yellow);
  color: var(--brand-dark);
}
.drawer-search__btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }

/* ===== MOBILE DRAWER ===== */
/* Высота — по ВИДИМОЙ части экрана. На iOS `100vh` (и fixed bottom:0) считается
   по layout viewport, в который входит область под нижней панелью Safari: низ
   шторки уезжал под панель браузера, и последние пункты меню («Возврат»,
   телефоны, график) нельзя было ни увидеть, ни докрутить — содержимое короче
   layout viewport, поэтому прокрутки внутри панели не возникало вовсе.
   `dvh` меряет ровно то, что видно; `vh` оставлен фолбэком для старых браузеров. */
.mobile-drawer {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 1000;   /* must be ABOVE the sticky header (z-index: 200) so the panel covers it */
}
.mobile-drawer__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.3s;
}
.mobile-drawer__panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 300px;
  max-width: 85vw;
  background: white;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;   /* докрутили до конца — тянется панель, а не страница под ней */
  /* Нижний отступ учитывает «безопасную зону» (домашняя полоса iPhone),
     иначе последний пункт упирается прямо в кромку экрана. */
  /* Было 72px — место под крестик, стоявший отдельной строкой. Теперь он в одной
     строке с поиском, и панель начинается сразу с поля. */
  padding: 20px 20px 32px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
}
.mobile-drawer.open { display: block; }
.mobile-drawer.visible .mobile-drawer__overlay { opacity: 1; }
.mobile-drawer.visible .mobile-drawer__panel { transform: translateX(0); }

/* Крестик стоял в 12px от края панели, а всё её содержимое (поиск, пункты) —
   в 24px: иконка была смещена относительно колонки текста на пол-пальца, и это
   читалось как «съехала». Плюс он лежал внутри прокрутки панели и уезжал вверх,
   стоило пролистать меню (position:fixed там не спасает: у панели есть
   transform, а он делает её содержащим блоком для fixed-потомков). Поэтому
   кнопка вынесена из панели в саму шторку и держится за её края. */
.mobile-drawer__close {
  position: absolute;
  /* крестик в одной строке с поиском: 20 (отступ панели) + (48 − 44) / 2 */
  top: 22px;
  right: 20px;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s, background 0.2s, color 0.2s;
  background: rgba(255,255,255,0.92);
  width: 44px;   /* минимум для пальца; было 40 */
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 0;
  color: var(--brand-dark);
  cursor: pointer;
  border-radius: 8px;
}
/* Появляется вместе с панелью — она выезжает 0.3s, кнопка столько же тает. */
.mobile-drawer.visible .mobile-drawer__close { opacity: 1; }
.mobile-drawer__close svg { width: 22px; height: 22px; }
.mobile-drawer__close:hover,
.mobile-drawer__close:focus { background: var(--brand-light-gray); outline: none; }
.mobile-drawer__close:active { color: var(--brand-teal); }

.mobile-drawer__nav { display: flex; flex-direction: column; gap: 0; }
.mobile-drawer__nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-dark);
  border-bottom: 1px solid #f0f0f0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.mobile-drawer__nav a:last-child { border-bottom: none; }
.mobile-drawer__nav a:active { color: var(--brand-teal); }

.mobile-drawer__section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 2px solid var(--brand-light-gray);
}
.mobile-drawer__section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--brand-gray);
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.mobile-drawer__contacts {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mobile-drawer__contacts a {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-dark);
}
.mobile-drawer__contacts a svg {
  width: 18px;
  height: 18px;
  stroke: var(--brand-teal);
  fill: none;
  stroke-width: 2;
}
.mobile-drawer__schedule {
  font-size: 12px;
  color: var(--brand-gray);
  margin-top: 8px;
}

/* ===== RESPONSIVE ===== */
/* Ряд шапки перестаёт умещаться уже с 1280px: логотип + меню + поиск + иконки
   дают ~1290px. Сначала отыгрываем зазорами и шириной поиска. */
@media (max-width: 1320px) {
  .header .container { gap: 16px; }
  .header__nav { gap: 20px; }
  .header__search { width: 200px; }
}

/* Ниже 1100px дефицит доходит до 180px — зазорами его не закрыть, поэтому
   десктопная строка меню уходит в бургер (как тема уже делает на 768).
   Все её пункты есть в бургер-меню, лента категорий остаётся на месте. */
@media (max-width: 1100px) {
  .header__nav { display: none; }
  .burger-btn { display: flex; }
}

@media (max-width: 992px) {
  .top-bar__left { display: none; }
  .top-bar__right { gap: 14px; }
}

@media (max-width: 768px) {
  .top-bar { height: 36px; font-size: 12px; }
  .top-bar .container { justify-content: center; }
  .top-bar__left, .top-bar__right { display: none; }
  .top-bar__center { flex: 1; height: 36px; }
  .top-bar__slide { font-size: 12px; }

  .header { padding: 12px 0; position: sticky; top: 0; z-index: 200; background: #fff; }
  .header .container { gap: 8px; }
  /* Логотип «резиновый»: max-height держит прежние 30px там, где место есть,
     а на 360px он ужимается вместо того, чтобы выпихивать ряд иконок за экран
     (было: жёсткие height:30px+width:auto → header__icons вылезал на 11px). */
  .header__logo { flex: 0 1 auto; min-width: 0; }
  .header__logo img { height: auto; max-height: 30px; width: auto; max-width: 100%; }
  .header__nav { display: none; }
  .header__search { display: none; }
  .header__icons { gap: 2px; flex: 0 0 auto; }
  .header__icon { width: 44px; height: 44px; }
  .header__icon--desktop { display: none; }
  /* «?» уходит — его пункты (Доставка/Оплата/Возврат) есть в бургер-шторке и в
     подвале, а hover-меню на тапе всё равно неудобно. Освободившееся место
     занимает иконка поиска — ряд шапки не становится шире. */
  .header__help { display: none; }
  .header__icon--search { display: flex; }
  .burger-btn { display: flex; }

  .cat-nav { position: sticky; top: 65px; z-index: 199; }
  .cat-nav .container {
    overflow-x: auto;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .cat-nav .container::-webkit-scrollbar { display: none; }
  .cat-nav a { padding: 10px 14px; font-size: 12px; }
}

/* ============================================================
   ТЗ п.2 и п.11 — подсветка выбранного пункта меню и кнопка «Каталог»
   ============================================================ */

/* п.2: выбранная категория в ленте категорий.
   Акцент берём из темы — var(--brand-yellow) (#FFCF06), тот же, что в
   старом правиле #menu-list-top .menu-item a.active из style.css. */
.cat-nav a.active {
  background: rgba(0, 0, 0, 0.14);
  color: var(--brand-yellow);
  box-shadow: inset 0 -3px 0 var(--brand-yellow);
}
.cat-nav a.active:hover {
  background: rgba(0, 0, 0, 0.2);
  color: var(--brand-yellow);
}

/* п.2: активный пункт основной навигации в шапке. Фон белый — жёлтый на нём
   нечитаем, поэтому текст акцентным тиловым + жёлтое подчёркивание. */
.header__nav a.active {
  color: var(--brand-teal);
  border-bottom: 2px solid var(--brand-yellow);
  padding-bottom: 2px;
}

/* п.2: активный пункт в мобильном меню */
.mobile-drawer__nav a.active {
  color: var(--brand-teal);
  box-shadow: inset 3px 0 0 var(--brand-yellow);
  padding-left: 10px;
}

/* п.11: «Каталог» — кнопка, а не ссылка. Клик проворачивает ленту категорий,
   1:1 с getcatalog() на daiwa-store.ru и levenhukshop.ru
   (#menu-list-top .menu-item.toback{transform:rotateX(360deg)}). */
.header__nav a.header__nav-catalog { cursor: pointer; }
.cat-nav a {
  transform: rotateX(0deg);
  transition: background 0.2s, color 0.2s, transform 0.7s ease 0s;
}
.cat-nav.cat-nav--flip a { transform: rotateX(360deg); }
