@use 'sass:map';

@use 'mixins/mixins' as *;
@use 'mixins/var' as *;
@use 'common/var' as *;

@include b(scrollbar) {
  @include set-component-var('scrollbar', $scrollbar);
}

@include b(scrollbar) {
  overflow: hidden;
  position: relative;
  height: 100%;

  @include e(wrap) {
    overflow: auto;
    height: 100%;

    @include m(hidden-default) {
      scrollbar-width: none;
      &::-webkit-scrollbar {
        display: none;
      }
    }
  }

  @include e(thumb) {
    position: relative;
    display: block;
    width: 0;
    height: 0;
    cursor: pointer;
    border-radius: inherit;
    background-color: getColor(scrollbar-thumb-color);
    transition: background-color getCssVar(transition-duration)
      getCssVar(transition-function-ease);
    opacity: getCssVar(scrollbar-thumb-opacity);

    &:hover,
    &:active {
      background-color: getColor(scrollbar-thumb-color);
      opacity: getCssVar(scrollbar-thumb-hover-opacity);
    }
  }

  @include e(bar) {
    position: absolute;
    right: 2px;
    bottom: 2px;
    z-index: 1;
    border-radius: 4px;
    // padding: 2px;

    &:hover,
    &.highlight {
      background-color: getColor(scrollbar-thumb-color, 0.15);
      transition: background-color getCssVar(transition-duration-fast) linear;
    }

    @include when(vertical) {
      top: 2px;

      > div {
        width: 100%;
      }
    }

    @include when(horizontal) {
      left: 2px;

      > div {
        height: 100%;
      }
    }
  }
}

.#{$namespace}-scrollbar-fade {
  &-enter-active {
    transition: opacity 340ms ease-out;
  }

  &-leave-active {
    transition: opacity 120ms ease-out;
  }

  &-enter-from,
  &-leave-active {
    opacity: 0;
  }
}
