$scrollable: asScrollable !default;
$scrollable-bar-size: 4px !default;
$scrollable-bar-dragging-size: 10px !default;
$scrollable-bar-dragging-color: rgba(238, 238, 238, .6) !default;
$scrollable-bar-hovering-color: rgba(238, 238, 238, .4) !default;
$scrollable-bar-handle-offset: 5px !default;
$scrollable-bar-handle-color: rgba(224, 224, 224, .6) !default;
$scrollable-bar-handle-hovering-color: rgba(150, 150, 150, .6) !default;
$scrollable-bar-handle-dragging-color: rgba(150, 150, 150, .8) !default;

.#{$scrollable} {
  &.is-enabled {
    overflow: hidden !important;
  }

  &-container {
    .is-enabled & {
      box-sizing: content-box !important;
      overflow: hidden !important;
    }

    .is-enabled &::-webkit-scrollbar {
      width: 0;
      height: 0;
      -webkit-appearance: none;
    }

    .#{$scrollable}-vertical.is-enabled & {
      & {
        overflow-y: scroll !important;
      }
    }

    .#{$scrollable}-horizontal.is-enabled & {
      overflow-x: scroll !important;
    }
  }

  &-content {
    .is-enabled & {
      position: relative !important;
      overflow: visible !important;

      &::before,
      &::after {
        display: table;
        content: " ";
      }
      &::after {
        clear: both;
      }
    }
  }

  &-bar {
    .is-disabled & {
      display: none;
    }

    &-hide {
      opacity: 0;
      transition-delay: 400ms;
    }

    position: absolute;
    right: 0;
    bottom: 0;
    box-sizing: border-box;
    overflow: hidden;
    line-height: 0;
    user-select: none;
    border-radius: $scrollable-bar-size / 2;
    transition: opacity .5s;
    -webkit-touch-callout: none;
    user-input: disabled;
    user-focus: ignore;

    &.is-hovering {
      background: $scrollable-bar-hovering-color;
    }

    &.is-dragging {
      background: $scrollable-bar-dragging-color !important;
      opacity: 1;
    }

    &.is-disabled {
      display: none;
    }

    &-handle {
      position: absolute;
      top: 0;
      left: 0;
      line-height: 0;
      cursor: pointer;
      background: $scrollable-bar-handle-color;
      border-radius: $scrollable-bar-size / 2;
      transition: width, height .5s;
    }

    &.is-dragging &-handle {
      background: $scrollable-bar-handle-dragging-color !important;
    }

    &.is-dragging,
    &.is-hovering {
      border-radius: $scrollable-bar-dragging-size / 2;
      .#{$scrollable}-bar-handle {
        border-radius: $scrollable-bar-dragging-size / 2;
      }
    }

    &-vertical {
      width: $scrollable-bar-size;
      height: 100%;
      height: calc(100% - #{2 * $scrollable-bar-handle-offset});
      margin: $scrollable-bar-handle-offset ($scrollable-bar-dragging-size - $scrollable-bar-size) / 2;
    }

    &-vertical {
      &.is-dragging,
      &.is-hovering {
        width: $scrollable-bar-dragging-size;
        margin: $scrollable-bar-handle-offset 1px;
      }
    }

    &-vertical &-handle {
      width: 100%;
    }

    &-horizontal {
      width: 100%;
      width: calc(100% - #{2 * $scrollable-bar-handle-offset});
      height: $scrollable-bar-size;
      margin: ($scrollable-bar-dragging-size - $scrollable-bar-size) / 2 $scrollable-bar-handle-offset;
    }

    &-horizontal {
      &.is-dragging,
      &.is-hovering {
        height: $scrollable-bar-dragging-size;
        margin: 1px $scrollable-bar-handle-offset;
      }
    }

    &-horizontal &-handle {
      height: 100%;
    }
  }

  &.is-scrolling {
    .#{$scrollable}-bar {
      opacity: 1;
      transition: opacity 0;
    }
  }

  &.is-hovering {
    .#{$scrollable}-bar-handle {
      background: $scrollable-bar-handle-hovering-color;
    }
  }

  &.is-dragging {
    user-select: none;
    -webkit-touch-callout: none;
    user-input: disabled;
    user-focus: ignore;
  }
}
