// Default variables
$font-size-base: 16px !default;

// Functions
// List
// https://hugogiraudel.com/2013/08/08/advanced-sass-list-functions/
@function first($list) {
  @return nth($list, 1);
}

@function last($list) {
  @return nth($list, length($list));
}

// String
@function str-split($string, $separator) {
  // empty array/list
  $split-arr: ();
  // first index of separator in string
  $index: str-index($string, $separator);
  // loop through string
  @while $index != null {
    // get the substring from the first character to the separator
    $item: str-slice($string, 1, $index - 1);
    // push item to array
    $split-arr: append($split-arr, $item);
    // remove item and separator from string
    $string: str-slice($string, $index + 1);
    // find new index of separator
    $index: str-index($string, $separator);
  }
  // add the remaining string to list (the last item)
  $split-arr: append($split-arr, $string);

  @return $split-arr;
}

// Units
@function strip-unit($value) {
  @return $value / ($value * 0 + 1);
}

@function to-rem($value) {
  @return strip-unit($value) / strip-unit($font-size-base) * 1rem;
}
