/* ============================================================
   Каталог — категория с фильтрами (макет 4b: строки 475–591)
   + /catalogue (корневые категории)
   ============================================================ */

/* ---- крошки / шапка страницы ---- */
.cat-page { padding-top: 0; }
.cat-breadcrumbs {
  padding: 14px 0 0; font-size: 12.5px; font-weight: 700; color: var(--muted);
}
.cat-breadcrumbs a:hover { color: var(--terra); }
.cat-breadcrumbs__sep { margin: 0 6px; color: var(--muted); }
.cat-breadcrumbs__current { color: var(--ink-2); }

.cat-topbar {
  display: flex; align-items: baseline; gap: 16px; padding: 10px 0 22px; flex-wrap: wrap;
}
.cat-title { font-size: 32px; font-weight: 900; }
.cat-count { font-size: 14px; color: var(--muted); font-weight: 700; }
.cat-sort-form { margin-left: auto; }
.cat-sort {
  position: relative; background: #fff; border-radius: var(--r-pill);
  padding: 9px 34px 9px 18px; font-size: 13px; font-weight: 800; color: var(--ink-2);
}
.cat-sort::after {
  content: "▾"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--ink-3);
}
.cat-sort__select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background: transparent; border: 0; font: inherit; color: inherit; width: 100%; cursor: pointer;
}

/* ---- общий грид: сайдбар 280px + контент ---- */
.cat-layout { display: grid; grid-template-columns: 280px 1fr; gap: 28px; padding-bottom: 48px; align-items: start; }

/* ---- сайдбар ---- */
.cat-sidebar { display: flex; flex-direction: column; gap: 14px; }

.cat-widget { background: var(--green); border-radius: 20px; padding: 18px 20px; color: #fff; }
.cat-widget__title { font-weight: 900; font-size: 14.5px; }
.cat-widget__text { font-size: 12.5px; opacity: .92; margin: 6px 0 12px; line-height: 1.45; }
.cat-widget__btn {
  display: block; background: #fff; color: var(--green-ink); text-align: center;
  font-weight: 800; font-size: 13px; padding: 10px; border-radius: var(--r-pill);
}

.cat-block { background: #fff; border-radius: 20px; padding: 18px 22px; }
.cat-block__title { font-weight: 900; font-size: 14px; margin-bottom: 12px; }

/* Свёрнутый на мобиле блок фильтров (виджет подбора размера — вне details, виден всегда).
   Форма внутри — тот же вертикальный ритм, что раньше был на .cat-sidebar.
   <details> в разметке ВСЕГДА рендерится с атрибутом open (см. category.php) —
   нативное сворачивание содержимого <details> браузер выполняет на уровне
   рендеринга (не через display:none на детях), поэтому единственный надёжный
   способ управлять состоянием — снимать/не снимать сам атрибут open. На десктопе
   он не трогается (фильтры всегда открыты); на мобиле filters.js снимает его
   при загрузке (initFiltersCollapse). summary же — обычный элемент потока,
   его можно прятать чистым CSS независимо от open, что и делаем ниже. */
.cat-filters-form { display: flex; flex-direction: column; gap: 14px; }
.cat-filters-collapse > summary { list-style: none; cursor: pointer; display: none; }
.cat-filters-collapse > summary::-webkit-details-marker { display: none; }

.cat-check-list { display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
.cat-check { position: relative; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.cat-check input[type="checkbox"] {
  position: absolute; left: 0; top: 0; width: 20px; height: 20px; margin: 0; opacity: 0; cursor: pointer; z-index: 1;
}
.cat-check__box {
  width: 20px; height: 20px; flex: none; border-radius: 7px; border: 2px solid #e8d9c5;
  display: flex; align-items: center; justify-content: center; font-size: 12px; color: transparent;
  transition: background .15s, border-color .15s;
}
.cat-check input:checked + .cat-check__box { background: var(--terra); border-color: var(--terra); color: #fff; }
.cat-check__count { margin-left: auto; color: #c9b89e; font-size: 12px; font-weight: 700; }

/* Task 6 (Stage 5, персонализация): бейдж «ваш» на чипе веса сайдбара,
   соответствующем весу ребёнка из профиля (shop-personalize.js). Только
   подсказка — БЕЗ автоприменения фильтра, чип остаётся обычной ссылкой. */
.chip-mine-badge {
  background: var(--green); color: #fff; border-radius: var(--r-pill);
  font-size: 9.5px; font-weight: 900; text-transform: uppercase; letter-spacing: .02em;
  padding: 2px 6px; line-height: 1.4;
}

.cat-more-brands { margin-top: 10px; }
.cat-more-brands summary { cursor: pointer; color: var(--terra); font-weight: 800; font-size: 13px; }
.cat-more-brands .cat-check-list { margin-top: 10px; }

.cat-range { position: relative; height: 20px; margin: 14px 6px 10px; }
.cat-range__track { position: absolute; left: 0; right: 0; top: 8px; height: 4px; background: #f0e6d7; border-radius: 99px; }
.cat-range__fill { position: absolute; top: 8px; height: 4px; background: var(--terra); border-radius: 99px; left: 0; right: 0; }
.cat-range__input {
  position: absolute; left: 0; top: 0; width: 100%; height: 20px; margin: 0;
  background: transparent; appearance: none; -webkit-appearance: none; -moz-appearance: none; pointer-events: none;
}
.cat-range__input::-webkit-slider-runnable-track { background: transparent; height: 20px; }
.cat-range__input::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; pointer-events: auto;
  width: 16px; height: 16px; border-radius: 99px; background: #fff; border: 3px solid var(--terra);
  cursor: pointer; margin-top: 2px;
}
.cat-range__input::-moz-range-track { background: transparent; height: 20px; border: 0; }
.cat-range__input::-moz-range-thumb {
  pointer-events: auto; width: 16px; height: 16px; border-radius: 99px; background: #fff;
  border: 3px solid var(--terra); cursor: pointer;
}
.cat-range__labels { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 800; color: var(--ink-3); }

/* ---- активные фильтры / сброс ---- */
.cat-active-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; font-size: 12.5px; font-weight: 800; }
.cat-active-chip:hover { opacity: .85; }
.chip.cat-reset { background: #fff; color: var(--terra); }

.cat-empty { background: #fff; border-radius: var(--r-card); padding: 40px; text-align: center; color: var(--muted); }

/* ---- сетка товаров ---- */
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.cat-grid > * { min-width: 0; }

.cat-editor-tile { background: var(--pastel-cream); padding: 20px; display: flex; flex-direction: column; justify-content: space-between; }
.cat-editor-tile__eyebrow { font-size: 11.5px; font-weight: 800; color: #a5734c; text-transform: uppercase; letter-spacing: 1px; }
.cat-editor-tile__title { font-weight: 900; font-size: 16px; line-height: 1.35; margin-top: 8px; }
.cat-editor-tile__link { display: block; font-size: 13px; font-weight: 800; color: var(--terra); margin-top: 14px; }

.cat-more-wrap { display: flex; justify-content: center; margin-top: 24px; }

/* ---- карточка товара ---- */
.gc { padding: 16px; position: relative; }
/* L8: карточка товара не в наличии — мягко приглушаем (был мёртвый класс без стиля). */
.gc--oos { opacity: .75; }
/* z-index 3: выше фото (.gc__photo img z-2, которому z-2 нужен поверх подписи
   «фото скоро» z-1) — при равных z-2 картинка, будучи позже в DOM, накрывала бейдж. */
.gc__badges { position: absolute; top: 14px; left: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 3; }
.gc__badge-oos { background: #efe6d8; color: var(--ink-3); }
.gc__fav {
  position: absolute; top: 12px; right: 14px; font-size: 15px; color: #d9c6ac; z-index: 3;
  background: none; border: 0; cursor: pointer; line-height: 1;
}
/* ♡ активно (Stage 5, Task 2, favorites.js: .is-fav) — терракотовая заливка. */
.gc__fav.is-fav { color: var(--terra); }
.gc__photo-link { display: block; margin-bottom: 12px; }
.gc__photo { height: 150px; border-radius: var(--r-mini); overflow: hidden; position: relative; }
.gc__photo-caption { position: relative; z-index: 1; }
.gc__photo img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; z-index: 2;
}
.gc__rating { margin-bottom: 2px; }
.gc__title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-weight: 800; font-size: 14px; line-height: 1.3; margin: 4px 0 4px; min-height: 38px; color: inherit;
  overflow-wrap: anywhere;
}
.gc__title:hover { color: var(--terra); }
.gc__unit { font-size: 11.5px; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.gc__footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gc__prices { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.gc__add {
  background: var(--terra-bg); color: var(--terra); font-weight: 900; font-size: 17px;
  width: 34px; height: 34px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
}
.gc__add[disabled] { opacity: .4; cursor: not-allowed; }
.gc__stepper {
  display: flex; align-items: center; gap: 10px; background: var(--terra); color: #fff;
  border-radius: 12px; padding: 7px 12px; font-weight: 900; font-size: 13px;
}
.gc__stepper-btn { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0 2px; }
.gc__stepper-qty { min-width: 14px; text-align: center; }

/* ---- /catalogue: корневые категории ---- */
.cat-index { padding-top: 32px; padding-bottom: 48px; }
.cat-index__title { font-size: 32px; font-weight: 900; margin-bottom: 24px; }
.cat-index-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.cat-index-card { display: block; padding: 24px; }
.cat-index-card__title { font-weight: 800; font-size: 16px; }
.cat-index-card__count { font-size: 12.5px; font-weight: 700; color: var(--ink-3); margin-top: 6px; }
.pastel-cream { background: var(--pastel-cream); }
.pastel-peach { background: var(--pastel-peach); }
.pastel-lilac { background: var(--pastel-lilac); }
.pastel-rose { background: var(--pastel-rose); }
.pastel-blue { background: var(--pastel-blue); }

/* HIGH-3 (финальная ревизия этапа 2): одноколоночная раскладка до 1023px
   включительно — тот же аргумент, что и для .cart-layout/.gp-layout: на
   769–1023 сайдбар фильтров (280px) иначе стоял бы колонкой рядом с сеткой
   товаров. Остальная телефонная вёрстка каталога (2-колоночная сетка карточек,
   сворачивание фильтров в <details> и т.п.) остаётся на пороге 768px. */
@media (max-width: 1023px) {
  .cat-layout { grid-template-columns: 1fr; }
}

/* ---- мобильная версия ---- */
@media (max-width: 768px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .cat-sort-form { margin-left: 0; width: 100%; }
  .cat-topbar { padding-bottom: 16px; }

  /* Фильтры сворачиваются в <details> — без этого на 390px первая карточка
     товара уходит на несколько экранов вниз под всеми блоками сайдбара. */
  .cat-filters-collapse {
    background: #fff; border-radius: 20px; padding: 4px 18px;
  }
  .cat-filters-collapse > summary {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 0; font-weight: 900; font-size: 14px; color: var(--ink);
  }
  .cat-filters-collapse > summary::after { content: "▾"; color: var(--ink-3); font-weight: 700; }
  .cat-filters-collapse[open] > summary::after { content: "▴"; }
  .cat-filters-collapse > summary::marker { content: ""; }
  .cat-filters-collapse > .cat-filters-form { padding: 0 0 18px; }
}
