@use "../abstracts/mixins";

.jenkins-breadcrumbs {
  position: sticky;
  top: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  padding: 0.55rem 0.7rem 0.55rem 0.75rem;
  backdrop-filter: blur(15px);
  overflow-x: auto;
  background: var(--breadcrumbs-bar-background);

  &__list {
    display: contents;
    list-style-type: none;

    & > * {
      flex-shrink: 0;
    }

    &-item {
      position: relative;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      color: var(--text-color);
      font-weight: normal;
      font-size: var(--font-size-sm);
      padding: 0.2rem 0.4rem;

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

        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-weight: inherit;
        font-size: inherit;
        margin: 0;
        padding: 0;
        color: var(--text-color);
        margin-right: 0 !important;
        transition: var(--standard-transition);

        &::before,
        &::after {
          inset: -0.25rem -0.6rem;
        }

        &:hover,
        &:active,
        &:focus,
        &:focus-visible {
          color: var(--text-color);
        }
      }

      & > .model-link {
        @media (hover: none) {
          margin-right: 30px !important;
        }

        &:hover,
        &--open {
          margin-right: 30px !important;
        }
      }
    }

    // '>' separator between two items
    .children,
    .separator {
      position: relative;
      width: 1rem;
      height: 1rem;
      margin: 0.375rem 0.2rem;

      &::after {
        content: "";
        position: absolute;
        inset: 0;
        transition: var(--standard-transition);
        background: var(--text-color-secondary);
        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 Forward%3C/title%3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M184 112l144 144-144 144'/%3E%3C/svg%3E");
        opacity: 0.6;
      }
    }

    .separator {
      &:last-of-type {
        display: none;
      }
    }

    .children {
      cursor: pointer;

      &:hover {
        &::after {
          opacity: 1;
          transform: rotate(90deg);
        }
      }

      &:active {
        &::after {
          transform: translateY(2px) rotate(90deg);
          opacity: 0.5;
        }
      }

      &:hover,
      &:active,
      &:focus,
      &:focus-visible {
        &::after {
          background: var(--text-color);
        }
      }

      // Increase the hit target
      &::before {
        content: "";
        position: absolute;
        inset: -14px -5px;
        background: transparent;
      }
    }
  }
}

.jenkins-menu-dropdown-chevron {
  position: absolute;
  display: inline-block;
  width: 14px;
  height: 14px;
  right: 0;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 0;
  pointer-events: none;
  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;
        }
      }
    }
  }
}
