/* Catalog page (src/catalog.js, public/js/catalog.js): status tabs and sorting on top, filters in a sidebar on computers and
   in a bottom sheet on phones and tablets, chips of the active filters over the results. The cards: site.css. */
.cat { display: grid; grid-template-columns: 272px minmax(0, 1fr); grid-template-areas: "top top" "side main"; gap: 24px 40px; padding-bottom: 96px; }
.cat__top { grid-area: top; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.cat__top .tabs { justify-content: flex-start; }
.cat__bar { display: flex; align-items: center; gap: 8px; }
.cat__open { display: none; min-height: 44px; padding: 8px 18px 8px 14px; }
.cat__n { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--graphite); color: #fff; font-size: 12px; }
.cat__open:hover .cat__n { background: #fff; color: var(--graphite); }
.cat__side { grid-area: side; position: sticky; top: 96px; align-self: start; max-height: calc(100vh - 112px); overflow-y: auto; overscroll-behavior: contain; padding: 4px 8px 4px 4px; margin: -4px -8px -4px -4px; scrollbar-width: thin; }
.cat__main { grid-area: main; min-width: 0; }
.cat__found { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 36px; margin-bottom: 16px; }
.cat__count { color: var(--muted); font-size: 14px; font-weight: 500; }
.cat__count:focus { outline: none; }
.cat__chips { display: contents; }
.cat .grid { padding-bottom: 0; }
.cat .empty { padding: 40px 0 0; }
.empty__cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* chips of the active filters: a press removes one */
.chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 34px; padding: 4px 8px 4px 14px; border: 1px solid var(--line);
  border-radius: 999px; background: #fff; color: var(--graphite); font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip:hover { border-color: var(--graphite); }
.chip .i { width: 16px; height: 16px; color: var(--muted); }
.chip--reset { padding-inline: 4px; border-color: transparent; background: none; text-decoration: underline; text-underline-offset: 3px; }

/* the filters */
.facets { display: grid; gap: 22px; }
.facet { display: grid; gap: 10px; min-width: 0; margin: 0; padding: 0; border: 0; }
.facet__name { padding: 0; font-size: 14px; font-weight: 600; }
.facet .select, .facet .select select { width: 100%; }
.facet__out { margin-top: -6px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.fchips { display: flex; flex-wrap: wrap; gap: 6px; }
.fchip { position: relative; display: flex; }
.fchip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.fchip span { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 14px; border: 1.5px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 500; transition: background-color 0.15s, border-color 0.15s, color 0.15s; }
.fchip input:hover + span { border-color: var(--graphite); }
.fchip input:checked + span { border-color: var(--graphite); background: var(--graphite); color: #fff; }
.fchip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.facet--switch { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; cursor: pointer; }

/* two sliders on one track; the part between the thumbs is painted (--lo, --hi: 0…1, set by catalog.js) */
.dual { position: relative; height: 28px; }
.dual::before {
  content: ""; position: absolute; left: 12px; right: 12px; top: 12px; height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, var(--mist-2) calc(var(--lo, 0) * 100%), var(--graphite) 0 calc(var(--hi, 1) * 100%), var(--mist-2) 0);
}
.dual input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; background: none; -webkit-appearance: none; appearance: none; pointer-events: none; }
.dual input::-webkit-slider-runnable-track { height: 28px; background: none; }
.dual input::-moz-range-track { background: none; }
.dual input::-webkit-slider-thumb {
  -webkit-appearance: none; box-sizing: border-box; width: 24px; height: 24px; margin-top: 2px; border: 2px solid var(--graphite);
  border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(15, 17, 20, 0.18); cursor: grab; pointer-events: auto;
}
.dual input::-moz-range-thumb { box-sizing: border-box; width: 24px; height: 24px; border: 2px solid var(--graphite); border-radius: 50%; background: #fff; cursor: grab; pointer-events: auto; }
.dual input:focus-visible { outline: none; }
.dual input:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--focus); outline-offset: 2px; }
.dual input:focus-visible::-moz-range-thumb { outline: 2px solid var(--focus); outline-offset: 2px; }
.is-high .dual input:first-child { z-index: 1; }

/* phones and tablets: the filters live in a bottom sheet, a sticky bar opens it */
.fsheet { width: min(560px, 100%); max-width: 100%; max-height: min(88vh, 100%); margin: auto auto 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.fsheet[open] { display: flex; flex-direction: column; animation: sheet-up 0.3s cubic-bezier(0.2, 0.7, 0.2, 1); }
.fsheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 12px 22px; border-bottom: 1px solid var(--line); }
.fsheet__head h2 { font-size: 20px; }
.fsheet__head .modal__close { position: static; }
.fsheet__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 20px 22px; }
.fsheet__foot { padding: 12px 22px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
html:has(.fsheet[open]) { overflow: hidden; }

@media (max-width: 1099px) {
  .cat { display: block; }
  .cat__top { display: contents; }
  .cat__side { display: none; }
  .cat__bar {
    position: sticky; z-index: 5; top: 84px; margin: 12px calc(var(--gutter) * -1) 8px; padding: 8px var(--gutter);
    background: rgba(255, 255, 255, 0.92); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); transition: top 0.25s cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .cat__open { display: inline-flex; }
}
@media (max-width: 640px) {
  .cat__bar { top: 68px; }
  .hdr.is-away ~ main .cat__bar { top: 0; } /* the header slides away on the way down (site.js) */
  .cat__sort { flex: 1; min-width: 0; }
  .cat__sort select { width: 100%; }
}

/* a filter change: cards near the screen glide to their places (catalog.js names them only for this transition) */
html.is-filtering .ccard__media { view-transition-name: none !important; }
html.is-filtering::view-transition-group(*) { animation-duration: 0.3s; }
@media (prefers-reduced-motion: reduce) {
  .fsheet[open] { animation: none; }
}

/* Brand pages (/catalog/<brand>/, src/brand.js) and the brands' row on the catalog */
.page-head--crumbs { padding-top: 12px; }
.brandnav { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 20px; }
.brandnav a { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px; border: 1.5px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 500; text-decoration: none; }
.brandnav a:hover { border-color: var(--graphite); }
.brandnav span { color: var(--muted); }
.brand-models { padding-bottom: 32px; }
.brand-models h2 { margin-bottom: 12px; font-size: clamp(24px, 2.6vw, 32px); line-height: 1.2; }
.brand-models__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; padding: 0; list-style: none; }
.brand-models__list a { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--r-md); background: var(--mist); text-decoration: none; }
.brand-models__list a:hover b { text-decoration: underline; }
.brand-models__list span { color: var(--muted); font-size: 14px; }

/* Model pages (/catalog/<brand>/<model>/, src/brand.js): a few lines about it, what the stock says, the trims with prices */
.page-head .about { max-width: 72ch; margin-top: 12px; line-height: 1.6; }
.model-facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 16px 0 0; }
.model-facts dt { color: var(--muted); font-size: 13px; }
.model-facts dd { margin: 0; font-weight: 600; }
.model-trims { padding-bottom: 32px; }
.model-trims h2 { margin-bottom: 12px; font-size: clamp(24px, 2.6vw, 32px); line-height: 1.2; }
.model-trims__scroll { overflow-x: auto; }
.model-trims table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 15px; }
.model-trims th, .model-trims td { padding: 12px 14px 12px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.model-trims thead th { color: var(--muted); font-size: 13px; font-weight: 500; }
.model-trims tbody th { font-weight: 600; }
