// Variables
// ========================================================================

$grid-gutter-horizontal: 2.5rem;
$grid-gutter-vertical: 2.5rem;
$grid-gutter-large-horizontal: 3.5rem;
$grid-gutter-large-vertical: 3.5rem;
$grid-gutter-small-horizontal: 1rem;
$grid-gutter-small-vertical: 1rem;
$grid-divider-border: #ddd;
$grid-divider-border-width: 1px;


/* ========================================================================
   Component: Grid
 ========================================================================== */


/*
 * Micro clearfix
 */

.column:before,
.column:after {
    content: " ";
    display: table;
}

.column:after {
    clear: both;
}


/*
 * 1. Needed for the gutter
 * 2. Makes grid more robust so that it can be used with other block elements like lists
 */

.column {
    /* 1 */
    margin: 0 0 0 -$grid-gutter-horizontal;
    /* 2 */
    padding: 0;
    list-style: none;
}


/*
 * Grid cell
 * 1. Makes grid more robust so that it can be used with other block elements
 * 2. Create horizontal gutter
 * 3. 'float' is set by default so columns always behave the same and create a new block format context
 */

.column>* {
    /* 1 */
    margin: 0;
    /* 2 */
    padding-left: $grid-gutter-horizontal;
    /* 3 */
    float: left;
}


/*
 * Remove margin from the last-child
 */

.column>*> :last-child {
    margin-bottom: 0;
}


/* Grid gutter
 ========================================================================== */


/*
 * Vertical gutter
 */

.column+.column {
    margin-top: $grid-gutter-vertical;
}


/*
 * This class is set by JavaScript and applies a vertical gutter if the columns stack or float into the next row
 * Higher specificity to override margin
 */

.column>.column-margin {
    margin-top: $grid-gutter-vertical;
}


/*
 * Vertical gutter for panels
 */

.column>*>.apUI-panel+.apUI-panel {
    margin-top: $grid-gutter-vertical;
}


/*
 * Larger gutter for large screens
 */


/* Large screen and bigger */

@media (min-width: $breakpoint-xlarge) {
    /* Horizontal gutter */
    .column:not(.column-preserve) {
        margin-left: -$grid-gutter-large-horizontal;
    }
    .column:not(.column-preserve)>* {
        padding-left: $grid-gutter-large-horizontal;
    }
    /* Vertical gutter */
    .column:not(.column-preserve)+.column {
        margin-top: $grid-gutter-large-vertical;
    }
    .column:not(.column-preserve)>.column-margin {
        margin-top: $grid-gutter-large-vertical;
    }
    /* Vertical gutter for panels */
    .column:not(.column-preserve)>*>.apUI-panel+.apUI-panel {
        margin-top: $grid-gutter-large-vertical;
    }
}


/*
 * Small gutter
 * Higher specificity to override large gutter
 */

.column.column-small {
    margin-left: -$grid-gutter-small-horizontal;
}

.column.column-small>* {
    padding-left: $grid-gutter-small-horizontal;
}

.column.column-small+.column-small {
    margin-top: $grid-gutter-small-vertical;
}

.column.column-small>.column-margin {
    margin-top: $grid-gutter-small-vertical;
}

.column.column-small>*>.apUI-panel+.apUI-panel {
    margin-top: $grid-gutter-small-vertical;
}


/* Modifier: 'column-divider'
 ========================================================================== */


/*
 * Horizontal divider
 * Does not work with 'column-push-*', 'column-pull-*' and not if the columns float into the next row
 */

.column-divider:not(:empty) {
    margin-left: -$grid-gutter-horizontal;
    margin-right: -$grid-gutter-horizontal;
}

.column-divider>* {
    padding-left: $grid-gutter-horizontal;
    padding-right: $grid-gutter-horizontal;
}

.column-divider>[class*='column-width-1-']:not(.column-width-1-1):nth-child(n+2),
.column-divider>[class*='column-width-2-']:nth-child(n+2),
.column-divider>[class*='column-width-3-']:nth-child(n+2),
.column-divider>[class*='column-width-4-']:nth-child(n+2),
.column-divider>[class*='column-width-5-']:nth-child(n+2),
.column-divider>[class*='column-width-6-']:nth-child(n+2),
.column-divider>[class*='column-width-7-']:nth-child(n+2),
.column-divider>[class*='column-width-8-']:nth-child(n+2),
.column-divider>[class*='column-width-9-']:nth-child(n+2) {
    border-left: $grid-divider-border-width solid $grid-divider-border;
}


/* Tablet and bigger */

@media (min-width: $breakpoint-medium) {
    .column-divider>[class*='column-width-medium-']:not(.column-width-medium-1-1):nth-child(n+2) {
        border-left: $grid-divider-border-width solid $grid-divider-border;
    }
}


/* Desktop and bigger */

@media (min-width: $breakpoint-large) {
    .column-divider>[class*='column-width-large-']:not(.column-width-large-1-1):nth-child(n+2) {
        border-left: $grid-divider-border-width solid $grid-divider-border;
    }
}


/* Large screen and bigger */

@media (min-width: $breakpoint-xlarge) {
    /*
     * Large gutter
     */
    .column-divider:not(.column-preserve):not(:empty) {
        margin-left: -$grid-gutter-large-horizontal;
        margin-right: -$grid-gutter-large-horizontal;
    }
    .column-divider:not(.column-preserve)>* {
        padding-left: $grid-gutter-large-horizontal;
        padding-right: $grid-gutter-large-horizontal;
    }
    .column-divider:not(.column-preserve):empty {
        margin-top: $grid-gutter-large-vertical;
        margin-bottom: $grid-gutter-large-vertical;
    }
}


/*
 * Vertical divider
 */

.column-divider:empty {
    margin-top: $grid-gutter-vertical;
    margin-bottom: $grid-gutter-vertical;
    border-top: $grid-divider-border-width solid $grid-divider-border;
}


/* Even grid cell widths
 ========================================================================== */

[class*='column-width']>* {
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    width: 100%;
}

/* Sub-objects: 'column-width-*'
 ========================================================================== */

[class*='column-width'] {
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    width: 100%;
}


/*
 * Widths
 */


/* Whole */

.column-width-1-1 {
    width: 100%;
}


/* Halves */

.column-width-1-2,
.column-width-2-4,
.column-width-3-6,
.column-width-4-8,
.column-width-5-10 {
    width: 50%;
}


/* Thirds */

.column-width-1-3,
.column-width-2-6,
.column-width-3-9 {
    width: 33.333%;
}

.column-width-2-3,
.column-width-4-6,
.column-width-6-9 {
    width: 66.666%;
}


/* Quarters */

.column-width-1-4,
.column-width-2-8 {
    width: 25%;
}

.column-width-3-4,
.column-width-6-8 {
    width: 75%;
}


/* Fifths */

.column-width-1-5,
.column-width-2-10 {
    width: 20%;
}

.column-width-2-5,
.column-width-4-10 {
    width: 40%;
}

.column-width-3-5,
.column-width-6-10 {
    width: 60%;
}

.column-width-4-5,
.column-width-8-10 {
    width: 80%;
}


/* Sixths */

.column-width-1-6 {
    width: 16.666%;
}

.column-width-5-6 {
    width: 83.333%;
}


/* Sevenths */

.column-width-1-7 {
    width: 14.285714%;
}

.column-width-2-7 {
    width: 28.571429%;
}

.column-width-3-7 {
    width: 42.857143%;
}

.column-width-4-7 {
    width: 57.142857%;
}

.column-width-5-7 {
    width: 71.428571%;
}

.column-width-6-7 {
    width: 85.714286%;
}


/* Eighths */

.column-width-1-8 {
    width: 12.5%;
}

.column-width-3-8 {
    width: 37.5%;
}

.column-width-5-8 {
    width: 62.5%;
}

.column-width-7-8 {
    width: 87.5%;
}


/* Nineths */

.column-width-1-9 {
    width: 11.111%;
}

.column-width-2-9 {
    width: 22.222%;
}

.column-width-4-9 {
    width: 44.444%;
}

.column-width-5-9 {
    width: 55.555%;
}

.column-width-7-9 {
    width: 66.666%;
}

.column-width-8-9 {
    width: 88.888%;
}


/* Tenths */

.column-width-1-10 {
    width: 10%;
}

.column-width-3-10 {
    width: 30%;
}

.column-width-7-10 {
    width: 70%;
}

.column-width-9-10 {
    width: 90%;
}

/* Fifteenths */
.column-width-8-25-15 {
    width: 55%;
}

.column-width-9-25-15 {
    width: 61.67%;
}

.column-width-9-75-15 {
    width: 65%;
}


/* Phone landscape and bigger */

@media (min-width: $breakpoint-small) {
    /* Whole */
    .column-width-small-1-1 {
        width: 100%;
    }
    /* Halves */
    .column-width-small-1-2,
    .column-width-small-2-4,
    .column-width-small-3-6,
    .column-width-small-4-8,
    .column-width-small-5-10 {
        width: 50%;
    }
    /* Thirds */
    .column-width-small-1-3,
    .column-width-small-2-6,
    .column-width-small-3-9 {
        width: 33.333%;
    }
    .column-width-small-2-3,
    .column-width-small-4-6,
    .column-width-small-6-9 {
        width: 66.666%;
    }
    /* Quarters */
    .column-width-small-1-4,
    .column-width-small-2-8 {
        width: 25%;
    }
    .column-width-small-3-4,
    .column-width-small-6-8 {
        width: 75%;
    }
    /* Fifths */
    .column-width-small-1-5,
    .column-width-small-2-10 {
        width: 20%;
    }
    .column-width-small-2-5,
    .column-width-small-4-10 {
        width: 40%;
    }
    .column-width-small-3-5,
    .column-width-small-6-10 {
        width: 60%;
    }
    .column-width-small-4-5,
    .column-width-small-8-10 {
        width: 80%;
    }
    /* Sixths */
    .column-width-small-1-6 {
        width: 16.666%;
    }
    .column-width-small-5-6 {
        width: 83.333%;
    }
    /* Sevenths */
    .column-width-small-1-7 {
        width: 14.285714%;
    }
    .column-width-small-2-7 {
        width: 28.571429%;
    }
    .column-width-small-3-7 {
        width: 42.857143%;
    }
    .column-width-small-4-7 {
        width: 57.142857%;
    }
    .column-width-small-5-7 {
        width: 71.428571%;
    }
    .column-width-small-6-7 {
        width: 85.714286%;
    }
    /* Eighths */
    .column-width-small-1-8 {
        width: 12.5%;
    }
    .column-width-small-3-8 {
        width: 37.5%;
    }
    .column-width-small-5-8 {
        width: 62.5%;
    }
    .column-width-small-7-8 {
        width: 87.5%;
    }
    /* Nineths */
    .column-width-small-1-9 {
        width: 11.111%;
    }
    .column-width-small-2-9 {
        width: 22.222%;
    }
    .column-width-small-4-9 {
        width: 44.444%;
    }
    .column-width-small-5-9 {
        width: 55.555%;
    }
    .column-width-small-7-9 {
        width: 66.666%;
    }
    .column-width-small-8-9 {
        width: 88.888%;
    }
    /* Tenths */
    .column-width-small-1-10 {
        width: 10%;
    }
    .column-width-small-3-10 {
        width: 30%;
    }
    .column-width-small-7-10 {
        width: 70%;
    }
    .column-width-small-9-10 {
        width: 90%;
    }
    /* Fifteenths */
    .column-width-small-8-25-15 {
        width: 55%;
    }

    .column-width-small-9-25-15 {
        width: 61.67%;
    }

    .column-width-small-9-75-15 {
        width: 65%;
    }
}


/* Tablet and bigger */

@media (min-width: $breakpoint-medium) {
    /* Whole */
    .column-width-medium-1-1 {
        width: 100%;
    }
    /* Halves */
    .column-width-medium-1-2,
    .column-width-medium-2-4,
    .column-width-medium-3-6,
    .column-width-medium-4-8,
    .column-width-medium-5-10 {
        width: 50%;
    }
    /* Thirds */
    .column-width-medium-1-3,
    .column-width-medium-2-6,
    .column-width-medium-3-9 {
        width: 33.333%;
    }
    .column-width-medium-2-3,
    .column-width-medium-4-6,
    .column-width-medium-6-9 {
        width: 66.666%;
    }
    /* Quarters */
    .column-width-medium-1-4,
    .column-width-medium-2-8 {
        width: 25%;
    }
    .column-width-medium-3-4,
    .column-width-medium-6-8 {
        width: 75%;
    }
    /* Fifths */
    .column-width-medium-1-5,
    .column-width-medium-2-10 {
        width: 20%;
    }
    .column-width-medium-2-5,
    .column-width-medium-4-10 {
        width: 40%;
    }
    .column-width-medium-3-5,
    .column-width-medium-6-10 {
        width: 60%;
    }
    .column-width-medium-4-5,
    .column-width-medium-8-10 {
        width: 80%;
    }
    /* Sixths */
    .column-width-medium-1-6 {
        width: 16.666%;
    }
    .column-width-medium-5-6 {
        width: 83.333%;
    }
    /* Sevenths */
    .column-width-medium-1-7 {
        width: 14.285714%;
    }
    .column-width-medium-2-7 {
        width: 28.571429%;
    }
    .column-width-medium-3-7 {
        width: 42.857143%;
    }
    .column-width-medium-4-7 {
        width: 57.142857%;
    }
    .column-width-medium-5-7 {
        width: 71.428571%;
    }
    .column-width-medium-6-7 {
        width: 85.714286%;
    }
    /* Eighths */
    .column-width-medium-1-8 {
        width: 12.5%;
    }
    .column-width-medium-3-8 {
        width: 37.5%;
    }
    .column-width-medium-5-8 {
        width: 62.5%;
    }
    .column-width-medium-7-8 {
        width: 87.5%;
    }
    /* Nineths */
    .column-width-medium-1-9 {
        width: 11.111%;
    }
    .column-width-medium-2-9 {
        width: 22.222%;
    }
    .column-width-medium-4-9 {
        width: 44.444%;
    }
    .column-width-medium-5-9 {
        width: 55.555%;
    }
    .column-width-medium-7-9 {
        width: 66.666%;
    }
    .column-width-medium-8-9 {
        width: 88.888%;
    }
    /* Tenths */
    .column-width-medium-1-10 {
        width: 10%;
    }
    .column-width-medium-3-10 {
        width: 30%;
    }
    .column-width-medium-7-10 {
        width: 70%;
    }
    .column-width-medium-9-10 {
        width: 90%;
    }
    /* Fifteenths */
    .column-width-medium-8-25-15 {
        width: 55%;
    }

    .column-width-medium-9-25-15 {
        width: 61.67%;
    }

    .column-width-medium-9-75-15 {
        width: 65%;
    }
}


/* Desktop and bigger */

@media (min-width: $breakpoint-large) {
    /* Whole */
    .column-width-large-1-1 {
        width: 100%;
    }
    /* Halves */
    .column-width-large-1-2,
    .column-width-large-2-4,
    .column-width-large-3-6,
    .column-width-large-4-8,
    .column-width-large-5-10 {
        width: 50%;
    }
    /* Thirds */
    .column-width-large-1-3,
    .column-width-large-2-6,
    .column-width-large-3-9 {
        width: 33.333%;
    }
    .column-width-large-2-3,
    .column-width-large-4-6,
    .column-width-large-6-9 {
        width: 66.666%;
    }
    /* Quarters */
    .column-width-large-1-4,
    .column-width-large-2-8 {
        width: 25%;
    }
    .column-width-large-3-4,
    .column-width-large-6-8 {
        width: 75%;
    }
    /* Fifths */
    .column-width-large-1-5,
    .column-width-large-2-10 {
        width: 20%;
    }
    .column-width-large-2-5,
    .column-width-large-4-10 {
        width: 40%;
    }
    .column-width-large-3-5,
    .column-width-large-6-10 {
        width: 60%;
    }
    .column-width-large-4-5,
    .column-width-large-8-10 {
        width: 80%;
    }
    /* Sixths */
    .column-width-large-1-6 {
        width: 16.666%;
    }
    .column-width-large-5-6 {
        width: 83.333%;
    }
    /* Sevenths */
    .column-width-large-1-7 {
        width: 14.285714%;
    }
    .column-width-large-2-7 {
        width: 28.571429%;
    }
    .column-width-large-3-7 {
        width: 42.857143%;
    }
    .column-width-large-4-7 {
        width: 57.142857%;
    }
    .column-width-large-5-7 {
        width: 71.428571%;
    }
    .column-width-large-6-7 {
        width: 85.714286%;
    }
    /* Eighths */
    .column-width-large-1-8 {
        width: 12.5%;
    }
    .column-width-large-3-8 {
        width: 37.5%;
    }
    .column-width-large-5-8 {
        width: 62.5%;
    }
    .column-width-large-7-8 {
        width: 87.5%;
    }
    /* Nineths */
    .column-width-large-1-9 {
        width: 11.111%;
    }
    .column-width-large-2-9 {
        width: 22.222%;
    }
    .column-width-large-4-9 {
        width: 44.444%;
    }
    .column-width-large-5-9 {
        width: 55.555%;
    }
    .column-width-large-7-9 {
        width: 66.666%;
    }
    .column-width-large-8-9 {
        width: 88.888%;
    }
    /* Tenths */
    .column-width-large-1-10 {
        width: 10%;
    }
    .column-width-large-3-10 {
        width: 30%;
    }
    .column-width-large-7-10 {
        width: 70%;
    }
    .column-width-large-9-10 {
        width: 90%;
    }
    /* Fifteenths */
    .column-width-large-8-25-15 {
        width: 55%;
    }

    .column-width-large-9-25-15 {
        width: 61.67%;
    }

    .column-width-large-9-75-15 {
        width: 65%;
    }
}


/* Sub-object: 'column-push-*' and 'column-pull-*'
 ========================================================================== */


/*
 * Source ordering
 * Works only with 'column-width-medium-*'
 */


/* Tablet and bigger */

@media (min-width: $breakpoint-medium) {
    [class*='column-push-'],
    [class*='column-pull-'] {
        position: relative;
    }
    /*
     * Push
     */
    /* Halves */
    .column-push-1-2,
    .column-push-2-4,
    .column-push-3-6,
    .column-push-4-8,
    .column-push-5-10 {
        left: 50%;
    }
    /* Thirds */
    .column-push-1-3,
    .column-push-2-6,
    .column-push-3-9 {
        left: 33.333%;
    }
    .column-push-2-3,
    .column-push-4-6,
    .column-push-6-9 {
        left: 66.666%;
    }
    /* Quarters */
    .column-push-1-4,
    .column-push-2-8 {
        left: 25%;
    }
    .column-push-3-4,
    .column-push-6-8 {
        left: 75%;
    }
    /* Fifths */
    .column-push-1-5,
    .column-push-2-10 {
        left: 20%;
    }
    .column-push-2-5,
    .column-push-4-10 {
        left: 40%;
    }
    .column-push-3-5,
    .column-push-6-10 {
        left: 60%;
    }
    .column-push-4-5,
    .column-push-8-10 {
        left: 80%;
    }
    /* Sixths */
    .column-push-1-6 {
        left: 16.666%;
    }
    .column-push-5-6 {
        left: 83.333%;
    }
    /* Sevenths */
    .column-push-1-7 {
        left: 14.285714%;
    }
    .column-push-2-7 {
        left: 28.571429%;
    }
    .column-push-3-7 {
        left: 42.857143%;
    }
    .column-push-4-7 {
        left: 57.142857%;
    }
    .column-push-5-7 {
        left: 71.428571%;
    }
    .column-push-6-7 {
        left: 85.714286%;
    }
    /* Eighths */
    .column-push-1-8 {
        left: 12.5%;
    }
    .column-push-3-8 {
        left: 37.5%;
    }
    .column-push-5-8 {
        left: 62.5%;
    }
    .column-push-7-8 {
        left: 87.5%;
    }
    /* Nineths */
    .column-push-1-9 {
        left: 11.111%;
    }
    .column-push-2-9 {
        left: 22.222%;
    }
    .column-push-4-9 {
        left: 44.444%;
    }
    .column-push-5-9 {
        left: 55.555%;
    }
    .column-push-7-9 {
        left: 66.666%;
    }
    .column-push-8-9 {
        left: 88.888%;
    }
    /* Tenths */
    .column-push-1-10 {
        left: 10%;
    }
    .column-push-3-10 {
        left: 30%;
    }
    .column-push-7-10 {
        left: 70%;
    }
    .column-push-9-10 {
        left: 90%;
    }
    /*
     * Pull
     */
    /* Halves */
    .column-pull-1-2,
    .column-pull-2-4,
    .column-pull-3-6,
    .column-pull-4-8,
    .column-pull-5-10 {
        left: -50%;
    }
    /* Thirds */
    .column-pull-1-3,
    .column-pull-2-6,
    .column-pull-3-9 {
        left: -33.333%;
    }
    .column-pull-2-3,
    .column-pull-4-6,
    .column-pull-6-9 {
        left: -66.666%;
    }
    /* Quarters */
    .column-pull-1-4,
    .column-pull-2-8 {
        left: -25%;
    }
    .column-pull-3-4,
    .column-pull-6-8 {
        left: -75%;
    }
    /* Fifths */
    .column-pull-1-5,
    .column-pull-2-10 {
        left: -20%;
    }
    .column-pull-2-5,
    .column-pull-4-10 {
        left: -40%;
    }
    .column-pull-3-5,
    .column-pull-6-10 {
        left: -60%;
    }
    .column-pull-4-5,
    .column-pull-8-10 {
        left: -80%;
    }
    /* Sixths */
    .column-pull-1-6 {
        left: -16.666%;
    }
    .column-pull-5-6 {
        left: -83.333%;
    }
    /* Sevenths */
    .column-pull-1-7 {
        left: -14.285714%;
    }
    .column-pull-2-7 {
        left: -28.571429%;
    }
    .column-pull-3-7 {
        left: -42.857143%;
    }
    .column-pull-4-7 {
        left: -57.142857%;
    }
    .column-pull-5-7 {
        left: -71.428571%;
    }
    .column-pull-6-7 {
        left: -85.714286%;
    }
    /* Eighths */
    .column-pull-1-8 {
        left: -12.5%;
    }
    .column-pull-3-8 {
        left: -37.5%;
    }
    .column-pull-5-8 {
        left: -62.5%;
    }
    .column-pull-7-8 {
        left: -87.5%;
    }
    /* Nineths */
    .column-pull-1-9 {
        left: -11.111%;
    }
    .column-pull-2-9 {
        left: -22.222%;
    }
    .column-pull-4-9 {
        left: -44.444%;
    }
    .column-pull-5-9 {
        left: -55.555%;
    }
    .column-pull-7-9 {
        left: -66.666%;
    }
    .column-pull-8-9 {
        left: -88.888%;
    }
    /* Tenths */
    .column-pull-1-10 {
        left: -10%;
    }
    .column-pull-3-10 {
        left: -30%;
    }
    .column-pull-7-10 {
        left: -70%;
    }
    .column-pull-9-10 {
        left: -90%;
    }
}

// Hooks
// ========================================================================
@mixin hook-grid-misc() {}