/* ============================================================
   DUCKIT — catalog page only.
   Hero = oversized count over a carbon crop; body = sticky chassis
   filter over a dense card grid.
   ============================================================ */

/* ------------------------------------------------------------ hero */

.chero {
  position: relative;
  min-height: var(--band-h);
  display: grid;
  align-items: end;
  isolation: isolate;
}
.chero__media { position: absolute; inset: 0; z-index: -2; }
.chero__media img { width: 100%; height: 100%; object-fit: cover; }
.chero::before {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(10,10,11,0.72) 0%, rgba(10,10,11,0.40) 38%, rgba(10,10,11,0.95) 88%, var(--ink) 100%),
    linear-gradient(90deg, rgba(10,10,11,0.72), transparent 70%);
}
.chero__in { padding-block: clamp(44px, 6vw, 88px); }
.chero__h { font-size: clamp(2rem, 1.2rem + 3vw, 3.5rem); margin: 16px 0 20px; letter-spacing: -0.03em; }
.chero__n {
  color: var(--torch);
  font-size: clamp(3rem, 1.6rem + 6vw, 6.5rem);
  display: inline-block;
  line-height: 0.86;
  letter-spacing: -0.04em;
}
.chero__p { color: rgba(255, 255, 255, 0.84); max-width: 44ch; font-size: var(--t-md); }

/* ------------------------------------------------------------ sticky filter */

.cat { padding-bottom: var(--sec-y); }

/* Car on the left, everything about the part on the right. Both narrow the
   same grid, and either can be used on its own.
   .cat__panel is display:contents here so the rail and the filter bar land in
   the grid directly; on a phone it stops being transparent and becomes the
   sheet that holds them both. */
.cat__in {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0 clamp(20px, 2.4vw, 38px);
  padding-top: clamp(20px, 2.4vw, 32px);
}
.cat__panel, .cat__sheet-body { display: contents; }
/* the part filters run full width across the top — beside the 232px rail the
   33 categories and 41 styles were losing a chunk of the row to a scrollbar */
.cat__bar   { grid-column: 1 / -1; grid-row: 1; }
.cat__rail  { grid-column: 1; grid-row: 2; }
.cat__main  { grid-column: 2; grid-row: 2; min-width: 0; }
/* phone-only furniture */
.cat__mbar, .cat__sheet-head, .cat__sheet-foot, .cat__scrim { display: none; }

/* ---- left rail: marque -> series -> chassis */
.cat__rail {
  position: sticky;
  /* the filter bar sticks above it, so park under whatever height it is —
     --barh is measured in site.js and re-measured on resize */
  top: calc(var(--header-h) + var(--barh, 0px) + 16px);
  align-self: start;
  max-height: calc(100svh - var(--header-h) - var(--barh, 0px) - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  border-right: 1px solid var(--line);
  padding-right: 14px;
}
.cat__rail-h {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mute-dim);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.tree, .tree__kids { list-style: none; }
.tree__kids { margin-left: 12px; border-left: 1px solid var(--line); }
.tree__kids[hidden] { display: none; }

/* disclosure arrow on the nodes that have a branch under them */
.tw__chev { display: grid; flex: none; color: var(--mute-dim); transition: transform 0.2s var(--ease); }
.tw__chev svg { width: 14px; height: 14px; }
.tw[aria-expanded='true'] .tw__chev { transform: rotate(180deg); color: var(--torch); }

.tw {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 9px;
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  text-align: left;
  transition: color 0.16s var(--ease), background 0.16s var(--ease), border-color 0.16s var(--ease);
}
.tw__l {
  flex: 1;
  min-width: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mute);
}
.tw__s {
  font-family: var(--mono);
  font-size: 0.5625rem;
  letter-spacing: 0.06em;
  color: var(--mute-dim);
  white-space: nowrap;
}
.tw__n {
  font-family: var(--mono);
  font-size: 0.5625rem;
  letter-spacing: 0.06em;
  color: var(--mute-dim);
  flex: none;
}
/* marque sits a size up; series and chassis step down from it */
.tw--car .tw__l { font-size: 0.9375rem; color: var(--white); }
.tw--all .tw__l { font-size: 0.75rem; }
.tw--series .tw__l { font-size: 0.75rem; }
.tw--model .tw__l { font-family: var(--mono); font-weight: 500; font-size: 0.6875rem; letter-spacing: 0.1em; }
.tw:hover { background: var(--ink-3); }
.tw:hover .tw__l { color: var(--white); }
.tw[aria-pressed='true'] { border-left-color: var(--torch); background: var(--torch-dim); }
.tw[aria-pressed='true'] .tw__l { color: var(--torch); }
/* nothing catalogued under this branch yet — still selectable, the empty state
   invites the enquiry */
.tw--empty .tw__l, .tw--empty .tw__s, .tw--empty .tw__n { opacity: 0.42; }

/* ---- right column: service, category, style */
.cat__bar {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: rgba(10, 10, 11, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  margin-bottom: clamp(20px, 2.4vw, 32px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-block: 12px;
}

.cat__rows { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cat__row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cat__row[hidden] { display: none; }
.cat__lab {
  flex: none; width: 64px;
  font-family: var(--mono); font-size: 0.625rem; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--mute-dim);
}

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  /* a visible slim bar — the row scrolls, so say so */
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) rgba(255, 255, 255, 0.05);
  padding-bottom: 7px;
  flex: 1;
  min-width: 0;
}
.chips::-webkit-scrollbar { height: 6px; }
.chips::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); }
.chips::-webkit-scrollbar-thumb { background: var(--line-strong); }
.chips::-webkit-scrollbar-thumb:hover { background: var(--torch); }

.chip {
  flex: none;
  position: relative;
  display: flex;
  align-items: center;
  padding: 8px 13px;
  background: var(--ink-3);
  border: 1px solid var(--line);
  /* same fin notch as the buttons, scaled down */
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease);
}
.chip[hidden] { display: none; }
.chip__l {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
/* live result count, written by the cascade. Empty on the "All" chip. */
.chip__n {
  font-family: var(--mono);
  font-size: 0.5625rem;
  letter-spacing: 0.06em;
  color: var(--mute-dim);
  position: absolute;
  top: 4px; right: 6px;
}
.chip__n:empty { display: none; }
.chip:hover { border-color: var(--line-strong); background: var(--ink-4); }
.chip[aria-pressed='true'] { background: var(--torch); border-color: var(--torch); color: var(--ink); }
.chip[aria-pressed='true'] .chip__n { color: rgba(10, 10, 11, 0.6); }

.cat__reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--mute);
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.cat__reset svg { width: 12px; height: 12px; }
.cat__reset:hover { color: var(--torch); border-color: var(--torch); }
.cat__reset[hidden] { display: none; }

.cat__count {
  flex: none;
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
}

/* count + reset + sort, one line above the chip rows so the rows get the
   full width — with 33 categories and 41 styles they need it */
.cat__tools {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 2px;
}
.cat__tools .cat__count { margin-right: auto; }
.cat__sort { position: relative; display: inline-flex; align-items: center; }
.cat__sort select {
  appearance: none;
  -webkit-appearance: none;
  padding: 9px 34px 9px 14px;
  background: var(--ink-3);
  border: 1px solid var(--line);
  color: var(--white);
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
  cursor: pointer;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.cat__sort select:hover { border-color: var(--line-strong); background: var(--ink-4); }
.cat__sort svg { position: absolute; right: 12px; width: 15px; height: 15px; color: var(--mute); pointer-events: none; }
.cat__sort option { background: var(--ink-3); color: var(--white); }

/* ============================================================ phone
   Below 900px the whole filter panel becomes a full-screen sheet behind one
   Filter button. Three stacked horizontal scrollers is no way to shop on a
   phone; inside the sheet the chip rows wrap and the car tree stays vertical,
   which is what it wants to be anyway. */
@media (max-width: 900px) {
  .cat__in {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
  }
  .cat__main { grid-column: 1; grid-row: 2; }

  /* the sticky handle */
  .cat__mbar {
    grid-column: 1; grid-row: 1;
    position: sticky;
    top: var(--header-h);
    z-index: 41;
    display: flex;
    align-items: center;
    gap: 14px;
    padding-block: 10px;
    background: rgba(10, 10, 11, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
  }
  .cat__open {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    padding: 0 16px;
    background: var(--ink-3);
    border: 1px solid var(--line-strong);
    color: var(--white);
    font-family: var(--display);
    font-weight: 700;
    font-size: 0.8125rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
  }
  .cat__open svg { width: 17px; height: 17px; }
  .cat__badge {
    display: grid;
    place-items: center;
    min-width: 20px; height: 20px;
    padding-inline: 5px;
    background: var(--torch);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 0.6875rem;
  }
  .cat__badge[hidden] { display: none; }
  .cat__mbar .cat__count { font-size: 0.75rem; }

  /* the sheet itself */
  .cat__scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 88;
    background: rgba(10, 10, 11, 0.72);
  }
  .cat__scrim[hidden] { display: none; }
  .cat__panel {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0;
    z-index: 89;
    background: var(--ink);
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 0.28s var(--ease), visibility 0.28s;
  }
  .cat__panel.open { transform: none; visibility: visible; }

  .cat__sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: none;
    padding: 14px var(--pad-x);
    border-bottom: 1px solid var(--line);
  }
  .cat__sheet-h {
    font-family: var(--display); font-weight: 700; font-size: 1rem;
    letter-spacing: 0.06em; text-transform: uppercase;
  }
  .cat__sheet-x {
    display: grid; place-items: center;
    width: 44px; height: 44px;
    margin-right: -10px;
    background: transparent; border: 0; color: var(--white);
  }
  .cat__sheet-x svg { width: 20px; height: 20px; }

  /* rail + chip rows share ONE scroll inside the sheet — two nested scroll
     areas on a phone is a trap you can't get out of with a thumb */
  .cat__sheet-body {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .cat__rail, .cat__bar {
    grid-column: auto; grid-row: auto;
    position: static;
    align-self: stretch;
    width: auto;
    max-height: none;
    overflow: visible;
    border: 0;
    margin: 0;
    padding: 16px var(--pad-x) 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .cat__rail { border-bottom: 1px solid var(--line); padding-bottom: 14px; }
  .cat__bar  { padding-bottom: 24px; }
  .cat__rail-h { font-size: 0.6875rem; }

  /* touch-sized tree rows */
  .tw { min-height: 44px; padding: 9px 10px; }
  .tw__l { font-size: 0.875rem; }
  .tw--car .tw__l { font-size: 1rem; }
  .tw--series .tw__l, .tw--all .tw__l { font-size: 0.8125rem; }
  .tw--model .tw__l { font-size: 0.8125rem; }
  .tw__s, .tw__n { font-size: 0.6875rem; }

  /* chip rows wrap instead of scrolling sideways */
  .cat__rows { gap: 14px; }
  .cat__row { display: block; }
  .cat__lab { display: block; width: auto; margin-bottom: 7px; font-size: 0.6875rem; }
  .chips { display: flex; flex-wrap: wrap; overflow: visible; padding-bottom: 0; gap: 8px; }
  .chip { min-height: 40px; padding: 9px 14px; }
  .chip__l { font-size: 0.8125rem; }
  .chip__n { font-size: 0.6875rem; top: 3px; right: 5px; }

  /* tools move under the rows, sort full width */
  .cat__bar .cat__tools {
    order: 2;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 16px;
  }
  /* the sheet's footer already carries Reset and the live count */
  .cat__bar .cat__count, .cat__bar .cat__reset { display: none; }
  .cat__sort, .cat__sort select { width: 100%; }
  .cat__sort select { min-height: 44px; }

  .cat__sheet-foot {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    flex: none;
    padding: 12px var(--pad-x) calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--ink-2);
  }
  .cat__sheet-foot .btn { justify-content: center; min-height: 46px; }
}

/* ------------------------------------------------------------ grid */

.cat__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}
/* an author `display` beats the UA sheet's [hidden] rule, so say it explicitly —
   the car picker takes the grid's place and both were rendering */
.cat__grid[hidden] { display: none; }
@media (max-width: 1280px) { .cat__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .cat__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px)  { .cat__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
/* one card per row on a phone — at 390px two columns leave a 167px photo, which
   is too small to judge a bumper by */
@media (max-width: 560px)  { .cat__grid { grid-template-columns: minmax(0, 1fr); gap: 14px; } }

.card {
  display: flex;
  flex-direction: column;
  background: var(--ink-2);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: border-color 0.22s var(--ease), transform 0.22s var(--ease);
}
.card:hover { border-color: var(--torch); transform: translateY(-3px); }
.card[hidden] { display: none; }

.card__shot { padding: 0; display: block; position: relative; overflow: hidden; background: var(--ink-4); }
.card__shot img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  transition: transform 0.45s var(--ease);
}
.card:hover .card__shot img { transform: scale(1.06); }
.card__shot::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 62%, rgba(10, 10, 11, 0.55));
  pointer-events: none;
}

.card__body {
  padding: 14px 15px 17px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.card__plat {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--torch);
}
/* the part code above the title — 10px is fine on a monitor, not on a phone */
@media (max-width: 767px) {
  .card__plat { font-size: 0.6875rem; }
  .card__h { font-size: 1rem; }
}
.card__h {
  font-size: 0.9375rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.card__part { margin-top: auto; padding-top: 6px; font-size: var(--t-xs); color: var(--mute-dim); }

.cat__empty {
  padding: clamp(40px, 6vw, 72px) 0;
  text-align: center;
  color: var(--mute);
  font-size: var(--t-md);
}

/* ------------------------------------------------------------ pagination */

.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: clamp(36px, 5vw, 60px);
}
.pager[hidden] { display: none; }

.pager__btn {
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  background: var(--ink-3);
  border: 1px solid var(--line);
  color: var(--mute);
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.9375rem;
  letter-spacing: 0.02em;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease);
}
.pager__btn:hover { border-color: var(--line-strong); color: var(--white); background: var(--ink-4); }
.pager__btn[aria-current='true'] {
  background: var(--torch);
  border-color: var(--torch);
  color: var(--ink);
}
.pager__btn:disabled { opacity: 0.32; pointer-events: none; }
.pager__edge svg { width: 18px; height: 18px; }

/* ------------------------------------------------------------ car picker
   What the grid shows before a car is chosen. Same tiles as the rail, but
   sized to be looked at rather than scanned. */

.cat__cars[hidden] { display: none; }
.cat__cars-h {
  margin-bottom: clamp(16px, 2vw, 24px);
  color: var(--mute);
  font-size: var(--t-sm);
}
.cat__cars-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}

.carcard {
  position: relative;
  display: block;
  padding: 0;
  overflow: hidden;
  background: var(--ink-2);
  border: 1px solid var(--line);
  text-align: left;
  transition: border-color 0.22s var(--ease), transform 0.22s var(--ease);
}
.carcard:hover { border-color: var(--torch); transform: translateY(-3px); }

.carcard__media { display: block; position: relative; overflow: hidden; background: var(--ink-4); }
.carcard__media img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: transform 0.45s var(--ease);
}
.carcard:hover .carcard__media img { transform: scale(1.06); }
/* scrim so the label block reads over any photo */
.carcard__media::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg,
    transparent 28%,
    rgba(10, 10, 11, 0.45) 52%,
    rgba(10, 10, 11, 0.82) 76%,
    rgba(10, 10, 11, 0.95) 100%);
}

.carcard__body {
  position: absolute;
  inset: auto 0 0 0;
  display: block;
  padding: 13px 15px;
}
.carcard__over {
  display: block;
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--torch);
}
.carcard__h {
  display: block;
  margin-top: 4px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--white);
}
.carcard__meta {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  color: var(--mute);
}
.carcard__meta b { color: var(--white); font-weight: 500; }
/* nothing catalogued for it yet — still clickable, the empty state invites
   the enquiry, same as the rail */
.carcard--empty { opacity: 0.55; }

@media (max-width: 1280px) { .cat__cars-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .cat__cars-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px)  { .cat__cars-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
@media (max-width: 560px) {
  .cat__cars-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .carcard__h { font-size: 1.35rem; }
}
