/* ==========================================================================
   Блок: Хедер (.b-header)
   Scoped-стили: все селекторы под .b-header
   ========================================================================== */

.b-header {
  position: sticky;
  top: 0;
  z-index: 100;
  /* Матовое стекло: полупрозрачный тёплый фон + blur */
  background: rgba(247, 243, 236, 0.82);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
  transition: box-shadow var(--transition), background-color var(--transition);
}

/* Лёгкая тень после начала скролла (класс ставит app.js) */
.b-header.is-scrolled {
  background: rgba(247, 243, 236, 0.9);
  box-shadow: 0 6px 24px rgba(59, 52, 55, 0.08);
}

.b-header__container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

/* --------------------------------------------------------------------------
   Верхняя информационная строка
   -------------------------------------------------------------------------- */
.b-header__top {
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
  /* Строка плавно схлопывается при скролле */
  max-height: 40px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.b-header.is-scrolled .b-header__top {
  max-height: 0;
  opacity: 0;
  border-bottom-color: transparent;
}

.b-header__top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 9px;
}

.b-header__top-text {
  text-transform: uppercase;
}

.b-header__top-phone {
  font-weight: 600;
  color: var(--text);
  transition: color var(--transition);
}

.b-header__top-phone:hover {
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   Основная строка: навигация — логотип — навигация + иконки
   -------------------------------------------------------------------------- */
.b-header__main {
  border-bottom: 1px solid var(--line);
}

.b-header__main-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding-block: 18px;
  transition: padding-block 0.3s ease;
}

/* Уменьшение высоты при скролле */
.b-header.is-scrolled .b-header__main-inner {
  padding-block: 10px;
}

.b-header__nav {
  display: flex;
  align-items: center;
  gap: 32px;
  flex: 1 1 0;
}

.b-header__nav--right {
  justify-content: flex-end;
}

.b-header__nav-link {
  position: relative;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  padding-block: 6px;
  transition: color var(--transition);
}

/* Тонкое подчёркивание при наведении */
.b-header__nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transition: right 0.3s ease;
}

.b-header__nav-link:hover {
  color: var(--accent);
}

.b-header__nav-link:hover::after {
  right: 0;
}

/* --------------------------------------------------------------------------
   Логотип по центру: «АМО» в рукописной рамке + подпись
   -------------------------------------------------------------------------- */
.b-header__logo {
  flex: 0 0 auto;
  text-align: center;
}

.b-header__logo-link {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.b-header__logo-badge {
  position: relative;
  display: grid;
  place-items: center;
  width: 132px;
  height: 60px;
  transition: transform 0.3s ease;
}

/* Лёгкое уменьшение логотипа при скролле */
.b-header.is-scrolled .b-header__logo-badge {
  transform: scale(0.9);
}

.b-header__logo-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--accent);
}

.b-header__logo-text {
  position: relative;
  font-family: var(--font-serif);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: 0.14em;
  /* Компенсация letter-spacing, чтобы текст был по центру рамки */
  margin-right: -0.14em;
  color: var(--text);
  line-height: 1;
}

.b-header__logo-tag {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: lowercase;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Правая часть и иконки
   -------------------------------------------------------------------------- */
.b-header__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 28px;
  flex: 1 1 0;
}

.b-header__nav--right {
  flex: 0 0 auto;
}

.b-header__icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.b-header__icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--text);
  transition: color var(--transition), background-color var(--transition);
}

.b-header__icon svg {
  width: 23px;
  height: 23px;
}

.b-header__icon:hover {
  color: var(--accent);
  background: var(--lavender-soft);
}

/* Счётчик избранного/корзины на иконке */
.b-header__counter {
  position: absolute;
  top: 1px;
  right: -1px;
  min-width: 17px;
  height: 17px;
  padding-inline: 4px;
  display: grid;
  place-items: center;
  border-radius: 100px;
  background: var(--accent);
  color: #FFF;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
}

/* --------------------------------------------------------------------------
   Бургер (скрыт на десктопе)
   -------------------------------------------------------------------------- */
.b-header__burger {
  display: none;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--text);
}

.b-header__burger svg {
  width: 24px;
  height: 24px;
}

/* --------------------------------------------------------------------------
   Мобильное меню — drawer слева
   -------------------------------------------------------------------------- */
.b-header__mobile {
  position: fixed;
  inset: 0;
  z-index: 200;
  visibility: hidden;
  /* панель за левым краем не должна давать горизонтальный скролл */
  overflow: hidden;
  transition: visibility 0s 0.35s;
}

.b-header__mobile.is-open {
  visibility: visible;
  transition-delay: 0s;
}

.b-header__mobile-overlay {
  position: absolute;
  inset: 0;
  background: rgba(59, 52, 55, 0.35);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.b-header__mobile.is-open .b-header__mobile-overlay {
  opacity: 1;
}

.b-header__mobile-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(340px, 88vw);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 24px 28px;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.35s ease;
}

.b-header__mobile.is-open .b-header__mobile-panel {
  transform: translateX(0);
}

.b-header__mobile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.b-header__mobile-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
}

.b-header__mobile-close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--muted);
}

.b-header__mobile-close svg {
  width: 20px;
  height: 20px;
}

.b-header__mobile-nav {
  display: flex;
  flex-direction: column;
  padding-block: 14px;
  border-bottom: 1px solid var(--line);
}

.b-header__mobile-caption {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.b-header__mobile-link {
  padding-block: 10px;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  transition: color var(--transition), padding-left var(--transition);
}

.b-header__mobile-link:hover {
  color: var(--accent);
  padding-left: 6px;
}

.b-header__mobile-foot {
  margin-top: auto;
  padding-top: 20px;
}

.b-header__mobile-phone {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.b-header__mobile-note {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* --------------------------------------------------------------------------
   Адаптив
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  /* На планшете правое меню прячем, чтобы не теснить иконки */
  .b-header__nav--right {
    display: none;
  }
}

@media (max-width: 768px) {
  /* На мобильных blur убираем: иначе backdrop-filter делает хедер
     containing block для fixed-панели мобильного меню */
  .b-header,
  .b-header.is-scrolled {
    background: var(--bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .b-header__top {
    display: none;
  }

  .b-header__burger {
    display: grid;
    flex: 0 0 auto;
  }

  .b-header__nav--left {
    display: none;
  }

  /* Логотип остаётся по центру: бургер и иконки по краям */
  .b-header__main-inner {
    gap: 12px;
    padding-block: 12px;
  }

  .b-header__logo {
    margin-inline: auto;
  }

  .b-header__logo-badge {
    width: 108px;
    height: 50px;
  }

  .b-header__logo-text {
    font-size: 27px;
  }

  .b-header__right {
    flex: 0 0 auto;
    gap: 0;
  }

  /* Поиск и аккаунт доступны внутри меню/на страницах — в шапке не тесним */
  .b-header__icon[aria-label="Поиск"],
  .b-header__icon[aria-label="Личный кабинет"] {
    display: none;
  }
}

@media (max-width: 480px) {
  .b-header__logo-tag {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Полнэкранный поиск-оверлей (разметка в header.html, логика — search.js)
   -------------------------------------------------------------------------- */
.b-header__search {
  position: fixed;
  inset: 0;
  z-index: 300;
  visibility: hidden;
  transition: visibility 0s .35s;
}

.b-header__search.is-open {
  visibility: visible;
  transition-delay: 0s;
}

.b-header__search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(43, 36, 40, .45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .3s ease;
}

.b-header__search.is-open .b-header__search-backdrop {
  opacity: 1;
}

.b-header__search-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 40px;
  max-height: 100vh;
  overflow-y: auto;
  padding: 48px max(24px, calc((100vw - var(--container)) / 2 + var(--container-pad))) 56px;
  background: var(--bg);
  box-shadow: 0 24px 60px rgba(43, 36, 40, .18);
  transform: translateY(-102%);
  transition: transform .38s cubic-bezier(.22, 1, .36, 1);
}

.b-header__search.is-open .b-header__search-panel {
  transform: translateY(0);
}

.b-header__search-close {
  position: absolute;
  top: 18px;
  right: 20px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--muted);
  transition: color var(--transition), background-color var(--transition), transform var(--transition);
}

.b-header__search-close:hover {
  color: var(--accent);
  background: var(--lavender-soft);
  transform: rotate(90deg);
}

.b-header__search-main {
  min-width: 0;
}

/* Большое поле с автофокусом */
.b-header__search-field {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--text);
  color: var(--text);
}

.b-header__search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  font-family: var(--font-serif);
  font-size: clamp(26px, 3.4vw, 40px);
  font-weight: 500;
  color: var(--text);
  outline: none;
}

.b-header__search-input::placeholder {
  color: var(--muted);
  opacity: .55;
}

.b-header__search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* Популярные запросы */
.b-header__search-popular {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.b-header__search-popular-label {
  font-size: 13px;
  color: var(--muted);
  margin-right: 4px;
}

.b-header__search-chip {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background-color var(--transition);
}

.b-header__search-chip:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--lavender-soft);
}

/* Результаты */
.b-header__search-results {
  margin-top: 32px;
}

.b-header__search-hint,
.b-header__search-empty {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}

.b-header__search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.b-header__search-card {
  display: block;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  transition: box-shadow var(--transition), transform var(--transition);
}

.b-header__search-card:hover {
  box-shadow: var(--shadow-soft);
  transform: translateY(-2px);
}

.b-header__search-card-img {
  aspect-ratio: 3 / 4;
  background: var(--surface-2);
  overflow: hidden;
}

.b-header__search-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.b-header__search-card-body {
  padding: 12px 14px 14px;
}

.b-header__search-card-name {
  display: block;
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.b-header__search-card-meta {
  display: block;
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
}

.b-header__search-card-price {
  display: block;
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

/* Лёгкая реклама справа */
.b-header__search-promo {
  position: relative;
  align-self: start;
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface-2);
  min-height: 100%;
}

.b-header__search-promo-img {
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: cover;
  display: block;
}

.b-header__search-promo-body {
  position: absolute;
  inset: auto 0 0 0;
  padding: 56px 24px 24px;
  background: linear-gradient(to top, rgba(43, 36, 40, .72), rgba(43, 36, 40, 0));
  color: #FDFBF7;
}

.b-header__search-promo-title {
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 500;
}

.b-header__search-promo-text {
  margin: 0 0 10px;
  font-size: 15px;
  opacity: .92;
}

.b-header__search-promo-link {
  font-size: 14px;
  font-weight: 600;
  color: #FDFBF7;
  border-bottom: 1px solid rgba(253, 251, 247, .6);
}

@media (max-width: 1024px) {
  .b-header__search-panel {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .b-header__search-promo {
    display: none;
  }
}

@media (max-width: 768px) {
  .b-header__search-panel {
    padding-top: 64px;
  }
}
