/* ==========================================================================
   QRBELL Store — Shop / catalogue page (spec §13, §14, §67)
   --------------------------------------------------------------------------
   Loaded only by pages/shop.html. All selectors namespaced `.shop-*` under
   `.store-shop`, so nothing here reaches the homepage or product page.

   Desktop: filter sidebar + product grid.
   Mobile:  category rail + a sticky Filter / Sort bar opening bottom sheets.
   ========================================================================== */

.store-shop {
  --shop-gap: var(--space-6);
  --shop-rail: 244px;
}

@media (min-width: 1200px) {
  .store-shop { --shop-gap: var(--space-8); --shop-rail: 264px; }
}


/* ==========================================================================
   PAGE HEAD — compact. The catalogue starts as high up as possible.
   ========================================================================== */

.shop-head {
  padding-block: var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

/* Breadcrumb and back link occupy the same row — only one renders at any
   breakpoint — so the title sits directly beneath it. */
.shop-head__nav { min-height: 24px; }

.shop-head__title {
  margin: var(--space-3) 0 var(--space-1);
  font-size: 1.375rem;
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
}

@media (min-width: 768px) { .shop-head__title { font-size: 1.75rem; } }

.shop-head__sub {
  margin: 0;
  max-width: 62ch;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

/* Category rail — horizontal scroll on mobile, wraps on desktop */
.shop-rail {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
  margin-inline: calc(var(--gutter) * -1);
  padding-inline: var(--gutter);
  padding-bottom: var(--space-1);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.shop-rail::-webkit-scrollbar { display: none; }
.shop-rail > * { flex: 0 0 auto; scroll-snap-align: start; }

@media (min-width: 992px) {
  .shop-rail { flex-wrap: wrap; overflow: visible; margin-inline: 0; padding-inline: 0; }
}


/* ==========================================================================
   LAYOUT
   ========================================================================== */

.shop-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--shop-gap);
  padding-block: var(--space-5) var(--space-10);
  align-items: start;
}

/* Filters moved to a full-width bar above the grid (see .shop-filterbar),
   so the body is a single column at every breakpoint. */

/* -- Sidebar: desktop only. Mobile gets the same filters in a sheet. ------ */
.shop-aside { display: none; }

@media (min-width: 992px) {
  .shop-aside {
    display: block;
    position: sticky;
    top: calc(var(--header-height-desktop) + var(--space-4));
    max-height: calc(100vh - var(--header-height-desktop) - var(--space-8));
    overflow-y: auto;
    scrollbar-width: thin;
    padding-right: var(--space-2);
  }
}

.shop-filter { padding-block: var(--space-4); border-bottom: 1px solid var(--color-border); }
.shop-filter:first-child { padding-top: 0; }
.shop-filter:last-child { border-bottom: 0; }

.shop-filter__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
}

.shop-filter__list,
.shop-price { display: flex; flex-direction: column; }

/* Checkbox row with a live count on the right.
   Base sizing is touch-first — 44px, per spec §52 — because this same markup
   is what the mobile filter sheet renders. The desktop sidebar overrides it
   to a much tighter row below, where the pointer is precise. */
.shop-check {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--touch-min);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background-color var(--transition-base);
}
.shop-check:hover { background: var(--color-surface-alt); }

.shop-check input { width: 18px; height: 18px; accent-color: var(--color-accent); cursor: pointer; flex: 0 0 auto; }
.shop-check__label { flex: 1 1 auto; min-width: 0; font-size: var(--text-base); }
.shop-check__count {
  flex: 0 0 auto;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

/* Desktop sidebar: dense rows. A filter list is scanned, not read — nine
   categories at 44px each pushed Price and Type below the fold. */
.shop-aside .shop-check {
  min-height: 28px;
  padding: 2px var(--space-2);
  gap: var(--space-2);
}
.shop-aside .shop-check input { width: 15px; height: 15px; }
.shop-aside .shop-check__label { font-size: var(--text-sm); }
.shop-aside .shop-check__count { font-size: var(--text-2xs); }
.shop-aside .shop-filter { padding-block: var(--space-3); }
.shop-aside .shop-filter__title { margin-bottom: var(--space-1); }
.shop-aside .qb-input { min-height: 36px; padding-block: var(--space-2); font-size: var(--text-sm); }


/* ==========================================================================
   FILTER BAR — Search, Price and the stock toggle on one row (§13)
   Full-width strip under the page head; wraps gracefully on small screens.
   ========================================================================== */

.shop-filters {
  padding-block: var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.shop-filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
}

.shop-filterbar__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.shop-filterbar__field .qb-label { margin: 0; }

.shop-filterbar__field--search { flex: 1 1 280px; }

.shop-filterbar__field .qb-input,
.shop-filterbar__field .qb-select {
  min-height: 42px;
}

.shop-filterbar__field .qb-input-group { width: 100%; }
.shop-filterbar__field .qb-select { width: auto; min-width: 160px; }

/* Stock toggle styled as a pill button so it reads as a peer of the two
   inputs rather than a stray checkbox. */
.shop-filterbar__check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 42px;
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  white-space: nowrap;
  cursor: pointer;
  transition: border-color var(--transition-base), background-color var(--transition-base);
}
.shop-filterbar__check:hover { border-color: var(--qb-navy-900); }
.shop-filterbar__check:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
}

@media (max-width: 640px) {
  .shop-filterbar__field--search { flex-basis: 100%; }
  .shop-filterbar__field .qb-select { width: 100%; }
  .shop-filterbar__check { flex: 1 1 100%; justify-content: center; }
}


/* ==========================================================================
   TOOLBAR — count, sort, grid/list
   ========================================================================== */

.shop-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.shop-toolbar__count {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.shop-toolbar__count strong { color: var(--color-text); font-weight: var(--weight-semibold); }

.shop-toolbar__actions { display: flex; align-items: center; gap: var(--space-2); }

/* Compact sort control — a native select keeps it accessible for free */
.shop-sort {
  min-height: 38px;
  padding: var(--space-1) var(--space-8) var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
  width: auto;
}

.shop-view { display: none; }

@media (min-width: 768px) {
  .shop-view {
    display: inline-flex;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
  }
  .shop-view__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    color: var(--color-text-muted);
    transition: background-color var(--transition-base), color var(--transition-base);
  }
  .shop-view__btn + .shop-view__btn { border-left: 1px solid var(--color-border); }
  .shop-view__btn:hover { background: var(--color-surface-alt); color: var(--color-text); }
  .shop-view__btn.is-active { background: var(--qb-navy-900); color: var(--color-text-invert); }
}

/* Active filter chips */
.shop-active {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.shop-active:empty { display: none; }


/* ==========================================================================
   LIST VIEW — the grid/list toggle (spec §13)
   ========================================================================== */

.qb-pgrid.is-list { grid-template-columns: minmax(0, 1fr) !important; gap: var(--space-3); }

.qb-pgrid.is-list .qb-pcard { flex-direction: row; }
.qb-pgrid.is-list .qb-pcard__media { flex: 0 0 116px; aspect-ratio: 1 / 1; }
.qb-pgrid.is-list .qb-pcard__body { padding: var(--space-3) var(--space-4); }
.qb-pgrid.is-list .qb-pcard__cta { width: auto; align-self: flex-start; }

@media (min-width: 768px) {
  .qb-pgrid.is-list .qb-pcard__media { flex-basis: 180px; }
  .qb-pgrid.is-list .qb-pcard__benefit { -webkit-line-clamp: 3; line-clamp: 3; }
}


/* ==========================================================================
   MOBILE FILTER BAR — sticky, opens the filter and sort sheets
   ========================================================================== */

.shop-mobilebar {
  position: sticky;
  top: var(--header-height-mobile);
  z-index: var(--z-sticky);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

@media (min-width: 992px) { .shop-mobilebar { display: none; } }

.shop-mobilebar__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-min);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}
.shop-mobilebar__btn:hover { border-color: var(--qb-navy-900); }

/* Count bubble showing how many filters are on */
.shop-mobilebar__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
}


/* ==========================================================================
   LOAD MORE
   ========================================================================== */

.shop-more {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-8);
}

.shop-more__progress {
  width: 180px;
  height: 4px;
  background: var(--color-surface-sunken);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.shop-more__bar { height: 100%; background: var(--color-primary); transition: width var(--transition-base); }

.shop-more__text { color: var(--color-text-muted); font-size: var(--text-xs); }


/* ==========================================================================
   CATEGORY CONTEXT — shown when the shop is filtered to one category (§14)
   ========================================================================== */

.shop-usecases {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.shop-usecase {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  background: var(--color-surface-alt);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}
.shop-usecase i { color: var(--color-success-strong); }
