/* Каталог: подборки сверху, слева панель фильтров, справа результаты.
   На телефоне панель выезжает снизу шторкой. */
.catalog { padding-top: clamp(16px, 3vw, 32px); display: grid; gap: 26px; }
.catalog__head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px; }
.catalog__title { display: grid; gap: 4px; }
.catalog__total { color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.search { display: flex; align-items: center; gap: 10px; width: min(360px, 100%); height: 48px; padding: 0 16px; border-radius: var(--r-sm); background: var(--surface); color: var(--faint); }
.search:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.search svg { width: 18px; height: 18px; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); }
.search input::placeholder { color: var(--faint); }

/* ── подборки ── */
.collections { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.collection {
  position: relative; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px;
  min-width: 0; padding: 14px 14px 14px 12px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); text-align: left; cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t) var(--ease-out);
}
.collection:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.collection:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.collection.is-active { background: var(--accent-soft); border-color: var(--accent); }
.collection__art { width: 44px; height: 44px; object-fit: contain; transition: transform var(--t) var(--ease-out); }
.collection:hover .collection__art { transform: rotate(-8deg) scale(1.08); }
.collection__text { display: grid; gap: 2px; min-width: 0; }
.collection__text strong { font-weight: 600; font-size: var(--fs-sm); }
.collection__text small { color: var(--muted); font-size: var(--fs-xs); line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collection__count { position: absolute; top: 8px; right: 10px; color: var(--faint); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.collection.is-active .collection__count { color: var(--accent); }

/* ── раскладка ── */
.catalog__layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: clamp(20px, 3vw, 40px); align-items: start; }

/* ── панель фильтров ── */
.filters { position: sticky; top: calc(var(--header-h) + 16px); display: grid; gap: 6px; max-height: calc(100svh - var(--header-h) - 32px); overflow-y: auto; scrollbar-width: thin; padding-right: 4px; }
.filters__head { display: none; }
.filters__foot { display: flex; gap: 8px; padding-top: 8px; }
.filters__foot [data-apply] { display: none; }
.fgroup { margin: 0; padding: 14px 0; border: 0; border-top: 1px solid var(--line); min-width: 0; }
.fgroup:first-child { border-top: 0; padding-top: 0; }
.fgroup legend { padding: 0; margin-bottom: 10px; color: var(--faint); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.fgroup__list { display: grid; gap: 2px; }

.opt {
  display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-xs);
  background: none; color: var(--muted); text-align: left; cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
}
.opt:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.opt:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.opt:disabled { opacity: 0.35; cursor: default; }
.opt[aria-pressed="true"] { color: var(--text); }
.opt__mark { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--line-strong); color: var(--accent-ink); transition: background var(--t-fast), border-color var(--t-fast); }
.opt--radio .opt__mark { border-radius: 50%; }
.opt[aria-pressed="true"] .opt__mark { background: var(--accent); border-color: var(--accent); }
.opt__mark svg { width: 12px; height: 12px; stroke-width: 2.6; }
.opt--radio[aria-pressed="true"] .opt__mark svg { display: none; }
.opt--radio[aria-pressed="true"] .opt__mark::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-ink); }
.opt__count { color: var(--faint); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: none; color: var(--muted); font-size: var(--fs-sm); cursor: pointer; font-variant-numeric: tabular-nums;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.pill:hover:not(:disabled) { color: var(--text); border-color: var(--text); }
.pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill:disabled { opacity: 0.35; cursor: default; }
.pill[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }

/* ── результаты ── */
.results { display: grid; gap: 20px; min-width: 0; }
.results__bar { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.results__filters-btn { display: none; gap: 8px; }
.results__filters-btn svg { width: 18px; height: 18px; }
.results__badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; }
.results__active { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.active-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px 6px 12px; border-radius: 999px;
  border: 0; background: var(--surface-2); color: var(--text); font-size: var(--fs-sm); cursor: pointer;
}
.active-chip svg { width: 14px; height: 14px; color: var(--muted); }
.active-chip:hover svg { color: var(--text); }
.active-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sort { margin-left: auto; flex: none; }
.sort select {
  height: 40px; padding: 0 36px 0 14px; border-radius: var(--r-xs); border: 1px solid var(--line-strong);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa3a0' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
  color: var(--text); font-size: var(--fs-sm); appearance: none; cursor: pointer;
}
.sort select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tiles--catalog { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.catalog__empty { display: grid; justify-items: center; gap: 12px; padding: 48px 0; color: var(--muted); text-align: center; }
.catalog__empty img { width: 88px; height: 88px; opacity: 0.9; }
.filters-scrim { display: none; }

@media (max-width: 1180px) {
  .collections { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tiles--catalog { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .catalog__layout { grid-template-columns: minmax(0, 1fr); }
  .collections {
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
    margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); padding-block: 2px;
  }
  .collections::-webkit-scrollbar { display: none; }
  .collection { flex: 0 0 min(220px, 64vw); scroll-snap-align: start; }
  .results__filters-btn { display: inline-flex; }
  .results__bar { flex-wrap: wrap; }
  .results__active { order: 3; flex-basis: 100%; }
  .results__active:empty { display: none; }

  /* шторка фильтров */
  .filters {
    position: fixed; z-index: 120; left: 0; right: 0; bottom: 0; top: auto;
    max-height: min(82svh, 720px); padding: 0; gap: 0; overflow: hidden;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: var(--bg-2); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow);
    transform: translateY(105%); visibility: hidden;
    transition: transform var(--t) var(--ease-out), visibility 0s linear var(--t);
  }
  .filters.is-open { transform: none; visibility: visible; transition: transform var(--t) var(--ease-out); }
  .filters__head { display: flex; align-items: center; justify-content: space-between; padding: 18px var(--gutter) 10px; }
  .filters__head h2 { font-size: var(--fs-lg); }
  .filters__close { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--surface); color: var(--text); cursor: pointer; }
  .filters__close svg { width: 18px; height: 18px; }
  .filters__body { overflow-y: auto; padding: 0 var(--gutter) 8px; overscroll-behavior: contain; }
  .filters__foot { padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
  .filters__foot .btn { flex: 1; }
  .filters__foot [data-apply] { display: inline-flex; }
  .filters-scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 119; background: rgba(0, 0, 0, 0.55); animation: fade-in var(--t) both; }
  html.filters-open { overflow: hidden; }
}

@media (max-width: 760px) {
  .search { width: 100%; }
  .tiles--catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .collection, .collection__art, .filters { transition: none; }
}
