/*
 * Breadcrumb: a quiet, clearly secondary trail above eyebrow and title. label/s size, subtle colour, small caret
 * between the items, links underlined on hover and focus only, the current page is text and a little stronger.
 * Space to the eyebrow or title comes from the page-head tokens (--page-head-gap-meta), not from here.
 * Phones: long items are cut with an ellipsis (the full text stays in the markup, so the accessible names are complete),
 * the current page wraps instead.
 */
@layer components {
  .breadcrumb__list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-4) var(--space-4);
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--color-text-subtle);
    font-size: var(--type-label-s-size);
    line-height: var(--type-label-s-line-height);
    font-weight: var(--font-weight-regular);
  }

  .breadcrumb__item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-4);
    min-width: 0;
    max-inline-size: 100%;
  }

  .breadcrumb__item + .breadcrumb__item::before {
    content: "";
    flex: none;
    inline-size: 12px;
    block-size: 12px;
    background-color: currentcolor;
    -webkit-mask: url("../../icons/regular/caret-right.svg") center / contain no-repeat;
    mask: url("../../icons/regular/caret-right.svg") center / contain no-repeat;
  }

  .breadcrumb__link {
    color: var(--color-text-subtle);
    display: block;
    text-decoration: none;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .breadcrumb__link:hover,
  .breadcrumb__link:focus-visible {
    color: var(--color-text-default);
    text-decoration: underline;
    text-underline-offset: 0.2em;
  }

  .breadcrumb__current {
    color: var(--color-text-default);
    font-weight: var(--font-weight-medium);
    overflow-wrap: anywhere;
  }

  /* Middle items of a long trail are the first to give way on phones. */
  @media (max-width: 1023px) {
    .breadcrumb__item:not(:first-child):not(:last-child) .breadcrumb__link {
      max-inline-size: 10ch;
    }

    .breadcrumb__item:first-child:not(:last-child) .breadcrumb__link {
      max-inline-size: 18ch;
    }
  }
}
