/*------------------------------------*\
    $MIXINS
\*------------------------------------*/
/**
 * Create a fully formed type style (sizing and vertical rhythm) by passing in a
 * single value, e.g.:
 *
   `@include font-size(10px);`
 *
 * Thanks to @redclov3r for the `line-height` Sass:
 * twitter.com/redclov3r/status/250301539321798657
 */
@mixin font-size($font-size, $line-height:true){
    font-size:$font-size;
    font-size:($font-size / $global-font-size)*1rem;
    @if $line-height == true{
        line-height: $font-size / $global-font-size * $line-height-ratio;
    }
}


/**
 * Style any number of headings in one fell swoop, e.g.:
 *
   .foo{
       @include headings(1, 3){
           color:#BADA55;
       }
    }
 *
 * With thanks to @lar_zzz, @paranoida, @rowanmanning and ultimately
 * @thierrylemoulec for refining and improving my initial mixin.
 */
@mixin headings($from: 1, $to: 6){
    %base-heading {
        @content
    }

    @if $from >= 1 and $to <= 6{
        @for $i from $from through $to{
            h#{$i}{
                @extend %base-heading;
            }
        }
    }
}


/**
 * Create vendor-prefixed CSS in one go, e.g.
 *
   `@include vendor(border-radius, 4px);`
 *
 */
@mixin vendor($property, $value...){
    -webkit-#{$property}:$value;
       -moz-#{$property}:$value;
        -ms-#{$property}:$value;
         -o-#{$property}:$value;
            #{$property}:$value;
}




/**
 * Force overly long spans of text to truncate, e.g.:
 *
   `@include truncate(100%);`
 *
 * Where `$truncation-boundary` is a united measurement.
 */
@mixin truncate($truncation-boundary){
    max-width:$truncation-boundary;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}


/**
 * CSS arrows!!! But... before you read on, you might want to grab a coffee...
 *
 * This mixin creates a CSS arrow on a given element. We can have the arrow
 * appear in one of 12 locations, thus:
 *
 *       01    02    03
 *    +------------------+
 * 12 |                  | 04
 *    |                  |
 * 11 |                  | 05
 *    |                  |
 * 10 |                  | 06
 *    +------------------+
 *       09    08    07
 *
 * You pass this position in along with a desired arrow color and optional
 * border color, for example:
 *
 * `@include arrow(top, left, red)`
 *
 * for just a single, red arrow, or:
 *
 * `@include arrow(bottom, center, red, black)`
 *
 * which will create a red triangle with a black border which sits at the bottom
 * center of the element. Call the mixin thus:
 *
   .foo{
       background-color:#BADA55;
       border:1px solid #ACE;
       @include arrow(top, left, #BADA55, #ACE);
   }
 *
 */
@mixin arrow($arrow-edge, $arrow-location, $arrow-color, $border-color: $arrow-color){

    @if $arrow-edge == top{

        @extend %arrow--top;

        &:before{
            border-bottom-color:$border-color!important;
        }

        &:after{
            border-bottom-color:$arrow-color!important;
        }

        @if $arrow-location == left{
            @extend %arrow--left;
        }

        @if $arrow-location == center{
            @extend %arrow--center;
        }

        @if $arrow-location == right{
            @extend %arrow--right;
        }

    }

    @if $arrow-edge == right{

        @extend %arrow--far;

        &:before{
            border-left-color:$border-color!important;
        }

        &:after{
            border-left-color:$arrow-color!important;
        }

        @if $arrow-location == top{
            @extend %arrow--upper;
        }

        @if $arrow-location == center{
            @extend %arrow--middle;
        }

        @if $arrow-location == bottom{
            @extend %arrow--lower;
        }

    }

    @if $arrow-edge == bottom{

        @extend %arrow--bottom;

        &:before{
            border-top-color:$border-color!important;
        }

        &:after{
            border-top-color:$arrow-color!important;
        }

        @if $arrow-location == left{
            @extend %arrow--left;
        }

        @if $arrow-location == center{
            @extend %arrow--center;
        }

        @if $arrow-location == right{
            @extend %arrow--right;
        }

    }

    @if $arrow-edge == left{

        @extend %arrow--near;

        &:before{
            border-right-color:$border-color!important;
        }

        &:after{
            border-right-color:$arrow-color!important;
        }

        @if $arrow-location == top{
            @extend %arrow--upper;
        }

        @if $arrow-location == center{
            @extend %arrow--middle;
        }

        @if $arrow-location == bottom{
            @extend %arrow--lower;
        }

    }

}


@mixin element-overflow {
  margin-left: -99999px - $baseline;
  margin-right: -99999px;
  padding-left: 99999px;
  padding-right: 99999px;
}

@mixin border-radius($radius: $border-radius) {
  -webkit-border-radius: $radius;
     -moz-border-radius: $radius;
      -ms-border-radius: $radius;
          border-radius: $radius;
}

@mixin text-small {
    @include font-size($global-font-size - 2, false);
	line-height: 1rem;
}

@mixin text-normal {
    @include font-size($global-font-size);
}

@mixin word-wrap() {
  overflow-wrap: break-word;
  word-wrap: break-word;
  -ms-word-break: break-all;
  word-break: break-word;
  -ms-hyphens: auto;
  -moz-hyphens: auto;
  -webkit-hyphens: auto;
  hyphens: auto;
}
