@import 'commons';

.m-sidebar {
    display: inline-block;

    &__wrap {
        transition-duration: $m-transition-duration;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background: none;
        display: flex;
        justify-content: center;
        align-items: center;
        outline: none;
        min-width: $m-min-width;
        user-select: none;

        @include m-is-ie() {
            display: block;
        }

        &.m--is-close-on-backdrop {
            cursor: pointer;
            -webkit-tap-highlight-color: transparent;
        }

        &.m--is-full-height {
            &.m--is-origin-bottom .m-sidebar__article {
                height: calc(100% - #{$m-touch-size * 2});
            }
        }

        &.m--is-origin {

            &-top,
            &-right,
            &-left {
                .m-sidebar__article {
                    top: 0;
                    bottom: 0;
                }
            }

            &-top {

                &.m--is-enter,
                &.m--is-leave-to {
                    .m-sidebar__article {
                        transform: translate3d(0, -100%, 0);
                    }
                }
            }

            &-bottom {
                .m-sidebar__article {
                    max-height: calc(100% - #{$m-touch-size * 2});
                    bottom: 0;
                }

                &.m--is-enter,
                &.m--is-leave-to {
                    .m-sidebar__article {
                        transform: translate3d(0, calc(100% + #{$m-touch-size}), 0);
                        bottom: 0;
                    }
                }
            }

            &-right {

                &.m--is-enter,
                &.m--is-leave-to {
                    .m-sidebar__article {
                        transform: translate3d(100%, 0, 0);
                    }
                }
            }

            &-left {

                &.m--is-enter,
                &.m--is-leave-to {
                    .m-sidebar__article {
                        transform: translate3d(-100%, 0, 0);
                    }
                }
            }
        }
    }

    &__article {
        transition: transform $m-transition-duration-lg ease-in-out;
        position: absolute;
        right: 0;
        left: 0;
        transform: translate3d(0, 0, 0);
        display: flex;
        flex-direction: column;
        width: 100%;
        min-height: $m-touch-size-lg;
        max-height: 100%;
        background: $m-color-white;
        box-shadow: 0 3px 5px rgba(0, 0, 0, 0.15);
        outline: none;
        cursor: auto;
    }

    &__close-button {
        transition: color $m-transition-duration-lg ease, background $m-transition-duration-lg ease;
        position: absolute;
        top: 0;
        right: 0;
        padding: $m-space-sm $m-space;
        background: none;
        border: none;
        @include m-font-size();
        color: $m-color-white;
        cursor: pointer;
        outline: none;
        text-decoration: none;
        line-height: 1;
        transform: translate3d(0, -100%, 0);

        &:hover,
        &:focus {
            color: $m-color-grey;
        }
    }

    &__header,
    &__body,
    &__footer {
        position: relative;

        &.m--no-padding {
            padding: 0;
        }

        > :first-child {
            margin-top: 0;

            > :first-child {
                margin-top: 0;
            }
        }
    }

    &__header {
        padding: $m-space-sm $m-space;
        width: 100%;

        &.m--has-close-button-right {
            padding-right: $m-touch-size;

            .m-sidebar__header__close-button {
                right: 0;
            }
        }

        &.m--has-close-button-left {
            padding-left: $m-touch-size;

            .m-sidebar__header__close-button {
                left: 0;
            }
        }

        &.m--no-content {
            height: $m-touch-size;
        }

        &__close-button.m-icon-button {
            position: absolute;
            top: 50%;
            transform: translate3d(0, -50%, 0);
        }

        h1,
        h2,
        h3,
        h4,
        h5,
        h6 {
            margin: 0;
            @include m-font-size('h2');
            font-weight: $m-font-weight-semi-bold;
        }
    }

    &__body {
        padding: $m-space;
        flex: 1 1 auto;
        overflow: auto;
        user-select: text;

        @include m-scrollbar();
    }

    &__footer {
        padding: $m-space-sm $m-space;
    }
}
