/* List pages use the Pano wall's tiles: a lead with four compact rows beside
   it, then a grid. Every story is one card link. */

.gorunum-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gorunum-list > li {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.gorunum-list > li > .g-card {
  flex: 1 1 auto;
}

.gorunum-list .g-card--stacked {
  gap: 0;
}

.gorunum-list .g-card--stacked .g-card__body {
  padding: 8px 10px 10px;
}

.gorunum-list > li:has(> .g-card--lead),
.gorunum-list > li:has(> .g-card--latest),
.gorunum-list > .gorunum-list__ad {
  grid-column: 1 / -1;
}

/* A story without a photo fills its cell with a larger, centred title. */
.gorunum-list .g-card--stacked.g-card--text,
.gorunum-list .g-card--text.g-tile {
  justify-content: center;
}

body:not(.g-profile--columnist) .gorunum-list > li:not(:has(> .g-card--latest)) .g-card--text .g-card__title {
  font-size: var(--wp--preset--font-size--pano-card-lg);
}

/* Spots are printed for every story but shown only under a category lead. */
.gorunum-list .gorunum-spot {
  display: none;
}

.category .gorunum-list > li:has(> .g-card--lead) .gorunum-spot {
  display: block;
  margin: 0;
  padding: 0 10px 12px;
  background: var(--wp--preset--color--tile);
  font-size: var(--wp--preset--font-size--spot);
  line-height: 1.45;
}

.g-tile.g-card--lead .g-card__title {
  font-size: var(--wp--preset--font-size--pano-card-xl);
  line-height: 1.06;
}

.g-card--latest .g-card__date {
  color: var(--wp--preset--color--brand-deep);
  font-weight: 700;
}

.gorunum-list .g-card--latest .g-card__title {
  font-size: var(--wp--preset--font-size--pano-card-text);
}

/* Search results and a reporter's page have no lead: the first result takes
   the row so a full page of 17 leaves no hole. */
:is(.search, .g-profile--reporter) .gorunum-list > li:first-child {
  grid-column: 1 / -1;
}

.g-search-count {
  margin: 0;
  color: var(--wp--preset--color--stone);
  font-size: var(--wp--preset--font-size--meta);
}

.g-latest-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.g-latest-grid > li {
  display: flex;
  min-width: 0;
}

.g-latest-grid .g-card {
  flex: 1 1 auto;
  gap: 0;
}

.g-latest-grid .g-card__body {
  padding: 8px 10px 10px;
}

/* A columnist's archive: compact rows, like a table of contents. */
.g-profile--columnist .gorunum-list .g-tile .g-card__title {
  font-size: var(--wp--preset--font-size--pano-card-text);
}

.g-profile--columnist .gorunum-list {
  grid-template-columns: minmax(0, 1fr);
}

.g-profile--columnist .gorunum-list > li:first-child {
  grid-column: auto;
}

@media (min-width: 768px) {
  .gorunum-list,
  .g-latest-grid {
    gap: 10px;
  }

  .gorunum-list > li:has(> .g-card--latest) {
    grid-column: auto;
  }

  .gorunum-list .g-card--stacked .g-card__body,
  .g-latest-grid .g-card__body {
    padding: 10px 14px 12px;
  }

  .category .gorunum-list > li:has(> .g-card--lead) .gorunum-spot {
    padding: 0 14px 14px;
  }

  /* The first row takes the whole width: 1 + 16 fills a full page of 17. */
  .g-profile--columnist .gorunum-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .g-profile--columnist .gorunum-list > li:first-child {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1024px) {
  .gorunum-list {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-flow: row dense;
  }

  .gorunum-list > li {
    grid-column: span 4;
  }

  /* Lead on eight columns over four rows, the four compact rows beside it,
     then three across: 1 + 4 + 12 fills every row. */
  .gorunum-list > li:has(> .g-card--lead) {
    grid-column: 1 / 9;
    grid-row: span 4;
  }

  .gorunum-list > li:has(> .g-card--latest) {
    grid-column: 9 / 13;
  }

  /* A lead without a photo is only as tall as its text. */
  .gorunum-list > li:has(> .g-card--lead.g-card--text) {
    grid-row: auto;
  }

  .gorunum-list > li.gorunum-list__ad:nth-child(n) {
    grid-column: 1 / -1;
  }

  .g-latest-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* Two results open the plain grid, then three across: 2 + 15 fills every row. */
  :is(.search, .g-profile--reporter) .gorunum-list > li:first-child,
  :is(.search, .g-profile--reporter) .gorunum-list > li:nth-child(2) {
    grid-column: span 6;
  }

  /* Two open the page, then three across: 2 + 15 fills a full page of 17. */
  .g-profile--columnist .gorunum-list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .g-profile--columnist .gorunum-list > li {
    grid-column: span 2;
  }

  .g-profile--columnist .gorunum-list > li:first-child,
  .g-profile--columnist .gorunum-list > li:nth-child(2) {
    grid-column: span 3;
  }
}

/* Rows past the first screen are drawn, and their photos fetched, as the reader nears them. */
.gorunum-list > li:nth-child(n+7) {
  content-visibility: auto;
  contain-intrinsic-size: auto 300px;
}
