//==============================================================================
// Helper function(s)
//==============================================================================

// Check if value is an integer and returns true or false
@function is-int($number) {
  @return type-of($number) == number and floor(abs($number)) == abs($number);
}

// Returns a number without a unit. For example 16px becomes 16
@function stripUnits($number) {
  @return $number / ($number * 0 + 1);
}

// Returns an EM value. For example 24px becomes 1.5em
@function emCalc($target, $context: $base-font-size) {
  @return stripUnits(($target / $context)) + 0em;
}

// Returns an EM value that is a multiple of our defined base vertical unit. For
// example 3 becomes 1.125em
@function emRhythm($lines: $base-vertical-unit, $font-size: $base-em-font-size, $silent: false) {
  @if is-int($lines) == false and $silent == false {
    @warn  #{$lines} + $not-integer-txt;
  }
  @return (stripUnits($lines) * stripUnits($base-vertical-unit)) / (stripUnits($font-size) * stripUnits($base-font-size)) + 0em;
}

// Returns a unitless number that is a multiple of our defined base vertical unit.
// For example 3 becomes 1.125
@function unitlessRhythm($lines: $base-line-multi, $font-size: $base-em-font-size, $silent: false) {
  @if is-int($lines) == false and $silent == false {
    @warn #{$lines} + $not-integer-txt;
  }
  @return ($lines * stripUnits($base-vertical-unit)) / (stripUnits($font-size) * stripUnits($base-font-size));
}
