@use "./../../../styles/tokens/space";
@use "./../../../styles/tokens/breakpoint";
@use "./../../../styles/tokens/color";
@use "./../../../styles/tools/generate";
@use "./../../../styles/tools/convert";
@use "../../Megamenu/styles/config" as megamenuConfig;
@use "sass:map" as sass-map;
@use "../../Container/styles/mixins" as containerMixins;

@mixin anchor-navigation() {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--color-background-primary) !important;
  border-bottom: 1px solid var(--color-border-strong);

  .horizontal-scroll {
    &::-webkit-scrollbar {
      display: none !important;
      width: 0 !important;
      height: 0 !important;
      background: transparent !important;
    }

    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
}

@mixin anchor-navigation-item() {
  margin-right: space.get("large") !important;
  margin-bottom: 0 !important;
  padding: convert.to-rem(25px) 0 !important;
  white-space: nowrap;
  color: inherit;
  text-decoration: none !important;
  display: inline-block;
  cursor: pointer;
  font-size: convert.to-rem(16px) !important;
  line-height: convert.to-rem(20px) !important;
  font-weight: 700 !important;

  &:link,
  &:visited,
  &:active {
    color: inherit;
    text-decoration: none !important;
  }

  &:last-child {
    margin-right: 0;
  }

  @include breakpoint.get("sm", "down") {
    margin-right: convert.to-rem(10px) !important;
    padding: convert.to-rem(15px) 0 !important;
  }

  &:focus-visible,
  &.is-active {
    box-shadow: megamenuConfig.$active-line;
    color: inherit;
    text-decoration: none !important;
    outline: none;
  }

  @media (hover: hover) and (pointer: fine) {
    &:hover,
    &:active {
      box-shadow: megamenuConfig.$active-line;
      color: inherit;
      text-decoration: none !important;
      outline: none;
    }
  }
}

@mixin anchor-navigation-content() {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;

  &:before,
  &:after {
    z-index: 1;
    width: convert.to-rem(72px);
    content: "";
    position: absolute;
    top: 0;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  &:before {
    left: 0;
    background: linear-gradient(
      to left,
      transparent 0%,
      var(--color-background-primary) 70%
    );
  }

  &:after {
    right: 0;
    background: linear-gradient(
      to right,
      transparent 0%,
      var(--color-background-primary) 70%
    );
  }

  &.has-left-overflow:before {
    opacity: 1;
  }

  &.has-right-overflow:after {
    opacity: 1;
  }

  @include breakpoint.get("sm", "down") {
    overflow: hidden;
    flex-direction: column;

    &:before,
    &:after {
      height: convert.to-rem(50px);
    }
  }

  @include breakpoint.get("md") {
    &:has(.anchor-navigation__content-right).has-right-overflow:after {
      opacity: 0;
    }

    @include containerMixins.base;
  }

  // TODO: Remove when external .container wrapper is fully removed in consuming apps.
  &.container {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
  }
}

@mixin anchor-navigation-content-left() {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  scroll-snap-type: none !important;

  &.is-draggable {
    user-select: none;
    cursor: -webkit-grab;
    cursor: grab;
  }

  &.is-dragging {
    cursor: -webkit-grabbing;
    cursor: grabbing;
    scroll-snap-type: none !important;
    scroll-behavior: auto;

    > * {
      scroll-snap-align: none;
    }
  }

  @include breakpoint.get("sm", "down") {
    width: 100%;

    .anchor-navigation__content:has(.anchor-navigation__content-right) & {
      border-bottom: 1px solid var(--color-border-strong);
    }

    li:first-child {
      padding-left: convert.to-rem(10px) !important;
    }
  }
}

@mixin anchor-navigation-content-right() {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: space.get("medium");
  position: relative;
  z-index: 1;

  &:before {
    z-index: -1;
    width: 100px;
    content: "";
    position: absolute;
    inset: -10px 0 0 -40px;
    transform: translate3d(10px, 8px, -1px);
    background: conic-gradient(
      from 90deg at 15% -20%,
      var(--color-background-primary) 2%,
      var(--color-background-primary) 80%
    );
    filter: blur(10px);
    border-radius: inherit;
  }

  @include breakpoint.get("sm", "down") {
    padding-top: space.get("small");
    padding-bottom: space.get("small");
    padding-left: convert.to-rem(25px);
    width: 100%;
    justify-content: space-between;

    @include containerMixins.base;

    &:before {
      display: none;
    }
  }
}
