/*
 * 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-page-title {
  align-items: center;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "title sub-title actions"
    "description description description"
    "tags tags tags";
  margin: 0 0 var(--nx-spacing-4x) 0;

  .nx-h1 {
    grid-area: title;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: unset;
  }

  .nx-btn-bar {
    grid-area: actions;
    margin: 0 0 0 var(--nx-spacing-6x);
  }

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

.nx-page-title__headings {
  display: contents;
}

.nx-page-title__sub-title {
  @include nx-text-helpers.truncate-ellipsis;
  border-left: 1px solid var(--nx-color-page-title-divider);
  margin: 0 0 0 var(--nx-spacing-4x);
  padding-left: var(--nx-spacing-4x);
  min-width: 150px;
  max-width: unset;
}

.nx-page-title__description {
  grid-area: description;
  margin-top: var(--nx-spacing-2x);
  max-width: var(--nx-width-text-wrapping);

  + .nx-page-title__tags {
    margin-top: var(--nx-spacing-4x);
  }

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

.nx-page-title__tags {
  display: flex;
  flex-wrap: wrap;
  grid-area: tags;
  row-gap: var(--nx-spacing-2x);
  margin-top: var(--nx-spacing-2x);

  // required due to specificity, removes bottom margin from children of nx-page-title__tags
  > :nth-child(1n) {
    margin-bottom: 0;
  }

  .nx-policy-violation-indicator {
    + .nx-tag {
      margin-left: var(--nx-spacing-2x);
    }

    + .nx-threat-counter-container {
      .nx-threat-counter {
        &:first-child {
          margin-left: var(--nx-spacing-2x);
        }
      }
    }
  }

  .nx-threat-counter-container {
    display: contents;
    .nx-threat-counter {
      margin: 0 var(--nx-spacing-4x) 0 0;

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

    + .nx-tag {
      margin-left: var(--nx-spacing-6x);
    }
  }

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