/* A library's albums or people on the albums page (albums/_section): a heading with its buttons, above one row of
   album cards that scrolls sideways */
.album-section {
  margin: var(--space-3) 0 var(--space-5);
}

.album-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);

  h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;

    .meta {
      color: var(--meta-text-color);
      font-weight: normal;
    }
  }

  .actions {
    flex-wrap: nowrap;
  }
}

/* A chevron that turns to point up while the section is expanded */
.album-section-toggle {
  svg {
    transition: rotate 0.2s ease-out;

    @media (prefers-reduced-motion: reduce) {
      transition: none;
    }
  }

  &[aria-expanded="true"] svg {
    rotate: 180deg;
  }
}

/* What the row's cards are sized to. Only the row is in it, so menus over the section aren't held inside it */
.album-section-body {
  container-type: inline-size;
}

/* Cards as wide as fit two and a bit on phones, so the next one shows at the edge. Wider screens fit a whole number
   of them, at least 12rem wide, so they keep their size once the row is expanded */
.album-row {
  --album-columns: 2.25;
  --album-gaps: 2;
  --album-card-width: calc((100% - var(--album-gaps) * var(--space-3)) / var(--album-columns));

  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--album-card-width);
  gap: var(--space-3);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  padding-bottom: var(--space-2);
  list-style: none;

  > li {
    scroll-snap-align: start;
  }

  @container (min-width: 37.5rem) { --album-columns: 3; --album-gaps: 2; }
  @container (min-width: 50.25rem) { --album-columns: 4; --album-gaps: 3; }
  @container (min-width: 63rem) { --album-columns: 5; --album-gaps: 4; }
  @container (min-width: 75.75rem) { --album-columns: 6; --album-gaps: 5; }
  @container (min-width: 88.5rem) { --album-columns: 7; --album-gaps: 6; }
  @container (min-width: 101.25rem) { --album-columns: 8; --album-gaps: 7; }

  /* Two rows on phones, which still scroll. Wider screens show every album, in as many rows as they need */
  .album-section.expanded & {
    grid-template-rows: repeat(2, auto);

    @container (min-width: 37.5rem) {
      grid-auto-flow: row;
      grid-template-rows: none;
      grid-template-columns: repeat(var(--album-columns), minmax(0, 1fr));
      overflow-x: visible;
    }
  }
}
