@layer components {
  /* A route-based empty state (no courses yet) — the public counterpart to admin's. */
  .empty {
    margin-block: var(--block-space-double);
    color: var(--color-muted);
  }

  /* The course index: the same card grid as the post list, but each card carries a
     lesson count instead of a date. */
  .course-list {
    display: grid;
    gap: var(--block-space);
    /* The same fluid grid as the post list, so both break to the same column count.
       A definite track max (e.g. 22rem) makes auto-fill count columns by that max —
       only ~2 fit a 72rem page; a 1fr max counts by the 16rem min instead, giving 3.
       The card itself is capped (below) so a lone course still stays card-sized. */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    margin-block: var(--block-space-double);
  }
  .course-list__item {
    display: flex;
    flex-direction: column;
    align-items: center; /* centred card — image and text share the centre line */
    text-align: center;
    /* Cap the card, not the grid track: a lone course stays card-sized (aligned to the
       start of its 1fr track) instead of stretching across the page. */
    max-inline-size: 22rem;
    gap: var(--inline-space-half);
    padding: var(--block-space);
    background: var(--color-surface-raised);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-large);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  }
  .course-list__item:hover {
    border-color: var(--color-border-strong);
    box-shadow: var(--shadow-large);
    transform: translateY(-2px);
  }
  /* Course banners vary (portrait teacher photos, landscape covers), so the image
     is contained and centred rather than full-bleed — kept at its own proportions
     with a capped height, like the article hero. */
  .course-list__media {
    display: block;
    margin-block-end: var(--inline-space-half);
  }
  .course-list__thumb {
    display: block;
    /* Centred in the card: with a definite width the wrapper no longer shrink-wraps it. */
    margin-inline: auto;
    /* Width capped at what the height cap allows, so the reserved box is the final box
       and a portrait banner isn't stretched into it (see the hero rule in layout.css). */
    --cap: 13rem;
    max-block-size: var(--cap);
    max-inline-size: min(100%, calc(var(--cap) * var(--ratio, 100)));
    block-size: auto;
    border-radius: var(--radius);
  }
  .course-list__link {
    font-family: var(--font-display);
    font-size: var(--text-large);
    font-weight: 600;
    line-height: 1.2;
    color: var(--color-text);
    text-wrap: balance;
  }
  .course-list__link:hover { color: var(--color-brand-strong); text-decoration: none; }
  .course-list__meta {
    margin-block: 0;
    color: var(--color-muted);
    font-size: var(--text-small);
  }
}
