/* ==========================================================================
   Razima — pages/shop.css
   فهرست فروشگاه، دسته، برند و جستجو (PLAN ۶.۴): سربرگ به رنگ خط، نوار فیلتر (دسکتاپ چسبان بالای شبکه، موبایل
   برگه‌ی پایین با قرص شناور)، شبکه‌ی ۲/۳/۴ ستونه، متن دسته. مقایسه هم این‌جاست.
   ========================================================================== */

/* ---------- سربرگ ---------- */
.lhead { background: var(--tint); border-bottom: 1px solid var(--line); }
.lhead__inner { display: grid; gap: 12px; padding-block: 18px 16px; }
.lhead__main { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 6px 24px; }
.lhead__text { display: grid; gap: 2px; max-width: 68ch; }
.lhead__latin { color: var(--tone); }
.lhead h1 { position: relative; padding-bottom: 12px; font-size: var(--fs-3xl); line-height: 1.45; }
.lhead h1::after { content: ""; position: absolute; inset-inline-start: 0; bottom: 0; width: 48px; height: 8px; background: var(--tone); -webkit-mask: var(--zz-mask); mask: var(--zz-mask); }
.lhead__desc { margin-top: 6px; color: var(--fg-muted); font-size: var(--fs-sm); line-height: 2; }
.lhead__count { color: var(--fg-muted); font-size: var(--fs-sm); white-space: nowrap; }
.lhead__count b { color: var(--fg); font-size: var(--fs-lg); font-weight: 800; }
.lhead__count span { color: var(--fg-subtle); font-size: var(--fs-xs); }
.lhead__chips { margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); }
.lchip { flex: none; background: var(--surface); scroll-snap-align: start; }
.lchip.is-active { border-color: var(--tone); color: var(--fg); background: var(--surface); box-shadow: inset 0 0 0 1px var(--tone); }
.lchip__note { color: var(--fg-subtle); font-size: var(--fs-2xs); font-weight: 600; }
@media (min-width: 1024px) {
  .lhead__inner { padding-block: 26px 22px; }
  .lhead__chips { flex-wrap: wrap; margin-inline: 0; padding-inline: 0; }
}

/* ---------- نوار فیلتر (دسکتاپ: چسبان بالای شبکه) ---------- */
.shop { padding-block: 18px 0; }
.fbar { margin-bottom: 18px; }
.fbar__head, .fbar__foot { display: none; }
.fbar__title { display: flex; align-items: center; gap: 8px; font-size: var(--fs-lg); font-weight: 750; }
.fgroup { position: relative; }
.fgroup__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: var(--fs-sm);
  font-weight: 650;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: border-color var(--dur-2), background-color var(--dur-2);
}
.fgroup__btn::-webkit-details-marker { display: none; }
.fgroup__btn:hover, .fgroup[open] > .fgroup__btn { border-color: var(--fg); }
.fgroup__btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fgroup__chev { color: var(--fg-subtle); transition: transform var(--dur-2) var(--ease); }
.fgroup[open] .fgroup__chev { transform: rotate(180deg); }
.fgroup__value { font-weight: 750; }
.fgroup__name:has(+ .fgroup__value)::after { content: ":"; color: var(--fg-subtle); }
.fgroup__n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding-inline: 5px; border-radius: var(--r-pill); background: var(--fg); color: var(--bg); font-size: var(--fs-2xs); font-weight: 750; line-height: 1; }
.fgroup__n .icon { width: 12px; height: 12px; }
.fgroup__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

.fopts { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.fopt { position: relative; cursor: pointer; }
.fopts--check, .fopts--list { display: grid; gap: 0; }
.fopts--check { max-height: 300px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.fopt--check, .fopt--radio { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 6px; border-radius: 10px; font-size: var(--fs-sm); transition: background-color var(--dur-2); }
.fopt--check:hover, .fopt--radio:hover { background: var(--bg-soft); }
.fopt__box { display: grid; flex: none; place-items: center; width: 20px; height: 20px; border: 1.5px solid var(--line-input); border-radius: 6px; color: transparent; transition: background-color var(--dur-1), border-color var(--dur-1); }
input:checked + .fopt__box { border-color: var(--fg); background: var(--fg); color: var(--bg); }
input:focus-visible + .fopt__box { outline: 2px solid var(--focus); outline-offset: 2px; }
.fopt__label { flex: 1; }
.fopt__n { color: var(--fg-subtle); font-size: var(--fs-2xs); font-weight: 600; }
.chip .fopt__n { margin-inline-start: 2px; }
.fopt--radio input { width: 18px; height: 18px; margin: 0; accent-color: var(--fg); }
.fopts--size { gap: 6px; max-width: 360px; }
.fopts--color { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 12px 4px; width: min(330px, 80vw); }
.fopt--color { display: grid; justify-items: center; gap: 6px; color: var(--fg-muted); font-size: var(--fs-2xs); text-align: center; line-height: 1.6; }
.fopt__dot { width: 30px; height: 30px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14), 0 0 0 3px var(--surface), 0 0 0 4px var(--line-strong); transition: box-shadow var(--dur-1); }
input:checked + .fopt__dot { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14), 0 0 0 3px var(--surface), 0 0 0 5px var(--fg); }
input:checked + .fopt__dot + .fopt__label { color: var(--fg); font-weight: 700; }
input:focus-visible + .fopt__dot { outline: 2px solid var(--focus); outline-offset: 6px; }
.fopts--price { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 290px; }
.fopts--price .input { min-height: 44px; }
.ftoggles { display: flex; flex-wrap: wrap; gap: 8px; }
.fopt--toggle .chip { gap: 6px; min-height: 40px; }
.fopt__tick { display: none; }
input:checked + .chip .fopt__tick { display: inline-block; color: inherit; }
input:checked + .chip--sale { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 .5px var(--accent); }

@media (min-width: 1024px) {
  .fbar {
    position: sticky;
    top: 76px;
    z-index: 30;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
  .fbar[hidden] { display: block !important; }
  .fbar__body { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .fgroup--sort { order: 10; margin-inline-start: auto; }
  .fgroup--sort .fgroup__pop { inset-inline-start: auto; inset-inline-end: 0; }
  .fgroup__pop {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-start: 0;
    z-index: 5;
    width: max-content;
    min-width: 220px;
    max-width: min(420px, 90vw);
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--sh-3);
    animation: rz-pop var(--dur-2) var(--ease) both;
  }
  /* بی JS نوار دکمه‌ی «اعمال» کلی را هم دارد (تیک‌های موجود/حراج) */
  html:not(.js) .fbar__foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
}
@keyframes rz-pop { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- موبایل: برگه‌ی پایین ---------- */
@media (max-width: 1023.98px) {
  .js .fbar {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 120;
    display: flex;
    flex-direction: column;
    max-height: min(88vh, 760px);
    margin: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    background: var(--surface);
    box-shadow: var(--sh-3);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform var(--dur-3) var(--ease-out), visibility 0s linear var(--dur-3);
  }
  .js .fbar.is-open { transform: none; visibility: visible; transition-delay: 0s; }
  .fbar__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); }
  [dir="rtl"] .fbar__head { padding: 10px 18px 10px 12px; }
  .fbar__head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: var(--line-strong); }
  .fbar__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 18px 12px; }
  .fgroup { border-bottom: 1px solid var(--line); }
  .fgroup__btn { display: flex; width: 100%; min-height: 54px; padding: 0 2px; border: 0; border-radius: 0; background: none; }
  .fgroup__btn:hover, .fgroup[open] > .fgroup__btn { border-color: transparent; }
  .fgroup__name { flex: 1; font-weight: 750; }
  .fgroup__pop { padding: 2px 0 16px; }
  .fgroup__foot { display: none; }
  .fopts--check { max-height: none; }
  .fopts--size { max-width: none; }
  .fopts--color, .fopts--price { width: auto; }
  .ftoggles { padding-block: 16px 4px; }
  .fbar__foot { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
  .fbar__foot .btn:only-child { grid-column: 1 / -1; }
  /* بی JS: همان فرم درون صفحه، بالای شبکه */
  html:not(.js) .fbar { padding: 0 0 4px; border: 1px solid var(--line); border-radius: var(--r-lg); }
  html:not(.js) .fbar__head .btn-icon { display: none; }
  html:not(.js) .fbar__foot { border-top: 0; }

  .fpill {
    position: fixed;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    z-index: 95;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 20px;
    border-radius: var(--r-pill);
    background: var(--primary);
    color: var(--on-primary);
    font-size: var(--fs-sm);
    font-weight: 700;
    white-space: nowrap;
    box-shadow: var(--sh-2);
    transform: translateX(-50%);
    transition: transform var(--dur-2) var(--ease);
  }
  .fpill .icon { width: 18px; height: 18px; }
  .fpill:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
  .fpill__n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: var(--r-pill); background: var(--on-primary); color: var(--primary); font-size: var(--fs-2xs); }
  :root:has(.tabbar.is-hidden) .fpill { transform: translate(-50%, 64px); }
  .has-drawer .fpill { opacity: 0; pointer-events: none; }
}
@media (min-width: 1024px) { .fpill { display: none; } }

/* ---------- نتیجه‌ها ---------- */
.shop__active { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.chip--removable { min-height: 34px; padding: 4px 12px; border-color: transparent; background: var(--tint); color: var(--fg); font-size: var(--fs-xs); }
.chip--removable .icon { color: var(--fg-muted); }
.chip--removable:hover { background: var(--danger-bg); color: var(--danger); }
.chip--removable:hover .icon { color: var(--danger); }

.product-grid { display: grid; gap: 22px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px 20px; } }
@media (max-width: 420px) { .product-grid { gap: 18px 10px; } }
.product-grid + .pager { margin-top: 36px; }

/* ---------- حالت خالی ---------- */
.empty { display: grid; justify-items: center; gap: 12px; padding: clamp(36px, 6vw, 72px) 20px; border-radius: var(--r-xl); background: var(--bg-soft); text-align: center; }
.empty__hanger { width: 72px; height: 36px; background: var(--fg-subtle); }
.empty p { max-width: 48ch; color: var(--fg-muted); }

/* ---------- مقایسه ---------- */
.compare-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--bg); }
.compare { width: 100%; min-width: 640px; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.compare th, .compare td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.compare thead th { position: sticky; top: 0; background: var(--bg); vertical-align: bottom; }
.compare tbody th { width: 180px; color: var(--fg-muted); font-weight: 700; background: var(--bg-soft); }
.compare tbody tr:hover td { background: var(--bg-soft); }
.compare__product { display: grid; gap: 8px; justify-items: start; min-width: 180px; }
.compare__product img { width: 120px; height: 120px; object-fit: contain; border-radius: var(--r); background: var(--grad-media); }
.compare__product a { font-weight: 800; line-height: 1.7; }
.compare__product a:hover { color: var(--primary); }
.compare__diff td { color: var(--fg); font-weight: 700; }

/* ---------- متن کامل دسته یا برند (توضیحات پنل)، با «مشاهده‌ی بیشتر» ---------- */
.cat-about { margin-block: clamp(24px, 4vw, 48px); }
.readmore {
  position: relative;
  padding: clamp(20px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--bg);
}
.cat-about__title { margin: 0 0 12px; font-size: var(--fs-xl); }
.readmore__body { max-width: 86ch; }
.readmore__body h2 { font-size: var(--fs-lg); }
.readmore__body h3 { font-size: var(--fs-md); }
.readmore__body table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); display: block; overflow-x: auto; }
.readmore__body th, .readmore__body td { padding: 8px 12px; border: 1px solid var(--line); text-align: start; }
.readmore.is-collapsible:not(.is-open) .readmore__body {
  max-height: 260px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent);
  mask-image: linear-gradient(180deg, #000 55%, transparent);
}
.readmore__toggle { margin-top: 12px; }
.readmore.is-open .readmore__toggle .icon { transform: rotate(180deg); }
