@use '../../00-settings/settings' as *;
@use '../../00-mixins/mixins' as *;
@use '../../11-base/fonts/icons' as *;

/* stylelint-disable max-nesting-depth */
.breadcrumb {
  margin: 0 0 20px;
  clear: both;

  ul,
  ol {
    flex-wrap: wrap;
    max-width: calc(100vw - 40px);
    margin: 0;
    list-style: none;

    li {
      @include icon('chevron-right', 'after');

      display: inline-flex;
      align-items: center;
      height: 38px;
      margin-right: 8px;
      margin-bottom: 0;
      padding-left: 0;

      &::before {
        display: none;
      }

      &::after {
        @include theme('color', 'color-primary', 'breadcrumb-arrows-color');

        margin: 0 0 0 8px;
      }

      &:last-of-type {
        margin-right: 0;

        &::after {
          content: '';
          display: none;
        }
      }

      > * {
        @include small-text;
      }

      a {
        @include normal-text;
        @include small-text;

        line-height: initial;

        &,
        &[href^="http://"],
        &[href^="https://"] {
          &:not(.no-icon, .tag) {
            &::after {
              display: none;
            }
          }
        }
      }

      a,
      span {
        display: inline-block;
      }
    }

    &.nav--mobile-breadcrumb {
      display: block;

      @media (min-width: $bp-tablet) {
        display: none;
      }
    }
  }

  .expandable {
    a {
      @include bold-text;

      padding: 0 7px;
      border-color: transparent;
      outline: 2px solid currentcolor;
      line-height: 19px;

      &:hover,
      &:focus {
        @include theme('background-color', 'color-primary-light', 'link-hover-background');
      }

      &,
      &:focus,
      &:hover {
        background-image: none;
      }
    }

    &::after {
      line-height: 1.6rem;
    }
  }

  &[aria-expanded="false"] {
    ul,
    ol {
      li:not(.expandable, :nth-last-child(-n+3), :nth-child(-n+2)) {
        display: none;
      }

      @include tablet-and-below {
        display: flex;
        align-items: center;

        li:not(.expandable) {
          min-width: 60px;

          a,
          span {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }

        li:not(.expandable, :nth-last-child(-n+3)) {
          display: none;
        }
      }
    }
  }

  ///
  /// Links in the breadcrumb should never have icons.
  ///
  [class*="cs--"] & a {
    &::after {
      content: none;
    }
  }
}
