/*
 * Directory search page.
 *
 * Filters sit above results on mobile and beside them from 900px. They are
 * never collapsed behind a toggle on mobile: the design rules require that
 * search and filter fundamentals stay visible at every width.
 */

.nbd-directory {
  padding-block: var(--nbd-space-5) var(--nbd-space-7);
}

.nbd-directory__head {
  padding-bottom: var(--nbd-space-4);
  margin-bottom: var(--nbd-space-5);
  border-bottom: var(--nbd-hairline);
}

.nbd-directory__title {
  font-size: var(--nbd-text-2xl);
  margin-bottom: var(--nbd-space-2);
}

.nbd-directory__lede {
  color: var(--nbd-muted);
  max-width: 62ch;
  margin: 0;
}

.nbd-directory__layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--nbd-space-5);
}

@media (min-width: 900px) {
  .nbd-directory__layout {
    grid-template-columns: 260px 1fr;
    gap: var(--nbd-space-6);
    align-items: start;
  }
}

/* ---------------------------------------------------------------- filters */

.nbd-filters {
  background: var(--nbd-white);
  border: var(--nbd-hairline);
  border-radius: var(--nbd-radius);
  padding: var(--nbd-space-4);
}

@media (min-width: 900px) {
  .nbd-filters {
    position: sticky;
    top: var(--nbd-space-4);
    /* Long facet lists must not trap the page scroll. */
    max-height: calc(100vh - var(--nbd-space-6));
    overflow-y: auto;
  }
}

.nbd-filters__title {
  font-size: var(--nbd-text-base);
  padding-bottom: var(--nbd-space-2);
  margin-bottom: var(--nbd-space-3);
  border-bottom: var(--nbd-hairline);
}

.nbd-filters__field { margin-bottom: var(--nbd-space-4); }

.nbd-filters__label,
.nbd-filters__legend {
  display: block;
  font-size: var(--nbd-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--nbd-muted);
  margin-bottom: var(--nbd-space-2);
  padding: 0;
}

.nbd-filters input[type="search"],
.nbd-filters select {
  width: 100%;
  min-height: 44px;
  padding: var(--nbd-space-2) var(--nbd-space-3);
  border: 1px solid var(--nbd-border-strong);
  border-radius: var(--nbd-radius);
  background: var(--nbd-white);
  color: var(--nbd-ink);
  font-family: inherit;
  font-size: var(--nbd-text-sm);
}

.nbd-filters__group {
  border: 0;
  padding: 0;
  margin: 0 0 var(--nbd-space-4);
}

/* ------------------------------------------------- collapsible facet groups */

/* Long facets (country is 49 entries) render as <details>. Without this a
   mobile visitor scrolled the entire list before reaching a single result. */
.nbd-filters__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--nbd-space-2);
  min-height: 44px;
  cursor: pointer;
  margin-bottom: 0;
  /* The default triangle is tiny and inconsistent across browsers; the row
     itself is the affordance and it carries its own marker below. */
  list-style: none;
}

.nbd-filters__summary::-webkit-details-marker { display: none; }

.nbd-filters__summary::after {
  content: "+";
  font-family: var(--nbd-font-mono);
  font-size: var(--nbd-text-base);
  font-weight: 400;
  color: var(--nbd-ink);
}

.nbd-filters__group--collapsible[open] > .nbd-filters__summary::after {
  content: "–";
}

.nbd-filters__summary:focus-visible {
  outline: 2px solid var(--nbd-red);
  outline-offset: 2px;
}

/* Cap the height of a long open list so the filters panel never becomes taller
   than the results it filters. */
.nbd-filters__group--collapsible .nbd-filters__options {
  max-height: 260px;
  overflow-y: auto;
  padding-top: var(--nbd-space-2);
}

.nbd-filters__check {
  display: flex;
  align-items: center;
  gap: var(--nbd-space-2);
  /* 36px rather than 44: these are stacked rows where the label is also the
     target, so the effective hit area spans the full row width. */
  min-height: 36px;
  font-size: var(--nbd-text-sm);
  cursor: pointer;
}

.nbd-filters__check input {
  width: 18px;
  height: 18px;
  accent-color: var(--nbd-red);
  flex: none;
}

.nbd-filters__count {
  margin-left: auto;
  color: var(--nbd-muted);
  font-family: var(--nbd-font-mono);
  font-size: var(--nbd-text-xs);
}

.nbd-filters__actions {
  display: flex;
  align-items: center;
  gap: var(--nbd-space-2);
  padding-top: var(--nbd-space-3);
  margin: 0;
  border-top: var(--nbd-hairline);
}

/* ---------------------------------------------------------------- results */

.nbd-activefilters {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--nbd-space-2);
  margin-bottom: var(--nbd-space-3);
}

.nbd-activefilters__label {
  font-size: var(--nbd-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--nbd-muted);
}

.nbd-chip--active {
  border-color: var(--nbd-red-deep);
  color: var(--nbd-red-deep);
}

.nbd-chip__remove {
  font-size: var(--nbd-text-base);
  line-height: 1;
  color: var(--nbd-red-deep);
}

.nbd-directory__count {
  font-family: var(--nbd-font-mono);
  font-size: var(--nbd-text-sm);
  color: var(--nbd-muted);
  padding-bottom: var(--nbd-space-3);
  margin-bottom: var(--nbd-space-4);
  border-bottom: var(--nbd-hairline);
}

@media (min-width: 1000px) {
  /* Two columns inside the results pane, since the filter rail already
     consumes horizontal space. */
  .nbd-grid--results { grid-template-columns: repeat(2, 1fr); }
}

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

.nbd-pagination {
  margin-top: var(--nbd-space-5);
  padding-top: var(--nbd-space-4);
  border-top: var(--nbd-hairline);
}

.nbd-pagination__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--nbd-space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nbd-pagination__link,
.nbd-pagination__current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--nbd-space-2);
  border: var(--nbd-hairline);
  border-radius: var(--nbd-radius);
  font-size: var(--nbd-text-sm);
  font-weight: 600;
  text-decoration: none;
}

.nbd-pagination__link {
  background: var(--nbd-white);
  color: var(--nbd-ink);
}

.nbd-pagination__link:hover,
.nbd-pagination__link:focus-visible {
  border-color: var(--nbd-ink);
  color: var(--nbd-ink);
}

.nbd-pagination__current {
  background: var(--nbd-red);
  border-color: var(--nbd-red);
  color: var(--nbd-white);
}
