@use 'sass:math';

@import 'vars';

$font-family-mono: 'Courier New', 'Menlo', 'DejaVu Sans Mono',
  'Bitstream Vera Sans Mono', Courier, monospace !default;
$font-family-mono-code: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo',
  'Courier', monospace !default;
$font-family-sans-serif: 'Open Sans', sans-serif !default;
$font-family-tajawal: 'Tajawal', sans-serif !default;

$base-font-size: 16px !default; // Default, Use with em() and rem() functions

$typescale-map: (
  'giga': 4.625rem,
  'mega': 3.625rem,
  'alpha': 2.25rem,
  'beta': 1.75rem,
  'omicron': 1.5625rem,
  'sigma': 1.375rem,
  'gamma': 1.25rem,
  'delta': 1.125rem,
  'epsilon': 1rem,
  'zeta': 0.875rem,
  'omega': 0.75rem,
  'theta': 0.6875rem,
  //replaced legal with the greek work theta
);

@mixin typescale($size) {
  @if map-has-key($typescale-map, $size) {
    font-size: map-get($typescale-map, $size);
  } @else {
    @warn 'This is not a step of the WFP Type Scale!';
  }
}

@function rem($px) {
  @return math.div($px, $base-font-size) * 1rem;
}

@function em($px) {
  @return math.div($px, $base-font-size) * 1em;
}

@mixin font-family {
  font-family: $font-family-sans-serif;

  &:lang(ar) {
    font-family: $font-family-tajawal;
  }
}

// There are two line heights to choose from. One for headings and one for body text
@mixin line-height($el) {
  @if $el == 'heading' {
    line-height: 1.25;
  } @else if $el == 'body' {
    line-height: 1.5;
  } @else {
    @warn 'Invalid argument used for @mixin line-height($el) . Please use 'heading' or 'body'.';
  }
}

// Only applied to bold weight text
@mixin font-smoothing {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@mixin letter-spacing {
  letter-spacing: 0;
}

$font-size-map: (
  '74': 4.625rem,
  //74px rather => 4.625rem
  '58': 3.625rem,
  //58px rather => 3.625rem
  '36': 2.25rem,
  '28': 1.75rem,
  '25': 1.5625rem,
  '22': 1.375rem,
  '20': 1.25rem,
  '18': 1.125rem,
  '16': 1rem,
  '14': 0.875rem,
  '12': 0.75rem,
  '11': 0.6875rem,
);

@mixin font-size($size) {
  @if map-has-key($font-size-map, $size) {
    font-size: map-get($font-size-map, $size);
  } @else {
    @warn 'This is not a step of the WFP Type Scale! Valid sizes are 11, 12, 14, 16, 18, 20, 28, 36, 54, and 76';
  }
}
