/*------------------------------------*\
    $GLOBAL MIXINS
\*------------------------------------*/
/**
 * TYPE............Mixins used for typography
 * LAYOUT..........Mixins used for layout
 */

/*------------------------------------*\
    $TYPE
\*------------------------------------*/
@mixin font-size($font-size: 1.6) {
  font-size: ($font-size * 10) + px;
  font-size: $font-size + rem;
}

@mixin line-height($line-height: 1.6) {
  line-height: ($line-height * 10) + px;
  line-height: $line-height + rem;
}

@mixin type($font-family: $type-default-sans-serif, $font-size: false, $line-height: false, $color: $type-color, $font-weight: 400, $font-style: normal) {
  font-family: $font-family;
  @include font-size($font-size);
  @include line-height($line-height);
  font-weight: $font-weight;
  font-style: $font-style;
  color: $color;
}

/*------------------------------------*\
    $LAYOUT
\*------------------------------------*/
@mixin padding-top($padding: 1.6) {
  padding-top: ($padding * 10) + px;
  padding-top: $padding + rem;
}

@mixin padding-right($padding: 1.6) {
  padding-right: ($padding * 10) + px;
  padding-right: $padding + rem;
}

@mixin padding-bottom($padding: 1.6) {
  padding-bottom: ($padding * 10) + px;
  padding-bottom: $padding + rem;
}

@mixin padding-left($padding: 1.6) {
  padding-left: ($padding * 10) + px;
  padding-left: $padding + rem;
}

@mixin padding($padding-top: false, $padding-right: false, $padding-bottom: false, $padding-left: false) {
  @include padding-top($padding-top);
  @include padding-right($padding-right);
  @include padding-bottom($padding-bottom);
  @include padding-left($padding-left);
}

@mixin margin-top($margin: 1.6) {
  margin-top: ($margin * 10) + px;
  margin-top: $margin + rem;
}

@mixin margin-right($margin: 1.6) {
  margin-right: ($margin * 10) + px;
  margin-right: $margin + rem;
}

@mixin margin-bottom($margin: 1.6) {
  margin-bottom: ($margin * 10) + px;
  margin-bottom: $margin + rem;
}

@mixin margin-left($margin: 1.6) {
  margin-left: ($margin * 10) + px;
  margin-left: $margin + rem;
}

@mixin margin($margin-top: false, $margin-right: false, $margin-bottom: false, $margin-left: false) {
  @include margin-top($margin-top);
  @include margin-right($margin-right);
  @include margin-bottom($margin-bottom);
  @include margin-left($margin-left);
}

@mixin width($width: 1) {
  width: ($width * 10) + px;
  width: $width+ rem;
}

@mixin height($height: 1) {
  height: ($height * 10) + px;
  height: $height+ rem;
}

@mixin max-width($max-width: 1) {
  max-width: ($max-width * 10) + px;
  max-width: $max-width+ rem;
}

@mixin max-height($max-height: 1) {
  max-height: ($max-height * 10) + px;
  max-height: $max-height+ rem;
}

@mixin top($margin: 1.6) {
  top: ($margin * 10) + px;
  top: $margin + rem;
}

@mixin right($margin: 1.6) {
  right: ($margin * 10) + px;
  right: $margin + rem;
}

@mixin bottom($margin: 1.6) {
  bottom: ($margin * 10) + px;
  bottom: $margin + rem;
}

@mixin left($margin: 1.6) {
  left: ($margin * 10) + px;
  left: $margin + rem;
}

@mixin vertical-align {
  position: relative;
  top: 50%;
  -webkit-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  transform: translateY(-50%);
}

@mixin vertical-align-unset {
  top: auto;
  -webkit-transform: translateY(0);
  -ms-transform: translateY(0);
  transform: translateY(0);
}

/*------------------------------------*\
    $SPRITES
\*------------------------------------*/
@mixin sprite-width($sprite) {
  width: nth($sprite, 5);
}

@mixin sprite-height($sprite) {
  height: nth($sprite, 6);
}

@mixin sprite-position($sprite) {
  $sprite-offset-x: nth($sprite, 3);
  $sprite-offset-y: nth($sprite, 4);
  background-position: $sprite-offset-x  $sprite-offset-y;
}

@mixin sprite-image($sprite) {
  $sprite-image: nth($sprite, 9);
  background-image: url(#{$sprite-image});
}

@mixin sprite-no-dim($sprite) {
  @include sprite-image($sprite);
  @include sprite-position($sprite);
}

/**
* Output sprite image along with its dimensions
* Params: sprite name, optional background color (defaults to transparent)
*/
@mixin sprite($sprite, $bgcolor: transparent) {
  @include sprite-image($sprite);
  @include sprite-position($sprite);
  @include sprite-width($sprite);
  @include sprite-height($sprite);
  background-color: $bgcolor;
}

/*------------------------------------*\
    $ICONS
\*------------------------------------*/

@mixin icon($icon_name, $side: left, $vertical-adjustment: 0, $horizontal-adjustment: 0) {
    @if $side == "right" {
        &:after {
            content: " ";
            @include sprite($icon_name);
            float: $side;
            @include vertical-align;
            margin-left: 6px;
            margin-top: $vertical-adjustment;
            left: $horizontal-adjustment;
        }
    }
    @else {
        &:before {
            content: " ";
            @include sprite($icon_name);
            float: $side;
            @include vertical-align;
            margin-right: 6px;
            margin-top: $vertical-adjustment;
            left: $horizontal-adjustment;
        }
    }
}


/*------------------------------------*\
    $TOOLTIPS
\*------------------------------------*/
@mixin triangle($direction, $size: 6px, $color: #222){
    content: '';
    display: block;
    position: absolute;
    height: 0; width: 0;
    @if ($direction == 'up'){
        border-bottom: $size solid $color;
        border-left: 1/2*$size solid transparent;
        border-right: 1/2*$size solid transparent;
    }
    @else if ($direction == 'down'){
        border-top: $size solid $color;
        border-left: 1/2*$size solid transparent;
        border-right: 1/2*$size solid transparent;
    }
    @else if ($direction == 'left'){
        border-top: 1/2*$size solid transparent;
        border-bottom: 1/2*$size solid transparent;
        border-right: $size solid $color;
    }
    @else if ($direction == 'right'){
        border-top: 1/2*$size solid transparent;
        border-bottom: 1/2*$size solid transparent;
        border-left: $size solid $color;
    }
}

@mixin hui_tooltip($content: attr(data-tooltip), $direction: top) {
    position: relative;
    &:before, &:after {
        display: none;
        z-index: 98;
    }
    &:hover {
        &:after { // for text bubble
            content: $content;
            display: block;
            position: absolute;
            height: 30px;
            white-space: nowrap;
            color: #fff;
            background-color: #1f2c33;
            @include type(Alright Sans, 1.2, 3, #FFF, 500);
            border-radius: 5px;
            padding: 0 14px;
        }
        @if ($direction == 'top'){
            &:before {
                @include triangle(down, 7px, #1f2c33);
                top: -10px;
                margin-top: 0;
                left: 50%;
                margin-left: -3px;
            }
            &:after {
                top: -39px;
                left: 50%;
                margin-left: -50px;
            }
        }
        @else if ($direction == 'bottom'){
            &:before {
                @include triangle(up, 6px, #1f2c33);
                top: auto; margin-top: 0;
                bottom: -6px;
                left: 47%;
            }
            &:after {
                bottom: -28px;
                left: 47%;
                margin-left: -20px;
            }
        }
    }
}