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

// spacing
$crispy__helpers__spacing-gap: 8px !default;
$crispy__helpers__spacing-steps: 6 !default;
$crispy__helpers__spacing-max-steps: 3 !default;
$crispy__helpers__spacing-breakpoints: (
    $crispy__md: 12px
) !default;

// width
$crispy__helpers__width: (
    '25' : 25%,
    '50' : 50%,
    '75' : 75%,
    '100': 100%
) !default;

@mixin crispy__helpers() {

    /**
     *  borders
     *
     *
     */

    .bordered {
        border: $crispy__border !important;
    }

    .rounded {
        border-radius: $crispy__border-radius !important;
    }

    .round {
        border-radius: 50% !important;
    }

    .borderless {
        border: 0 !important;
    }

    .radiusless {
        border-radius: 0 !important;
    }


    /**
     * typography
     *
     *
     */

    .text-left {
        text-align: left !important;
    }

    .text-right {
        text-align: right !important;
    }

    .text-center {
        text-align: center !important;
    }

    .text-justify {
        text-align: justify !important;
    }

    .text-uppercase {
        text-transform: uppercase !important;
    }

    .text-lowercase {
        text-transform: lowercase !important;
    }

    .text-crossed {
        text-decoration: line-through !important;
    }

    .text-underline {
        text-decoration: underline !important;
    }

    .text-capitalize {
        text-transform: capitalize !important;
    }

    .text-italic {
        font-style: italic !important;
    }

    .text-light {
        font-weight: lighter !important;
    }

    .text-normal {
        font-weight: normal !important;
    }

    .text-medium {
        font-weight: medium !important;
    }

    .text-bold {
        font-weight: bolder !important;
    }

    // getting default
    $defaultFontSize: getDefault($crispy__font-sizes);

    @each $name, $font-size in $crispy__font-sizes {
        .text-size-#{$name} {
            font-size: $font-size !important;
            @include crispy__media-breakpoints-font-size($crispy__font-size-breakpoints, $font-size, $defaultFontSize, true);
        }
    }


    /**
     *  colors
     *
     *
     */

    @each $name, $color in $crispy__colors {
        .text-color-#{$name} {
            color: $color !important;
        }
    }

    @each $name, $color in $crispy__colors {
        .border-color-#{$name} {
            border-color: $color !important;
        }
    }

    @each $name, $color in $crispy__colors {
        .background-color-#{$name} {
            background-color: $color !important;
        }
    }


    /**
     *  floating
     *
     *
     */

    .float-left {
        float: left;
    }

    .float-right {
        float: right;
    }

    .float-none {
        float: none;
    }

    .centered {
        margin-left: auto;
        margin-right: auto;
    }

    .clearfix {
        @include crispy__clearfix();
    }

    /**
     *  flex
     *
     *
     */

    .display-flex {
        display: flex;
    }

    /**
     *  position
     *
     *
     */

    .absolute {
        position: absolute !important;
    }

    .fixed {
        position: fixed !important;
    }

    .relative {
        position: relative !important;
    }


    /**
     *  hide & show
     *
     *
     */

    .hide {
        display: none !important;

        &-xs {
            @include crispy__media-xs() {
                display: none !important;
            }
        }

        &-sm {
            @include crispy__media-sm() {
                display: none !important;
            }
        }

        &-md {
            @include crispy__media-md() {
                display: none !important;
            }
        }

        &-lg {
            @include crispy__media-lg() {
                display: none !important;
            }
        }

        &-xlg {
            @include crispy__media-xlg() {
                display: none !important;
            }
        }
    }

    .show {
        display: block !important;

        &-inline {
            display: inline !important;
        }

        &-inline-block {
            display: inline-block !important;
        }

        &-xs {
            @include crispy__media-xs() {
                display: block !important;

                &-inline {
                    display: inline !important;
                }

                &-inline-block {
                    display: inline-block !important;
                }
            }
        }

        &-sm {
            @include crispy__media-sm() {
                display: block !important;

                &-inline {
                    display: inline !important;
                }

                &-inline-block {
                    display: inline-block !important;
                }
            }
        }

        &-md {
            @include crispy__media-md() {
                display: block !important;

                &-inline {
                    display: inline !important;
                }

                &-inline-block {
                    display: inline-block !important;
                }
            }
        }

        &-lg {
            @include crispy__media-lg() {
                display: block !important;

                &-inline {
                    display: inline !important;
                }

                &-inline-block {
                    display: inline-block !important;
                }
            }
        }

        &-xlg {
            @include crispy__media-xlg() {
                display: block !important;
                &-inline {
                    display: inline !important;
                }

                &-inline-block {
                    display: inline-block !important;
                }
            }
        }
    }

    /**
     *
     *
     */

    .height-100 {
        height: 100%;
    }

    /**
     *  width
     *
     *
     */

    @each $name, $width in $crispy__helpers__width {
        .width-#{$name} {
            width: $width !important;
        }
    }


    /**
     *  margin & padding
     *
     *
     */

    .marginless {
        margin: 0 !important;
    }

    .paddingless {
        padding: 0 !important;
    }

    @for $i from 0 through $crispy__helpers__spacing-steps {
        .margin-top-#{$i} {
            margin-top: ($crispy__helpers__spacing-gap * factor($i)) !important;

            @if $i > 0 {
                @include crispy__media-breakpoints-calculate('margin-top', factor($i), $crispy__helpers__spacing-breakpoints, true);
            }
        }

        .margin-bottom-#{$i} {
            margin-bottom: ($crispy__helpers__spacing-gap * factor($i)) !important;

            @if $i > 0 {
                @include crispy__media-breakpoints-calculate('margin-bottom', factor($i), $crispy__helpers__spacing-breakpoints, true);
            }
        }

        .padding-top-#{$i} {
            padding-top: ($crispy__helpers__spacing-gap * $i) !important;

            @if $i > 0 {
                @include crispy__media-breakpoints-calculate('padding-top', factor($i), $crispy__helpers__spacing-breakpoints, true);
            }
        }

        .padding-bottom-#{$i} {
            padding-bottom: ($crispy__helpers__spacing-gap * $i) !important;

            @if $i > 0 {
                @include crispy__media-breakpoints-calculate('padding-bottom', factor($i), $crispy__helpers__spacing-breakpoints, true);
            }
        }

        // to reduce size of css only use max steps
        @if $i < $crispy__helpers__spacing-max-steps {
            .margin-left-#{$i} {
                margin-left: ($crispy__helpers__spacing-gap * $i) !important;

                @if $i > 0 {
                    @include crispy__media-breakpoints-calculate('margin-left', factor($i), $crispy__helpers__spacing-breakpoints, true);
                }
            }

            .margin-right-#{$i} {
                margin-right: ($crispy__helpers__spacing-gap * $i) !important;

                @if $i > 0 {
                    @include crispy__media-breakpoints-calculate('margin-right', factor($i), $crispy__helpers__spacing-breakpoints, true);
                }
            }

            .padding-left-#{$i} {
                padding-left: ($crispy__helpers__spacing-gap * $i) !important;

                @if $i > 0 {
                    @include crispy__media-breakpoints-calculate('padding-left', factor($i), $crispy__helpers__spacing-breakpoints, true);
                }
            }

            .padding-right-#{$i} {
                padding-right: ($crispy__helpers__spacing-gap * $i) !important;

                @if $i > 0 {
                    @include crispy__media-breakpoints-calculate('padding-right', factor($i), $crispy__helpers__spacing-breakpoints, true);
                }
            }
        }
    }
}
