/* ============================================================================
 * Pershume — shop archive + brand taxonomy (MOBILE-FIRST).
 *
 * Enqueue ONLY on the product listing pages (is_shop() / is_product_category()
 * / is_product_taxonomy() / is_tax('product_brand')). Loads AFTER style.css and
 * woocommerce.css and OWNS the whole archive + brand layout, so it reuses the
 * :root tokens from style.css (--accent / --ink / --line / --gut / --radius …).
 *
 * Authored mobile-first: the base rules target a ~390px phone (80% of traffic);
 * min-width media queries scale up to tablet (2-col) and desktop (3-col, sticky
 * sidebar). Every grid uses minmax(0,1fr) so cards never force overflow.
 * Class names match the markup emitted by inc/template-functions.php so the
 * existing drawer / collapse / chip JS in theme.js keeps working untouched.
 * ========================================================================== */

/* ---------------------------------------------------------------------------
 * Page header (shop / category / tag) + brand hero
 * ------------------------------------------------------------------------- */
.shop-head {
  position: relative;
  padding-block: clamp(24px, 6vw, 44px) clamp(18px, 4vw, 30px);
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(120% 130% at 100% 0%, rgba(107, 107, 179, .1) 0%, rgba(107, 107, 179, 0) 56%),
    var(--paper);
}
.shop-head .label {
  margin-bottom: 11px;
}
.shop-head-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}
.shop-head h1 {
  font-size: clamp(25px, 7vw, 42px);
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.2;
  color: var(--ink);
}
.shop-head .sh-sub {
  margin-top: 8px;
  max-width: 52ch;
  font-size: 13px;
  line-height: 1.9;
  font-weight: 300;
  color: var(--ink-soft);
}
.shop-head .sh-desc {
  margin-top: 8px;
  max-width: 64ch;
  font-size: 13px;
  line-height: 1.95;
  font-weight: 300;
  color: var(--ink-soft);
}
.shop-head .sh-desc p {
  margin: 0 0 .5em;
}
.shop-head .sh-desc p:last-child {
  margin-bottom: 0;
}

/* result-count pill */
.shop-head .res-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 8px 15px;
  border-radius: 30px;
  background: rgba(107, 107, 179, .08);
  border: 1px solid rgba(107, 107, 179, .2);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-deep);
  white-space: nowrap;
}
.shop-head .res-count b {
  font-weight: 800;
  color: var(--accent-deep);
}

/* brand hero */
.brand-head {
  padding-block: clamp(26px, 6vw, 52px) clamp(20px, 4vw, 32px);
  background:
    radial-gradient(130% 120% at 0% 0%, rgba(74, 74, 178, .12) 0%, rgba(74, 74, 178, 0) 58%),
    radial-gradient(120% 120% at 100% 0%, rgba(107, 107, 179, .08) 0%, rgba(107, 107, 179, 0) 55%),
    var(--paper);
}
.brand-head .brand-head-main {
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand-head .brand-logo {
  flex: none;
}
.brand-head .brand-logo img {
  display: block;
  max-height: 56px;
  width: auto;
  padding: 9px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(74, 74, 178, .08);
}

/* ---------------------------------------------------------------------------
 * Layout shell
 * ------------------------------------------------------------------------- */
.shop {
  padding-block: clamp(26px, 6vw, 64px) clamp(44px, 8vw, 90px);
}
.shop-grid {
  display: block;
  align-items: start;
}
.shop-main {
  min-width: 0;
}

/* ---------------------------------------------------------------------------
 * Mobile filter trigger + sort toolbar
 * ------------------------------------------------------------------------- */
.filter-bar-m {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 20px;
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  border-radius: 30px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background .3s, border-color .3s;
}
.filter-btn:hover,
.filter-btn:focus-visible {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  outline: none;
}
.filter-btn svg {
  width: 17px;
  height: 17px;
}
.filter-btn .filter-btn-n {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  margin-inline-start: 2px;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.tb-count {
  font-size: 12.5px;
  color: var(--ink-soft);
  font-weight: 300;
}
.tb-count b {
  color: var(--ink);
  font-weight: 700;
}
.tb-sort {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.tb-sort .ts-lbl {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}
.tb-sort .ts-lbl svg {
  width: 15px;
  height: 15px;
  color: var(--accent);
}
.sort-pills {
  display: inline-flex;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: #fff;
}
.sort-pills::-webkit-scrollbar {
  display: none;
}
.sort-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  cursor: pointer;
  border-inline-start: 1px solid var(--line);
  transition: color .25s, background .25s;
}
.sort-pill:first-child {
  border-inline-start: 0;
}
.sort-pill:hover {
  color: var(--ink);
}
.sort-pill.on {
  background: var(--accent);
  color: #fff;
}

/* ---------------------------------------------------------------------------
 * Sidebar — off-canvas drawer on phones, sticky rail on desktop
 * ------------------------------------------------------------------------- */
.sb-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(28, 27, 36, .5);
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s, visibility .35s;
}
.sb-overlay.on {
  opacity: 1;
  visibility: visible;
}

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-end: 0;
  z-index: 91;
  width: min(360px, 90vw);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  box-shadow: -18px 0 44px rgba(74, 74, 178, .14);
  transform: translateX(100%);
  transition: transform .4s cubic-bezier(.2, .7, .3, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px var(--gut) 0;
}
.sidebar.open {
  transform: translateX(0);
}

.sb-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 14px;
  margin-bottom: 4px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.sb-head .sbh-t {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.sb-head .sbh-t svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}
.sb-clear {
  margin-inline-start: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-deep);
  transition: opacity .25s;
}
.sb-clear:hover {
  opacity: .65;
}
.sb-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 17px;
  cursor: pointer;
  transition: border-color .25s, color .25s;
}
.sb-close:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}

/* collapsible groups */
.fgroup {
  border-bottom: 1px solid var(--line-soft);
}
.fg-head {
  width: 100%;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px;
  background: transparent;
  border: 0;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  text-align: start;
  cursor: pointer;
}
.fg-head .fg-ar {
  font-size: 12px;
  color: var(--ink-soft);
  transition: transform .35s cubic-bezier(.2, .7, .3, 1);
}
.fgroup.collapsed .fg-ar {
  transform: rotate(-90deg);
}
.fg-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 2px 16px;
}
.fgroup.collapsed .fg-body {
  display: none;
}

/* checkbox rows (brand / concentration) */
.crow {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 2px 0;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  transition: color .25s;
}
.crow:hover {
  color: var(--ink);
}
.crow input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.crow .box {
  width: 20px;
  height: 20px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  transition: background .2s, border-color .2s;
}
.crow input:checked + .box {
  background: var(--accent);
  border-color: var(--accent);
}
.crow input:checked + .box::after {
  content: "✓";
}
.crow input:focus-visible + .box {
  box-shadow: 0 0 0 3px rgba(107, 107, 179, .25);
}
.crow .ct {
  flex: 1;
  min-width: 0;
}
.crow input:checked ~ .ct {
  color: var(--ink);
  font-weight: 600;
}
.crow .cn {
  flex: none;
  font-family: "Segoe UI", sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: #9a9aa6;
}

/* chips (notes / volume) */
.fchips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 6px;
}
.fchip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 30px;
  line-height: 1.3;
  cursor: pointer;
  transition: color .25s, border-color .25s, background .25s;
}
.fchip:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}
.fchip.on {
  background: rgba(107, 107, 179, .09);
  border-color: var(--accent);
  color: var(--accent-deep);
}
.fchip .fc-ic {
  margin-inline-end: 5px;
  font-size: 13px;
  line-height: 1;
}

/* price range */
.ps-vals {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 0 6px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.ps-vals label {
  flex: 1 1 120px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.ps-vals input {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 44px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink);
  transition: border-color .25s, box-shadow .25s;
}
.ps-vals input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(107, 107, 179, .14);
  outline: none;
}
.ps-vals input::-webkit-outer-spin-button,
.ps-vals input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* apply button — sticks to the drawer base on phones */
.sb-apply {
  position: sticky;
  bottom: 0;
  z-index: 2;
  width: 100%;
  margin-top: 14px;
  padding: 15px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 30px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 -10px 22px rgba(255, 255, 255, .85);
  transition: background .3s, border-color .3s;
}
.sb-apply:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

/* ---------------------------------------------------------------------------
 * Product grid — 1 col (phone) → 2 col (tablet) → 3 col (desktop)
 * ------------------------------------------------------------------------- */
.shop-main .grid,
.pershume-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

/* ---------------------------------------------------------------------------
 * Empty state
 * ------------------------------------------------------------------------- */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: clamp(48px, 12vw, 80px) 20px;
  color: var(--ink-soft);
}
.empty .e-emoji {
  display: block;
  margin-bottom: 14px;
  font-size: 42px;
}
.empty h3 {
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}
.empty p {
  font-size: 13px;
  font-weight: 300;
  line-height: 1.9;
  max-width: 36ch;
  margin-inline: auto;
}

/* ---------------------------------------------------------------------------
 * Pagination (Persian numerals are produced by pershume_fa_pagination())
 * ------------------------------------------------------------------------- */
.woocommerce-pagination {
  margin-top: clamp(30px, 6vw, 54px);
}
.woocommerce-pagination ul {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
  border: 0;
}
.woocommerce-pagination ul li {
  margin: 0;
  border: 0;
}
.woocommerce-pagination ul li a,
.woocommerce-pagination ul li span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: border-color .25s, color .25s, background .25s;
}
.woocommerce-pagination ul li a:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}
.woocommerce-pagination ul li span.current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ===========================================================================
 * ≥ 600px — header row, inline toolbar
 * ========================================================================= */
@media (min-width: 600px) {
  .shop-head-row {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
  }
  .shop-head .res-count {
    margin-top: 0;
    align-self: flex-end;
  }
  .toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .tb-sort {
    flex-wrap: wrap;
  }
}

/* ===========================================================================
 * ≥ 768px — widen brand logo
 * ========================================================================= */
@media (min-width: 768px) {
  .brand-head .brand-logo img {
    max-height: 64px;
  }
}

/* ===========================================================================
 * ≥ 901px — static sidebar rail, no drawer / overlay; 2-col product grid
 * ========================================================================= */
@media (min-width: 901px) {
  .shop-grid {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    gap: clamp(24px, 3vw, 44px);
  }
  .filter-bar-m {
    display: none;
  }
  .sb-overlay {
    display: none;
  }
  .sidebar {
    position: sticky;
    top: 96px;
    inset-inline-end: auto;
    bottom: auto;
    z-index: auto;
    width: auto;
    max-height: calc(100vh - 116px);
    padding: 0;
    background: transparent;
    box-shadow: none;
    transform: none;
    overflow-y: auto;
    overscroll-behavior: auto;
  }
  .sb-close {
    display: none;
  }
  .sb-head {
    padding-top: 0;
  }
  .sb-apply {
    position: static;
    box-shadow: none;
  }
  .shop-main .grid,
  .pershume-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(14px, 1.6vw, 22px);
  }
}

/* ===========================================================================
 * ≥ 1081px — 3-col product grid (matches the homepage .grid)
 * ========================================================================= */
@media (min-width: 1081px) {
  .shop-main .grid,
  .pershume-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* search-results: non-product hits render as a simple text card in the grid */
.search-post {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  text-decoration: none;
  color: inherit;
  transition: border-color .3s, box-shadow .3s, transform .3s;
}
.search-post:hover {
  border-color: rgba(107, 107, 179, .35);
  box-shadow: 0 16px 34px -20px rgba(40, 36, 80, .3);
  transform: translateY(-4px);
}
.search-post h3 { font-size: 16px; font-weight: 700; line-height: 1.5; color: var(--ink); }
.search-post p { font-size: 13px; font-weight: 300; line-height: 1.9; color: var(--ink-soft); }
.search-post .sp-more { margin-top: auto; font-size: 12.5px; font-weight: 600; color: var(--accent-deep); }
