/* ================================================================
   SEARCH OVERLAY — Moon Juice style  (biomentor / myshop)
   ================================================================ */

/* ── Backdrop — starts below header (header z-index: 9600 sits above) ── */
.bm-so__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, .45);
  z-index: 9300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
}
.bm-so__backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* Header must sit above overlay + backdrop */
#bm-header {
  z-index: 9600 !important;
  position: relative !important;
}

/* ── Overlay container ── */
.bm-so {
  position: fixed;
  /* top is set dynamically by JS to header.getBoundingClientRect().bottom */
  top: 72px;
  left: 0;
  right: 0;
  z-index: 9400;
  background: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .10);

  /* Slides down from just behind header */
  transform: translateY(-12px);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: transform 280ms ease, opacity 280ms ease, visibility 0ms linear 280ms;
}
.bm-so.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition: transform 280ms ease, opacity 280ms ease, visibility 0ms linear;
}

/* Оверлей вищий за екран (форма + товари + запити) — прокручується всередині,
   max-height виставляє JS у header.php: висота вікна мінус позиція оверлею */
.bm-so {
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Body scroll lock */
body.bm-search-open {
  overflow: hidden;
}

/* ── Inner panel ── */
.bm-so__panel {
  display: flex;
  align-items: flex-start;
  gap: 0;
  max-width: 1280px;
  margin: 0 auto;
  padding: 48px 40px 56px;
  min-height: 420px;
}

/* ── Left: products (70%) ── */
.bm-so__left {
  flex: 1;
  min-width: 0;
  padding-right: 48px;
  border-right: 1px solid #EFE9DF;
}

/* ── Right: search panel (30%) ── */
.bm-so__right {
  flex: 0 0 320px;
  padding-left: 48px;
  position: relative;
  padding-top: 0;
}

/* ── Section labels ── */
.bm-so__section-label {
  font-family: 'Golos Text', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #9B9589;
  margin: 0 0 24px;
}

/* ── Close button ── */
.bm-so__close {
  position: absolute;
  top: 0;
  right: 0;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  color: #9B9589;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 150ms;
}
.bm-so__close:hover { color: #1A1A1A; }

/* ── Search form ── */
.bm-so__form {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1.5px solid #1A1A1A;
  padding-bottom: 10px;
  margin-bottom: 36px;
  margin-top: 36px; /* space below the × button */
}

.bm-so__input {
  flex: 1;
  border: none;
  outline: none;
  font-family: 'Golos Text', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: #1A1A1A;
  background: transparent;
  padding: 0;
  line-height: 1.5;
}
.bm-so__input::placeholder { color: #C8C0B4; }

.bm-so__submit {
  background: none;
  border: none;
  cursor: pointer;
  color: #6B6560;
  display: flex;
  align-items: center;
  padding: 0;
  transition: color 150ms;
  flex-shrink: 0;
}
.bm-so__submit:hover { color: #1A1A1A; }

/* ── Popular queries ── */
.bm-so__queries { }

.bm-so__query-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bm-so__query-list a {
  font-family: 'Golos Text', sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: #3A3530;
  text-decoration: none;
  line-height: 2;
  transition: color 140ms;
  display: block;
}
.bm-so__query-list a:hover { color: #1A1A1A; }

/* ── Product cards grid ── */
.bm-so__products {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

/* ── Single product card ── */
.bm-so-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: #1A1A1A;
}

.bm-so-card__img-wrap {
  position: relative;
  background: #F5F0E8;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  margin-bottom: 14px;
}

.bm-so-card .bm-so-card__img {   /* два класи: перебиваємо .woocommerce-page img { height:auto } */
  position: absolute;   /* заповнює рамку незалежно від aspect-ratio */
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0;
  display: block;
  transition: transform 320ms ease;
}
.bm-so-card:hover .bm-so-card__img {
  transform: scale(1.05);
}

.bm-so-card__name {
  font-family: 'Golos Text', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #1A1A1A;
  margin: 0 0 3px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bm-so-card__sub {
  font-family: 'Golos Text', sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: #9B9589;
  margin: 0 0 8px;
}

.bm-so-card__link {
  font-family: 'Golos Text', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #3A3530;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 140ms;
  margin-top: auto;
}
.bm-so-card:hover .bm-so-card__link { color: #1A1A1A; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 1000px) {
  .bm-so__panel { padding: 40px 24px 48px; }
  .bm-so__right { flex: 0 0 260px; padding-left: 32px; }
  .bm-so__left { padding-right: 32px; }
  .bm-so__products { grid-template-columns: repeat(4, 1fr); gap: 14px; }
}

@media (max-width: 768px) {
  .bm-so__panel {
    flex-direction: column;
    padding: 56px 20px 40px;
    gap: 0;
    min-height: auto;
  }

  .bm-so__left {
    border-right: none;
    border-bottom: 1px solid #EFE9DF;
    padding-right: 0;
    padding-bottom: 32px;
    margin-bottom: 32px;
    width: 100%;
  }

  .bm-so__right {
    flex: 0 0 auto;
    width: 100%;
    padding-left: 0;
  }

  /* на мобільному поле пошуку — першим, товари під ним */
  .bm-so__right { order: -1; margin-bottom: 28px; }
  .bm-so__form { margin-top: 0; margin-bottom: 24px; }
  .bm-so__input { font-size: 16px; }   /* 16px — щоб iOS не зумив поле при фокусі */
  .bm-so__close { top: -40px; right: 0; }

  .bm-so__products {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .bm-so-card__img-wrap { aspect-ratio: 3/4; }
}

@media (max-width: 480px) {
  .bm-so__panel { padding: 52px 16px 32px; }
  .bm-so__products { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
