//
// 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/rtl/mixins";
@import "@material/theme/mixins";
@import "@material/typography/mixins";
@import "./variables";

// postcss-bem-linter: define snackbar
.mdc-snackbar {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 50%;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
  padding-right: 24px;
  padding-left: 24px;
  transform: translate(-50%, 100%);
  transition: mdc-animation-exit-permanent(transform, .25s);
  background-color: $mdc-snackbar-background-color;
  pointer-events: none;
  will-change: transform;

  @media (max-width: ($mdc-snackbar-tablet-breakpoint - 1)) {
    left: 0;
    width: 100%;
    transform: translate(0, 100%);
  }

  @media (min-width: $mdc-snackbar-tablet-breakpoint) {
    min-width: 288px;
    max-width: 568px;
    border-radius: 2px;
  }
}

.mdc-snackbar--align-start {
  @media (min-width: $mdc-snackbar-tablet-breakpoint) {
    @include mdc-rtl-reflexive-position(left, 24px);

    bottom: 24px;
    transform: translate(0, 200%);
  }

  @media (max-width: ($mdc-snackbar-tablet-breakpoint - 1)) {
    bottom: 0;
    left: 0;
    width: 100%;
    transform: translate(0, 100%);
  }
}

.mdc-snackbar--active {
  transform: translate(0);
  transition: mdc-animation-enter(transform, .25s);
  pointer-events: auto;

  &:not(.mdc-snackbar--align-start) {
    transform: translate(-50%, 0);

    @media (max-width: ($mdc-snackbar-tablet-breakpoint - 1)) {
      bottom: 0;
      left: 0;
      width: 100%;
      transform: translate(0);
    }
  }
}

.mdc-snackbar__action-wrapper {
  @include mdc-rtl-reflexive-property(padding, 24px, 0);
}

.mdc-snackbar--action-on-bottom {
  flex-direction: column;
}

.mdc-snackbar__text {
  @include mdc-typography(body1);
  @include mdc-rtl-reflexive-box(margin, right, auto, ".mdc-snackbar");

  display: flex;
  align-items: center;
  height: 48px;
  transition: mdc-animation-exit-permanent(opacity, .3s);
  opacity: 0;
  color: $mdc-snackbar-foreground-color;

  @media (min-width: $mdc-snackbar-tablet-breakpoint) {
    @include mdc-rtl-reflexive-property(padding, 0, 24px);
  }
}

.mdc-snackbar--action-on-bottom .mdc-snackbar__text {
  margin-right: inherit;
}

.mdc-snackbar--action-on-bottom .mdc-snackbar__action-wrapper {
  @include mdc-rtl-reflexive-box(margin, left, auto);

  flex-direction: column;
  justify-content: flex-start;
  margin-top: -12px;
  margin-bottom: 8px;
}

.mdc-snackbar--multiline .mdc-snackbar__text {
  height: 80px;
}

.mdc-snackbar__action-button {
  @include mdc-typography(button);
  @include mdc-theme-prop(color, secondary);

  padding: 0;
  transition: mdc-animation-exit-permanent(opacity, .3s);
  border: none;
  outline: none;
  background-color: transparent;
  opacity: 0;
  user-select: none;
  -webkit-appearance: none;
  visibility: hidden;

  &::-moz-focus-inner {
    border: 0;
  }

  &:hover {
    cursor: pointer;
  }

  &:not([aria-hidden]) {
    visibility: inherit;
  }
}

.mdc-snackbar--active .mdc-snackbar__text,
.mdc-snackbar--active .mdc-snackbar__action-button:not([aria-hidden]) {
  transition: mdc-animation-exit-permanent(opacity, .3s);
  opacity: 1;
}

// stylelint-disable plugin/selector-bem-pattern
.mdc-snackbar--multiline.mdc-snackbar--action-on-bottom .mdc-snackbar__text {
  margin: 0;
}
// stylelint-enable plugin/selector-bem-pattern

// postcss-bem-linter: end
