.root,
:global(:root) {
  --scroll-area-scrollbar-size: 8px;
}

.scrollArea {
  width: 100%;
  height: 100%;
  border: 1px solid black;
}

.scrollAreaViewport {
  width: 100%;
  height: 100%;
}

.scrollbar {
  display: flex;
  /* ensures no selection */
  user-select: none;
  /* disable browser handling of all panning and zooming gestures on touch devices */
  touch-action: none;
  transition: background 160ms ease-out;
  padding: 2px;
  background: rgba(0, 0, 0, 0.3);
  &:hover {
    background: rgba(0, 0, 0, 0.5);
  }
  &[data-orientation='vertical'] {
    width: var(--scroll-area-scrollbar-size);
  }
  &[data-orientation='horizontal'] {
    flex-direction: column;
    height: var(--scroll-area-scrollbar-size);
  }
}

.thumb {
  flex: 1;
  /* increase target size for touch devices https://www.w3.org/WAI/WCAG21/Understanding/target-size.html */
  position: relative;
  &::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    min-width: 44px;
    min-height: 44px;
  }
  background: black;
  border-radius: var(--scroll-area-scrollbar-size);
}

.corner {
  background: rgba(0, 0, 0, 0.3);
  position: relative;
  &::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: black;
    width: var(--scroll-area-scrollbar-size);
    height: var(--scroll-area-scrollbar-size);
    border-radius: var(--scroll-area-scrollbar-size);
  }
}

.animatedThumb {
  &[data-state='visible'] {
    animation: scrollArea-fadeIn 300ms ease;
  }
  &[data-state='hidden'] {
    animation: scrollArea-fadeOut 300ms ease;
  }
}

@keyframes scrollArea-fadeIn {
  from {
    transform: scale(0.2);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes scrollArea-fadeOut {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.2);
    opacity: 0;
  }
}
