/*
 * SPDX-FileCopyrightText: 2024 Siemens AG
 *
 * SPDX-License-Identifier: MIT
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

@use 'misc/common-variables' as vars;

@mixin font-smoothing {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smooting: grayscale;
}

@mixin text-format(
  $font-size,
  $line-height,
  $font-weight: $font-weight-normal,
  $color-inverted: false
) {
  font-family: Siemens Sans, sans-serif;
  font-size: $font-size;
  font-weight: $font-weight;
  line-height: $line-height;

  @if $color-inverted {
    color: var(--theme-color-inv-std-text);
  } @else {
    color: var(--theme-color-std-text);
  }

  @include font-smoothing();
}

@mixin text-default($color-inverted: false) {
  @include text-format(
    vars.$font-size-default,
    vars.$line-height-default,
    vars.$font-weight-normal,
    $color-inverted
  );
}

@mixin text-default-single($color-inverted: false) {
  @include text-format(
    vars.$font-size-default,
    vars.$line-height-default-single,
    vars.$font-weight-normal,
    $color-inverted
  );
}

@mixin text-default-title($color-inverted: false) {
  @include text-format(
    vars.$font-size-default,
    vars.$line-height-default,
    vars.$font-weight-bold,
    $color-inverted
  );
}

@mixin text-default-title-single($color-inverted: false) {
  @include text-format(
    vars.$font-size-default,
    vars.$line-height-default-single,
    vars.$font-weight-bold,
    $color-inverted
  );
}

@mixin text-xs($color-inverted: false) {
  @include text-format(
    vars.$font-size-xs,
    vars.$line-height-xs,
    vars.$font-weight-normal,
    $color-inverted
  );
}

@mixin text-s($color-inverted: false) {
  @include text-format(
    vars.$font-size-s,
    vars.$line-height-s,
    vars.$font-weight-normal,
    $color-inverted
  );
}

@mixin text-caption($color-inverted: false) {
  @include text-format(
    vars.$font-size-caption,
    vars.$line-height-caption,
    vars.$font-weight-bold,
    $color-inverted
  );
}

@mixin text-caption-single($color-inverted: false) {
  @include text-format(
    vars.$font-size-caption,
    vars.$line-height-caption-single,
    vars.$font-weight-bold,
    $color-inverted
  );
}

@mixin text-l($color-inverted: false) {
  @include text-format(
    vars.$font-size-l,
    vars.$line-height-l,
    vars.$font-weight-normal,
    $color-inverted
  );
}

@mixin text-l-single($color-inverted: false) {
  @include text-format(
    vars.$font-size-l,
    vars.$line-height-l-single,
    vars.$font-weight-normal,
    $color-inverted
  );
}

@mixin text-l-title($color-inverted: false) {
  @include text-format(
    vars.$font-size-l,
    vars.$line-height-l,
    vars.$font-weight-bold,
    $color-inverted
  );
}

@mixin text-l-title-single($color-inverted: false) {
  @include text-format(
    vars.$font-size-l,
    vars.$line-height-l-single,
    vars.$font-weight-bold,
    $color-inverted
  );
}

@mixin text-h2($color-inverted: false) {
  @include text-format(
    vars.$font-size-xl,
    vars.$line-height-h2,
    vars.$font-weight-bold,
    $color-inverted
  );
}

@mixin text-xl($color-inverted: false) {
  @include text-format(
    vars.$font-size-xl,
    vars.$line-height-xl,
    vars.$font-weight-normal,
    $color-inverted
  );
}

@function automatic-text-color($color, $theshold: 50) {
  @if (lightness($color) > $theshold) {
    @return rgba(0, 0, 0, 0.99);
  } @else {
    @return rgba(255, 255, 255, 0.99);
  }
}
