@import "../core/index-noreset.scss";
@import "scss/variable";

#{$drawer-prefix} {
  position: fixed;
  z-index: 1001;
  width: 0%;
  height: 100%;
  transition: transform 0.3s $curve-subtleEaseOut, 
    height 0s ease 0.3s, width 0s ease 0.3s;
  > * {
    transition: transform 0.3s $curve-subtleEaseOut,
      box-shadow 0.3s $curve-subtleEaseOut;
  }

  &-content-wrapper {
    position: absolute;
  }

  #{$drawer-prefix}-content {
    width: 100%;
    height: 100%;
  }

  &-left, &-right {
    top: 0;
    width: 0%;
    height: 100%;
    #{$drawer-prefix}-content-wrapper {
      height: 100%;
    }
    &#{$drawer-prefix}-open {
      width: 100%;
      transition: transform 0.3s $curve-subtleEaseOut;
    }
    #{$drawer-prefix}-open.no-mask {
      width: 0%;
    }
  }

  &-left {
    left: 0;

    #{$drawer-prefix} {
      &-content-wrapper {
        left: 0;
      }
    }
    &#{$drawer-prefix}-open {
      #{$drawer-prefix}-content-wrapper {
        box-shadow: $drawer-shadow-right;
      }
    }
  }

  &-right {
    right: 0;

    #{$drawer-prefix} {
      &-content-wrapper {
        right: 0;
      }
    }
    &#{$drawer-prefix}-open {
      #{$drawer-prefix}-content-wrapper {
        box-shadow: $drawer-shadow-left;
      }
    }
    &.no-mask {
      right: 1px;
      transform: translateX(1px);
    }
  }

  &-top, &-bottom {
    left: 0;
    width: 100%;
    height: 0%;
    #{$drawer-prefix}-content-wrapper {
      width: 100%;
    }
    &#{$drawer-prefix}-open {
      height: 100%;
      transition: transform 0.3s $curve-subtleEaseOut;
    }
    #{$drawer-prefix}-open.no-mask {
      height: 0%;
    }
  }

  &-top {
    top: 0;

    &#{$drawer-prefix}-open {
      #{$drawer-prefix}-content-wrapper {
        box-shadow: $drawer-shadow-down;
      }
    }
  }

  &-bottom {
    bottom: 0;

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

  &#{$drawer-prefix}-open {
    #{$drawer-prefix} {
      &-mask {
        height: 100%;
        opacity: 1;
        transition: none;
        animation: drawerFadeIn 0.3s $curve-subtleEaseOut;
      }
    }
  }

  &-title {
    margin: 0;
    color: $gray-08;
    font-weight: $font-weight-medium;
    font-size: $font-size-subhead;
    line-height: $line-height-subhead;
  }

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

  &-close {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 10;
    padding: $S16;
    .#{$css-prefix}icon.#{$css-prefix}medium {
      font-size: $S20;
    }

    #{$drawer-prefix}-header-no-title & {
      margin-right: var(--scroll-bar);
      padding-right: calc(16px - var(--scroll-bar));; 
    }
  }

  &-header {
    position: relative;
    padding: $S16 $S24;
    color: $gray-08;
    background: $background-section;
    border-bottom: 1px solid $gray-03;
  }

  &-header-no-title {
    color: $gray-08;
    background: $background-section;
  }

  &-wrapper-body {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    width: 100%;
    height: 100%;
  }

  &-body {
    flex-grow: 1;
    padding: $S24;
    overflow: auto;
    font-size: $font-size-body;
    line-height: $line-height-body;
    word-wrap: break-word;
  }

  &-footer {
    flex-shrink: 0;
    padding: 10px $S24;
    border-top: 1px solid $gray-03;
  }

  &-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0;
    background-color: rgba($color: #000, $alpha: 0.45);
    opacity: 0;
    transition: opacity 0.3s linear, height 0s ease 0.3s;
  }

  &-open {
    &-content {
      box-shadow: $shadow-02;
    }
  }
}

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