/* ---- Sidebar & Filters ---- */
.catalog-sidebar {
  position: sticky;
  top: 148px;
  align-self: start;
  max-height: calc(100vh - 170px);
  overflow: auto;
  padding-right: 18px;
}

.catalog-filter-head {
  display: block;
}

.catalog-filter-head h2 {
  display: none;
}

.catalog-filter-head button {
  display: none;
}

.catalog-sidebar section {
  border-bottom: 1px solid rgba(195, 198, 214, 0.45);
  padding: 0 0 28px;
  margin-bottom: 28px;
}

.catalog-sidebar h3 {
  font-family: var(--cat-display);
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 18px;
}

.catalog-category {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--cat-muted);
  font-size: 17px;
  font-weight: 600;
  padding: 8px 0;
  transition: color 0.15s ease;
}

.catalog-category:hover {
  color: var(--cat-primary);
}

.catalog-category:active {
  color: var(--cat-primary);
  opacity: 0.7;
}

.catalog-category.is-open {
  color: var(--cat-primary);
  font-weight: 900;
}

.catalog-category-filter {
  position: sticky;
  top: 0;
  z-index: 2;
  width: 100%;
  border: 1px solid var(--cat-line);
  border-radius: 8px;
  background: var(--cat-surface);
  color: inherit;
  font-size: 15px;
  padding: 9px 12px;
  margin: 0 0 14px;
}

.catalog-category-filter:focus {
  outline: none;
  border-color: var(--cat-primary);
}

.catalog-category-list {
  display: flex;
  flex-direction: column;
}

.catalog-category-empty {
  color: var(--cat-muted);
  font-size: 14px;
  margin: 4px 0;
}

.catalog-category-wrap + .catalog-category-wrap {
  border-top: 1px solid rgba(195, 198, 214, 0.3);
}

.catalog-category-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  transition: background-color 0.15s ease;
}

.catalog-category-row:hover {
  background: var(--cat-low);
}

.catalog-category-row:active {
  background: var(--cat-line);
}

.catalog-category-row .catalog-category {
  width: auto;
  flex: 1;
  justify-content: flex-start;
}

.catalog-category-toggle,
.catalog-category-leaf-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--cat-muted);
}

.catalog-category-toggle {
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.catalog-category-toggle:hover {
  background: var(--cat-low);
  color: var(--cat-primary);
}

.catalog-category-toggle:active {
  background: var(--cat-line);
}

.catalog-subcats {
  display: grid;
  gap: 2px;
  margin: 4px 0 8px;
  padding-left: 18px;
}

.catalog-subcats a {
  display: block;
  color: var(--cat-muted);
  border-radius: 6px;
  padding: 6px 8px;
  margin: 0 -8px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.catalog-subcats a:hover {
  background: var(--cat-low);
  color: var(--cat-primary);
}

.catalog-subcats a:active {
  background: var(--cat-line);
}

.catalog-subcats .is-active {
  color: var(--cat-primary);
  font-weight: 900;
}

.catalog-range {
  width: 100%;
  accent-color: var(--cat-primary);
}

.catalog-range-values {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
}

.catalog-range-values span {
  border: 1px solid var(--cat-line);
  border-radius: 6px;
  background: var(--cat-low);
  padding: 7px 14px;
}

.catalog-sidebar label {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--cat-muted);
  font-size: 17px;
  margin: 12px 0;
}

.catalog-sidebar input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--cat-primary);
}

.catalog-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--cat-gold);
  padding: 0;
}

/* ---- Toolbar (Mobile) ---- */
.catalog-toolbar {
  display: none;
}

.catalog-filter-scrim {
  display: none;
}

@media (max-width: 760px) {
  :root {
    --catalog-filter-top-offset: 136px;
    --catalog-filter-bottom-offset: 64px;
  }

  .catalog-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    width: min(86vw, 360px);
    height: calc(100vh - var(--catalog-filter-top-offset) - var(--catalog-filter-bottom-offset) - env(safe-area-inset-bottom));
    height: calc(100dvh - var(--catalog-filter-top-offset) - var(--catalog-filter-bottom-offset) - env(safe-area-inset-bottom));
    margin-top: var(--catalog-filter-top-offset);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    background: #fff;
    box-shadow: 20px 0 50px rgba(25, 27, 35, 0.18);
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    padding: 18px 18px 24px;
  }

  .catalog-sidebar.is-open {
    transform: translateX(0);
  }

  .catalog-filter-head {
    position: sticky;
    top: 0;
    z-index: 3;
    height: 56px;
    background: #fff;
    margin: -18px -18px 0;
    padding: 18px 18px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .catalog-category-filter {
    top: 56px;
  }

  .catalog-filter-head h2 {
    display: block;
    font-family: var(--cat-display);
    font-size: 28px;
    font-weight: 900;
  }

  .catalog-filter-head button {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: var(--cat-low);
  }

  .catalog-filter-scrim {
    position: fixed;
    top: 0;
    right: 0;
    bottom: auto;
    left: 0;
    z-index: 90;
    height: calc(100vh - var(--catalog-filter-top-offset) - var(--catalog-filter-bottom-offset) - env(safe-area-inset-bottom));
    height: calc(100dvh - var(--catalog-filter-top-offset) - var(--catalog-filter-bottom-offset) - env(safe-area-inset-bottom));
    margin-top: var(--catalog-filter-top-offset);
    background: rgba(25, 27, 35, 0.3);
  }

  .catalog-sidebar section {
    margin-bottom: 20px;
    padding-bottom: 20px;
  }

  .catalog-category-list {
    max-height: none;
    overflow-y: visible;
    padding-bottom: 12px;
  }

  body.filter-open .catalog-filter-scrim {
    display: block;
  }

  /* Without this, the page behind the drawer still scrolls on touch,
     competing with the drawer's own scroll and making it feel stuck. */
  body.filter-open {
    overflow: hidden;
  }

  .catalog-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid rgba(195, 198, 214, 0.45);
    border-bottom: 1px solid rgba(195, 198, 214, 0.45);
    padding: clamp(14px, 4vw, 22px) 0;
  }

  .catalog-toolbar > button {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 0;
    background: transparent;
    color: var(--cat-muted);
    font-size: clamp(18px, 5vw, 22px);
    font-weight: 800;
  }
}

@media (max-width: 575.98px) {
  :root {
    --catalog-filter-top-offset: 124px;
    --catalog-filter-bottom-offset: 64px;
  }
}

.catalog-sidebar .catalog-spec-filter {
  display: grid;
  gap: 8px;
}

.catalog-sidebar .catalog-spec-option small {
  color: var(--cat-muted);
  font-weight: 500;
}

.catalog-sidebar .catalog-spec-option {
  margin: 0;
}
