/* Панель пошуку «Знайдіть подарунок за 1 хвилину».

   Окремий файл, бо панель стоїть і на головній, і в каталозі
   (шаблон common/search_panel.twig). Поки стилі жили в home-hero.css,
   у каталозі вони не підключались — панель лишалась без оформлення,
   а вбудовані SVG-іконки без заданих розмірів роздувались на всю
   ширину сторінки. */

.home-search {
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: 24px 28px;
  position: relative;
  z-index: 2;
  /* Панель "звисає" з кремової секції на білий фон.
     Зсув робимо margin-ом, а не transform-ом, щоб чіпи нижче враховували його
     в розмітці й не залазили під панель. */
  margin-top: 40px;
  margin-bottom: -40px;
}

.home-search__label {
  font-weight: 600;
  color: var(--home-text);
  margin-bottom: 16px;
}

.home-search__label .accent {
  color: var(--home-accent-bright);
}

.home-search__form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.home-search__field {
  flex: 1 1 150px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--home-border);
  border-radius: 999px;
  padding: 11px 18px;
}

/* Поле пошуку ширше за фільтри-селекти */
.home-search__field--query {
  flex: 1.6 1 240px;
  position: relative;
}

/* Текст не має заходити під круглу кнопку справа */
.home-search__field--query input {
  padding-right: 52px;
  box-sizing: border-box;
}

.home-search__go {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--home-accent, #d6473a);
  cursor: pointer;
}

.home-search__go:hover {
  color: var(--home-accent-dark, #b83a2f);
}

.home-search__go svg {
  width: 20px;
  height: 20px;
}

.home-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  color: var(--home-icon);
}

.home-search__field input {
  border: none;
  outline: none;
  width: 100%;
  background: transparent;
  color: var(--home-text);
  font-size: 0.875rem;
}

.home-search__field input::placeholder {
  color: var(--home-placeholder);
}

/* --- випадайка фільтра --- */

/* Поле-фільтр саме не має внутрішніх полів: їх бере на себе кнопка,
   інакше клікабельною була б лише середина, а не вся «пігулка». */
.home-search__field--select {
  position: relative;
  padding: 0;
  border: 0;
  display: block;
}

.home-search__toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 18px;
  border: 1px solid var(--home-border);
  border-radius: 999px;
  background: #fff;
  color: var(--home-placeholder);
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.home-search__toggle:hover,
.home-search__field--select.is-open .home-search__toggle {
  border-color: var(--home-accent-bright);
}

/* Обраний варіант — темним, підказка лишається сірою */
.home-search__field--select.is-chosen .home-search__toggle {
  color: var(--home-text);
}

.home-search__value {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-search__caret {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  color: var(--home-icon);
  transition: transform 0.15s ease;
}

.home-search__field--select.is-open .home-search__caret {
  transform: rotate(180deg);
}

/* Сам список. Абсолютний, щоб відкриття не розсовувало панель. */
.home-search__list {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 8px;
  list-style: none;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(60, 30, 24, 0.18);
}

.home-search__field--select.is-open .home-search__list {
  display: block;
}

.home-search__option {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--home-text);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}

.home-search__option:hover {
  background: var(--home-chip-bg);
}

.home-search__option.is-selected {
  background: var(--home-chip-bg);
  color: var(--home-accent-bright);
  font-weight: 600;
}

.home-search__empty {
  display: block;
  padding: 9px 12px;
  color: var(--home-placeholder);
  font-size: 0.85rem;
}

/* --- шторка фільтрів ---
   На компі це просто обгортка: display:contents прибирає її з розкладки,
   і поля лягають прямими flex-дітьми .home-search__form, як і раніше.
   Шторкою вона стає лише на телефоні (нижче). */
.home-search__drawer,
.home-search__drawer-sheet {
  display: contents;
}

.home-search__drawer-backdrop,
.home-search__drawer-head,
.home-search__drawer-apply {
  display: none;
}

.home-search__submit {
  /* Пігулка (999px), як усі кнопки сайту — раніше тут був 10px,
     єдина кнопка на сайті не в формі пігулки. */
  border-radius: 999px;
  padding: 12px 30px;
  /* 600, а не 500 — див. пояснення в product-card.css */
  font-weight: 600;
  font-size: 0.875rem;
  background: var(--home-accent);
  border: 1px solid var(--home-accent);
  color: #fff;
  flex: 0 0 auto;
}

.home-search__submit:hover {
  background: var(--home-accent-dark);
  border-color: var(--home-accent-dark);
  color: #fff;
}

.home-search__submit-icon {
  display: none;
  width: 18px;
  height: 18px;
}

.home-search__submit-text-mobile {
  display: none;
}


/* --- телефон --- */
@media (max-width: 767.98px) {
  .home-search {
    margin-top: 24px;
    margin-bottom: 24px;
  }

  .home-categories {
    margin-top: 24px;
  }
}

@media (max-width: 767.98px) {
  /* Пошук: окрема біла картка під фото (не накладається), всередині поле + "Фільтр" */
  .home-search {
    display: flex;
    align-items: center;
    margin: 16px 0 0;
    padding: 12px;
    border-radius: 18px;
    box-shadow: var(--shadow-card);
    position: relative;
    z-index: 3;
  }

  .home-search__label {
    display: none;
  }

  .home-search__form {
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    width: 100%;
  }

  .home-search__field:not(.home-search__field--query) {
    display: none;
  }

  .home-search__field--query {
    flex: 1 1 auto;
    border: 1px solid var(--home-border);
    border-radius: 999px;
    padding: 10px 16px;
  }

  /* На вузькому екрані поле й так тісне поряд з кнопкою «Фільтр» —
     кружечок трохи менший, щоб лишити більше місця під текст. */
  .home-search__field--query input {
    padding-right: 40px;
  }

  .home-search__go {
    width: 28px;
    height: 28px;
    right: 8px;
  }

  .home-search__go svg {
    width: 18px;
    height: 18px;
  }

  /* Пігулка, як поле пошуку поруч і як решта кнопок на телефоні —
     прямокутник із заокругленням тут вибивався з решти сторінки.
     Вертикальні поля 12px зрівнюють її по висоті з полем пошуку. */
  .home-search__submit {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 999px;
    padding: 12px 18px;
    font-size: 0.8rem;
    font-weight: 600;
  }

  .home-search__submit-icon {
    display: block;
  }

  .home-search__submit-text-mobile {
    display: inline-block;
  }

  .home-search__submit-text-desktop {
    display: none;
  }

  /* Шторка: кнопка «Фільтр» більше не надсилає форму одразу — вона
     відкриває цю шторку знизу з полями, і вже там є своя кнопка
     «Показати варіанти», яка й надсилає форму. */
  .home-search__drawer {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 70;
    visibility: hidden;
  }

  .home-search__drawer.is-open {
    visibility: visible;
  }

  .home-search__drawer-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    background: rgba(34, 31, 29, 0.45);
    opacity: 0;
    transition: opacity 0.25s ease;
  }

  .home-search__drawer.is-open .home-search__drawer-backdrop {
    opacity: 1;
  }

  .home-search__drawer-sheet {
    display: block;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 82vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 18px var(--page-gutter) calc(18px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -12px 32px rgba(60, 30, 24, 0.18);
    transform: translateY(100%);
    transition: transform 0.28s ease;
  }

  .home-search__drawer.is-open .home-search__drawer-sheet {
    transform: translateY(0);
  }

  .home-search__drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
  }

  .home-search__drawer-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--home-text);
  }

  .home-search__drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--home-chip-bg);
    color: var(--home-text);
  }

  .home-search__drawer-close svg {
    width: 16px;
    height: 16px;
  }

  /* Усередині шторки поля показуємо — загальне правило вище ховає їх
     тільки поза шторкою. */
  .home-search__drawer .home-search__field--select {
    display: block;
  }

  .home-search__drawer .home-search__field--select + .home-search__field--select {
    margin-top: 12px;
  }

  .home-search__drawer-apply {
    display: block;
    width: 100%;
    margin-top: 20px;
    padding: 14px;
    border: 0;
    border-radius: 999px;
    background: var(--home-accent);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
  }

  body.filters-drawer-open {
    overflow: hidden;
  }
}
