/* Section page — filters sidebar + product grid with toolbar/pagination */

.xf-secpage {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  align-items: flex-start;
}

/* ─── Filters sidebar ─────────────────────────────────────── */
/* Sticky column with internal scroll + pinned actions bar at the bottom —
   the classic long-facet pattern so "Применить" is always reachable even
   in sections with 40+ smart-filter groups. Mobile falls back to a plain
   static column (see the @media block below). */
.xf-filters {
  position: sticky;
  top: 110px;
  max-height: calc(100vh - 130px);
  display: flex;
  flex-direction: column;
  gap: 0;
}
.xf-filters__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex: 0 0 auto;
}
.xf-filters__body {
  flex: 1 1 auto;
  overflow-y: auto;
  /* Negative margin + matching padding so the scrollbar sits in a gutter
     and doesn't clip the group contents. */
  padding-right: 10px;
  margin-right: -10px;
  min-height: 0;
}
.xf-filters__actions {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  padding-top: 14px;
  margin-top: 4px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg);
  position: relative;
}
/* Fade the last bit of scroll content into the actions bar so it's clear
   there's more above than what fits. */
.xf-filters__actions::before {
  content: "";
  position: absolute;
  top: -20px;
  left: 0;
  right: 10px;
  height: 20px;
  pointer-events: none;
  background: linear-gradient(to top, var(--bg), rgba(255,255,255,0));
}
.xf-filters__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.xf-filters__reset {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-3);
  transition: color .15s;
}
@media (hover: hover) {
  .xf-filters__reset:hover { color: var(--text-2); }
}

.xf-filter-group {
  border-top: 1px solid var(--line-soft);
  padding: 14px 0;
}
.xf-filter-group:first-of-type { border-top: 0; padding-top: 14px; }
/* Native <details> summary as the group toggle — chevron from arrow-down. */
.xf-filter-group > summary {
  list-style: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0;
  user-select: none;
}
.xf-filter-group > summary::-webkit-details-marker { display: none; }
.xf-filter-group > summary::after {
  content: "";
  width: 14px;
  height: 14px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239a98a6' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>") center/contain no-repeat;
  transform: rotate(-90deg);
  transition: transform .18s ease;
  flex: 0 0 14px;
}
.xf-filter-group[open] > summary::after { transform: rotate(0); }
.xf-filter-group[open] > summary { margin-bottom: 12px; }
/* Legacy non-<details> group title (still used by a couple of callers) */
.xf-filter-group > .xf-filter-group__title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 12px;
}
.xf-filter-group__options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}
.xf-filter-group__more {
  margin-top: 4px;
  padding-top: 4px;
}
.xf-filter-group__more > summary {
  list-style: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 6px 0;
}
.xf-filter-group__more > summary::-webkit-details-marker { display: none; }
@media (hover: hover) {
  .xf-filter-group__more > summary:hover { color: var(--text-2); }
}
.xf-filter-group__more[open] > summary { color: var(--text-2); }
.xf-filter-group__more .xf-check + .xf-check { margin-top: 10px; }

/* Stock toggle — compact, sits just under the header (no group chrome). */
.xf-check--toggle {
  padding: 10px 0 6px;
}

/* Price range inputs */
.xf-price-range {
  display: flex;
  gap: 8px;
}
.xf-price-range__input {
  flex: 1;
  position: relative;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  transition: border-color .15s;
}
.xf-price-range__input:focus-within { border-color: var(--accent-line); }
.xf-price-range__input > span {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-3);
  margin-bottom: 2px;
}
.xf-price-range__input input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  padding: 0;
}
/* Hide number spinners */
.xf-price-range__input input::-webkit-outer-spin-button,
.xf-price-range__input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.xf-price-range__input input[type=number] { appearance: textfield; -moz-appearance: textfield; }

/* Checkbox facet */
.xf-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  user-select: none;
}
.xf-check input { position: absolute; opacity: 0; pointer-events: none; }
.xf-check__box {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--line);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, background .15s;
}
.xf-check__box::after {
  content: "";
  width: 9px;
  height: 9px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12l5 5L20 7'/></svg>") center/contain no-repeat;
  opacity: 0;
  transition: opacity .12s;
}
.xf-check input:checked + .xf-check__box {
  border-color: var(--accent);
  background: var(--accent);
}
.xf-check input:checked + .xf-check__box::after { opacity: 1; }
.xf-check input:checked ~ .xf-check__label { color: var(--text); }
.xf-check__label { flex: 1; }
.xf-check__count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
}

.xf-filters__apply {
  flex: 1;
  margin-top: 0;
}

/* ─── Toolbar ─────────────────────────────────────────────── */
.xf-secpage__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.xf-secpage__result {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-2);
}
.xf-secpage__tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.xf-secpage__sort-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-3);
}
.xf-select {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 8px 34px 8px 12px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239a98a6' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  transition: border-color .15s;
}
@media (hover: hover) {
  .xf-select:hover { border-color: var(--line); }
}
.xf-select:focus { outline: 0; border-color: var(--accent-line); }

/* ─── Active filter chips ─────────────────────────────────── */
.xf-secpage__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.xf-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 12px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-2);
  transition: border-color .15s, color .15s, background .15s;
}
@media (hover: hover) {
  .xf-chip:hover {
  border-color: var(--accent-line);
  color: var(--text);
  background: var(--surface-2);
}
}
.xf-chip__x {
  display: inline-flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-3);
}
@media (hover: hover) {
  .xf-chip:hover .xf-chip__x { color: var(--text-2); }
}

/* ─── Product grid inside section (3-col due to sidebar) ─── */
.xf-secpage__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.xf-secpage__grid .xf-product-card__title { min-height: 52px; }

.xf-secpage__empty {
  padding: 40px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line-soft);
  border-radius: 14px;
  color: var(--text-2);
  font-size: 14px;
}
.xf-secpage__empty a { color: var(--accent-2); margin-left: 4px; }

/* ─── Pagination ──────────────────────────────────────────── */
.xf-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line-soft);
  gap: 16px;
  flex-wrap: wrap;
}
.xf-pagination__meta {
  font-size: 12.5px;
  color: var(--text-3);
}
.xf-pagination__pages {
  display: flex;
  gap: 4px;
  align-items: center;
}
.xf-pagination__page {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
}
@media (hover: hover) {
  .xf-pagination__page:hover { border-color: var(--line); color: var(--text); }
}
.xf-pagination__page.is-active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.xf-pagination__gap {
  color: var(--text-3);
  font-family: var(--font-mono);
  padding: 0 4px;
}

/* ─── Filter sheet — FAB + close + overlay (mobile-only controls) ───
   DOM is rendered unconditionally in section.php leaf branch; display is
   CSS-gated so desktop users never see them and assistive trees stay
   clean. Mobile styles live in the @media block below. */
.xf-filter-fab,
.xf-filter-sheet__overlay,
.xf-filter-sheet__head { display: none; }

/* ─── Mobile (≤ 767px) ──────────────────────────────────────
   Sidebar → bottom-sheet slide-up; product grid 2-col;
   toolbar + pagination компактнее; FAB всегда видим, открывает sheet. */
@media (max-width: 767px) {
  .xf-secpage {
    grid-template-columns: 1fr;
    gap: 12px;
    /* FAB hover + iOS home-indicator safe-area чтобы pagination не
       прятался под FAB'ом и под системной плашкой iPhone. */
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }

  /* Filters aside → fixed bottom sheet. Hidden by default, body class flips it in. */
  .xf-secpage__filters {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 85vh;
    max-height: 85vh;
    z-index: 80;
    background: var(--bg);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -18px 40px -12px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* iOS home-indicator safe-area — внутренний отступ снизу, чтобы
       кнопка «Применить» не пряталась под системной полосой. */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  body.xf-filter-open .xf-secpage__filters { transform: translateY(0); }

  /* Sheet head — title + close, pinned top. */
  .xf-filter-sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-soft);
    flex: 0 0 auto;
  }
  .xf-filter-sheet__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .xf-filter-sheet__close {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
  }

  /* Form inside sheet — full-height flex column, body scrolls, actions pinned. */
  .xf-filters {
    position: static;
    max-height: none;
    height: 100%;
    flex: 1 1 auto;
    padding: 14px 18px 16px;
    min-height: 0;
  }
  .xf-filters__head { display: none; }
  .xf-filters__body {
    overflow-y: auto;
    padding-right: 6px;
    margin-right: -6px;
  }
  .xf-filters__actions {
    padding-top: 12px;
    margin-top: 10px;
    background: var(--bg);
  }
  .xf-filters__actions::before {
    top: -16px;
    height: 16px;
    right: 0;
  }

  /* Overlay — sits below sheet, above content. */
  .xf-filter-sheet__overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 79;
    background: oklch(0 0 0 / 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
  }
  body.xf-filter-open .xf-filter-sheet__overlay {
    opacity: 1;
    pointer-events: auto;
  }
  body.xf-filter-open { overflow: hidden; }

  /* FAB — always-visible pill, bottom-center, above content padding.
     safe-area offset чтобы FAB не уезжал под iOS home-indicator. */
  .xf-filter-fab {
    display: inline-flex;
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 70;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 999px;
    font-family: var(--font-sans);
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 14px 30px -10px oklch(0.45 0.22 270 / 0.55);
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
  }
  .xf-filter-fab:active { transform: translateX(-50%) scale(0.97); }
  .xf-filter-fab svg { width: 16px; height: 16px; }
  .xf-filter-fab__badge {
    font-family: var(--font-mono);
    font-size: 11.5px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0;
  }
  /* Hide badge when empty (when N=0 no element is rendered, so this is a noop) */
  .xf-filter-fab__badge:empty { display: none; }

  /* Product grid — 2 col. Keep .xf-product-card tweaks from home.css. */
  .xf-secpage__grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .xf-secpage__grid .xf-product-card__title { min-height: 58px; }

  /* Page head / breadcrumbs */
  .xf-catpage__head { margin-bottom: 4px; }
  .xf-catpage__title { font-size: 26px; letter-spacing: -0.8px; }
  .xf-catpage__title-row { flex-wrap: wrap; gap: 8px; }
  /* Inline-flow on mobile + slash via ::before, не как отдельный sibling.
     Когда слеш — отдельный flex/inline child, browser breaks между «/» и
     следующим элементом, и слеш висит сиротой в конце строки. Решение
     keeps existing markup (<span>/</span> across personal/order/landing),
     hides separator-spans on mobile (even children — see crumbs index
     pattern: a, span, a, span, [a|span]) и добавляет «/» через ::before
     на нечётных не-первых детях — слеш становится частью inline-run'а
     анкора и переносится с ним вместе. */
  .xf-crumbs { font-size: 12px; display: block; line-height: 1.6; }
  .xf-crumbs > a, .xf-crumbs > span { display: inline; }
  .xf-crumbs > *:nth-child(even) { display: none; }
  .xf-crumbs > *:nth-child(odd):not(:first-child)::before {
    content: "/";
    margin-right: 6px;
    color: var(--text-3);
  }

  /* Toolbar: result сверху, sort full-width снизу. */
  .xf-secpage__toolbar { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 14px; }
  .xf-secpage__tools { justify-content: space-between; gap: 10px; }
  .xf-select { flex: 1; padding: 10px 34px 10px 12px; font-size: 13px; }
  .xf-secpage__sort-label { flex: 0 0 auto; }

  /* Chips row — wrap как есть, просто компактнее */
  .xf-secpage__chips { gap: 6px; margin-bottom: 10px; }
  .xf-chip { padding: 5px 8px 5px 10px; font-size: 12px; }

  /* Pagination — компактнее */
  .xf-pagination {
    flex-direction: column;
    align-items: stretch;
    margin-top: 22px;
    padding-top: 18px;
    gap: 10px;
  }
  .xf-pagination__meta { text-align: center; font-size: 11.5px; }
  .xf-pagination__pages { justify-content: center; flex-wrap: wrap; }
  .xf-pagination__page { min-width: 44px; height: 44px; padding: 0 10px; font-size: 13.5px; }
  .xf-check { min-height: 44px; }
}
