/*
 * 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-text-link {
  color: var(--nx-color-link);
  cursor: pointer;
  text-decoration: underline;

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

  &--truncate {
    align-items: baseline;
    display: flex;
  }

  .nx-code {
    color: var(--nx-color-link);
  }

  &:focus {
    // outline-offset scales the border-radius so this
    // was changed to 4px to get it visually close to
    // var(--nx-border-radius) or (6px).
    border-radius: 4px;
    outline: var(--nx-focus-outline-width) solid var(--nx-color-interactive-border-focus);

    &, .nx-code {
      color: var(--nx-color-link-focus);
    }
  }

  &:hover {
    &, .nx-code {
      color: var(--nx-color-link-hover);
    }
  }

  &:active, &:active:focus {
    outline: none;

    &, .nx-code {
      color: var(--nx-color-link-active);
    }
  }

  .nx-icon.fa-external-link-alt {
    margin-left: var(--nx-spacing-base);
  }

  &.disabled, &[disabled] {
    &, &:hover, &:focus {
      color: var(--nx-color-text-disabled);
      cursor: default;
      text-decoration: underline;
    }
  }

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

button.nx-text-link {
  @include nx-text-helpers.truncate-ellipsis;
  @include nx-text-helpers.regular;

  background: initial;
  border: initial;
  display: block;
  font-size: var(--nx-font-size);
  line-height: var(--nx-line-height);
  max-width: 100%;
  padding: initial;
  text-decoration: underline;
}
