// All those stuff should be redone when we'll have nib/autoprefixer,
// so we could use such thing multiple times inside any property.
// Two main things that should be then:
// 1. The main thing: average_color fallback.
// 2. Simplier syntax in stops.

gradient()
  $colors = ()

  if utilus_is_array(arguments)
    for $stop in arguments
      if utilus_is_array($stop)
        push($colors, rgba($stop[0], $stop[1]))
      else
        if type($stop) == 'rgba'
          push($colors, $stop)
        else
          push($colors, rgba(last($colors), $stop))
  else
    $colors = arguments[0]

  $average_color = utilus_average_color($colors)
  $colors = join(', ',$colors)
  background: rgba-ie($average_color)
  if !ie
    background: unquote('linear-gradient(' + $colors + ')')
