/*
 * 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-tabs {
  margin: var(--nx-spacing-4x) 0 var(--nx-spacing-6x) 0;
}

.nx-tab-list {
  border-bottom: var(--nx-border-default);
  display: flex;
  margin: 0 0 var(--nx-spacing-6x) 0;
  padding: 0;

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

.nx-tab-panel {
  &:focus {
    outline: solid 1px var(--nx-color-interactive-border-focus);
    outline-offset: -1px;
  }

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

.nx-tab {
  @include nx-text-helpers.truncate-ellipsis;

  box-sizing: border-box;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: inline-block;
  flex-shrink: 1;
  list-style: none;
  margin: 0 var(--nx-spacing-4x) -1px 0;
  // subtract border thickness for consistent spacing
  padding: var(--nx-spacing-4x) var(--nx-spacing-6x) calc(var(--nx-spacing-4x) - 2px) var(--nx-spacing-6x);
  position: relative;
  text-align: center;
  min-width: 80px;
  max-width: 240px;
  background-color: transparent;
  z-index: 0;

  &::before {
    box-sizing: border-box;
    border-radius: 6px;
    content: '';
    height: calc(100% - 6px);
    position: absolute;
    left: 0;
    top: 4px;
    width: 100%;
    z-index: -1;
  }

  &.active {
    @include nx-text-helpers.semi-bold;

    border-bottom: 2px solid var(--nx-color-interactive-border-focus);
    color: var(--nx-color-interactive-border-focus);
  }

  &:hover:not(.active) {
    @include nx-text-helpers.semi-bold;
    color: var(--nx-color-text-stark);

    &::before {
      background-color: var(--nx-color-tab-background-hover);
    }
  }

  &:focus {
    &::before {
      border: var(--nx-border-width-alt) solid var(--nx-color-interactive-border-focus);
    }
  }

  &:focus-visible {
    outline: none;
  }

  // a hidden copy of the text, always at semi-bold weight, to enfore consistent element width
  .nx-tab__hidden-children {
    display: block;
    font-weight: 600;
    height: 0;
    overflow: hidden;
    visibility: hidden;
  }
}
