/* Category page (reference look, main branch: css/00-base.css tokens, 09-newly-added card grid, 05 pill).
   Breadcrumb, title, category pills, filter chip row + sort (>=768), Filters bottom sheet (<768), grid, empty state.
   Card internals belong to components.css. Filter UI shows only with JS (html.js). */

.cat {
  --cat-accent: var(--accent, #dd2745); --cat-heading: var(--heading, #2e2d42); --cat-body: var(--body, #333);
  --cat-muted: var(--muted, #757575); --cat-line: var(--border-card, #cbd5e1); --cat-pink: var(--pink-band, #fbf3f3);
  --cat-tint: #fdeff1;
  padding: 0 0 56px; background: var(--page-bg, #fff); color: var(--cat-body); font-family: var(--font, "Public Sans", system-ui, sans-serif);
}
.cat .container { max-width: calc(var(--container, 1344px) + 2 * var(--gutter, 48px)); padding-inline: var(--gutter, 48px); }

/* Breadcrumb (shared look with the product page) */
.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; margin: 0; padding: 0; list-style: none; font-size: 12px; line-height: 16px; color: var(--muted, #757575); }
.crumbs li { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.crumbs li + li::before { content: "/"; color: var(--border-card, #cbd5e1); }
.crumbs a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; text-decoration: none; color: inherit; }
.crumbs a:hover { color: var(--accent, #dd2745); }
.crumbs [aria-current] { color: var(--heading, #2e2d42); overflow-wrap: anywhere; }

/* Title */
.cat__head { display: grid; gap: 4px; margin: 4px 0 16px; }
.cat__title { margin: 0; font-family: var(--font, "Public Sans", system-ui, sans-serif); font-weight: 700; font-size: 24px; line-height: 32px; letter-spacing: -.4px; color: var(--cat-heading); }
.cat__lead { margin: 0; font-size: 16px; line-height: 20px; color: var(--cat-muted); max-width: 52rem; }

/* Pills: reference pill shape (40px radius). Used for category links and filter chips. */
.chip { position: relative; display: inline-flex; }
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; opacity: 0; cursor: pointer; }
.chip__face {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; white-space: nowrap;
  border: 1px solid var(--cat-line); border-radius: var(--r-pill, 40px); background: #fff;
  font-size: 14px; line-height: 20px; font-weight: 500; color: var(--cat-heading); text-decoration: none;
  transition: border-color .2s ease, background-color .2s ease, color .2s ease;
}
.chip:hover .chip__face, a.chip__face:hover { border-color: var(--cat-accent); color: var(--cat-accent); }
.chip input:checked + .chip__face, .cat__cat[aria-current="page"] { border-color: var(--cat-accent); background: var(--cat-tint); color: #b81c37; font-weight: 600; }
.chip input:focus-visible + .chip__face { outline: 2px solid var(--cat-heading); outline-offset: 2px; }
.swatch { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 1px solid rgba(46, 45, 66, .35); }

/* Category links: one scrolling row on phones, wraps from tablet up. */
.cat__cats { display: flex; gap: 8px; margin: 0 calc(var(--gutter, 48px) * -1); padding: 0 var(--gutter, 48px) 4px; list-style: none; overflow-x: auto; scrollbar-width: none; }
.cat__cats::-webkit-scrollbar { display: none; }
@media (min-width: 768px) { .cat__cats { flex-wrap: wrap; margin-inline: 0; padding-inline: 0; overflow: visible; } }

/* Bar: filter chips (desktop) + count, clear, Filters button (phone) and sort */
.cat__bar { display: grid; gap: 12px; margin: 20px 0 20px; padding: 16px 0; border-block: 1px solid var(--drawer-row, #e2e8f0); }
.cat__filters, .cat__clear, .cat__filters-btn, .cat__sort { display: none; }
.cat__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.cat__count { margin: 0 auto 0 0; font-size: 14px; line-height: 20px; color: var(--cat-muted); }
.js .cat__filters-btn { display: inline-flex; }
.js .cat__sort { display: flex; align-items: center; gap: 8px; }
.cat__sort label { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--cat-muted); }
.cat__sort select {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--border-search, #afafaf); border-radius: var(--r-md, 8px);
  background: #fff; font: 500 14px/20px var(--font, "Public Sans", sans-serif); color: var(--cat-heading); cursor: pointer;
}
.cat__count { order: 3; flex-basis: 100%; }
@media (min-width: 768px) {
  .cat__bar { grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 16px 32px; }
  .js .cat__filters { display: block; }
  .js .cat__clear { display: inline-flex; }
  .js .cat__filters-btn { display: none; }
  .cat__tools { flex-wrap: nowrap; justify-content: flex-end; }
  .cat__count { order: 0; flex-basis: auto; margin: 0; white-space: nowrap; }
}

/* Filter groups: legend + chips on one wrapping line. Float takes the legend out of the fieldset border so it flows. */
.filters { display: grid; gap: 12px; }
.filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.filter-group legend { float: left; margin-right: 4px; padding: 0; font-size: 12px; line-height: 16px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--cat-muted); }

/* Buttons */
.cat__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px;
  border: 1px solid var(--cat-line); border-radius: var(--r-md, 8px); background: #fff;
  font: 600 14px/20px var(--font, "Public Sans", sans-serif); color: var(--cat-heading); cursor: pointer;
  transition: border-color .2s ease, background-color .2s ease, color .2s ease;
}
.cat__btn:hover { border-color: var(--cat-accent); color: var(--cat-accent); }
.cat__btn--accent { border-color: var(--cat-accent); background: var(--cat-accent); color: #fff; }
.cat__btn--accent:hover { background: #c41f3b; color: #fff; }
.cat__badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--cat-accent); color: #fff; font-size: 12px; line-height: 1; }
.cat__badge[hidden] { display: none; }
.cat__clear {
  align-items: center; min-height: 44px; padding: 0 4px; border: 0; background: none; cursor: pointer;
  font: 600 14px/20px var(--font, "Public Sans", sans-serif); color: var(--cat-accent);
}
.cat__clear:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Grid: 2 cols phone, 3 tablet, 4 laptop, 5 wide. */
.cat .cat__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 8px; margin: 0; padding: 0; list-style: none; }
.cat__grid > li { display: grid; min-width: 0; }
@media (min-width: 768px) { .cat .cat__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 12px; } }
@media (min-width: 1024px) { .cat .cat__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .cat .cat__grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* Empty state on the pink band */
.cat__empty { display: grid; justify-items: start; gap: 8px; padding: 32px 24px; border-radius: var(--r-card, 16px); background: var(--cat-pink); }
.cat__empty[hidden] { display: none; }
.cat__empty .cat__btn { margin-top: 8px; }

/* Bottom sheet (<768). The filter form moves in while it is open. */
html:has(.sheet[open]) { overflow: hidden; }
.sheet {
  width: 100%; max-width: none; max-height: 85dvh; margin: auto 0 0; padding: 0; border: 0;
  border-radius: var(--r-card, 16px) var(--r-card, 16px) 0 0; background: #fff; color: var(--body, #333);
  font-family: var(--font, "Public Sans", system-ui, sans-serif);
}
.sheet[open] { display: flex; flex-direction: column; animation: sheet-up .25s ease-out; }
.sheet::backdrop { background: rgba(46, 45, 66, .5); }
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--drawer-row, #e2e8f0); }
.sheet__title { margin: 0; font-size: 18px; line-height: 24px; font-weight: 700; color: var(--heading, #2e2d42); }
.sheet__x { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: var(--r-md, 8px); background: none; color: var(--heading, #2e2d42); cursor: pointer; }
.sheet__x:hover { background: var(--menu-active, #f8fafc); }
.sheet__x svg { width: 20px; height: 20px; }
.sheet__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px; }
.sheet .filters { gap: 20px; }
.sheet .filter-group legend { float: none; width: 100%; margin: 0 0 4px; }
.sheet__foot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--drawer-row, #e2e8f0); }
.sheet__count { grid-column: 1 / -1; margin: 0; font-size: 14px; color: var(--muted, #757575); }

@media (max-width: 767px) {
  .cat .container { padding-inline: var(--gutter, 16px); }
  .cat__title { letter-spacing: -.32px; }
  .cat__tools .cat__filters-btn, .cat__sort { flex: 1 1 0; }
  .cat__sort label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .cat__sort select { width: 100%; }
}
