@use 'sass:math';
@use 'sass:meta';
@use '../../functions/equals-true' as *;
@use '../../variables/misc' as *;

/// Resets text properties. If you want to reset `font-size` and `word-wrap`
/// (aka `overflow-wrap`) as well, pass `true` for those parameters.
///
/// @param {Bool} $reset-size [false] - Pass true to also reset `font-size`.
/// @param {Bool} $reset-wrap [false] - Pass true to also reset `word-wrap`.
///
/// @group Utilities
/// @require {function} equals-true
/// @require {variable} $base-font-size
@mixin reset-text($reset-size: false, $reset-wrap: false) {
  $_root-font-size: 1rem;

  font-family: $font-family-base;

  @if equals-true($reset-size) {
    @if meta.variable-exists('base-font-size') or
        meta.global-variable-exists('base-font-size')
    {
      $_root-font-size: if(
        math.is-unitless($base-font-size),
        math.div($base-font-size, 16) * 1rem,
        smth.$base-font-size
      );
    }

    font-size: $_root-font-size;
  }

  font-weight: $font-weight-normal;
  font-style: normal;
  line-height: $line-height-base;
  letter-spacing: normal;
  text-transform: none;
  white-space: normal;
  text-decoration: none;
  text-align: left;
  text-align: start;
  text-shadow: none;
  word-spacing: normal;
  word-break: normal;

  @if equals-true($reset-wrap) {
    word-wrap: normal;
  }

  line-break: auto;
}
