//
// Copyright 2019 Stijn de Witt. Some rights reserved.
// Licensed under the MIT Open Source license. 
// https://opensource.org/licenses/MIT
// See LICENSE for details.
//
// Based on code copyright 2018 Google Inc. All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// http://www.apache.org/licenses/LICENSE-2.0
// See LICENSE-MDC for details.
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under these licenses is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the licenses for the specific language governing permissions and
// limitations under these licenses.
// 

@import "../animation/functions";
@import "../elevation/mixins";
@import "../theme/mixins";
@import "../rtl/mixins";
@import "../typography/mixins";
@import "../typography/variables";

// postcss-bem-linter: define dialog

.mdc-dialog {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  visibility: hidden;
  z-index: 5;
}

.mdc-dialog__backdrop {
  @include mdc-theme-prop(background-color, text-primary-on-light);

  position: fixed;
  top: 0;
  left: 0;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  opacity: 0;
  z-index: -1;
}

.mdc-dialog__surface {
  @include elevation(24);
  @include mdc-theme-prop(background-color, background);

  display: inline-flex;
  flex-direction: column;
  width: calc(100% - 30px);
  min-width: 640px;
  max-width: 865px;
  transform: translateY(150px) scale(.8);
  border-radius: 2px;
  opacity: 0;

  @include mdc-rtl(".mdc-dialog") {
    text-align: right;
  }
}

.mdc-dialog__header {
  display: flex;
  align-items: center;
  padding: 24px 24px 0;

  @include mdc-rtl(".mdc-dialog") {
    text-align: right;
  }
}

.mdc-dialog__header__empty {
  padding: 0;
}

.mdc-dialog__header__title {
  @include typography(headline6);

  flex: 1;
  margin: 0;
}

.mdc-dialog__body {
  @include mdc-theme-prop(color, text-secondary-on-light);
  @include typography(body1);

  margin-top: 20px;
  padding: 0 24px 24px;
}

.mdc-dialog__body--scrollable {
  max-height: 195px;
  border-top: 1px solid rgba(0, 0, 0, .1);
  border-bottom: 1px solid rgba(0, 0, 0, .1);
  overflow-x: auto;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
}

.mdc-dialog__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  padding: 8px;
}

.mdc-dialog__footer__button {
  @include mdc-rtl-reflexive-box(margin, right, 8px);

  &:last-child {
    @include mdc-rtl-reflexive-box(margin, right, 0);
  }
}

.mdc-dialog__action {
  @include mdc-theme-prop(color, secondary);
}

// TODO: Replace with breakpoint variable
@media (max-width: 640px) {
  .mdc-dialog {
    min-width: 280px;
  }

  .mdc-dialog__surface {
    min-width: 280px;
  }

  .mdc-dialog__body {
    line-height: 24px;
  }
}

.mdc-dialog--animating {
  visibility: visible;

  .mdc-dialog__backdrop {
    transition: mdc-animation-enter(opacity, 120ms);
  }

  .mdc-dialog__surface {
    transition: mdc-animation-enter(opacity, 120ms), mdc-animation-enter(transform, 120ms);
  }
}

.mdc-dialog--open {
  visibility: visible;

  .mdc-dialog__backdrop {
    opacity: .3;
  }

  .mdc-dialog__surface {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

// postcss-bem-linter: end

.mdc-dialog-scroll-lock {
  overflow: hidden;
}
