@use "../abstracts/mixins";

.jenkins-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-left: 0.625rem;
  overflow: hidden;

  &__list {
    display: contents;

    & > * {
      z-index: 1;
    }

    &-item {
      display: contents;

      a::before {
        content: "";
        position: absolute;
        inset: -0.5rem -0.75rem !important;
        pointer-events: all !important;
      }

      & > a {
        @include mixins.item($border: false);

        --item-background: transparent;
        --item-background--hover: transparent;
        --item-background--active: transparent;
        --item-box-shadow--focus: transparent;

        transition: opacity var(--standard-transition);

        &::before,
        &::after {
          inset: -2px -6px;
          border: none;
        }

        &:hover {
          opacity: 0.7;
        }

        &:active {
          opacity: 0.4;
        }
      }

      & > a,
      span {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 1rem;
        font-size: var(--font-size-sm);
        font-weight: var(--font-bold-weight);
        margin: 0;
        padding: 0;
        color: inherit;
        text-decoration: none;
        text-wrap: nowrap;
        flex-shrink: 0;
      }

      // '/' separator between two items
      &::before {
        content: "";
        position: relative;
        width: 1rem;
        height: 1.25rem;
        flex-shrink: 0;
        mask-size: contain;
        mask-position: center;
        mask-repeat: no-repeat;
        mask-image: url("data:image/svg+xml,%3Csvg width='10' height='20' viewBox='0 0 10 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 18L8 2' stroke='black' stroke-width='1.5px' stroke-linecap='round'/%3E%3C/svg%3E%0A");
        background: color-mix(
          in sRGB,
          var(--text-color-secondary) 30%,
          transparent
        );

        @media (prefers-contrast: more) {
          background: var(--text-color);
        }
      }
    }
  }
}

.jenkins-menu-dropdown-chevron {
  position: absolute;
  display: inline-block;
  width: 14px;
  height: 14px;
  right: 0;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 0;
  transition: var(--standard-transition);
  background: transparent;
  top: 4px;

  &:hover {
    &::after {
      opacity: 1 !important;
    }
  }

  &:active {
    &::after {
      transform: translateY(2px);
      opacity: 0.5 !important;
    }
  }

  // Increase the hit target
  &::before {
    content: "";
    position: absolute;
    inset: -10px;
  }

  &::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 14px;
    opacity: 0;
    transition: var(--standard-transition);
    background: var(--text-color);
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'%3E%3Ctitle%3EChevron Down%3C/title%3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M112 184l144 144 144-144'/%3E%3C/svg%3E");
    mask-position: center;
    mask-repeat: no-repeat;
  }
}

.model-link {
  position: relative;
  transition: var(--standard-transition) !important;
  margin-right: 40px !important;

  @media (hover: none) {
    &::before,
    &::after {
      right: -30px !important;
    }

    .jenkins-menu-dropdown-chevron {
      right: -22px;

      &::after {
        opacity: 1;
      }
    }
  }

  @media (hover: hover) {
    & + a.model-link {
      margin-left: 0 !important;
    }

    & + a.jenkins-table__badge {
      margin-left: -1.5rem !important;
    }

    &--open {
      &::before {
        background-color: var(--item-background--hover) !important;
        right: -30px !important;
      }
    }

    &--open,
    &:hover {
      & + a.jenkins-table__badge {
        margin-left: -1.5rem !important;
        transform: translateX(1.5rem);
      }

      &::before,
      &::after {
        right: -30px;
      }

      .jenkins-menu-dropdown-chevron {
        pointer-events: all;
        right: -22px;

        &::after {
          opacity: 0.5;
        }
      }
    }
  }
}

.model-link--float {
  z-index: 0;

  @media (hover: none) {
    margin-right: 30px !important;

    &::before,
    &::after {
      right: -30px !important;
    }

    .jenkins-menu-dropdown-chevron {
      right: -10px;

      &::after {
        opacity: 1;
      }
    }
  }

  @media (hover: hover) {
    margin-right: 0 !important;

    &::before,
    &::after {
      content: "";
      position: absolute;
      inset: -7px -10px;
      opacity: 0;
      border-radius: 6px;
      transition: var(--standard-transition);
    }

    &::before {
      z-index: -2;
      background: var(--background);
    }

    &::after {
      z-index: -1;
      background: var(--text-color);
    }

    &:hover {
      z-index: 10;

      @media (hover: hover) {
        &::before,
        &::after {
          right: calc((2ch + 14px) * -1);
        }
      }

      &::before {
        opacity: 1;
      }

      &::after {
        opacity: 0.15;
      }

      .jenkins-menu-dropdown-chevron {
        &::after {
          opacity: 0.5;
          display: none;
        }
      }
    }
  }
}
