/* The catalogue on v6 (store-1027 A1): /shop, /category/<slug>,
   /brand/<slug> and /search, browse.php's non-home branch.

   The same family as the home (.hm-*, shop.css) and the platform page
   (.ip-*, platform.css): --store-* tokens only, logical properties only, and
   every rule scoped under .ct (or body.shop--catalogue) so nothing reaches
   the rest of the shop. Loaded after shop.css, on these views alone.

   Mobile first: one column, the filters folded behind their summary; the
   toolbar is one row from 900px, the grid 2/3/4 columns from 560/980/1280.

   Pictures (tl-0952, the owner's 590 x 300 rule): every card picture sits in
   a 590:300 frame, whole (never cropped or stretched), centred, and never
   drawn past its own pixel size. The frame's ground is --store-card until
   the TL's frame PR adds --store-surface (an alias of it); then this sheet
   switches and drops whatever that PR already covers. */

/* The home hero's two glows, full-bleed behind the title block: drawn on the
   body so they reach both edges without widening the page. */
body.shop--catalogue {
  background:
    radial-gradient(40rem 20rem at 85% 120px, var(--store-glow-a), transparent 70%) no-repeat,
    radial-gradient(30rem 18rem at 8% 300px, var(--store-glow-b), transparent 70%) no-repeat,
    var(--store-bg);
}

.ct { color: var(--store-ink); font-family: var(--store-body); padding-top: 0; }
.ct h1, .ct h2, .ct h3 { color: var(--store-ink); text-wrap: balance; }
.ct-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; padding: 0; border: 0; }
.ct :is(a, button, summary, input, select):focus-visible { outline: 3px solid var(--store-accent); outline-offset: 2px; }

/* ---- buttons (the .hm-btn look, which is scoped to .hm) ---- */
.ct-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 44px; padding: .65em 1.15em; border-radius: var(--store-r-btn);
  border: 1px solid var(--store-accent); color: var(--store-accent); background: transparent;
  font: 600 .95rem/1.2 var(--store-body); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, transform .15s;
}
.ct-btn:hover { background: var(--store-accent-soft); }
.ct .ct-btn--primary { background: var(--store-accent); color: var(--store-accent-ink); }
.ct .ct-btn--primary:hover { background: var(--store-accent-d); }
.ct .ct-btn--ghost { border-color: var(--store-line); color: var(--store-ink); background: var(--store-card); }
.ct .ct-btn--ghost:hover { border-color: var(--store-accent); color: var(--store-accent); }
.ct-btn[hidden] { display: none; }
.ct-btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* ---- title block (the .ip-ihead pattern, no collage) ---- */
.ct-head {
  display: grid; gap: 20px; align-items: end; grid-template-columns: minmax(0, 1fr);
  padding-block: 36px 28px; min-width: 0;
}
@media (min-width: 900px) { .ct-head { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 40px; } }
.ct-head__copy { display: grid; gap: 6px; min-width: 0; }
.ct-eyebrow { margin: 0; font: 600 .75rem/1 var(--store-body); letter-spacing: .14em; text-transform: uppercase; color: var(--store-muted); }
.ct-head h1 { margin: 0; font: 500 clamp(1.7rem, 1.2rem + 2.2vw, 2.6rem)/1.15 var(--store-display); letter-spacing: -.01em; overflow-wrap: anywhere; }
.ct-sub { margin: 4px 0 0; color: var(--store-muted); font-size: 1.08rem; max-width: 52ch; }
.ct-count { margin: 2px 0 0; color: var(--store-muted); font-size: .92rem; }

.ct-search { display: flex; gap: 8px; min-width: 0; }
.ct-search input {
  flex: 1 1 auto; min-width: 0; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--store-line); border-radius: var(--store-r-btn); background: var(--store-card);
  color: var(--store-ink); font: 400 1rem/1.2 var(--store-body);
}
.ct-search input::placeholder { color: var(--store-muted); }
.ct-search .ct-btn { min-height: 48px; flex: none; }

/* ---- /shop's own sections (the v6 frame; their cards are a follow-up) ----
   The older tokens those partials read are pointed at the store's, so their
   colours match the page around them without touching their markup. */
.ct-front {
  --bg: var(--store-bg); --bg2: var(--store-card); --bg3: var(--store-bg2);
  --border: var(--store-line); --border2: var(--store-line);
  --text: var(--store-ink); --text2: var(--store-muted);
}
.ct-front > section { padding-block: 56px; margin: 0; border-block-start: 1px solid var(--store-line); scroll-margin-top: calc(var(--store-hdr) + 12px); }
.ct-front > section h2 { font-family: var(--store-display); font-weight: 500; letter-spacing: -.01em; }
@media (max-width: 719.98px) { .ct-front > section { padding-block: 40px; } }

/* ---- the catalogue: pills, toolbar, grid ---- */
.ct-catalogue { padding-block: 8px 64px; border-block-start: 1px solid var(--store-line); scroll-margin-top: calc(var(--store-hdr) + 12px); min-width: 0; }
.ct--front .ct-catalogue { padding-block-start: 56px; }
.ct-catalogue__head { display: grid; gap: 4px; margin-bottom: 20px; }
.ct-catalogue__head h2 { margin: 0; font: 500 clamp(1.4rem, 3.4vw, 1.9rem)/1.2 var(--store-display); }

.ct-pills, .ct-sort { position: relative; display: flex; align-items: center; gap: 6px; min-width: 0; }
.ct-pills { margin-block: 16px 8px; }
.ct-pills__track, .ct-sort__track {
  display: flex; gap: 8px; list-style: none; margin: 0; padding: 2px; min-width: 0; flex: 1 1 auto;
  overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; overscroll-behavior-x: contain;
}
.ct-pills__track::-webkit-scrollbar, .ct-sort__track::-webkit-scrollbar { display: none; }
.ct-pills__track > li { flex: none; scroll-snap-align: start; }
.ct-pill, .ct-sort__link {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--store-line); border-radius: 999px; background: var(--store-card);
  color: var(--store-ink); font: 500 .92rem/1 var(--store-body); text-decoration: none; white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.ct-pill:hover, .ct-sort__link:hover { border-color: var(--store-accent); color: var(--store-accent); }
.ct-pill.is-current, .ct-sort__link.is-current { border-color: var(--store-accent); background: var(--store-accent-soft); color: var(--store-accent); font-weight: 600; }
.ct-pill__count { font-size: .78rem; color: var(--store-muted); font-variant-numeric: tabular-nums; }
.ct-pill.is-current .ct-pill__count { color: inherit; }
.ct-sort__link { scroll-snap-align: start; flex: none; }

/* Arrows only where there is a pointer to use them and room for them. */
.ct-pills__nav {
  display: none; flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--store-line); background: var(--store-card); color: var(--store-ink); cursor: pointer;
  align-items: center; justify-content: center;
}
.ct-pills__nav svg { width: 18px; height: 18px; }
[dir="rtl"] .ct-pills__nav svg { transform: scaleX(-1); }
@media (hover: hover) and (min-width: 720px) { .ct-pills.is-scrollable .ct-pills__nav { display: inline-flex; } }

/* A row that runs past its box fades at the inline end, so a cut-off chip
   reads as "more this way" (tl-1501 b); the fade sits on the start side in
   ar. Set by the script in browse.php, so a row that fits keeps a hard edge. */
.ct .is-scrollable > .ct-pills__track, .ct .is-scrollable > .ct-sort__track {
  -webkit-mask-image: linear-gradient(to right, var(--store-ink) calc(100% - 40px), transparent);
  mask-image: linear-gradient(to right, var(--store-ink) calc(100% - 40px), transparent);
}
[dir="rtl"] .ct .is-scrollable > .ct-pills__track, [dir="rtl"] .ct .is-scrollable > .ct-sort__track {
  -webkit-mask-image: linear-gradient(to left, var(--store-ink) calc(100% - 40px), transparent);
  mask-image: linear-gradient(to left, var(--store-ink) calc(100% - 40px), transparent);
}

/* The toolbar: filters on the start side, sort on the end side. */
.ct-toolbar { display: grid; gap: 12px; margin-block: 12px 8px; min-width: 0; }
@media (min-width: 900px) { .ct-toolbar { grid-template-columns: minmax(0, 1fr) auto; align-items: center; } }
.ct-sort { justify-content: flex-start; }
.ct-sort__track { padding-block: 2px; }

.ct-filters { min-width: 0; }
.ct-filters__toggle {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--store-line); border-radius: var(--store-r-btn); background: var(--store-card);
  color: var(--store-ink); font: 600 .95rem/1 var(--store-body); cursor: pointer; list-style: none;
}
.ct-filters__toggle::-webkit-details-marker { display: none; }
.ct-filters[open] > .ct-filters__toggle { border-color: var(--store-accent); color: var(--store-accent); }
.ct-filters__count {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--store-accent); color: var(--store-accent-ink); font-size: .78rem; font-variant-numeric: tabular-nums;
}
.ct-filters__form { display: grid; gap: 12px; margin-top: 10px; padding: 16px; border: 1px solid var(--store-line); border-radius: var(--store-r); background: var(--store-card); }
.ct-filter { display: grid; gap: 6px; min-width: 0; }
.ct-filter__label { font: 600 .82rem/1.2 var(--store-body); color: var(--store-muted); }
.ct-filter select {
  width: 100%; min-width: 0; min-height: 44px; padding-block: 0; padding-inline: 12px 36px;
  border: 1px solid var(--store-line); border-radius: var(--store-r-btn); background-color: var(--store-card);
  color: var(--store-ink); font: 500 .92rem/1.2 var(--store-body); cursor: pointer;
}
.ct-filter.is-set select { border-color: var(--store-accent); background-color: var(--store-accent-soft); color: var(--store-accent); font-weight: 600; }
.ct-filters__apply { width: 100%; }

/* From 720px the selects sit in the toolbar, labelled by their "Any …" first
   option, and apply on change (the script in _filters.php). */
@media (min-width: 720px) {
  .ct-filters__toggle { display: none; }
  .ct-filters__form { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; background: none; }
  .ct-filter { flex: 0 1 auto; }
  .ct-filter__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .ct-filter select { width: auto; max-width: 15rem; }
  .ct-filters__apply { width: auto; }
}

.ct-active { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-block: 4px 8px; }
.ct-active__chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px;
  background: var(--store-accent-soft); color: var(--store-accent); font: 600 .85rem/1 var(--store-body); text-decoration: none;
}
.ct-active__clear { font: 600 .85rem/1 var(--store-body); color: var(--store-accent); padding: 10px 4px; }

/* ---- the grid and its cards (shop_product_card(), restyled here only) ---- */
.ct-grid { display: grid; gap: 16px; list-style: none; margin: 16px 0 0; padding: 0; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) { .ct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 980px) { .ct-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; } }
@media (min-width: 1280px) { .ct-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.ct-grid .shop-card {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--store-card); border: 1px solid var(--store-line); border-radius: var(--store-r);
  overflow: hidden; transition: box-shadow .2s, border-color .2s; transform: none;
}
.ct-grid .shop-card:hover { box-shadow: var(--store-shadow); border-color: var(--store-accent-soft); transform: none; }

/* The frame: 590:300, the picture whole inside it, at most its own size. */
.ct-grid .shop-card-media {
  position: relative; aspect-ratio: 590 / 300; overflow: hidden;
  background: var(--store-card); border-block-end: 1px solid var(--store-line);
}
.ct-grid .shop-card-media img {
  position: absolute; inset: 0; margin: auto;
  width: auto; height: auto; max-width: 100%; max-height: 100%;
  object-fit: scale-down; object-position: center; transition: none;
}
.ct-grid .shop-card:hover .shop-card-media img { transform: none; }
.ct-grid .shop-card-preview { background: var(--store-card); color: var(--store-ink); box-shadow: var(--store-shadow); min-height: 40px; }

.ct-grid .shop-card-kicker { margin: 16px 16px 0; color: var(--store-muted); font-size: .78rem; }
.ct-grid .shop-card-kind { padding: 0; background: none; color: var(--store-muted); font: 600 .7rem/1 var(--store-body); letter-spacing: .12em; }
.ct-grid .shop-card-kind.is-platform { background: none; color: var(--store-accent); }
.ct-grid .shop-card-kind.is-service { background: none; color: var(--store-gold-ink); }
.ct-grid .shop-card h3 { margin: 8px 16px 0; font: 600 1.05rem/1.3 var(--store-display); color: var(--store-ink); }
.ct-grid .shop-card-kicker + h3 { margin-top: 6px; }
.ct-grid .shop-card h3 a:hover { color: var(--store-accent); }
.ct-grid .shop-card-works { margin: 10px 16px 0; color: var(--store-muted); font-size: .78rem; }
.ct-grid .shop-card-works-chip { border-color: var(--store-line); background: var(--store-bg2); color: var(--store-ink); }
.ct-grid .shop-card-rating { margin: 8px 16px 0; color: var(--store-muted); font-size: .82rem; }

/* Price and Buy pinned to the foot, so a row's prices line up. */
.ct-grid .shop-card-foot { margin: auto 16px 16px; padding-block-start: 14px; border-block-start: 1px solid var(--store-line); }
.ct-grid .shop-card-price { color: var(--store-ink); font-size: 1.02rem; }
.ct-grid .shop-card-price.is-free { color: var(--store-accent); background: var(--store-accent-soft); }
.ct-grid .shop-card-was { color: var(--store-muted); }
.ct-grid .shop-card-buy {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px;
  border-radius: var(--store-r-btn); background: var(--store-accent); color: var(--store-accent-ink);
}
.ct-grid .shop-card-buy:hover { background: var(--store-accent-d); }

/* ---- pagination and the empty state ---- */
.ct-pages { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-top: 32px; }
.ct-pages__pos { color: var(--store-muted); font-size: .92rem; font-variant-numeric: tabular-nums; }

.ct-empty {
  display: grid; justify-items: center; gap: 10px; margin-top: 16px; padding: 48px 20px; text-align: center;
  border: 1px dashed var(--store-line); border-radius: var(--store-r); background: var(--store-card);
}
.ct-empty h2 { margin: 0; font: 500 1.4rem/1.25 var(--store-display); }
.ct-empty p { margin: 0 0 6px; color: var(--store-muted); max-width: 46ch; }

@media (prefers-reduced-motion: reduce) {
  .ct-btn, .ct-pill, .ct-sort__link, .ct-grid .shop-card { transition: none; }
}
