/* ==========================================================================
   BAKKAR PRINTING — THEME "INDUSTRIAL PRECISION"
   pages/products.css — products.html ONLY.
   --------------------------------------------------------------------------
   Everything reusable (page-head, pcard, toolbar, segmented, chip, tag, pager,
   empty, crumbs, cta-band) lives in components.css and is used as-is.
   This file holds only what is genuinely unique to the catalogue page:

     · .pcat      the catalogue's SLIM page header (see components.css §18d —
                  .page-head / .page-head--slim). This file only tunes it.
     · .cat       the two-column catalogue body (filter rail + results)
     · .pside     the filter rail — collapses to an accordion below 1024px
     · .ptree     the hierarchical category index with counts
     · .pcloud    the tag cloud
     · .pnudge    the "need a custom size?" quote plate
     · .presults  the results column: toolbar, active chips, grid, pager
     · .pspec     the per-card technical spec rows (structure / material …)

   Geometry is sharp (radius 0 everywhere), rules are 1px hairlines, motion is
   140–220ms on the theme curve. All box directions are LOGICAL — RTL is free.
   ========================================================================== */


/* ==========================================================================
   1. THE CATALOGUE'S SLIM PAGE HEADER
   --------------------------------------------------------------------------
   The markup is the shared kit's .page-head.page-head--slim (components.css
   §18d): breadcrumb · index · H1 · ONE line of sub-copy, ~92px at 390 and
   ~120px at 1440 — the catalogue itself starts immediately below it. Every
   colour below resolves through a token, so the title block is a drafting
   sheet on PAPER and a graphite plate in the DARK, with no edit.

   This block only TUNES that component for the catalogue:
     · the index reads as a drawing reference — "/ 03"
     · the H1 stays condensed + uppercase in Latin, natural in Arabic
     · the sub-line is held to a technical measure
   ========================================================================== */
.pcat .page-head__index {
  font-variant-numeric: tabular-nums;
}
.pcat .page-head__index::before {
  content: "/ ";
  color: var(--line-contrast);
}

/* h1 already inherits the condensed display face + uppercase from base.css;
   only the tracking is a catalogue decision. Arabic has no condensed cut, so
   the RTL token set zeroes the tracking and the uppercase is a no-op. */
.pcat .page-head__title {
  letter-spacing: var(--track-tight);
}

.pcat .page-head__sub {
  max-inline-size: 68ch;
  color: var(--fg-muted);
}


/* ==========================================================================
   2. CATALOGUE BODY — filter rail + results
   ========================================================================== */
.cat__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-8);
  align-items: start;
}

@media (min-width: 1024px) {
  .cat__grid {
    /* The rail is a fixed measure; the results take the rest. */
    grid-template-columns: 17.5rem minmax(0, 1fr);
    gap: clamp(var(--s-7), 3vw, var(--s-10));
  }
}


/* ==========================================================================
   3. THE FILTER RAIL
   --------------------------------------------------------------------------
   ≥1024px: a sticky column, always open.
   <1024px: a single hairline plate with a disclosure button; app JS toggles
            [hidden] on the panel, so it is genuinely removed from the a11y
            tree when closed.
   ========================================================================== */
.pside {
  min-inline-size: 0;
  border: var(--bw-hair) solid var(--line);
  background-color: var(--surface);
}

.pside__title {
  display: none;
}

/* -- The mobile disclosure --------------------------------------------------
   Kept full-width and square. The caret rotates; nothing bounces. */
.pside__toggle {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  inline-size: 100%;
  min-block-size: 52px;
  padding-inline: var(--s-5);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--track-wide);
  color: var(--fg);
  background-color: var(--surface-2);
  border-block-end: var(--bw-hair) solid var(--line);
  transition: var(--t-color);
}
.pside__toggle:hover { color: var(--accent); }
.pside__toggle-label { flex: 1; text-align: start; }
.pside__caret {
  inline-size: 14px;
  block-size: 14px;
  flex: none;
  color: var(--fg-subtle);
  transition: transform var(--dur-2) var(--ease);
}
.pside__toggle[aria-expanded="true"] .pside__caret { transform: rotate(180deg); }
.pside__toggle[aria-expanded="true"] { color: var(--accent); }

.pside__panel[hidden] { display: none; }

@media (min-width: 1024px) {
  .pside {
    position: sticky;
    inset-block-start: calc(var(--masthead-h-sm) + var(--s-5));
    max-block-size: calc(100svh - var(--masthead-h-sm) - var(--s-9));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .pside__toggle { display: none; }
  .pside__title {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-5);
    font-family: var(--font-mono);
    font-size: var(--fs-2xs);
    text-transform: uppercase;
    letter-spacing: var(--track-wide);
    color: var(--fg-subtle);
    background-color: var(--surface-2);
    border-block-end: var(--bw-hair) solid var(--line);
  }
  .pside__title::before {
    content: "";
    inline-size: 18px;
    block-size: 2px;
    background-color: var(--accent);
    flex: none;
  }
  /* Never let the sticky rail hide its own [hidden] state on resize. */
  .pside__panel[hidden] { display: block; }
}

/* -- A block inside the rail ---------------------------------------------- */
.pblock {
  padding: var(--s-6) var(--s-5);
  border-block-end: var(--bw-hair) solid var(--line);
}
.pblock:last-child { border-block-end: 0; }

.pblock__head {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  margin-block-end: var(--s-5);
}
.pblock__n {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--accent);
  flex: none;
  font-variant-numeric: tabular-nums;
}
.pblock__t {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: var(--track-tight);
  color: var(--fg-strong);
}
[dir="rtl"] .pblock__t {
  text-transform: none;
  font-size: var(--fs-base);
  line-height: 1.5;
}


/* ==========================================================================
   4. CATEGORY TREE (the hierarchy, with counts)
   ========================================================================== */
.ptree {
  display: flex;
  flex-direction: column;
  border-block-start: var(--bw-hair) solid var(--line-faint);
}
.ptree__item { display: block; }

.ptree__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-block-size: 40px;
  padding-block: var(--s-2);
  padding-inline: var(--s-3) var(--s-2);
  border-block-end: var(--bw-hair) solid var(--line-faint);
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  line-height: 1.3;
  transition: var(--t-color);
}
.ptree__link::before {
  /* The red slab that flags the active row. */
  content: "";
  position: absolute;
  inset-block: -1px;
  inset-inline-start: 0;
  inline-size: var(--bw-slab);
  background-color: var(--accent);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform var(--dur-2) var(--ease);
}
.ptree__link:hover {
  color: var(--fg-strong);
  background-color: var(--surface-3);
}
.ptree__link.is-active {
  color: var(--fg-strong);
  background-color: var(--surface-3);
  font-weight: var(--fw-semi);
}
.ptree__link.is-active::before { transform: scaleY(1); }

.ptree__idx {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--line-contrast);
  flex: none;
  font-variant-numeric: tabular-nums;
}
.ptree__link.is-active .ptree__idx { color: var(--accent); }

.ptree__name {
  flex: 1;
  min-inline-size: 0;
}

.ptree__n {
  flex: none;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--fg-subtle);
  font-variant-numeric: tabular-nums;
  padding-inline: var(--s-2);
}

/* -- The child level ------------------------------------------------------ */
.ptree__kids {
  display: flex;
  flex-direction: column;
  background-color: var(--surface-2);
}
.ptree__kids .ptree__link {
  padding-inline-start: var(--s-8);
  font-size: var(--fs-xs);
  min-block-size: 36px;
  color: var(--fg-subtle);
}
.ptree__kids .ptree__link::after {
  /* the tick that makes the indent read as a tree, not padding */
  content: "";
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: var(--s-5);
  inline-size: 7px;
  block-size: 1px;
  background-color: var(--line-strong);
}
.ptree__kids .ptree__link:hover,
.ptree__kids .ptree__link.is-active { color: var(--fg-strong); }
.ptree__kids .ptree__link.is-active::after { background-color: var(--accent); }


/* ==========================================================================
   5. TAG CLOUD
   ========================================================================== */
.pcloud {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.pcloud .chip {
  min-block-size: 30px;
  padding-inline: var(--s-3);
}


/* ==========================================================================
   6. THE QUOTE NUDGE — "Need a custom size?"
   ========================================================================== */
.pnudge {
  background-color: var(--surface-2);
  border-inline-start: var(--bw-slab) solid var(--accent);
}
.pnudge__title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  line-height: 1.08;
  text-transform: uppercase;
  color: var(--fg-strong);
}
[dir="rtl"] .pnudge__title { text-transform: none; line-height: 1.45; }

.pnudge__body {
  margin-block: var(--s-3) var(--s-5);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--fg-muted);
}
.pnudge__actions {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.pnudge__wa {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--track-wide);
  color: var(--fg-subtle);
  transition: var(--t-color);
}
.pnudge__wa svg { inline-size: 13px; block-size: 13px; flex: none; }
.pnudge__wa:hover { color: var(--accent); }


/* ==========================================================================
   7. RESULTS COLUMN
   ========================================================================== */
.presults { min-inline-size: 0; }
.presults:focus { outline: none; }
.presults:focus-visible {
  outline: var(--focus-w) solid var(--focus-color);
  outline-offset: 6px;
}

/* -- Toolbar --------------------------------------------------------------
   The component gives us the hairline rules top and bottom; its top rule
   lines up exactly with the top border of the filter rail. */
.presults__toolbar {
  margin-block-end: var(--s-6);
  align-items: flex-end;
}
.presults__toolbar .toolbar__group--controls {
  gap: var(--s-4);
}

.pctrl {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  min-inline-size: 0;
}
.pctrl__label { white-space: nowrap; }
.pctrl .select { min-inline-size: 10.5rem; }
.pctrl--cat .select { min-inline-size: 13rem; max-inline-size: 18rem; }
.pctrl--per .select { min-inline-size: 6.5rem; }

/* The count sits on the baseline of the controls, not above them. */
.presults__count {
  padding-block-end: var(--s-3);
}
.presults__count b {
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}

.pview {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.pview .segmented__btn { padding-inline: var(--s-3); min-inline-size: 44px; justify-content: center; }

@media (max-width: 599px) {
  .presults__toolbar { align-items: stretch; }
  .presults__toolbar .toolbar__group--controls {
    inline-size: 100%;
    justify-content: space-between;
  }
  .pctrl { flex: 1 1 8rem; }
  .pctrl--cat { flex: 1 1 100%; }
  .pctrl .select,
  .pctrl--cat .select,
  .pctrl--per .select {
    min-inline-size: 0;
    max-inline-size: none;
    inline-size: 100%;
  }
}

/* -- Active filter chips -------------------------------------------------- */
.pactive {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  margin-block-end: var(--s-6);
  background-color: var(--surface-2);
  border: var(--bw-hair) solid var(--line);
  border-inline-start: var(--bw-slab) solid var(--accent);
}
.pactive[hidden] { display: none; }
.pactive__label { flex: none; }
.pactive__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  flex: 1;
  min-inline-size: 0;
}
.pactive__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  max-inline-size: 100%;
}
.pactive__k {
  color: var(--accent);
  flex: none;
}
.pactive__v {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-inline-size: 18ch;
  text-transform: none;
  letter-spacing: var(--track-none);
}
.pactive__chip .chip__x { flex: none; }
.pactive__chip:hover .chip__x { opacity: 1; }
.pactive__clear { flex: none; }

/* -- The grid ------------------------------------------------------------- */
.pgrid {
  display: grid;
  gap: var(--s-6);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr));
}
/* One column of full-width rows in list view. */
.pgrid--list {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-5);
}
/* The row card gets room to breathe: a longer excerpt and a 2-up spec table. */
@media (min-width: 640px) {
  .pgrid--list .pcard--row .pcard__excerpt { -webkit-line-clamp: 4; }
  .pgrid--list .pcard--row .pcard__media { inline-size: 17rem; }
  .pgrid--list .pcard--row .pspec {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--s-6);
  }
  /* In two columns every row keeps its rule, so it still reads as a table. */
  .pgrid--list .pcard--row .pspec__row {
    border-block-end: var(--bw-hair) solid var(--line-faint);
  }
}
/* The empty state must span the whole results column. */
.pgrid .empty { grid-column: 1 / -1; }

/* -- Per-card technical spec rows ----------------------------------------- */
.pspec {
  margin-block-start: var(--s-1);
  border-block-start: var(--bw-hair) solid var(--line);
}
.pspec__row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: var(--s-3);
  padding-block: var(--s-2);
  border-block-end: var(--bw-hair) solid var(--line-faint);
}
.pspec__row:last-child { border-block-end: 0; }
.pspec__k {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: var(--track-wide);
  color: var(--fg-subtle);
}
[dir="rtl"] .pspec__k { text-transform: none; }
.pspec__v {
  margin: 0;
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--fg);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (max-width: 419px) {
  .pspec__row { grid-template-columns: 4.5rem minmax(0, 1fr); gap: var(--s-2); }
}

/* -- Pager + closing note ------------------------------------------------- */
.presults__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s-5);
  margin-block-start: var(--s-8);
  padding-block-start: var(--s-6);
  border-block-start: var(--bw-hair) solid var(--line);
}
.presults__pager[hidden] { display: none; }
.presults__note {
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--fg-subtle);
  max-inline-size: 44ch;
}


/* ==========================================================================
   8. CLOSING CTA
   ========================================================================== */
.products-cta { padding-block: clamp(3rem, 2rem + 4vw, 6rem); }
.products-cta__mail {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--fg-muted);
  transition: var(--t-color);
}
.products-cta__mail svg { inline-size: 15px; block-size: 15px; flex: none; }
.products-cta__mail:hover { color: var(--accent); }
