//
// Copyright 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

@import "@material/animation/functions";
@import "@material/elevation/mixins";
@import "@material/rtl/mixins";
@import "../mixins";
@import "../variables";
@import "../slidable/mixins";
@import "../slidable/variables";

.mdc-drawer--temporary {
  @include mdc-drawer-base_;
  @include mdc-drawer-ink-color($mdc-temporary-drawer-ink-color);
  @include mdc-drawer-fill-color($mdc-temporary-drawer-fill-color);
  @include mdc-drawer-scrim-color($mdc-temporary-drawer-scrim-color, $mdc-temporary-drawer-scrim-opacity);

  position: fixed;
  top: 0;
  left: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  contain: strict;
  z-index: 5;

  // Shaded background
  &::before {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    opacity: 0;
    opacity: var(--mdc-temporary-drawer-opacity, 0);
    content: "";
    will-change: opacity;
  }

  .mdc-drawer__drawer {
    @include mdc-elevation(16);
    @include mdc-rtl-reflexive-position(left, 0);
    @include mdc-slideable-drawer;

    display: flex;
    position: absolute;
    flex-direction: column;
    box-sizing: border-box;
    width: calc(100% - 56px);
    max-width: 280px;
    overflow: hidden;
    touch-action: none;

    // TODO(sgomes): replace with global breakpoints when we have them
    @media (min-width: 600px) {
      width: calc(100% - 64px);
      max-width: 320px;
    }
  }

  .mdc-drawer__content {
    flex-grow: 1;
    box-sizing: border-box;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  .mdc-drawer__footer {
    @include mdc-elevation(2);

    flex-shrink: 0;
  }

  &.mdc-drawer--open {
    pointer-events: auto;

    &::before {
      opacity: 1;
      opacity: var(--mdc-temporary-drawer-opacity, 1);
    }

    .mdc-drawer__drawer {
      @include mdc-slideable-drawer-open;
    }

    // Specificity fix to ensure that mdc-drawer is not translated off-screen within an RTL context
    @include mdc-rtl {
      .mdc-drawer__drawer {
        @include mdc-slideable-drawer-open;
      }
    }
  }

  &.mdc-drawer--animating {
    &::before {
      transition: mdc-animation-enter(opacity, .3s);
    }

    .mdc-drawer__drawer {
      transition: $mdc-slidable-drawer-transition-close;
    }

    &.mdc-drawer--open .mdc-drawer__drawer {
      transition: $mdc-slidable-drawer-transition-open;
    }
  }
}

.mdc-drawer-scroll-lock {
  overflow: hidden;
}
