/**
 * Mixin for handling media queries.
 * Breakpoints are defined inside core/_variables.scss
 * You can use custom breakpoints. Example: @include breakpoint ('min-width: 1500px') { ... }
 *
 * @param {String} $breakpoint
 */
@mixin breakpoint ($breakpoint) {
    @if map-has-key($breakpoints, $breakpoint) {
        @media #{inspect(map-get($breakpoints, $breakpoint))} {
            @content;
        }
    } @else {
        @media (#{inspect($breakpoint)}) {
            @content;
        }
    }
}

/**
 * Use this mixin for the parent element that holds the columns of grid.
 * Columns has display: inline-block property so to kill the default gap, we need to set font-size to 0.
 * Font size will be reset inside col mixin.
 */
@mixin row {
    font-size: 0;
}

/**
 * Creates column with given gap on the sides and align since it's inline-block.
 * Column has 100% width on mobile.
 * You can add 'fluid' class to perserve width on the mobile.
 *
 * @param {Number} $col - Number of columns
 * @param {Number} $sum - Sum of colums
 * @param {Number} $gap - Gap on the left and the right side
 * @param {Boolean} $first - If you set this to true, you will not have gap on the left side.
 * @param {Boolean} $last - If you set this to true, you will not have gap on the right side.
 */
@mixin col ($col, $sum, $gap: 1em, $first: false, $last: false) {
    width: percentage($col / $sum);
    float: left;
    padding-left: if($first, 0, $gap);
    padding-right: if($last, 0, $gap);
}

/**
 * Vertically center child element
 *
 * @param {String} $child - Child selector which you want to verticaly center.
 */
@mixin vertical-center-content ( $child ) {
    font-size: 0;

    &:before, &:after {
        content: "";
        display: inline-block;
        height: 100%;
        vertical-align: middle;
    }

    #{$child} {
        font-size: rem($base-font-size);
        display: inline-block;
        vertical-align: middle;
    }
}

/**
 * Return background position for svg sprite with png fallback
 *
 * @param {String} $icon
 */
@mixin sprite($icon) {
    width: sprite-attr($icon, width) + 5;
    height: sprite-attr($icon, height) + 5;
    background-image: url(../img/sprite.svg);
    background-position: sprite-attr($icon, backgroundX) sprite-attr($icon, backgroundY);

    #{$ieSprite} & {
        background-image: url(../img/sprite.png);
    }
}

/**
 * Return content propery of iconfont icon
 *
 * @param {String} $icon
 */
@mixin iconfont($icon) {
    @extend %iconfont;
    content: map-get($iconfont, $icon);
}

/**
 * Clear floats using clearfix technique.
 */
@mixin clearfix {
    &:after {
        content: "";
        display: table;
        clear: both;
    }
}

/**
 * Visually hide text using text-indent technique.
 */
@mixin hide-text {
    text-indent: -9999em;
    overflow: hidden;
    text-align: left;
}

/**
 * Remove default stylig for lists.
 */
@mixin reset-list {
    margin: 0;
    padding: 0;
    list-style: none;
}
