/*
 * Copyright (c) 2019-present Sonatype, Inc.
 * This program and the accompanying materials are made available under
 * the terms of the Eclipse Public License 2.0 which accompanies this
 * distribution and is available at https://www.eclipse.org/legal/epl-2.0/.
 */
@use '../../scss-shared/nx-container-helpers';
@use '../../scss-shared/nx-text-helpers';

.nx-breadcrumb {
  align-items: baseline;
  display: grid;

  // See Sections 7.2.1 (regarding auto), 12.4, and 12.5.1 of the [grid spec](https://www.w3.org/TR/css-grid-2/).
  // Grid tracks start at their min size, which auto picks up from the children's min-width and is therefore
  // 0 here. They then are grown equally until each one hits its maximum content size (thanks to the max-content part
  // of our minmax) or the container is filled, resulting in the desired behavior of truncation applying only to
  // the longest children as needed until all tracks are truncated to equal width.
  grid-template-columns: repeat(4, minmax(auto, max-content));
  font-size: var(--nx-font-size-s);
  max-width: 800px;

  &__list {
    display: contents;
  }

  &__list-item {
    align-items: baseline;
    display: flex;

    &--link-container {
      min-width: 0;
    }

    &::after {
      color: var(--nx-color-text-stark);
      content: '/';
      flex: 0;
      margin: 0 var(--nx-spacing-2x);
    }

    &:last-child::after {
      content: none;
    }


    @include nx-container-helpers.container-horizontal;
  }

  &__link {
    @include nx-text-helpers.truncate-ellipsis;

    min-width: 0;

    &--current {
      color: var(--nx-color-text-stark);
      font-weight: 600;
    }
  }


  .nx-dropdown-menu {
    right: unset;
    left: 0;

    width: auto;
    min-width: 150px;
    max-width: 250px;
  }

  .nx-dropdown-link {
    margin-right: var(--nx-spacing-6x);
    max-width: calc(100% - var(--nx-spacing-4x) - var(--nx-spacing-6x));
  }
}
