/**
 * React Modal style
**/

$prefixCls: rc-modal;

// 如果变量作为属性或 class 名则必须要以#{$variables}形式使用
.#{$prefixCls} {
  // 去掉 body 的滚动条
  &-open {
    overflow: hidden;

    .#{$prefixCls}-mask {
      display: block;
    }
    .#{$prefixCls} {
      display: flex;
    }

    .#{$prefixCls} {
      overflow-x: hidden;
      overflow-y: auto;
    }
  }

  // Modal mask
  &-mask {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.3);
    display: none;
  }

  & {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1001;
    display: none;
    overflow: hidden;
    // Prevent Chrome on Windows from adding a focus outline. For details, see
    // https://github.com/twbs/bootstrap/pull/10951.
    outline: 0;
    -webkit-overflow-scrolling: touch;
  }

  &-dialog {
    width: 100%;
  }

  &-content {
    position: relative;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0, 0, 0, .2);
    border-radius: 5px;
    outline: 0;
  }

  &-header {
    padding: 15px;
    border-bottom: 1px solid #e5e5e5;
  }

  &-title {
  }

  &-close {
    position: absolute;
    right: 15px;

    transition: opacity 140ms;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1ex;
    margin: 0;
    opacity: .4;
    font-size: 24px;
    text-decoration: none;

    &-x:after {
      content: '\00d7'
    }

    &:hover,
    &:focus {
      opacity: .8;
      outline: 0;
      text-decoration: none;
    }
  }

  &-body {
    position: relative;
    padding: 20px;
  }

  &-footer {
    border-top: 1px solid #e5e5e5;
    padding: 10px;
    text-align: right;
    border-radius: 0 0 5px 5px;
  }

  @media (min-width: 544px) {
    &-dialog {
      width: 600px;
    }
  }
}

// 自定义显示位置
.#{$prefixCls} {
  &-left {
    align-items: center;
    justify-content: flex-start;
  }

  &-right {
    align-items: center;
    justify-content: flex-end;
  }

  &-top {
    align-items: flex-start;
    justify-content: center;
  }

  &-bottom {
    align-items: flex-end;
    justify-content: center;
  }

  &-center {
    align-items: center;
    justify-content: center;
  }

  &-left-top {
    align-items: flex-start;
    justify-content: flex-start;
  }

  &-left-bottom {
    align-items: flex-end;
    justify-content: flex-start;
  }

  &-right-top {
    align-items: flex-start;
    justify-content: flex-end;
  }

  &-right-bottom {
    align-items: flex-end;
    justify-content: flex-end;
  }
}

// 动画效果
.#{$prefixCls} {

  // modal 动画
  @mixin effect() {
    animation-duration: 0.3s;
    animation-fill-mode: both;
  }

  &-zoom-enter,
  &-zoom-appear {
    opacity: 0;
    @include effect();
    animation-timing-function: cubic-bezier(0.08, 0.82, 0.17, 1);
    animation-play-state: paused;
  }

  &-zoom-leave {
    @include effect();
    animation-timing-function: cubic-bezier(0.6, 0.04, 0.98, 0.34);
    animation-play-state: paused;
  }

  &-zoom-enter.#{$prefixCls}-zoom-enter-active,
  &-zoom-appear.#{$prefixCls}-zoom-appear-active {
    animation-name: rcModalZoomIn;
    animation-play-state: running;
  }

  &-zoom-leave.#{$prefixCls}-zoom-leave-active {
    animation-name: rcModalZoomOut;
    animation-play-state: running;
  }

  @keyframes rcModalZoomIn {
    0% {
      opacity: 0;
      transform: scale(0, 0);
    }
    100% {
      opacity: 1;
      transform: scale(1, 1);
    }
  }
  @keyframes rcModalZoomOut {
    0% {

      transform: scale(1, 1);
    }
    100% {
      opacity: 0;
      transform: scale(0, 0);
    }
  }

  // mask animation
  @mixin fade-effect() {
    animation-duration: 0.3s;
    animation-fill-mode: both;
    animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2);
  }

  &-fade-enter,
  &-fade-appear {
    opacity: 0;
    @include fade-effect();
    animation-play-state: paused;
  }

  &-fade-leave {
    @include fade-effect();
    animation-play-state: paused;
  }

  &-fade-enter.#{$prefixCls}-fade-enter-active,
  &-fade-appear.#{$prefixCls}-fade-appear-active {
    animation-name: rcModalFadeIn;
    animation-play-state: running;
  }

  &-fade-leave.#{$prefixCls}-fade-leave-active {
    animation-name: rcModalFadeOut;
    animation-play-state: running;
  }

  @keyframes rcModalFadeIn {
    0% {
      opacity: 0;
    }
    100% {
      opacity: 1;
    }
  }

  @keyframes rcModalFadeOut {
    0% {
      opacity: 1;
    }
    100% {
      opacity: 0;
    }
  }
}
