@import '../../style/themes/index';

// Preserve the typo for compatibility
// https://github.com/ant-design/ant-design/issues/14628
@yee-dawer-prefix-cls: ~'@{yee-prefix}-drawer';

@yee-drawer-prefix-cls: @yee-dawer-prefix-cls;

.@{yee-drawer-prefix-cls} {
  position: fixed;
  z-index: @yee-zindex-modal;
  width: 0%;
  height: 100%;
  transition:
    transform @yee-animation-duration-slow @yee-ease-base-out,
    height 0s ease @yee-animation-duration-slow,
    width 0s ease @yee-animation-duration-slow;
  > * {
    transition:
      transform @yee-animation-duration-slow @yee-ease-base-out,
      box-shadow @yee-animation-duration-slow @yee-ease-base-out;
  }

  &-content-wrapper {
    position: absolute;
  }
  .@{yee-drawer-prefix-cls}-content {
    width: 100%;
    height: 100%;
  }

  &-left,
  &-right {
    top: 0;
    width: 0%;
    height: 100%;
    .@{yee-drawer-prefix-cls}-content-wrapper {
      height: 100%;
    }
    &.@{yee-drawer-prefix-cls}-open {
      width: 100%;
      transition: transform @yee-animation-duration-slow @yee-ease-base-out;
    }
    &.@{yee-drawer-prefix-cls}-open.no-mask {
      width: 0%;
    }
  }

  &-left {
    &.@{yee-drawer-prefix-cls}-open {
      .@{yee-drawer-prefix-cls}-content-wrapper {
        box-shadow: @yee-shadow-1-right;
      }
    }
  }

  &-right {
    right: 0;

    .@{yee-drawer-prefix-cls} {
      &-content-wrapper {
        right: 0;
      }
    }
    &.@{yee-drawer-prefix-cls}-open {
      .@{yee-drawer-prefix-cls}-content-wrapper {
        box-shadow: @yee-shadow-1-left;
      }
      // https://github.com/ant-design/ant-design/issues/18607, Avoid edge alignment bug.
      &.no-mask {
        right: 1px;
        transform: translateX(1px);
      }
    }
  }

  &-top,
  &-bottom {
    left: 0;
    width: 100%;
    height: 0%;

    .@{yee-drawer-prefix-cls}-content-wrapper {
      width: 100%;
    }
    &.@{yee-drawer-prefix-cls}-open {
      height: 100%;
      transition: transform @yee-animation-duration-slow @yee-ease-base-out;
    }
    &.@{yee-drawer-prefix-cls}-open.no-mask {
      height: 0%;
    }
  }

  &-top {
    top: 0;

    &.@{yee-drawer-prefix-cls}-open {
      .@{yee-drawer-prefix-cls}-content-wrapper {
        box-shadow: @yee-shadow-1-down;
      }
    }
  }

  &-bottom {
    bottom: 0;

    .@{yee-drawer-prefix-cls} {
      &-content-wrapper {
        bottom: 0;
      }
    }
    &.@{yee-drawer-prefix-cls}-open {
      .@{yee-drawer-prefix-cls}-content-wrapper {
        box-shadow: @yee-shadow-1-up;
      }
      &.no-mask {
        bottom: 1px;
        transform: translateY(1px);
      }
    }
  }

  &.@{yee-drawer-prefix-cls}-open {
    .@{yee-drawer-prefix-cls} {
      &-mask {
        height: 100%;
        opacity: 1;
        transition: none;
        animation: antdDrawerFadeIn @yee-animation-duration-slow @yee-ease-base-out;
      }
    }
  }

  &-title {
    margin: 0;
    color: @yee-heading-color;
    font-weight: 500;
    font-size: @yee-font-size-lg;
    line-height: 22px;
  }

  &-content {
    position: relative;
    z-index: 1;
    overflow: auto;
    background-color: @yee-component-background;
    background-clip: padding-box;
    border: 0;
  }

  &-close {
    position: absolute;
    top: 0;
    right: 0;
    z-index: @yee-zindex-popup-close;
    display: block;
    width: 56px;
    height: 56px;
    padding: 0;
    color: @yee-text-color-secondary;
    font-weight: 700;
    font-size: @yee-font-size-lg;
    font-style: normal;
    line-height: 56px;
    text-align: center;
    text-transform: none;
    text-decoration: none;
    background: transparent;
    border: 0;
    outline: 0;
    cursor: pointer;
    transition: color @yee-animation-duration-slow;
    text-rendering: auto;

    &:focus,
    &:hover {
      color: @yee-icon-color-hover;
      text-decoration: none;
    }
  }

  &-header {
    position: relative;
    padding: @yee-drawer-header-padding;
    color: @yee-text-color;
    background: @yee-component-background;
    border-bottom: @yee-border-width-base @yee-border-style-base @yee-border-color-split;
    border-radius: @yee-border-radius-base @yee-border-radius-base 0 0;
  }

  &-header-no-title {
    color: @yee-text-color;
    background: @yee-component-background;
  }

  &-body {
    padding: @yee-drawer-body-padding;
    font-size: @yee-font-size-base;
    line-height: @yee-line-height-base;
    word-wrap: break-word;
  }
  &-wrapper-body {
    height: 100%;
    overflow: auto;
  }

  &-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0;
    background-color: @yee-modal-mask-bg;
    opacity: 0;
    filter: ~'alpha(opacity=45)';
    transition:
      opacity @yee-animation-duration-slow linear,
      height 0s ease @yee-animation-duration-slow;
  }
  &-open {
    &-content {
      box-shadow: @yee-shadow-2;
    }
  }
}

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