/* ============================================================================
   @CORE -> MIXINS -> FONT SIZE
   ========================================================================= */


/**
 * Create a fully formed type style (sizing and vertical rhythm) by passing in
 * a single value, e.g.
 *
   .foo {
     @include font-size(12);
   }
 *
 * This will generate a `rem`-based font-size, as well as a unitless
 * line-height which will place the element on your baseline, e.g.
 *
   .foo {
     font-size: 0.75rem;
     line-height: 2;
   }
 *
 * If you do not want Scally to generate a line-height for you then simply pass
 * in your own as a second parameter e.g.
 *
   .foo {
     @include font-size(12, 1.5);
   }
 *
 * This will yield:
 *
   .foo {
     font-size: 0.75rem;
     line-height: 1.5;
   }
 *
 * This parameter can be any integer including an integer with `px` appended,
 * `inherit`, or `normal` e.g.
 *
   .foo {
     @include font-size(12, 18px);
   }

   .foo {
     @include font-size(12, inherit);
   }

   .foo {
     @include font-size(12, normal);
   }
 *
 * Any line-heights with `px` appended will still output as a unitless
 * line-height e.g.
 *
   .foo {
     @include font-size(12, 18px);
   }
 *
 * This will yield:
 *
   .foo {
     font-size: 0.75rem;
     line-height: 1.5;
   }
 *
 * If you don't want a line-height at all, pass in a second parameter of
 * `none` or `false`:
 *
   .foo {
     @include font-size(12, none);
   }
 *
 * This will yield:
 *
   .foo {
     font-size: 0.75rem;
   }
 *
 * @example
   .foo {
     @include font-size(18);
   }

   .foo {
     @include font-size(12, 1.5);
   }

   .foo {
     @include font-size(12, 18px);
   }

   .foo {
     @include font-size(12, none);
   }

   .foo {
     @include font-size(24, inherit);
   }

   .foo {
     @include font-size(24, normal);
   }

   .foo {
     @include font-size(24, false, true);
   }
   or
   .foo {
     @include font-size(24, 1.2, !important);
   }

   .foo {
     @include font-size(24, auto, !important);
   }
 *
 * @credit
 * https://github.com/inuitcss/tools.mixins/blob/master/_tools.mixins.scss
 */


@mixin font-size($font-size-value, $line-height-value: auto, $sledgehammer: false) {

  $important: if($sledgehammer, " !important", "");
  $font-size-value: strip-unit($font-size-value);

  font-size: (($font-size-value / strip-unit($font-size)) * 1rem)#{$important};

  @if $line-height-value == auto {
    line-height: ceil($font-size-value / $line-height) * ($line-height /
      $font-size-value)#{$important};
  }
  @else {
    @if (type-of($line-height-value) == number) {
      @if unitless($line-height-value) {
        line-height: $line-height-value#{$important};
      }
      @else {
        line-height: strip-unit($line-height-value) / $font-size-value#{$important};
      }
    }
    @elseif $line-height-value == inherit or $line-height-value == normal {
      line-height: $line-height-value#{$important};
    }
    @elseif ($line-height-value != none and $line-height-value != false) {
      @warn "D'oh! `#{$line-height-value}` is not a valid value for `line-height`."
    }
  }
}