/* ==========================================================================
   Kedn Hub — Product listing page (category/PLP): breadcrumb, page intro,
   filters sidebar, toolbar, product grid, pagination, empty state.
   ========================================================================== */

.breadcrumb {
  padding-block: var(--space-4);
  font-size: var(--text-small);
  color: var(--color-text-muted);
}

.breadcrumb a {
  color: var(--color-text-muted);
}

.breadcrumb a:hover {
  color: var(--color-accent-strong);
}

.breadcrumb__sep {
  margin-inline: var(--space-2);
}

.breadcrumb__current {
  color: var(--color-text);
}

.plp-intro {
  padding-block: var(--space-4) var(--space-6);
  max-width: 48rem;
}

.plp-intro h1 {
  font-family: var(--font-display);
  font-size: var(--text-h1);
  line-height: var(--leading-tight);
}

.plp-intro p {
  margin-top: var(--space-3);
  color: var(--color-text-muted);
}

.plp-layout {
  display: grid;
  /* minmax(0, …), not 1fr: a plain 1fr track keeps an `auto` minimum and
     refuses to shrink below its content, so a wide horizontal brand rail
     inside it pushes the whole page sideways on mobile. minmax(0, 1fr)
     lets the column shrink so the rail's own overflow-x scrolls instead. */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
  padding-bottom: var(--space-9);
  align-items: start;
}

/* ---- Toolbar ---- */
.plp-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-hairline);
}

.plp-toolbar__result-count {
  font-size: var(--text-small);
  color: var(--color-text-muted);
  min-width: 0;
}

.plp-toolbar__result-count strong {
  color: var(--color-text);
}

.plp-brand-clear {
  color: var(--color-accent-strong);
  white-space: nowrap;
  margin-left: var(--space-1);
}
.plp-brand-clear:hover {
  text-decoration: underline;
}

.plp-toolbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  min-width: 0;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-small);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border: none;
  border-bottom: 1px solid var(--color-text);
  padding: 0 0 2px;
  transition: color var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard);
}

.filter-toggle:hover {
  color: var(--color-accent-strong);
  border-color: var(--color-accent-strong);
}

.filter-toggle svg {
  width: 14px;
  height: 14px;
}

.sort-select {
  border: none;
  border-bottom: 1px solid var(--color-text);
  background: transparent;
  padding: 0 0 2px;
  font-size: var(--text-small);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text);
  border-radius: 0;
}

/* ---- Filters sidebar ----
   Below the 1024px breakpoint this becomes a slide-in drawer (fixed +
   transform, same off-canvas mechanism as .mobile-nav) driven by the
   existing .is-open class toggle — no new markup or JS required. */
.filters {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: var(--z-mobile-nav);
  width: min(22rem, 88vw);
  display: block;
  overflow-y: auto;
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6) var(--space-6);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform var(--duration-slow) var(--ease-out), visibility 0s linear var(--duration-slow);
}

.filters.is-open {
  transform: translateX(0);
  visibility: visible;
  transition: transform var(--duration-slow) var(--ease-out);
}

.filters__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-hairline);
}

.filters__head h2 {
  font-family: var(--font-display);
  font-size: var(--text-h3);
}

.filters__clear {
  font-size: var(--text-label);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-accent-strong);
}

.filters__head-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Closes the drawer without resetting anything - lets a visitor dismiss
   the panel and see the already-live-filtered results while keeping
   their checked filters. Same off-canvas scrim/close recipe as
   .mobile-nav - not shown at 1024px+, where the sidebar isn't a drawer. */
.filters__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  color: var(--color-text);
}

.filters__close svg {
  width: 1.25rem;
  height: 1.25rem;
}

.filters-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-mobile-nav);
  background: rgba(11, 10, 8, 0.45);
}

.filters-scrim[hidden] {
  display: none;
}

.filter-group {
  padding-block: var(--space-5);
  border-top: 1px solid var(--color-hairline);
}

.filter-group:first-of-type {
  border-top: none;
  padding-top: 0;
}

.filter-group__title {
  font-size: 11px;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.filter-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-block: var(--space-2);
  font-size: var(--text-small);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-standard);
}

.filter-option:hover {
  color: var(--color-text);
}

.filter-option input {
  accent-color: var(--color-accent-strong);
  width: 14px;
  height: 14px;
}

.filter-group__scroll {
  max-height: 14rem;
  overflow-y: auto;
  padding-right: var(--space-2);
}

.filter-group__empty {
  font-size: var(--text-small);
  color: var(--color-text-muted);
  padding: var(--space-1) 0;
}

/* ---- Product grid ----
   auto-fill + minmax(8rem, 1fr) on mobile packs in as many ~8rem-or-wider
   columns as the screen actually fits (2 on most phones, 3 on wider ones)
   instead of a fixed 2-up grid of much bigger cards; restores to the
   original fixed 3-up layout at 640px+ - see that breakpoint. */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: var(--space-4);
}

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

/* ---- Browse-by-brand view (one horizontal row per brand) ---- */
.product-grid--grouped {
  display: block;
  min-width: 0;
}

.plp-brands {
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
  min-width: 0;
}

.plp-brand-row {
  min-width: 0;
  overflow: clip;            /* nothing here can push the page sideways */
  border-top: 1px solid var(--color-hairline, var(--color-border));
  padding-top: var(--space-5);
  /* Skip layout + paint for rows that aren't near the viewport - keeps
     scrolling smooth on a category page with 20-30 brand rails. The
     intrinsic size is a rough placeholder so the scrollbar doesn't jump. */
  content-visibility: auto;
  contain-intrinsic-size: auto 24rem;
}
.plp-brand-row:first-child {
  border-top: none;
  padding-top: 0;
}

.plp-brand-row__head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-bottom: var(--space-3);
}

.plp-brand-row__head h2 {
  font-family: var(--font-display);
  font-size: var(--text-h3);
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.plp-brand-row__head h2 a {
  color: inherit;
}
.plp-brand-row__head h2 a:hover {
  color: var(--color-accent-strong);
}

.plp-brand-row__head h2 span {
  font-family: var(--font-body);
  font-size: var(--text-label);
  color: var(--color-text-muted);
  letter-spacing: var(--tracking-wide);
}

.plp-brand-row__all {
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--color-accent-strong);
  white-space: nowrap;
}
.plp-brand-row__all:hover {
  text-decoration: underline;
}

.plp-brand-row__track {
  display: flex;
  gap: var(--space-4);
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;   /* horizontal overscroll doesn't chain to the page */
  scroll-snap-type: x proximity;    /* proximity, not mandatory - far less scroll jank */
  padding-bottom: var(--space-3);
  scrollbar-width: thin;
  scrollbar-color: var(--color-warm-neutral) transparent;
}

.plp-brand-row__track > .product-card {
  flex: 0 0 9.5rem;
  scroll-snap-align: start;
}

.plp-brand-row__more {
  flex: 0 0 6rem;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px dashed var(--color-border);
  background: var(--color-surface);
  font-family: var(--font-display);
  font-size: var(--text-h3);
  color: var(--color-text);
  text-decoration: none;
}
.plp-brand-row__more span {
  font-family: var(--font-body);
  font-size: var(--text-label);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.plp-brand-row__more:hover {
  border-color: var(--color-accent-strong);
}

@media (min-width: 640px) {
  .plp-brand-row__track > .product-card { flex-basis: 12rem; }
  .plp-brand-row__more { flex-basis: 7rem; }
  .plp-brand-row__head {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-1) var(--space-4);
  }
  .plp-brand-row__head h2 { font-size: var(--text-h2); }
}

.plp-empty {
  padding: var(--space-9) var(--space-5);
  text-align: center;
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border);
}

.plp-empty p:first-child {
  font-family: var(--font-display);
  font-size: var(--text-h3);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.plp-empty .btn {
  margin-top: var(--space-6);
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-7);
}

.pagination button {
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--color-border);
  font-size: var(--text-small);
}

.pagination button:hover {
  border-color: var(--color-accent-strong);
  color: var(--color-accent-strong);
}

.pagination button[aria-current="true"] {
  background: var(--color-black);
  border-color: var(--color-black);
  color: var(--color-off-white);
}

/* ---- Compare checkbox (on product cards) ---- */
.compare-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-size: var(--text-label);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-muted);
  cursor: pointer;
}

.compare-check input {
  accent-color: var(--color-accent-strong);
  width: 15px;
  height: 15px;
}

/* ---- Compare tray (floating, appears once 1+ items selected) ---- */
.compare-tray {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-header);
  background: var(--color-black);
  color: var(--color-off-white);
  box-shadow: 0 -8px 24px rgba(11, 10, 8, 0.2);
}

.compare-tray[hidden] {
  display: none;
}

.compare-tray__inner {
  max-width: var(--container-max);
  margin-inline: auto;
  padding: var(--space-4) var(--container-pad);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

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

.compare-tray__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-charcoal);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-small);
}

.compare-tray__chip button {
  color: var(--color-warm-neutral);
  font-size: var(--text-body-lg);
  line-height: 1;
}

.compare-tray__actions {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.compare-tray__actions .text-link {
  color: var(--color-warm-neutral);
}

.btn--disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

/* ==========================================================================
   Breakpoints
   ========================================================================== */

@media (min-width: 640px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-5);
  }
}

@media (min-width: 1024px) {
  .plp-layout {
    grid-template-columns: 16.5rem minmax(0, 1fr);
    gap: var(--space-8);
  }

  .filters {
    position: sticky;
    inset: auto;
    top: calc(var(--sticky-top-height, var(--header-height)) + var(--space-6));
    align-self: start;
    max-height: calc(100vh - var(--sticky-top-height, var(--header-height)) - var(--space-8));
    width: auto;
    z-index: 1;
    background: transparent;
    box-shadow: none;
    padding: 0 var(--space-5) 0 0;
    transform: none;
    visibility: visible;
    transition: none;
  }

  .filter-toggle {
    display: none;
  }

  .filters__close {
    display: none;
  }

  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
  }
}

@media (min-width: 1280px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-7);
  }
}

@media (min-width: 1600px) {
  .product-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
