/* ==========================================================================
   STUDIO — pages/products.css
   The catalogue. Sidebar filter + toolbar + ruled card grid + pager.

   Everything reusable (.cards, .card, .toolbar, .viewsw, .pager, .chip,
   .empty, .phead) already lives in components.css — this file only adds the
   things that exist ONLY on this page:

     .cata   the two-column catalogue layout
     .fil    the category filter rail (sticky on desktop, disclosure on mobile)
     .pcard  the two spec chips injected into a product card
     .pempty the composed empty state

   House rules, unchanged: no gradients, hairlines instead of shadows, radii
   8–12px, motion 150–220ms ease-out, all layout in LOGICAL properties.
   ========================================================================== */

/* ==========================================================================
   PAGE HEADER
   The slim page-header variant now lives in the kit (components.css,
   `.phead--slim`) because products, categories, agents and contact all wear
   it. The only thing this page adds is the clamp on the sub-line.
   ========================================================================== */

/* A category's description is long-form copy written for the mega-menu, so in
   the sub-line it is CLAMPED — two lines on mobile, one on desktop, where the
   90–140px budget is being enforced. The full text is never lost: it is what
   the empty state prints in full when a category holds nothing by design. */
.phead--slim .phead__sub--clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (min-width: 900px) {
  .phead--slim .phead__sub--clamp {
    -webkit-line-clamp: 1;
    line-clamp: 1;
  }
}

/* ==========================================================================
   CATALOGUE LAYOUT
   The grid starts immediately under the page header — no hero, no band.
   ========================================================================== */
.cata {
  padding-block: var(--sp-8) var(--section-y);
}

.cata__in {
  display: grid;
  gap: var(--sp-8);
  align-items: start;
}
@media (min-width: 960px) {
  .cata__in {
    grid-template-columns: 232px minmax(0, 1fr);
    column-gap: var(--sp-10);
  }
}
@media (min-width: 1200px) {
  .cata__in { grid-template-columns: 260px minmax(0, 1fr); }
}

.cata__main { min-inline-size: 0; }

/* the fade the grid does when the filter/sort/page changes.
   160ms, opacity only — nothing slides, nothing springs. */
@keyframes cataIn { from { opacity: 0; } to { opacity: 1; } }
.cata__results.is-fresh { animation: cataIn var(--dur-2) var(--ease); }
@media (prefers-reduced-motion: reduce) {
  .cata__results.is-fresh { animation: none; }
}

/* ==========================================================================
   FILTER RAIL
   ========================================================================== */
.fil { min-inline-size: 0; }
@media (min-width: 960px) {
  .fil {
    position: sticky;
    inset-block-start: calc(var(--header-h) + var(--sp-6));
  }
}

/* the mobile disclosure button — a full-width hairline row */
.fil__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  inline-size: 100%;
  min-block-size: 48px;
  padding-inline: var(--sp-4);
  border: var(--border-1);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  transition: var(--t-color);
}
.fil__toggle:hover { border-color: var(--border-strong); background: var(--bg-surface); }
.fil__toggle-l { display: flex; align-items: center; gap: var(--sp-2); }
.fil__toggle-l svg { inline-size: 17px; block-size: 17px; flex: none; color: var(--text-muted); }
.fil__chev {
  inline-size: 16px;
  block-size: 16px;
  flex: none;
  color: var(--text-muted);
  transition: transform var(--dur-2) var(--ease);
}
.fil__toggle[aria-expanded="true"] .fil__chev { transform: rotate(180deg); }
/* how many filters are on, shown on the collapsed button */
.fil__toggle-n {
  display: inline-grid;
  place-items: center;
  min-inline-size: 20px;
  block-size: 20px;
  padding-inline: 5px;
  border-radius: var(--r-pill);
  background: var(--accent-fill);
  color: var(--c-white);
  font-size: var(--fs-label);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.fil__body {
  display: grid;
  gap: var(--sp-7);
  margin-block-start: var(--sp-4);
  padding: var(--sp-5);
  border: var(--border-1);
  border-radius: var(--r-lg);
  background: var(--bg);
}

.fil__group { display: grid; gap: var(--sp-3); min-inline-size: 0; }
.fil__legend { color: var(--text-muted); }

/* the refine field */
.fil__search { position: relative; }
.fil__search .input { padding-inline-start: var(--sp-9); }
.fil__search-ico {
  position: absolute;
  inset-inline-start: var(--sp-3);
  inset-block-start: 50%;
  transform: translateY(-50%);
  inline-size: 17px;
  block-size: 17px;
  color: var(--text-muted);
  pointer-events: none;
}

/* --- the category tree -------------------------------------------------- */
.fil__tree { display: grid; gap: 2px; list-style: none; }
.fil__sub {
  display: grid;
  gap: 2px;
  list-style: none;
  margin-block-start: 2px;
  margin-inline-start: var(--sp-3);
  padding-inline-start: var(--sp-3);
  border-inline-start: var(--border-1);
}

.fil__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-block-size: 40px;
  padding-block: var(--sp-2);
  padding-inline: var(--sp-3);
  border-radius: var(--r-sm);
  border-inline-start: 2px solid transparent;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  transition: var(--t-color);
}
.fil__link:hover { background: var(--bg-surface); color: var(--text); }
.fil__link[aria-current="page"] {
  background: var(--bg-surface);
  border-inline-start-color: var(--accent);
  color: var(--text);
  font-weight: var(--fw-semibold);
}
.fil__name { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fil__n {
  flex: none;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.fil__link[aria-current="page"] .fil__n { color: var(--text-secondary); }

/* the child rows sit a notch quieter than their parent */
.fil__sub .fil__link { font-size: var(--fs-xs); min-block-size: 36px; }

/* --- collapsed on small screens ---------------------------------------- */
@media (max-width: 959px) {
  .fil__body { display: none; }
  .fil.is-open .fil__body { display: grid; }
}
@media (min-width: 960px) {
  .fil__toggle { display: none; }
  .fil__body { margin-block-start: 0; }
}

/* ==========================================================================
   ACTIVE FILTER CHIPS
   Rendered ONLY when something is actually filtering. Never an empty row.
   ========================================================================== */
.cata__active {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding-block-end: var(--sp-5);
}
/* A class that sets `display` beats the UA's [hidden] rule, so every region
   this page hides needs saying so explicitly. */
.cata__active[hidden],
.toolbar[hidden],
.fil__toggle-n[hidden] { display: none; }
.cata__active-lbl { flex: none; color: var(--text-muted); }

.chip--rm { padding-inline-end: var(--sp-3); }
.chip--rm .chip__x { transition: opacity var(--dur-2) var(--ease); }
.chip--rm:hover .chip__x { opacity: 1; }

.chip--clear {
  border-color: transparent;
  background: none;
  color: var(--text-accent);
  font-weight: var(--fw-semibold);
  padding-inline: var(--sp-3);
}
.chip--clear:hover {
  background: var(--accent-wash);
  border-color: var(--accent-wash-bd);
  color: var(--text-accent);
}

/* ==========================================================================
   TOOLBAR — the per-page select is narrower than the sort select.
   (products.css loads after components.css, so this beats `.toolbar .select`.)
   ========================================================================== */
.toolbar .select--pp { min-inline-size: 0; padding-inline-start: var(--sp-3); }
.toolbar__count strong { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   PRODUCT CARD — the spec chips.
   The shared card gives us photo / category label / name / material line /
   quote foot. The catalogue adds two attribute chips so a buyer can scan
   for "food grade", "zipper", "vacuum" without opening the product.
   ========================================================================== */
.pcard__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-block-start: var(--sp-1);
}
.card--row .pcard__tags { margin-block-start: var(--sp-2); }

/* ==========================================================================
   PAGER — buttons, not links, because the page never reloads.
   The wrapper is hidden outright when there is only one page.
   ========================================================================== */
.cata__pager[hidden] { display: none; }
.pager__link { cursor: pointer; }
.pager__link:disabled { opacity: 0.4; pointer-events: none; }

/* ==========================================================================
   EMPTY STATE
   Some categories legitimately hold nothing (Labels & Sleeves is printed to
   the customer's artwork — there is no standing catalogue for it). That has
   to read as an invitation, not as a fault.
   ========================================================================== */
.pempty { padding-block: var(--sp-11) var(--sp-10); }
.pempty .empty__text + .empty__text { margin-block-start: calc(var(--sp-2) * -1); }
.pempty__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-3);
  margin-block-start: var(--sp-3);
}
.pempty__q {
  font-weight: var(--fw-semibold);
  color: var(--text);
}

/* ==========================================================================
   CLOSING CTA — the page's one dark moment.
   ========================================================================== */
.pcta {
  display: grid;
  gap: var(--sp-7);
  align-items: center;
}
@media (min-width: 900px) {
  .pcta { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); column-gap: var(--sp-10); }
}
.pcta__title { font-size: var(--fs-h2); max-inline-size: 18ch; }
.pcta__lead {
  margin-block-start: var(--sp-4);
  color: var(--text-on-ink-mut);
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
  max-inline-size: 54ch;
}
.pcta__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
@media (min-width: 900px) {
  .pcta__actions { justify-content: flex-end; }
}
