//== Cover px to rem
@function printPx($value) {
    $pxSize: $value;
    @return #{$pxSize}px;
}

@function printEm($value) {
    $emSize: $value / 16;
    @return #{$emSize}em;
}

@function printRem($value) {
    //Default font size on html element is 100%, equivalent to 16px, font size body = 62.5% of the html is 10px;
    $remSize: $value / 10;
    @return #{$remSize}rem;
}

// y = mx + b
// m = (y2 - y1) / (x2 - x1)
// b = y - mx
@function resize-font($min-size, $max-size, $min-width, $max-width) {
    $x: $max-width - $min-width;
    $m: ($max-size - $min-size) / ($x);
    $b: $min-size - ($m * $x) + px;
    $mx: ($m * 100) + vw;
    @return calc(#{$mx} + #{$b});
}

// =============================================================================
// libsass (v3.5)
// =============================================================================
$rem-baseline: 16px !default;
$rem-fallback: false !default;
$rem-px-only: false !default;

@function rem-separator($list, $separator: false) {
    @if $separator == "comma" or $separator == "space" {
        @return append($list, null, $separator);
    }

    @if function-exists("list-separator") == true {
        @return list-separator($list);
    }

    // list-separator polyfill by Hugo Giraudel (https://sass-compatibility.github.io/#list_separator_function)
    $test-list: ();
    @each $item in $list {
        $test-list: append($test-list, $item, space);
    }

    @return if($test-list == $list, space, comma);
}

@function rem-convert($to, $values...) {
    $result: ();
    $separator: rem-separator($values);

    @each $value in $values {
        @if type-of($value) == "number" and unit($value) == "rem" and $to == "px" {
            $result: append($result, $value / 1rem * $rem-baseline, $separator);
        } @else if type-of($value) == "number" and unit($value) == "px" and $to == "rem" {
            $result: append($result, $value / $rem-baseline * 1rem, $separator);
        } @else if type-of($value) == "list" {
            $value-separator: rem-separator($value);
            $value: rem-convert($to, $value...);
            $value: rem-separator($value, $value-separator);
            $result: append($result, $value, $separator);
        } @else {
            $result: append($result, $value, $separator);
        }
    }

    @return if(length($result) == 1, nth($result, 1), $result);
}

@function rem($values...) {
    @if $rem-px-only {
        @return rem-convert(px, $values...);
    } @else {
        @return rem-convert(rem, $values...);
    }
}