/*
 * 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 'nx-container-helpers';

// Deprecated. Now using variable --nx-font-family
@mixin nx-font-family() {
  font-family: Open Sans, sans-serif;
}

@mixin regular() {
  font-family: var(--nx-font-family);
  font-weight: normal;
}

@mixin italic() {
  font-family: var(--nx-font-family);
  font-style: italic;
}

@mixin bold() {
  font-family: var(--nx-font-family);
  font-weight: bold;
}

@mixin bold-italic() {
  font-family: var(--nx-font-family);
  font-style: italic;
  font-weight: bold;
}

@mixin semi-bold() {
  font-family: var(--nx-font-family);
  font-weight: 600;
}

@mixin semi-bold-italic() {
  font-family: var(--nx-font-family);
  font-style: italic;
  font-weight: 600;
}

@mixin truncate-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@mixin monospace() {
  font-family: Courier Prime, monospace;
}

// Deprecated.
// for specificity reasons this should be called using a custom class on the <body> tag
// e.g. `<body className="nx-body nx-body--my-app">`
@mixin font-size($custom-font-size) {
  &.nx-body,

  // buttons
  .nx-btn:not(.nx-btn--small),
  .nx-dropdown-link,
  .nx-dropdown-button,

  button.nx-text-link,

  // form elements
  .nx-label,
  .nx-text-input__input,
  .nx-radio,
  .nx-checkbox {
    font-size: $custom-font-size;
  }
}

%nx-p {
  margin: var(--nx-spacing-4x) 0 var(--nx-spacing-6x) 0;
  max-width: var(--nx-width-text-wrapping);
}

%nx-code {
  @include monospace;
  background-color: var(--nx-color-code-background);
  border: 1px solid var(--nx-color-code-border);
  border-radius: 4px;
  color: var(--nx-color-code-text);
  // These paddings are added so the inline text matches the adjacent body text.
  padding: 4px 1px 0 1px;
  white-space: nowrap;

  // This padding is so the calculated height of the
  // monospace inline text matches the adjacent body text.
  .nx-text-link {
    padding-top: 4px;
  }
}

%nx-pre {
  @include monospace;
  background-color: var(--nx-color-component-background);
  border: 1px solid var(--nx-color-pre-border);
  border-left-width: 8px;
  border-radius: var(--nx-border-radius);
  font-size: var(--nx-font-size);
  margin: var(--nx-spacing-4x) 0 var(--nx-spacing-6x) 0;
  padding: var(--nx-spacing-6x);
  white-space: pre-wrap;
  max-width: var(--nx-width-text-wrapping);

  // "code" used below to support Markdown text in NxVulnerabilityDetails
  code, .nx-code {
    @include monospace;
    background-color: inherit;
    border: 0;
    color: inherit;
    padding: 0;
    white-space: inherit;
  }
}

%nx-blockquote {
  background-color: var(--nx-color-blockquote-background);
  border: var(--nx-border-default);
  border-left-width: 8px;
  border-radius: var(--nx-border-radius);
  margin: var(--nx-spacing-4x) 0 var(--nx-spacing-6x) 0;
  padding: var(--nx-spacing-6x);
  max-width: var(--nx-width-text-wrapping);

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

//Class that allows making content visible only to screen readers
@mixin visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}
