.sidebar {
  position: sticky;
  top: 3rem;
  z-index: 9;
  width: 400px;
  height: calc(100vh - 3rem);

  @apply bg-white;
  .dark & {
    @apply bg-dark-gray-950;
  }

  @apply flex;
  @apply flex-col;
  @apply border-r;
  @apply border-l;
  @apply border-gray-200;
  .dark & {
    @apply border-dark-gray-800;
  }

  // lg screen and below
  @screen lg-max {
    position: fixed;
    transform: translateX(-100%);
    // like silk
    will-change: transform;

    width: 80%;
    @screen md {
      width: auto;
      min-width: 50%;
    }

    & {
      transition: transform ease-in-out 150ms;
    }

    &.open {
      transform: translateX(0);
    }
  }

  @screen lg {
    // hide based on pre-flight class
    .sidebar-closed &,
    // when on a larger screen, the sidebar should only rely on the open class
    &:not(.open) {
      display: none;
    }
  }

  // when on mobile, wait for the component to be mounted
  // so as to prevent a closing animation when loading the page
  @screen lg-max {
    &:not(.mounted) {
      display: none;
    }
  }
}

.sidebar-mask {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 8;

  animation: fade-in 300ms;

  @screen lg-max {
    background-color: rgba(0, 0, 0, 0.3);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
