/*------------------------------------*\
    $LAYOUT
\*------------------------------------*/

/**
 * The inuitcss layout system uses `box-sizing: border-box;` and
 * `display: inline-block;` to create an extremely powerful, flexible
 * alternative to the traditional grid system. Combine the layout items with
 * the widths found in `trumps.widths`.
 */

// Predefine the variables below in order to alter and enable specific features.
$layout-gutter:           $base-spacing-unit !default;
$layout-gutter--small:    halve($layout-gutter) !default;
$layout-gutter--large:    double($layout-gutter) !default;

$enable-layout--small:    false !default;
$enable-layout--large:    false !default;
$enable-layout--flush:    false !default;
$enable-layout--rev:      false !default;
$enable-layout--middle:   false !default;
$enable-layout--bottom:   false !default;
$enable-layout--right:    false !default;
$enable-layout--center:   false !default;





// Here we set a variable assuming that `box-sizing: border-box;` is not set
// globally. If it has been previously been defined, the following variable will
// be overriden and will be set to `true`.
$global-border-box: false !default;





/**
 * Begin a layout group.
 */
.#{$namespace}layout,
%#{$namespace}layout {
    list-style: none;
    margin:  0;
    padding: 0;
    margin-left: -$layout-gutter;
}

    /**
     * 1. Cause columns to stack side-by-side.
     * 2. Space columns apart.
     * 3. Align columns to the tops of each other.
     * 4. Full-width unless told to behave otherwise.
     * 5. Required to combine fluid widths and fixed gutters.
     */
    .#{$namespace}layout__item,
    %#{$namespace}layout__item {
        display: inline-block; /* [1] */
        padding-left: $layout-gutter; /* [2] */
        vertical-align: top; /* [3] */
        width: 100%; /* [4] */

        @if $global-border-box == false {
            -webkit-box-sizing: border-box; /* [5] */
               -moz-box-sizing: border-box; /* [5] */
                    box-sizing: border-box; /* [5] */
        }

    }





@if ($enable-layout--small == true) {

    /**
     * Layouts with small gutters.
     */

    .#{$namespace}layout--small,
    %#{$namespace}layout--small {
        margin-left: -($layout-gutter--small);

        > .#{$namespace}layout__item,
        > %#{$namespace}layout__item {
            padding-left: $layout-gutter--small;
        }

    }

}

@if ($enable-layout--large == true) {

    /**
     * Layouts with large gutters.
     */

    .#{$namespace}layout--large,
    %#{$namespace}layout--large {
        margin-left: -($layout-gutter--large);

        > .#{$namespace}layout__item,
        > %#{$namespace}layout__item {
            padding-left: $layout-gutter--large;
        }

    }

}





@if ($enable-layout--flush == true) {

    /**
     * Layouts with no gutters.
     */

    .#{$namespace}layout--flush,
    %#{$namespace}layout--flush {
        margin-left: 0;

        > .#{$namespace}layout__item,
        > %#{$namespace}layout__item {
            padding-left: 0;
        }

    }

}





@if ($enable-layout--rev == true) {

    /**
     * Reversed rendered order of layout items, e.g. items 1, 2, 3, 4 in your
     * markup will display in order 4, 3, 2, 1 on your page.
     */

    .#{$namespace}layout--rev,
    %#{$namespace}layout--rev {
        direction: rtl;
        text-align: left;

        > .#{$namespace}layout__item,
        > %#{$namespace}layout__item {
            direction: ltr;
            text-align: left;
        }

    }

}





@if ($enable-layout--middle == true) {

    /**
     * Align layout items to the vertical centers of each other.
     */

    .#{$namespace}layout--middle,
    %#{$namespace}layout--middle {

        > .#{$namespace}layout__item,
        > %#{$namespace}layout__item {
            vertical-align: middle;
        }

    }

}

@if ($enable-layout--bottom == true) {

    /**
     * Align layout items to the vertical bottoms of each other.
     */

    .#{$namespace}layout--bottom,
    %#{$namespace}layout--bottom {

        > .#{$namespace}layout__item,
        > %#{$namespace}layout__item {
            vertical-align: bottom;
        }

    }

}





@if ($enable-layout--right == true) {

    /**
     * Make the layout items fill up from the right hand side.
     */

    .#{$namespace}layout--right,
    %#{$namespace}layout--right {
        text-align: right;

        > .#{$namespace}layout__item,
        > %#{$namespace}layout__item {
            text-align: left;
        }

    }

}

@if ($enable-layout--center == true) {

    /**
     * Make the layout items fill up from the center outward.
     */

    .#{$namespace}layout--center,
    %#{$namespace}layout--center {
        text-align: center;

        > .#{$namespace}layout__item,
        > %#{$namespace}layout__item {
            text-align: left;
        }

    }

}