//
// Copyright 2017 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions://
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

@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
