/**
 *  mixins
 *
 *
 *  @author Björn Hase, Tentakelfabrik
 *  @license http://opensource.org/licenses/MIT The MIT License
 *  @link https://github.com/tentakelfabrik/crispy-css
 *
 */


/**
 *  Clear Floats
 *
 *
 *
 */

@mixin crispy__clearfix() {
    &::before,
    &::after {
        display: table;
        content: ' ';
    }

    &::after {
        clear: both;
    }
}


/**
 *  clear styles from list
 *
 *
 */

@mixin crispy__clearlist() {
    list-style: none;
    margin: 0;
    padding: 0;

    li {
        margin: 0;
        padding: 0;
    }
}


/**
 *  media-queries as mixins
 *  based on breakpoints from variables
 *
 *
 *
 */

@mixin crispy__media-xs() {
    @media only screen and (min-width:$crispy__xs) {
        @content;
    }
}

@mixin crispy__media-sm() {
    @media only screen and (min-width: $crispy__sm) {
        @content;
    }
}

@mixin crispy__media-md() {
    @media only screen and (min-width: $crispy__md) {
        @content;
    }
}

@mixin crispy__media-lg() {
    @media only screen and (min-width: $crispy__lg) {
        @content;
    }
}

@mixin crispy__media-xlg() {
    @media only screen and (min-width: $crispy__xlg) {
        @content;
    }
}

@mixin crispy__media-xxs-only() {
    @media only screen and (max-width: $crispy__xs) {
        @content;
    }
}

@mixin crispy__media-xxs-only() {
    @media only screen and (max-width: $crispy__xs - 1) {
        @content;
    }
}

@mixin crispy__media-xs-only() {
    @media only screen and (min-width: $crispy__xs) and (max-width: $crispy__sm - 1) {
        @content;
    }
}

@mixin crispy__media-sm-only() {
    @media only screen and (min-width: $crispy__sm) and (max-width: $crispy__md - 1) {
        @content;
    }
}

@mixin crispy__media-md-only() {
    @media only screen and (min-width: $crispy__md) and (max-width: $crispy__lg - 1) {
        @content;
    }
}

@mixin crispy__media-lg-only() {
    @media only screen and (min-width: $crispy__lg) and (max-width: $crispy__xlg - 1) {
        @content;
    }
}

@mixin crispy__media-xlg-only() {
    @media only screen and (min-width: $crispy__xlg) {
        @content;
    }
}


/**
 *  Set property and his value for each Breakpoint
 *
 *  (
 *      $crispy__md: 10px
 *  )
 *
 *
 *  @param  {css} $property
 *  @param  {map} $breakpoints
 *  @param  {Boolean} $important   [false]
 *
 */

@mixin crispy__media-breakpoints($property, $breakpoints, $important: false) {
    @each $breakpoint, $value in $breakpoints {
        @media only screen and (min-width: $breakpoint) {
            @if $important == false {
                #{$property}: $value;
            } @else {
                #{$property}: $value !important;
            }
        }
    }
}


/**
 *  Set property and his value with an factor for each Breakpoint
 *
 *  (
 *      $crispy__md: 10px
 *  )
 *
 *  @param  {css} $property
 *  @param  {number} $factor
 *  @param  {map} $breakpoints
 *  @param  {Boolean} $important   [false]
 *
 */

@mixin crispy__media-breakpoints-calculate($property, $factor, $breakpoints, $important: false) {
    @each $breakpoint, $value in $breakpoints {
        @media only screen and (min-width: $breakpoint) {
            @if $important == false {
                #{$property}: ($value * $factor);
            } @else {
                #{$property}: ($value * $factor) !important;
            }
        }
    }
}

/**
 *  Set font-size from Breakpoints, use for calculating difference from font-size and default font-size
 *
 *  (
 *      $crispy__md: 1rem
 *  )
 *
 *  @param  {map}  $breakpoints
 *  @param  {unit}  $font-size
 *  @param  {unit}  $default
 *  @param  {Boolean} $important   [false]
 *
 */
@mixin crispy__media-breakpoints-font-size($breakpoints, $font-size, $default, $important: false) {
    @each $breakpoint, $value in $breakpoints {

        // getting diff
        $factor: (stripUnit($font-size) - stripUnit($default)) + 1;

        // ignore if factor is zero
        @if $factor > 0 {
            @media only screen and (min-width: $breakpoint) {
                @if $important == false {
                    font-size: ($value * $factor);
                } @else {
                    font-size: ($value * $factor) !important;
                }
            }
        }
    }
}
