/*
  @a-pollo-doc
  @author: [Vittorio Vittori](http://github.com/vitto)
  @category: Functions
  @code: Usage example
    .selector {
      width: scale-value(40px, 0.5);
    }
  @css: The CSS generated
    .selector {
      width: 20px;
    }
  @date: 2017-01-05T15:01:54+01:00
  @type: function
  @icon: fa fa-expand
  @title: Math
  @name: scale-value
  @param: {unit-value} ($value) [required]
          The unit value to be scaled, es: `10px`, `2em`, etc.
  @param: {number} ($scale) [required]
          The scale number to change the value, es: `0.5`, `1`, `1.75`, etc.
  @public: true
  @returns: unit-value
  @text: Scales unit values passed, the return value will be rounded.
  @version: 4.0.0
*/

@function scale-value($value, $scale) {
  @return round($value * $scale);
}

/*
  @a-pollo-doc
  @author: [Vittorio Vittori](http://github.com/vitto)
  @category: Functions
  @code: Usage example
    $spacing: 20px;
    .selector {
      padding: spacing(1.5);
    }
  @css: The CSS generated
    .selector {
      padding: 30px;
    }
  @date: 2017-02-21T14:14:40+01:00
  @type: function
  @icon: fa fa-expand
  @name: spacing
  @param: {number} ($scale) [1]
          The number used to scale `$spacing` core var
  @public: true
  @returns: unit-value
  @text: Scales `$spacing` core var based on a numeric parameter
  @version: 4.0.0
*/

@function spacing($scale: 1) {
  @return scale-value($spacing, $scale);
}

/*
  @a-pollo-doc
  @author: [Vittorio Vittori](http://github.com/vitto)
  @category: Functions
  @code: Usage example
    $spacing: 20px;
    $margin: 7px;
    .selector {
      margin: s(2, $margin);
      padding: s(1.5);
    }
  @css: The CSS generated
    .selector {
      margin: 14px;
      padding: 30px;
    }
  @date: 2017-02-21T14:19:02+01:00
  @type: function
  @icon: fa fa-expand
  @name: s
  @param: {number} ($scale) [1]
          The number used to scale the `$value` passed or to scale `$spacing` core var if `$value` is not passed
  @param: {unit-value} ($value) [null]
          The unit value scaled by `$scale` parameter
  @public: true
  @returns: unit-value
  @text: Works as function `scale-value` if you pass all parameters. Works as function `spacing` if you skip the second parameter.
  @version: 4.0.0
*/

@function s($scale: 1, $value: null) {
  @if $value == null {
    @return spacing($scale);
  } @else {
    @return scale-value($value, $scale);
  }
}

/*
  @a-pollo-doc
  @author: [Vittorio Vittori](http://github.com/vitto)
  @category: Functions
  @code: Usage example
    .selector {
      width: step(4, 12);
    }
  @css: The CSS generated
    .selector {
      width: 33.33333%;
    }
  @date: 2017-02-21T14:30:00+01:00
  @type: function
  @icon: fa fa-balance-scale
  @name: step
  @param: {integer} ($grid-columns-used) [1]
          Used to set the current column size based on `$grid-columns-total` parameter
  @param: {integer} ($grid-columns-total) [$row-columns-total]
          The ratio of the grid system you are adding
  @public: true
  @returns: unit-value
  @text: A step function to generate grid system sizes.
  @version: 4.0.0
*/

@function step($grid-columns-used, $grid-columns-total: $row-columns-total) {
  @return ($grid-columns-used * 100 / $grid-columns-total) * 1%;
}
