@layer pages {
  .logbook {
    display: grid;
    align-content: start;
    gap: var(--space);
    width: 100%;
    max-width: var(--wide-width);
    margin: 0 auto;
    padding: var(--space-double) var(--space);
  }

  /* Filters in a column on the right on wide screens (E.5), under the title otherwise */
  @media (min-width: 60rem) {
    .logbook {
      grid-template-columns: 1fr 15rem;
      grid-template-rows: auto 1fr;
      column-gap: var(--space-double);
    }

    .logbook__header { grid-area: 1 / 1; }
    .logbook__articles { grid-area: 2 / 1; }
    /* Level with the top of the thumbnails (review 4.3) */
    .filters { grid-area: 2 / 2; align-self: start; }
  }

  .logbook__header h1 { margin-bottom: var(--space-half); }

  .logbook__filter {
    margin: 0;
    color: var(--color-grey);
  }

  .logbook__empty { color: var(--color-grey); }

  /* About twelve thumbnails on a laptop screen, then scroll (E.3) */
  .cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: var(--space-double) var(--space);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  @media (min-width: 40rem) {
    .cards { grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); }
  }

  .card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    color: var(--color-ink);
    text-decoration: none;
  }

  .card__photo {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--radius);
    background: var(--color-grey-lightest);
  }

  /* A portrait photo is shown whole, centred between white bands */
  .card__photo--portrait {
    object-fit: contain;
    background: var(--color-white);
  }

  /* A long title is cut after two lines (E.2) */
  .card__title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    color: var(--color-blue-dark);
    font-weight: bold;
    line-height: 1.35;
  }

  .card:hover .card__title { text-decoration: underline; }

  .card__date {
    color: var(--color-grey);
    font-size: var(--text-small);
  }

  .filters {
    display: flex;
    flex-direction: column;
    gap: var(--space);
  }

  .filters__group {
    padding: var(--space);
    border-radius: var(--radius);
    background: var(--color-blue-lightest);
  }

  .filters__heading {
    margin: 0 0 var(--space-half);
    font-size: var(--text-normal);
  }

  .filters__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.8rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  @media (min-width: 60rem) {
    .filters__list { flex-direction: column; }
  }

  .filters__link {
    font-size: var(--text-small);
    text-decoration: none;
  }

  .filters__link:hover { text-decoration: underline; }

  .filters__link[aria-current="page"] {
    font-weight: bold;
    color: var(--color-blue-dark);
  }

  .article {
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: var(--space-double) var(--space);
  }

  .article__leg {
    margin: 0 0 var(--space-half);
    font-size: var(--text-small);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .article__leg a { text-decoration: none; }

  .article__title { margin-bottom: var(--space-half); }

  .article__meta {
    margin: 0 0 var(--space-half);
    color: var(--color-grey);
    font-size: var(--text-small);
  }

  .article__position { white-space: nowrap; }

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

  .article__tag {
    padding: 0.1rem 0.6rem;
    border-radius: 1rem;
    background: var(--color-blue-light);
    font-size: var(--text-small);
    text-decoration: none;
  }

  .article__photo {
    width: 100%;
    margin: var(--space) 0;
    border-radius: var(--radius);
  }

  /* The map of the leg (review 5.4). On a phone it takes the width of the
     screen, square, after the text; a finger scrolls the page past it and
     two fingers move the map (map_controller, compact). */
  .article__map-box { margin-top: var(--space-double); }

  .article__map {
    aspect-ratio: 1;
    inline-size: 100%;
    border-radius: var(--radius);
  }

  /* Under the map, centred, in the size of the other links; the random
     article a line further down */
  .article__map-more,
  .article__map-random {
    margin: var(--space-half) 0 0;
    text-align: center;
  }

  .article__map-random { margin-top: 1lh; }

  /* Wide screens: the side margins shrink by 45 %, the text gets wider and
     the map sits in the right column, level with the title, and stays in
     sight while reading. */
  @media (min-width: 64rem) {
    .article--with-map {
      --article-map-size: 17rem;

      display: grid;
      grid-template-columns: minmax(0, 1fr) var(--article-map-size);
      align-content: start;
      column-gap: var(--space-double);
      max-width: none;
      padding-inline: calc((100vw - var(--content-width)) / 2 * 0.55);
    }

    .article--with-map > * { grid-column: 1; }
    .article--with-map .prose { max-width: none; }

    .article--with-map .article__map-box {
      position: sticky;
      top: calc(var(--navigation-height) + var(--space));
      grid-column: 2;
      grid-row: 1 / span 20;
      align-self: start;
      margin-top: 0;
    }
  }

  /* Back to the list on the left, the next article on the right, level with
     the edges of the text */
  .article__footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space);
    margin-top: var(--space-double);
    padding-top: var(--space);
    border-top: 1px solid var(--color-grey-light);
  }

  .article__next { margin-inline-start: auto; text-align: end; }

  /* The footer of the site, inside the article: centred on the text, not on
     the page beside the map */
  .article > .footer { margin-top: var(--space-double); }
}
