@mixin no-anchor-underline() {
  position: static;
  text-decoration: none;

  &::before {
    display: none;
    box-shadow: none;
  }
}

@mixin anchor-underline(
  $underline-color: color(ui, link),
  $hover-color: currentColor
) {
  position: relative;
  display: inline-block;
  text-decoration: none;

  &::before {
    position: absolute;
    bottom: 1px;
    left: 0;
    z-index: -1;
    width: 100%;
    height: 3px;
    box-shadow: 0 2px 0 currentColor;
    content: '';
    transition: transform 250ms ease(out-sine), color 250ms linear;
    transition-delay: 100ms;
    transform: scaleX(0);
  }

  &:hover {
    color: $hover-color;
    transition: color 250ms linear;

    &::before {
      box-shadow: 0 2px 0 currentColor;
      transform: scaleX(1);
    }
  }
}

a {
  @at-root .no-anchor-underline &,
    &.no-anchor-underline,
    &.anchor-minimal,
    &.text-with-icon {
    @include no-anchor-underline();
  }

  @at-root .anchor-underline &,
    &.anchor-underline {
    @include anchor-underline(
      $hover-color: scale-color(color(uiLink, fgBase), $lightness: 25%)
    );
  }

  @at-root .link-list & {
    @include no-anchor-underline();
  }

  $base-link-color: color(uiLink, fgBase);

  color: $base-link-color;
  text-decoration: none;
  transition: color 100ms linear;

  &:visited {
    color: $base-link-color;
  }

  &:hover {
    color: scale-color($color: $base-link-color, $lightness: 25%);
  }

  &:active {
    color: $base-link-color;
  }

  &.disabled,
  &[disabled] {
    opacity: 0.6;
    filter: grayscale(0.6);
    pointer-events: none;
  }

  &.anchor-subtle {
    $color: color(gray, minus2);
    color: $color;

    &:hover {
      $hover-color: scale-color($color, $lightness: 25%);
      color: $hover-color;
    }
  }

  &.anchor-button-subtle {
    text-transform: uppercase;
    letter-spacing: letter-spacing(plus1);
  }
}
