/* Catalog toolbar: search + collapsible facets (sort, price, topics) + active pills.
   Палитра — в тон сайта: teal #087f75, текст #18333f, фон #f7fafa. */
#catalog { scroll-margin-top: 92px; }

#catalog .catalog-toolbar {
  position: sticky;
  top: 88px; /* под sticky-шапкой (76px) + зазор */
  z-index: 50;
  margin: 0 0 28px;
  padding: 18px 20px;
  background: rgb(255 255 255 / 0.96);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  backdrop-filter: saturate(140%) blur(10px);
  border: 1px solid #e1e9eb;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgb(20 43 59 / 0.08);
}

/* --- Поиск --- */
#catalog .catalog-search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}
#catalog .catalog-search > svg {
  position: absolute;
  left: 16px;
  width: 20px;
  height: 20px;
  color: #6b8288;
  pointer-events: none;
}
#catalog .catalog-search input {
  width: 100%;
  min-height: 56px;
  margin: 0;
  padding: 0 92px 0 48px;
  border: 1.5px solid #d5e2e4;
  border-radius: 16px;
  background: #f7fafa;
  color: #18333f;
  font: 500 16px/1.3 "FB Inter", Inter, system-ui, sans-serif;
  box-shadow: none;
}
#catalog .catalog-search input::placeholder { color: #7d9196; font-weight: 450; }
#catalog .catalog-search input:hover { border-color: #b9d2d0; background: #fff; }
#catalog .catalog-search input:focus {
  outline: none;
  background: #fff;
  border-color: #087f75;
  box-shadow: 0 0 0 4px #087f7520;
}
#catalog .catalog-search input::-webkit-search-cancel-button { display: none; }
#catalog .catalog-spinner {
  position: absolute;
  right: 52px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid #cfe3e0;
  border-top-color: #087f75;
  opacity: 0;
  pointer-events: none;
}
#catalog .catalog-toolbar.is-loading .catalog-spinner { opacity: 1; animation: catalog-spin 0.7s linear infinite; }
@keyframes catalog-spin { to { transform: rotate(360deg); } }
#catalog #catalogSearchClear {
  position: absolute;
  right: 8px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #5d7378;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
#catalog #catalogSearchClear:hover { background: #e7f3f0; color: #076a62; }

/* --- Раскрывающиеся фасеты (на десктопе всегда открыты) --- */
#catalog .catalog-facets { margin-top: 14px; }
#catalog .catalog-facets-toggle { display: none; }
#catalog .catalog-facets-body { display: block; }
#catalog .catalog-facets-inner { display: block; }

/* --- Поля «Сортировка» и «Цена» с видимыми подписями --- */
#catalog .catalog-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
#catalog .catalog-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
#catalog .catalog-field-label {
  font: 650 12px/1 "FB Inter", Inter, system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7d9196;
}
#catalog .catalog-field select {
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 0 42px 0 16px;
  border: 1.5px solid #d5e2e4 !important;
  border-radius: 14px !important;
  background: #f7fafa url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b8288' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right 14px center / 16px no-repeat !important;
  box-shadow: none !important;
  color: #18333f;
  font: 550 15px/1.3 "FB Inter", Inter, system-ui, sans-serif;
  appearance: none;
  cursor: pointer;
}
#catalog .catalog-field select:hover { border-color: #8fc5ba !important; background-color: #fff !important; }
#catalog .catalog-field select:focus {
  outline: none;
  background-color: #fff !important;
  border-color: #087f75 !important;
  box-shadow: 0 0 0 4px #087f7520 !important;
}
/* Выбранное (не дефолтное) значение подсвечиваем */
#catalog .catalog-field select.is-set {
  border-color: #087f75 !important;
  background-color: #edf7f4 !important;
  color: #0b4f49;
  font-weight: 650;
}

/* --- Чипы тематик: горизонтальная лента с масками выцветания --- */
#catalog .catalog-topics {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scrollbar-width: thin;
  scrollbar-color: #b9d2d0 transparent;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
}
#catalog .catalog-topics button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 16px;
  border: 1.5px solid #d7e4e5;
  border-radius: 999px;
  background: #fff;
  color: #294e55;
  font: 550 14px/1.2 "FB Inter", Inter, system-ui, sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}
#catalog .catalog-topics button:hover { border-color: #087f75; background: #f3faf8; transform: translateY(-1px); }
#catalog .catalog-topics button[aria-pressed="true"] {
  background: #087f75;
  border-color: #087f75;
  color: #fff;
  box-shadow: 0 4px 12px rgb(8 127 117 / 0.35);
}
#catalog .catalog-topics button:focus-visible { outline: 3px solid #35a894; outline-offset: 2px; }

/* --- Активные фильтры --- */
#catalog .catalog-active {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed #d5e2e4;
}
#catalog .catalog-active[hidden] { display: none; }
#catalog .catalog-active-label {
  font: 650 12px/1 "FB Inter", Inter, system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7d9196;
  margin-right: 2px;
}
#catalog .catalog-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 8px 4px 14px;
  border-radius: 999px;
  background: #edf7f4;
  color: #14594f;
  font-size: 13px;
  font-weight: 600;
}
#catalog .catalog-chip button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #14594f;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
#catalog .catalog-chip button:hover { background: #d7efe8; }
#catalog #catalogReset {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: #087f75;
  font: 650 13px/1 "FB Inter", Inter, system-ui, sans-serif;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
#catalog #catalogReset:hover { color: #076a62; }

/* --- Планшет: тулбар не липкий, поля в две колонки --- */
@media (max-width: 1023px) {
  #catalog .catalog-toolbar { position: static; padding: 16px; }
  #catalog .catalog-fields { grid-template-columns: 1fr 1fr; }
}

/* --- Мобильный: фасеты сворачиваются в кнопку «Фильтры» со счётчиком --- */
@media (max-width: 767px) {
  #catalog .catalog-toolbar { padding: 12px; border-radius: 16px; }
  #catalog .catalog-search input { min-height: 52px; font-size: 16px; } /* 16px — без зума на iOS */
  #catalog .catalog-facets { margin-top: 10px; }
  #catalog .catalog-facets-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 1.5px solid #d5e2e4;
    border-radius: 14px;
    background: #f7fafa;
    color: #18333f;
    font: 650 15px/1 "FB Inter", Inter, system-ui, sans-serif;
    cursor: pointer;
    list-style: none;
  }
  #catalog .catalog-facets-toggle::-webkit-details-marker { display: none; }
  #catalog .catalog-facets-toggle > svg { width: 20px; height: 20px; color: #087f75; }
  #catalog .catalog-facets-chevron { margin-left: auto; color: #6b8288 !important; transition: transform 0.2s ease; }
  #catalog .catalog-facets[open] .catalog-facets-chevron { transform: rotate(180deg); }
  #catalog .catalog-facets-count {
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    background: #087f75;
    color: #fff;
    font-size: 13px;
    line-height: 24px;
    text-align: center;
  }
  #catalog .catalog-facets-count[hidden] { display: none; }
  /* Плавное раскрытие без max-height-хаков */
  #catalog .catalog-facets-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.25s ease;
  }
  #catalog .catalog-facets[open] .catalog-facets-body { grid-template-rows: 1fr; }
  #catalog .catalog-facets-inner { overflow: hidden; min-height: 0; }
  #catalog .catalog-facets[open] .catalog-facets-inner { padding-top: 12px; }
  #catalog .catalog-fields { grid-template-columns: 1fr; }
  #catalog .catalog-field select { min-height: 52px; font-size: 16px; }
  #catalog .catalog-topics {
    margin: 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
    scrollbar-width: none;
  }
  #catalog .catalog-topics::-webkit-scrollbar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #catalog .catalog-toolbar.is-loading .catalog-spinner { animation: none; opacity: 0; }
  #catalog .catalog-facets-body { transition: none; }
  #catalog .catalog-topics button { transition: none; }
  #catalog .catalog-facets-chevron { transition: none; }
}

/* --- Best-practice pack 2026-09-28: доступность и аккуратность --- */
/* Крестик очистки: хит-зона 44px, визуально тот же × */
#catalog #catalogSearchClear {
  width: 44px;
  height: 44px;
  font-size: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#catalog #catalogSearchClear:focus-visible { outline: 3px solid #087f75; outline-offset: -3px; }
/* Крестик активного чипа: крупнее и с видимым фокусом */
#catalog .catalog-chip button { min-width: 32px; min-height: 32px; font-size: 20px; }
#catalog .catalog-chip button:focus-visible { outline: 3px solid #087f75; outline-offset: 2px; }
/* Коллапс ленты тематик: первые 10 чипов + кнопка «Показать все N» */
#catalog .catalog-topics.is-collapsed button[data-topic]:nth-child(n+11) { display: none; }
#catalog .catalog-topics-toggle {
  flex: 0 0 auto;
  align-self: flex-start;
  min-height: 44px;
  margin-top: 10px;
  padding: 8px 18px;
  border: 1.5px dashed #8fc5ba;
  border-radius: 999px;
  background: #f3faf8;
  color: #076a62;
  font: 650 14px/1.2 "FB Inter", Inter, system-ui, sans-serif;
  cursor: pointer;
  white-space: nowrap;
}
#catalog .catalog-topics-toggle:hover { background: #e7f3f0; border-style: solid; }
#catalog .catalog-topics-toggle:focus-visible { outline: 3px solid #087f75; outline-offset: 2px; }
/* Пагинация и селекты: безопасные тап-таргеты и обрезка длинных подписей */
#catalogPagination button,
#catalogPaginationTop button {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#catalog .catalog-field select { text-overflow: ellipsis; overflow: hidden; }
@media (max-width: 767px) {
  #catalogMore { width: 100%; min-height: 52px; }
}
