/* Discovery: community and tag indexes and tag post lists. */
@layer components {
  .discovery-header,
  .community-index,
  .tag-index,
  .community-index__empty-state,
  .tag-index__empty-state,
  .tag-show__empty {
    width: min(100%, var(--width-reading));
    margin-inline: auto;
  }

  .discovery-header {
    margin-bottom: var(--space-7);
    padding-bottom: var(--space-5);
    border-bottom: var(--border-thin) solid var(--color-border-strong);
  }

  .discovery-header--tag {
    width: min(100%, var(--width-reading));
  }

  .discovery-header__title {
    max-width: 16ch;
    margin: 0;
    font-size: var(--text-page-title);
    letter-spacing: -0.06em;
    line-height: 0.94;
    overflow-wrap: anywhere;
  }

  .discovery-header__lede {
    max-width: 38rem;
    margin: var(--space-4) 0 0;
    color: var(--color-text-muted);
    font-family: var(--font-reading);
    font-size: var(--text-lg);
    line-height: 1.45;
  }

  .discovery-header__back {
    margin: 0 0 var(--space-3);
    font-size: var(--text-sm);
    font-weight: 700;
  }

  .community-index,
  .tag-index,
  .tag-posts {
    margin-block: 0;
    padding: 0;
    list-style: none;
  }

  .community-index,
  .tag-index {
    border-top: var(--border-thin) solid var(--color-border);
  }

  .community-index__item {
    padding: var(--space-5) 0;
    border-bottom: var(--border-thin) solid var(--color-border);
  }

  .community-index__heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3) var(--space-5);
    min-width: 0;
  }

  .community-index__identity {
    display: grid;
    gap: var(--space-1);
    min-width: 0;
  }

  body:not(.error-layout) .community-index__name {
    justify-self: start;
    color: var(--color-text);
    font-family: var(--font-reading);
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: var(--leading-tight);
    overflow-wrap: anywhere;
    text-decoration: none;
  }

  body:not(.error-layout) .community-index__name:hover {
    color: var(--color-accent);
  }

  .community-index__slug {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    letter-spacing: 0.04em;
    overflow-wrap: anywhere;
  }

  .community-index__join-mode {
    flex: 0 1 auto;
    padding: var(--space-1) var(--space-2);
    border: var(--border-thin) solid var(--color-border-strong);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    font-weight: 700;
    line-height: var(--leading-tight);
    text-align: center;
  }

  .community-index__description {
    max-width: 60ch;
    margin: var(--space-3) 0 0;
    color: var(--color-text);
    font-family: var(--font-reading);
    line-height: var(--leading-relaxed);
    overflow-wrap: anywhere;
  }

  .community-index__member-count {
    margin: var(--space-3) 0 0;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }

  .tag-index__item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    min-width: 0;
    padding: var(--space-4) 0;
    border-bottom: var(--border-thin) solid var(--color-border);
  }

  body:not(.error-layout) .tag-index__link {
    min-width: 0;
    color: var(--color-text);
    font-family: var(--font-reading);
    /* A tag name is list content: one step below the page title. */
    font-size: var(--text-section-title);
    font-weight: 700;
    line-height: var(--leading-tight);
    overflow-wrap: anywhere;
    text-decoration: none;
  }

  body:not(.error-layout) .tag-index__link:hover {
    color: var(--color-accent);
  }

  .tag-index__count {
    flex: 0 0 auto;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }

  .tag-posts {
    width: min(100%, var(--width-reading));
    margin-inline: auto;
  }

  .tag-posts__item {
    margin: 0;
  }

  .community-index__empty-cta {
    margin-bottom: 0;
  }

  @media (max-width: 720px) {
    .discovery-header {
      margin-bottom: var(--space-6);
    }

    .community-index__heading {
      flex-direction: column;
      align-items: flex-start;
    }
  }
}
