/* Toys page (docs/pages/category-product.md, D-071). Shared components live in site.css.
   Phones: the bar, the filters on a card (price range, then the chips), two cards across. From 1024px: the filters on the right, the shelf beside them */

.cat {
  padding-top: var(--space-5);
}

/* ---------- The bar: how many, and in what order (C-02, C-06) ---------- */

.cat-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-line);
}

.cat-bar__head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.cat-bar__title {
  font: 600 var(--text-xl) / 1.2 var(--font-ui);
}

.cat-bar__count {
  color: var(--color-muted);
  font: 500 var(--text-s) / 1.2 var(--font-ui);
  font-variant-numeric: tabular-nums;
}

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

/* Phones only: the filters open and close under the bar. The number says how many are on */
.cat-filters-toggle {
  gap: 6px;
}

.cat-filters-toggle__count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding-inline: 5px;
  border-radius: var(--radius-full);
  background: var(--color-brand-red);
  color: var(--color-on-red);
  font: 600 var(--text-xs) / 1 var(--font-ui);
}

@media (max-width: 1023px) {
  .js .cat-filters:not(.is-open) {
    display: none;
  }
}

@media (min-width: 1024px) {
  .cat-filters-toggle {
    display: none;
  }
}

/* The sort is a real select: the phone opens its own picker. It sorts the page, it sends nothing */
.cat-sort {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cat-sort__label {
  color: var(--color-muted);
  font: 500 var(--text-s) / 1 var(--font-ui);
}

.cat-sort select {
  min-height: 44px;
  padding-inline: 16px 40px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  box-shadow: inset 0 0 0 1.5px var(--color-line);
  color: var(--color-ink);
  font: 500 var(--text-s) / 1 var(--font-ui);
  appearance: none;
  cursor: pointer;
  transition: box-shadow var(--duration-fast);
}

.cat-sort select:hover {
  box-shadow: inset 0 0 0 1.5px var(--color-ink);
}

.cat-sort svg {
  position: absolute;
  inset-inline-end: 14px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  rotate: -90deg;
  pointer-events: none;
}

@media (min-width: 900px) {
  .cat-bar__title {
    font-size: var(--text-2xl);
  }
}

/* ---------- Filters: a few that change a decision, instead of a hundred links (C-03) ---------- */

.cat-layout {
  display: grid;
  gap: var(--space-4);
  padding-top: var(--space-4);
}

/* Phones: the price range across the width, and the chips in a row under it */
.cat-filters {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-m);
  background: var(--color-surface);
}

.filter {
  display: grid;
  gap: var(--space-3);
}

.filter + .filter {
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-line);
}

.filter__title {
  font: 600 var(--text-s) / 1.2 var(--font-ui);
}

.filter__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.cat-filters__clear {
  justify-self: start;
  min-height: 32px;
  padding-inline: 0;
}

/* ---------- The price range: one track, two handles, a field at each end. They move each other ---------- */

.range {
  --lo: 0%;
  --hi: 100%;
  position: relative;
  height: 32px;
  margin-inline: 4px;
}

.range__track {
  position: absolute;
  inset-inline: 0;
  top: 50%;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--color-line);
  translate: 0 -50%;
}

/* The chosen part of the track, between the handles. RTL: the low end is on the right */
.range__fill {
  position: absolute;
  inset-block: 0;
  inset-inline-start: var(--lo);
  inset-inline-end: calc(100% - var(--hi));
  border-radius: inherit;
  background: var(--color-brand-red);
}

/* Two native sliders on top of each other: only their handles take the pointer, so each can be grabbed */
.range__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: none;
  pointer-events: none;
  appearance: none;
}

.range__input::-webkit-slider-runnable-track {
  height: 100%;
  background: none;
}

.range__input::-moz-range-track {
  background: none;
}

.range__input::-webkit-slider-thumb {
  width: 24px;
  height: 24px;
  margin-top: 4px;
  border: 3px solid var(--color-brand-red);
  border-radius: 50%;
  background: var(--color-surface);
  box-shadow: var(--shadow-lift);
  pointer-events: auto;
  cursor: grab;
  appearance: none;
  transition: scale var(--duration-base) var(--ease-spring);
}

.range__input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 3px solid var(--color-brand-red);
  border-radius: 50%;
  background: var(--color-surface);
  box-shadow: var(--shadow-lift);
  pointer-events: auto;
  cursor: grab;
  transition: scale var(--duration-base) var(--ease-spring);
}

/* M-39: the handle you hold grows a little, and settles when you let go */
.range__input:active::-webkit-slider-thumb,
.range__input:focus-visible::-webkit-slider-thumb {
  scale: 1.15;
  cursor: grabbing;
}

.range__input:active::-moz-range-thumb,
.range__input:focus-visible::-moz-range-thumb {
  scale: 1.15;
}

/* The ring goes on the handle, not on the invisible slider around it */
.range__input:focus-visible {
  outline: none;
}

.range__input:focus-visible::-webkit-slider-thumb {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.range__input:focus-visible::-moz-range-thumb {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.range__fields {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
}

.range__field {
  display: grid;
  flex: 1;
  gap: 4px;
}

.range__label {
  color: var(--color-muted);
  font: 500 var(--text-xs) / 1 var(--font-ui);
}

.range__box {
  position: relative;
  display: flex;
  align-items: center;
}

.range__shekel {
  position: absolute;
  inset-inline-start: 12px;
  color: var(--color-muted);
  font: 500 var(--text-s) / 1 var(--font-ui);
  pointer-events: none;
}

.range__box input {
  width: 100%;
  min-height: 44px;
  padding-inline: 30px 10px;
  border: 0;
  border-radius: var(--radius-s);
  background: var(--color-bg);
  box-shadow: inset 0 0 0 1.5px var(--color-line);
  color: var(--color-ink);
  font: 600 var(--text-m) / 1 var(--font-ui);
  font-variant-numeric: tabular-nums;
  appearance: textfield;
}

.range__box input::-webkit-inner-spin-button,
.range__box input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.range__box input:hover {
  box-shadow: inset 0 0 0 1.5px var(--color-muted);
}

.range__dash {
  padding-bottom: 12px;
  color: var(--color-muted);
}

@media (min-width: 1024px) {
  .cat-layout {
    grid-template-columns: 220px minmax(0, 1fr);
    column-gap: var(--space-7);
    align-items: start;
    padding-top: var(--space-5);
  }

  .cat-filters {
    position: sticky;
    top: calc(var(--bar-h) + var(--header-h) + var(--space-4));
  }
}

/* ---------- The shelf: the same cards as everywhere, two across on a phone (C-07) ---------- */

.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5) var(--space-4);
}

.cat-grid > [hidden] {
  display: none;
}

@media (min-width: 600px) {
  .cat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .cat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: var(--space-5);
  }
}

/* M-16: an empty shelf is the face's problem, and it says so with one way out */
.cat-empty {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  padding: var(--space-7) var(--space-4);
  border-radius: var(--radius-m);
  background: var(--color-surface);
  text-align: center;
}

.cat-empty .face {
  width: 56px;
  margin-bottom: var(--space-2);
  color: var(--color-brand-red); /* yellow would vanish on white: the red A, with white eyes */
  --face-ink: var(--color-surface);
}

.cat-empty__title {
  font: 600 var(--text-l) / 1.2 var(--font-ui);
}

.cat-empty__text {
  color: var(--color-muted);
}

.cat-empty .btn {
  margin-top: var(--space-2);
}
