/* Catalog page */
/* Everything is scoped under .pd-catalog (diecast/catalog.html). Needs pd-theme.css (:root tokens). */
.pd-catalog {
  --pd-panel: var(--pd-surface-2);   /* local alias */
  background: var(--pd-surface);
  color: var(--pd-text);
  padding-bottom: 2rem;
}
.pd-catalog a { color: inherit; }

/* Header band */
/* Header band: dusk glow + carbon weave + pulse line on the right (pd-theme.css) */
.pd-cat-hero {
  position: relative; overflow: hidden; isolation: isolate;
  background:
    var(--pd-dusk-glow),
    var(--pd-red-glow),
    var(--pd-carbon),
    var(--pd-bg);
  background-size: auto, auto, var(--pd-carbon-size), var(--pd-carbon-size), auto;
  background-position: 0 0, 0 0, var(--pd-carbon-pos), 0 0;
  border-bottom: 1px solid var(--pd-line);
  padding: 1.25rem 0 1.1rem;
}
/* The big pulse line on the right (::before glow + ::after line) is defined in pd-theme.css */
.pd-cat-admin { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.pd-cat-admin .btn { border-radius: var(--pd-radius-sm); font-size: .78rem; padding: .2rem .7rem; }
.pd-cat-hero-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pd-cat-logo {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  height: 64px; min-width: 64px; max-width: 160px;
  padding: .4rem .7rem;
  background: #fff; border-radius: var(--pd-radius-sm);
}
.pd-cat-logo img { max-height: 100%; max-width: 100%; object-fit: contain; }
.pd-cat-hero-text { flex: 1 1 14rem; min-width: 0; }
.pd-cat-eyebrow {
  display: inline-flex; align-items: center; gap: .55rem;
  color: var(--pd-silver); font-family: var(--pd-font-display);
  font-size: .95rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  margin: 0 0 .15rem;
}
.pd-cat-eyebrow::before { content: ""; flex: 0 0 auto; width: 2.15rem; height: 1em;   /* pulse from the logo */
  background: var(--pd-accent);
  -webkit-mask: var(--pd-pulse-mask) center / 100% 100% no-repeat;
          mask: var(--pd-pulse-mask) center / 100% 100% no-repeat; }
.pd-cat-title {
  color: #fff; font-family: var(--pd-font-display); font-style: italic; font-weight: 800;
  text-transform: uppercase; letter-spacing: .01em; margin: 0;
  font-size: clamp(1.8rem, 5vw, 3rem); line-height: 1;
}
.pd-cat-meta { margin: .3rem 0 0; color: var(--pd-text-2); font-size: .95rem; }
.pd-cat-count { color: var(--pd-accent-text); font-weight: 700; }
.pd-cat-castings {
  flex: 0 1 auto;
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .55rem .95rem;
  background: var(--pd-panel); border: 1px solid var(--pd-line); border-radius: var(--pd-radius-sm);
  color: var(--pd-text) !important; text-decoration: none; font-weight: 600; font-size: .9rem;
  transition: border-color .2s ease, color .2s ease;
}
.pd-cat-castings:hover, .pd-cat-castings:focus-visible { border-color: var(--pd-accent); color: var(--pd-accent-text) !important; }
.pd-cat-castings-new {
  background: var(--pd-accent-2); color: var(--pd-bg);  /* rust/amber secondary accent */
  border-radius: var(--pd-radius-sm); padding: .1rem .5rem;
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
}
.pd-cat-castings i { transition: transform .2s ease; }
.pd-cat-castings:hover i { transform: translateX(3px); }

/* Toolbar (sticky) */
.pd-cat-toolbar {
  position: sticky; top: 0; z-index: 1020;
  background: rgba(21, 23, 26, .96);  /* --pd-surface */
  border-bottom: 1px solid var(--pd-line);
  padding: .65rem 0;
}
/* Raised while the mobile sheet is open so sheet + backdrop sit above the page */
.pd-cat-toolbar.is-sheet-open { z-index: 1057; }
@media (min-width: 992px) {
  /* desktop only: backdrop-filter would trap the fixed mobile sheet */
  .pd-cat-toolbar { backdrop-filter: blur(6px); }
}
.pd-cat-searchrow { display: flex; align-items: center; gap: .5rem; }
.pd-cat-search { position: relative; flex: 1 1 auto; min-width: 0; }
.pd-cat-search .bi-search {
  position: absolute; left: .85rem; top: 50%; transform: translateY(-50%);
  color: var(--pd-muted); pointer-events: none; font-size: .9rem;
}
.pd-cat-search .form-control {
  height: 2.5rem; padding-left: 2.25rem;
  background: var(--pd-bg); border: 1px solid var(--pd-line-2); border-radius: var(--pd-radius-sm);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .5);
  color: var(--pd-text); font-size: 16px; /* no iOS zoom */
}
.pd-cat-search .form-control::placeholder { color: var(--pd-muted); }
.pd-cat-search .form-control:focus {
  background: var(--pd-surface-2); border-color: var(--pd-accent); color: #fff;
  box-shadow: 0 0 0 .2rem rgba(var(--pd-accent-rgb), .3);
}

/* Buttons (squared, technical) */
.pd-cat-btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  height: 2.5rem; padding: 0 1rem;
  background: var(--pd-panel); color: var(--pd-text) !important;
  border: 1px solid var(--pd-line-2); border-radius: var(--pd-radius-sm);
  font-weight: 700; font-size: .9rem; text-decoration: none; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.pd-cat-btn:hover, .pd-cat-btn:focus-visible { border-color: var(--pd-accent); color: var(--pd-accent-text) !important; }
.pd-cat-btn--accent { background: transparent; border-color: var(--pd-accent); color: var(--pd-accent-text) !important; }
.pd-cat-btn--accent:hover, .pd-cat-btn--accent:focus-visible { background: var(--pd-accent); color: var(--pd-accent-contrast) !important; }
.pd-cat-badge {
  min-width: 1.3rem; height: 1.3rem; padding: 0 .35rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--pd-accent); color: var(--pd-accent-contrast); border-radius: var(--pd-radius-sm);
  font-size: .72rem; font-weight: 800;
}
.pd-cat-badge[hidden] { display: none; }
.pd-cat-filters-toggle { display: none; }

/* Filter row */
.pd-cat-filters { margin-top: .6rem; }
.pd-cat-sheet-head, .pd-cat-sheet-foot { display: none; }
.pd-cat-filter-body { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

.pd-cat-pop { position: relative; }
.pd-cat-pill {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: .4rem;
  min-height: 2.1rem; padding: .3rem .85rem;
  background: var(--pd-panel); border: 1px solid var(--pd-line); border-radius: var(--pd-radius-sm);
  color: var(--pd-text); font-size: .85rem; font-weight: 600;
  transition: border-color .15s ease, color .15s ease;
}
.pd-cat-pill::-webkit-details-marker { display: none; }
.pd-cat-pill:hover, .pd-cat-pill:focus-visible, .pd-cat-pop[open] > .pd-cat-pill { border-color: var(--pd-accent); color: var(--pd-accent-text); }
.pd-cat-pill .bi-chevron-down { font-size: .7rem; transition: transform .15s ease; }
.pd-cat-pop[open] > .pd-cat-pill .bi-chevron-down { transform: rotate(180deg); }
.pd-cat-pop.has-value > .pd-cat-pill { border-color: rgba(var(--pd-accent-rgb), .6); }
.pd-cat-pill-n:empty { display: none; }
.pd-cat-pill-n {
  background: var(--pd-accent); color: var(--pd-accent-contrast); border-radius: var(--pd-radius-sm);
  padding: 0 .4rem; font-size: .72rem; font-weight: 800; line-height: 1.25rem;
}
.pd-cat-pop-panel {
  position: absolute; top: calc(100% + .4rem); left: 0; z-index: 1030;
  width: min(20rem, 90vw);
  background: var(--pd-surface-2); border: 1px solid var(--pd-line); border-top: 2px solid var(--pd-accent); border-radius: var(--pd-radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .55);
  padding: .5rem;
}
.pd-cat-pop-find {
  margin-bottom: .4rem;
  background: var(--pd-panel) !important; border-color: var(--pd-line-2) !important; color: var(--pd-text) !important;
  border-radius: var(--pd-radius-sm); font-size: 16px;
}
.pd-cat-pop-find:focus { border-color: var(--pd-accent) !important; box-shadow: 0 0 0 .2rem rgba(var(--pd-accent-rgb), .2); }
.pd-cat-checks { max-height: 18rem; overflow-y: auto; overscroll-behavior: contain; }
.pd-cat-check {
  display: flex; align-items: center; gap: .55rem;
  padding: .4rem .5rem; margin: 0;
  border-radius: .45rem; cursor: pointer; font-size: .9rem; color: var(--pd-text-2);
}
.pd-cat-check:hover { background: var(--pd-accent-soft); color: #fff; }
.pd-cat-check[hidden] { display: none; }
.pd-cat-check input { accent-color: var(--pd-accent); width: 1rem; height: 1rem; flex: 0 0 auto; }
.pd-cat-check-name { flex: 1 1 auto; min-width: 0; }
.pd-cat-check-n { color: var(--pd-muted); font-size: .78rem; }

.pd-cat-selects { display: flex; flex-wrap: wrap; gap: .5rem; margin-left: auto; }
.pd-cat-select {
  display: inline-flex; align-items: center; gap: .35rem; margin: 0;
  color: var(--pd-muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
}
.pd-cat-select .form-select {
  width: auto; min-height: 2.1rem;
  background-color: var(--pd-panel); color: var(--pd-text);
  border: 1px solid var(--pd-line); border-radius: var(--pd-radius-sm);
  font-size: .85rem; font-weight: 600; text-transform: none; letter-spacing: 0;
  padding-left: .85rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23cfcfcf' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}
.pd-cat-select .form-select:focus { border-color: var(--pd-accent); box-shadow: 0 0 0 .2rem rgba(var(--pd-accent-rgb), .2); }
.pd-cat-select .form-select option { background: var(--pd-surface-2); color: var(--pd-text); }

/* Active chips */
.pd-cat-chips { display: flex; align-items: center; gap: .5rem; margin-top: .6rem; }
.pd-cat-chips[hidden] { display: none; }
.pd-cat-chips-list {
  display: flex; gap: .4rem; flex: 0 1 auto; min-width: 0;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.pd-cat-chips-list::-webkit-scrollbar { display: none; }
.pd-cat-chip {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .35rem .2rem .7rem;
  background: var(--pd-accent-soft); border: 1px solid rgba(var(--pd-accent-rgb), .45); border-radius: var(--pd-radius-sm);
  color: var(--pd-text); font-size: .8rem; font-weight: 600; white-space: nowrap;
}
.pd-cat-chip-k { color: var(--pd-accent-text); font-weight: 700; }
.pd-cat-chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.4rem; height: 1.4rem; padding: 0;
  background: transparent; border: 0; border-radius: 50%; color: inherit;
}
.pd-cat-chip-x:hover, .pd-cat-chip-x:focus-visible { background: rgba(var(--pd-accent-rgb), .3); color: #fff; }
.pd-cat-clear-link {
  flex: 0 0 auto; color: var(--pd-accent-text) !important;
  font-size: .82rem; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.pd-cat-clear-link:hover { text-decoration: underline; }

/* Results */
.pd-cat-main { padding-top: 1rem; }
#pd-catalog-results { position: relative; transition: opacity .2s ease; min-height: 12rem; }
#pd-catalog-results.is-loading { opacity: .45; pointer-events: none; }
#pd-catalog-results.is-loading::after {
  content: ""; position: absolute; top: 4rem; left: 50%;
  width: 38px; height: 38px; margin-left: -19px;
  border: 3px solid rgba(var(--pd-accent-rgb), .25); border-top-color: var(--pd-accent);
  border-radius: 50%; animation: pd-cat-spin .8s linear infinite;
}
@keyframes pd-cat-spin { to { transform: rotate(360deg); } }
.pd-cat-resultbar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding-bottom: .6rem; margin-bottom: 1rem; border-bottom: 1px solid var(--pd-line);
  color: var(--pd-text-2); font-size: .9rem;
}
.pd-cat-resultcount strong { color: #fff; }
.pd-cat-filtered { color: var(--pd-accent-text); }
.pd-cat-pageof { color: var(--pd-muted); font-size: .85rem; }
.pd-cat-empty {
  text-align: center; padding: 3rem 1rem;
  background: var(--pd-panel); border: 1px dashed var(--pd-line-2); border-radius: var(--pd-radius); color: var(--pd-text-2);
}
.pd-cat-empty i { font-size: 2rem; color: var(--pd-accent-text); display: block; margin-bottom: .5rem; }

/* Card styling now lives in pd-cards.css (v2, dark + collection colors) */

/* Pagination */
.pd-cat-pager {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .6rem;
  margin: 1rem 0 2rem;
}
.pd-cat-pages { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; list-style: none; margin: 0; padding: 0; }
.pd-cat-page {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.4rem; height: 2.4rem; padding: 0 .6rem;
  background: var(--pd-panel); border: 1px solid var(--pd-line); border-radius: var(--pd-radius-sm);
  color: var(--pd-text) !important; font-weight: 700; font-size: .9rem; text-decoration: none;
  transition: border-color .15s ease, color .15s ease;
}
.pd-cat-page:hover, .pd-cat-page:focus-visible { border-color: var(--pd-accent); color: var(--pd-accent-text) !important; }
/* Current page = race number plate (white plate, black number) */
.pd-cat-page.is-active {
  background: #fff; border-color: #fff; color: var(--pd-bg) !important;
  font-family: var(--pd-font-display); font-style: italic; font-weight: 800; font-size: 1.05rem;
  box-shadow: inset 0 0 0 2px var(--pd-bg), 0 0 0 1px #fff;
}
.pd-cat-goto { margin: 0; }
.pd-cat-goto .form-select {
  width: auto; height: 2.4rem;
  background-color: var(--pd-panel); color: var(--pd-text);
  border: 1px solid var(--pd-line); border-radius: var(--pd-radius-sm); font-size: .85rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23cfcfcf' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}
.pd-cat-goto .form-select option { background: var(--pd-surface-2); color: var(--pd-text); }

.pd-cat-backdrop { display: none; }

/* Mobile / tablet: filters become a bottom sheet (only once JS is running;
   without JS they stay inline so they remain reachable). */
@media (max-width: 991.98px) {
  .pd-catalog.is-js .pd-cat-filters-toggle { display: inline-flex; }
  .pd-catalog.is-js .pd-cat-searchrow .pd-cat-btn--accent { padding: 0 .85rem; }

  .pd-catalog.is-js .pd-cat-filters {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1056;
    max-height: 85vh; margin: 0;
    display: flex; flex-direction: column;
    background: var(--pd-surface); border-top: 1px solid var(--pd-line);
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .6);
    transform: translateY(105%); visibility: hidden;
    transition: transform .25s ease, visibility 0s linear .25s;
  }
  .pd-catalog.is-js .pd-cat-filters.is-open {
    transform: none; visibility: visible;
    transition: transform .25s ease, visibility 0s;
  }
  .pd-catalog.is-js .pd-cat-sheet-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: .8rem 1rem; border-bottom: 1px solid var(--pd-line);
  }
  .pd-cat-sheet-close {
    width: 2.2rem; height: 2.2rem; border-radius: 50%;
    background: var(--pd-panel); border: 1px solid var(--pd-line-2); color: var(--pd-text);
  }
  .pd-catalog.is-js .pd-cat-filter-body {
    flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
    flex-direction: column; align-items: stretch; flex-wrap: nowrap;
    padding: .75rem 1rem;
  }
  .pd-catalog.is-js .pd-cat-sheet-foot {
    display: flex; gap: .5rem; padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--pd-line);
  }
  .pd-catalog.is-js .pd-cat-sheet-foot .pd-cat-btn { flex: 1 1 0; }

  /* In the sheet, filter panels expand inline */
  .pd-cat-pop > .pd-cat-pill { display: flex; width: 100%; min-height: 2.6rem; }
  .pd-cat-pill .bi-chevron-down { margin-left: auto; }
  .pd-cat-pop-panel { position: static; width: auto; margin-top: .4rem; box-shadow: none; }
  .pd-cat-checks { max-height: 40vh; }
  .pd-cat-selects { margin-left: 0; display: grid; grid-template-columns: 1fr 1fr; }
  .pd-cat-select { flex-direction: column; align-items: stretch; }
  .pd-cat-select .form-select { width: 100%; min-height: 2.6rem; font-size: 16px; }

  .pd-catalog.is-js .pd-cat-backdrop:not([hidden]) {
    display: block; position: fixed; inset: 0; z-index: 1055;
    background: rgba(0, 0, 0, .6);
  }
}
@media (max-width: 575.98px) {
  .pd-cat-logo { height: 48px; min-width: 48px; max-width: 110px; }
  .pd-cat-castings { width: 100%; border-radius: var(--pd-radius); }
  .pd-cat-page { min-width: 2.2rem; height: 2.2rem; }
}
body.pd-cat-sheet-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .pd-cat-btn, .pd-cat-pill, .pd-cat-page, .pd-cat-castings, .pd-cat-castings i,
  .pd-cat-pill .bi-chevron-down, #pd-catalog-results { transition: none !important; }
  .pd-cat-castings:hover i { transform: none; }
  .pd-catalog.is-js .pd-cat-filters, .pd-catalog.is-js .pd-cat-filters.is-open { transition: none !important; }
  #pd-catalog-results.is-loading::after { animation: none; }
}
