/**
 * AppBuckets UI
 *
 * _Typography @ src/styles/_core/_typography.scss
 *
 * Defined at 05 giu 2020
 * Copyright Marco Cavanna • 2020
 *
 * ---
 * Define React Bucket Typography
 *
 */

/******
    Define Google Fonts Mapping
******/
$google-fonts-weight-map: (
  // Sans Serif Font
  'Dosis' : (200, 400, 600, 800),
  'Lato' : (300, 400, 700, 900),
  'Montserrat' : (300, 400, 600, 700),
  'Nunito' : (300, 400, 700, 800),
  'Open Sans' : (300, 400, 600, 700),
  'Poppins' : (300, 400, 600, 700),
  'Quicksand' : (300, 400, 600, 700),
  'Roboto' : (300, 400, 500, 700),
  'Source Sans Pro' : (300, 400, 600, 700),
  'Ubuntu' : (300, 400, 500, 700),
  // Monospace Font
  'Roboto Mono' : 500,
  'Source Code Pro' : 400,
  'Ubuntu Mono' : 400
);

/// Check if font exists in mapping
@if $inject-custom-font == false {
  @if map-has_key($google-fonts-weight-map, $default-web-font) == false {
    @error 'Invalid Default Web Font #{$default-web-font}';
  }

  @if map-has_key($google-fonts-weight-map, $default-monospace-font) == false {
    @error 'Invalid Default Monospace Font #{$default-monospace-font}';
  }
}

/// Define Core variables
$font-sans-serif: $default-web-font;
$font-monospace: $default-monospace-font;
$font-size: $base-font-size;
$line-height: $default-line-height;

/// Build Core Font weight variables
$light: nth(map-get($google-fonts-weight-map, $font-sans-serif), 1);
$regular: nth(map-get($google-fonts-weight-map, $font-sans-serif), 2);
$semi-bold: nth(map-get($google-fonts-weight-map, $font-sans-serif), 3);
$bold: nth(map-get($google-fonts-weight-map, $font-sans-serif), 4);

/// Custom font inject variable override and checker
@if $inject-custom-font == true {
  // Override defaults
  $font-sans-serif: $custom-font-name;
  $light: $custom-font-light-weight;
  $regular: $custom-font-regular-weight;
  $semi-bold: $custom-font-semi-bold-weight;
  $bold: $custom-font-bold-weight;

  // Check custom font name
  @if str-length($font-sans-serif) == 0 {
    @error 'When using $inject-custom-font: true you must provide a $custom-font-name valid value';
  }

  // Check font weights
  @if $light == 0 {
    @error 'When using $inject-custom-font: true you must provide a valid $custom-font-light-weight value for font #{$font-sans-serif}';
  }

  @if $regular == 0 {
    @error 'When using $inject-custom-font: true you must provide a valid $custom-font-regular-weight value for font #{$font-sans-serif}';
  }

  @if $semi-bold == 0 {
    @error 'When using $inject-custom-font: true you must provide a valid $custom-font-semi-bold-weight value for font #{$font-sans-serif}';
  }

  @if $bold == 0 {
    @error 'When using $inject-custom-font: true you must provide a valid $custom-font-bold-weight value for font #{$font-sans-serif}';
  }
}

/// Map weight
$font-weight-map: (
  light : $light,
  regular : $regular,
  semi-bold : $semi-bold,
  bold : $bold
);

/// Declaring Font Families
$font-family-sans-serif: $font-sans-serif, -apple-system, 'Helvetica', 'Arial', sans-serif !default;
$font-family-monospace: $font-monospace, monospace !default;
$font-render-mode: optimizeLegibility !default;
