@mixin ext-box() {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
}

@mixin ext-inline-box() {
    display: -webkit-inline-box;
    display: -ms-inline-flexbox;
    display: inline-flex;
}

@mixin ext-box-align($align: stretch) {
    -webkit-box-align: $align;
    -ms-flex-align: $align;
    @if $align == start {
        align-items: flex-start;
    }
    @else if $align == end {
        align-items: flex-end;
    }
    @else {
        align-items: $align;
    }
}

@mixin ext-box-orient($orient: horizontal) {
    -webkit-box-orient: $orient;
    @if $orient == horizontal {
        -ms-flex-direction: row;
        flex-direction: row;
    } @else {
        -ms-flex-direction: column;
        flex-direction: column;
    }
}

@mixin ext-box-pack($pack: start) {
    -webkit-box-pack: $pack;
    -ms-flex-pack: $pack;
    @if $pack == start {
        justify-content: flex-start;
    }
    @else if $pack == end {
        justify-content: flex-end;
    }
    @else if $pack == justify {
        justify-content: space-between;
    }
    @else if $pack == center {
        justify-content: center;
    }
    @else {
        justify-content: $pack;
    }
}

@mixin ext-box-flex($flex: 1 1 auto) {
    -webkit-box-flex: nth($flex, 1);
    -ms-flex: $flex;
    flex: $flex;
    // workaround for firefox bug:
    // http://stackoverflow.com/questions/27424831/firefox-flexbox-overflow
    min-width: 0;
}

@mixin ext-box-direction($direction: normal, $orientation: row) {
    -webkit-box-direction: $direction;
    @if $direction == reverse {
        @if $orientation == row {
            -ms-flex-direction: row-reverse;
            flex-direction: row-reverse;
        } @else {
            -ms-flex-direction: column-reverse;
            flex-direction: column-reverse;
        }
    } @else {
        @if $orientation == row {
            -ms-flex-direction: row;
            flex-direction: row;
        } @else {
            -ms-flex-direction: column;
            flex-direction: column;
        }
    }
}
