/* Каталог: крошки, вкладки разделов, фильтры, панель сортировки. Основа в style.css */

/* ---------- Крошки и заголовок ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; font-size: 14px; line-height: 20px; color: var(--ink-2); }
.crumbs a:hover { color: var(--navy); }
.crumbs [aria-current] { color: var(--navy); }
.cat-head { margin-top: 14px; }
.cat-head .h1 { font-size: clamp(30px, 3vw, 40px); }

/* ---------- Вкладки разделов ---------- */
.cat-tabs { display: flex; gap: 28px; margin-top: 20px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tabs button {
  padding: 12px 0;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
/* Слово «товары» в первой вкладке: на телефоне скрыто, чтобы три вкладки встали в ширину экрана */
.cat-tabs button i { font-style: normal; }
/* Ряд шире экрана (совсем узкий телефон): правый край тает, это признак прокрутки. Класс ставит catalog.js */
.cat-tabs.is-cut { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }
.cat-tabs button span { margin-left: 6px; font-size: 14px; font-weight: 400; font-variant-numeric: tabular-nums; }
.cat-tabs button:hover { color: var(--navy); }
.cat-tabs button.is-active { color: var(--navy); border-color: var(--green); }

/* ---------- Раскладка: фильтры и сетка ---------- */
.cat-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 40px; margin-top: 32px; align-items: start; }

/* ---------- Фильтры ---------- */
/* Широкий экран: колонка липнет под шапку (её высоту в --head-h выставляет main.js) и не бывает выше окна.
   Группы прокручиваются внутри колонки: поля цены достижимы на любой высоте окна */
@media (min-width: 961px) {
  .filters { position: sticky; top: calc(var(--head-h, 0px) + 24px); display: flex; flex-direction: column; max-height: calc(100vh - var(--head-h, 0px) - 48px); }
  /* Поля по бокам и обратные отступы: рамка фокуса у чекбокса и тонкая полоса прокрутки не режутся краем.
     Нижнее поле под растворение: в конце списка тает пустое место, а не поля цены */
  .filters-scroll {
    min-height: 0;
    margin: 0 -12px 0 -4px;
    padding: 0 12px 28px 4px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(22, 41, 84, 0.22) transparent;
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  }
}
.fgroup { padding: 20px 0; border-top: 1px solid var(--line); }
.fgroup:first-child { padding-top: 0; border-top: 0; }
.fgroup[hidden], .fopt[hidden] { display: none; }
.fgroup h2 { margin-bottom: 10px; font-size: 15px; line-height: 22px; font-weight: 700; }
.fopt { position: relative; display: flex; align-items: center; gap: 12px; padding: 5px 0; font-size: 15px; line-height: 22px; cursor: pointer; }
.fopt input { position: absolute; left: 0; top: 7px; width: 18px; height: 18px; margin: 0; opacity: 0; cursor: pointer; }
.fopt .box {
  flex: none;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--white);
  box-shadow: inset 0 0 0 1.5px rgba(22, 41, 84, 0.6);
  transition: background-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.fopt .box svg { width: 12px; height: 12px; fill: none; stroke: var(--white); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.fopt:hover .box { box-shadow: inset 0 0 0 1.5px var(--navy); }
.fopt input:checked + .box { background: var(--navy); box-shadow: none; }
.fopt input:checked + .box svg { opacity: 1; }
.fopt input:focus-visible + .box { outline: 2px solid var(--navy); outline-offset: 2px; }
.fopt .n { margin-left: auto; font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
/* Пункт без товаров при текущем выборе: приглушён и не нажимается */
.fopt.is-off { color: rgba(22, 41, 84, 0.4); cursor: default; }
.fopt.is-off input { cursor: default; }
.fopt.is-off .n { color: inherit; }
.fopt.is-off .box, .fopt.is-off:hover .box { box-shadow: inset 0 0 0 1.5px rgba(22, 41, 84, 0.22); }
.fprice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fprice input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-s);
  background: var(--paper);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.2s var(--ease);
}
.fprice input::placeholder { color: var(--ink-2); }
.fprice input:hover, .fprice input:focus { background: var(--mint); outline: 0; }
.fprice-note { margin-top: 8px; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.filters-foot, .filters-apply { display: none; }

/* ---------- Панель над сеткой ---------- */
.cat-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; }
.cat-found { font-size: 16px; line-height: 24px; font-weight: 500; }
.sort { display: flex; align-items: center; gap: 12px; font-size: 15px; line-height: 22px; color: var(--ink-2); }
.sort select {
  appearance: none;
  -webkit-appearance: none;
  height: 44px;
  padding: 0 40px 0 14px;
  border: 0;
  border-radius: var(--r-s);
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23162954' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 12px center / 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--navy);
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}
.sort select:hover { background-color: var(--mint); }
.filters-toggle { display: none; }
.cat-picked { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-top: 12px; font-size: 15px; line-height: 22px; color: var(--ink-2); }
.cat-picked b { font-weight: 500; color: var(--navy); }
.cat-picked[hidden] { display: none; }
.cat-grid { margin-top: 24px; }
/* Цена и кнопка прижаты к низу, чтобы ряды карточек держали одну линию */
.cat-grid .card-buy { margin-top: auto; padding-top: 14px; }
.cat-grid[hidden] { display: none; }

/* ---------- Пустой результат ---------- */
.cat-empty { margin-top: 24px; padding: 48px 40px; border-radius: var(--r-l); background: var(--paper); }
.cat-empty p { margin-top: 8px; max-width: 46ch; color: var(--ink-2); }
.cat-empty .btn { margin-top: 24px; }
.cat-empty[hidden] { display: none; }

/* ---------- О разделе ---------- */
.cat-about { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 40px; margin-top: 72px; padding-top: 32px; border-top: 1px solid var(--line); }
.cat-about-text { max-width: 68ch; }
.cat-about-text p + p { margin-top: 12px; }
.cat-about-text .small { color: var(--ink-2); }

/* ---------- Планшет: фильтры уходят за кнопку ---------- */
@media (max-width: 960px) {
  .cat-layout { grid-template-columns: minmax(0, 1fr); gap: 0; margin-top: 24px; }
  /* Панель фильтров раскрывается под строкой с кнопкой: строка, выбранное, панель, сетка */
  .cat-layout > div { display: contents; }
  .cat-bar { order: 1; }
  .cat-picked { order: 2; }
  .filters { order: 3; display: none; margin-top: 16px; padding: 20px; border-radius: var(--r-l); background: var(--paper); }
  .filters.is-open { display: block; }
  .cat-grid, .cat-empty { order: 4; }
  /* Кнопка «Показать N товаров» держится у нижнего края экрана, пока панель в кадре; фон берёт у панели */
  .filters-foot { display: block; position: sticky; bottom: 0; margin-bottom: -12px; padding: 12px 0; background: inherit; }
  .filters .fprice input { background: var(--white); }
  .filters .fopt .box { background: var(--white); }
  .filters .fopt input:checked + .box { background: var(--navy); }
  .filters-apply { display: flex; width: 100%; }
  .filters-toggle { display: inline-flex; background: var(--paper); color: var(--navy); height: 44px; padding: 0 16px; font-size: 15px; }
  .filters-toggle:hover, .filters-toggle[aria-expanded="true"] { background: var(--mint); }
  .filters-toggle .cnt { width: 20px; height: 20px; border-radius: 50%; background: var(--navy); color: var(--white); font-size: 13px; line-height: 20px; font-weight: 700; text-align: center; }
  .filters-toggle .cnt[hidden] { display: none; }
  .cat-bar { flex-wrap: wrap; }
  .cat-found { order: -1; flex: 1 0 100%; }
  .cat-about { grid-template-columns: 1fr; gap: 12px; margin-top: 56px; }
}

/* ---------- Телефон ---------- */
@media (max-width: 720px) {
  .crumbs { margin-top: 16px; }
  .cat-tabs { gap: 18px; }
  .cat-tabs button { font-size: 15px; }
  .cat-tabs button i { display: none; }
  .sort > span { display: none; }
  .sort { flex: 1; min-width: 0; }
  .sort select { width: 100%; padding: 0 34px 0 12px; background-position: right 8px center; font-size: 14px; }
  .cat-empty { padding: 32px 20px; }
}

/* ---------- Узкий телефон: вкладки на размер меньше, чтобы три встали в ряд ---------- */
@media (max-width: 400px) {
  .cat-tabs button { font-size: 14px; }
}
