/**
 * Description of what this file is for
 *
 * @package  generator_css
 * @author   Martin Herweg <mherweg@zonedigital.com>
 */

/*
|--------------------------------------------------------------------------
| _tools.function.rem_calc
|--------------------------------------------------------------------------
*/

/* USAGE
 * RESULT
|--------------------------------------------------------------------------
| h1 { font-size: rem-calc(20px); }
| h1 { font-size: 1.25rem; }
|--------------------------------------------------------------------------
| h2 { font-size: rem-calc(20px, 18px) } // modify the em base to calc from
| h2 { font-size: 1.11111rem; }
|--------------------------------------------------------------------------
| h3 { padding: rem-calc(10 15px 10 20px, 18px) } // produce multiple values and modify the base value
| h3 { padding: 0.55556rem 0.83333rem 0.55556rem 1.11111rem; }
|--------------------------------------------------------------------------
 * Additional Informations are provided below by the Original Description of the Foundation Framework
 */

// REM CALC by Foundation

// New Syntax, allows to optionally calculate on a different base value to counter compounding effect of rem's.
// Call with 1, 2, 3 or 4 parameters, 'px' is not required but supported:
//
//   rem-calc(10 20 30px 40);
//
// Space delimited, if you want to delimit using comma's, wrap it in another pair of brackets
//
//   rem-calc((10, 20, 30, 40px));
//
// Optionally call with a different base (eg: 8px) to calculate rem.
//
//   rem-calc(16px 32px 48px, 8px);
//
// If you require to comma separate your list
//
//   rem-calc((16px, 32px, 48), 8px);

// Foundation by ZURB
// foundation.zurb.com
// Licensed under MIT Open Source

// This is the default html and body font-size for the base rem value.

@import 'tools.function.strip_unit';

$rem-base: 16px !default;

@function rem-calc($values, $base-value: $rem-base) {
  $max: length($values);

  @if $max == 1 { @return convert-to-rem(nth($values, 1), $base-value); }

  $rem-values: ();
  @for $i from 1 through $max {
    $rem-values: append($rem-values, convert-to-rem(nth($values, $i), $base-value));
  }
  @return $rem-values;
}

// CONVERT TO REM
/* stylelint-disable */
@function convert-to-rem($value, $base-value: $rem-base) {
  $value: strip-unit($value) / strip-unit($base-value) * 1rem;
  @if ($value == 0rem) { $value: 0; } // Turn 0rem into 0
  @return $value;
}
/* stylelint-enable */
