//
// @description :
// @author      : Adarsh Pastakia
// @copyright   : 2017
// @license     : MIT
@mixin browser-prefixed($prop, $val...) {
  -webkit-#{$prop}: $val;
  -moz-#{$prop}   : $val;
  -ms-#{$prop}    : $val;
  -o-#{$prop}     : $val;
  #{$prop}        : $val;
}
@mixin sticky() {
  position: -webkit-sticky;
  position: -moz-sticky;
  position: sticky;
}
@mixin scroll() {
  overflow                  : auto;
  -webkit-overflow-scrolling: touch;
}
@mixin box-shadow($val...) {
  box-shadow: $val;
}
// Postioning
@mixin position($pos:absolute,$coords:0) {
  position: $pos;
  @if length($coords)==1 {
    top   : nth($coords,1);
    right : nth($coords,1);
    bottom: nth($coords,1);
    left  : nth($coords,1);
  }
  @if length($coords)==2 {
    top   : nth($coords,1);
    right : nth($coords,2);
    bottom: nth($coords,1);
    left  : nth($coords,2);
  }
  @if length($coords)==3 {
    top   : nth($coords,1);
    right : nth($coords,2);
    bottom: nth($coords,3);
    left  : nth($coords,2);
  }
  @if length($coords)==4 {
    top   : nth($coords,1);
    right : nth($coords,2);
    bottom: nth($coords,3);
    left  : nth($coords,4);
  }
}

// From compass
@function brightness($color) {
  @if type-of($color) == color {
    @return (red($color) * 0.299 + green($color) * 0.587 + blue($color) * 0.114) / 255 * 100%;
  }
  @else {
    @return unquote("brightness(#{$color})");
  }
}
@function contrast-color($color, $dark: $black, $light: $white) {
   @if $color == null{
    @return null;
  }
  @else {
    $color-brightness     : brightness($color);
    $dark-text-brightness : brightness($dark);
    $light-text-brightness: brightness($light);
    @return if(abs($color-brightness - $light-text-brightness) > abs($color-brightness - $dark-text-brightness), $light, $dark);
  }
}
@function relative-color($color, $dark: $black, $light: $white) {
   @if $color == null{
    @return null;
  }
  @else {
    $color-brightness     : lightness($color);
    @return if(abs($color-brightness) > 50, $light, $dark);
  }
}
