/*
 * Publications listing: the cards on the Publications page, and the page
 * layout around them.
 *
 * The page's content region is a grid in the theme's main.css
 * (scss/views/_view_publications_indexed_search_api_facets.scss): three
 * columns at every width, with the filters on the left and the sort and the
 * cards on the right. The rules here add :has(.publications-listing) to win
 * over those, as main.css loads after component CSS. They:
 *
 * - give the search bar (the listing-search component) a row of its own
 *   above the filters and the cards, on wide screens;
 * - stack the search bar, filters, sort and cards below 992px, as on the
 *   search page;
 * - size the cards. Masonry takes its column width from the first card (the
 *   view's column width is the ".masonry-item" selector), so these widths
 *   set the columns: two, or one on phones. From 1200px, two columns are
 *   342px wide, as before.
 */

/* Wide screens: the search bar's row, across all three columns. */
@media (min-width: 992px) {
  .region-content:has(.view-publications-indexed-search-api-facets):has(.publications-listing):has(.listing-search) {
    grid-template-rows: auto 90px auto;
  }

  .region-content:has(.view-publications-indexed-search-api-facets):has(.publications-listing) > :has(> .listing-search) {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .region-content:has(.view-publications-indexed-search-api-facets):has(.publications-listing):has(.listing-search) > #block-chbrp-exposedformpublications-indexed-search-api-facetspage-1-2 {
    grid-row: 2 / 4;
  }

  .region-content:has(.view-publications-indexed-search-api-facets):has(.publications-listing):has(.listing-search) > #block-chbrp-exposedformpublications-indexed-search-api-facetspage-1 {
    grid-row: 2;
  }

  .region-content:has(.view-publications-indexed-search-api-facets):has(.publications-listing):has(.listing-search) > #block-chbrp-content {
    grid-row: 3;
  }
}

/* Narrower screens: search bar, filters, sort and cards, one below another. */
@media (max-width: 991.98px) {
  .region-content:has(.view-publications-indexed-search-api-facets):has(.publications-listing) {
    display: block;
  }

  .region-content:has(.view-publications-indexed-search-api-facets):has(.publications-listing) > #block-chbrp-exposedformpublications-indexed-search-api-facetspage-1 {
    margin-bottom: 30px;
  }
}

/* Tablets: each filter's checkboxes in two columns, so the filters take less room. */
@media (min-width: 576px) and (max-width: 991.98px) {
  .region-content:has(.view-publications-indexed-search-api-facets):has(.publications-listing) > #block-chbrp-exposedformpublications-indexed-search-api-facetspage-1-2 .bef-checkboxes {
    columns: 2;
    column-gap: 30px;
  }

  .region-content:has(.view-publications-indexed-search-api-facets):has(.publications-listing) > #block-chbrp-exposedformpublications-indexed-search-api-facetspage-1-2 .form-type-checkbox {
    break-inside: avoid;
  }
}

/* The cards: two columns, 45px apart (the view's Masonry gutter). */
.publications-listing .masonry-layout-publications-indexed-search-api-facets .views-row {
  width: calc((100% - 45px) / 2);
}

@media (max-width: 767.98px) {
  .publications-listing .masonry-layout-publications-indexed-search-api-facets .views-row {
    width: 100%;
  }
}
