/**
@prop --ux-scrollbar-bar-color: Background color of the bar
@prop --ux-scrollbar-bg-color: Background color of the component
@prop --ux-scrollbar-control-color: Color of control elements
@prop --ux-scrollbar-control-hover-color: Hover color of control elements
@prop --ux-scrollbar-control-width: Width of control elements
@prop --ux-scrollbar-control-height: Height of control elements
@prop --ux-scrollbar-gap: Gap size between scrollbar elements
@prop --ux-scrollbar-handle-color: Background color of the handle
@prop --ux-scrollbar-handle-length: Default length of the handle
@prop --ux-scrollbar-handle-size: Size of the handle
@prop --ux-scrollbar-icon-size: Size of scrollbar icons
@prop --ux-scrollbar-inset: Inset of the scrollbar container
@prop --ux-scrollbar-padding: Padding of the scrollbar container
@prop --ux-scrollbar-shadow: Box shadow of the scrollbar container
@prop --ux-scrollbar-size: Size of the component
@prop --ux-scrollbar-track-color: Color of the scrollbar track
@prop --ux-scrollbar-track-size: Size of the scrollbar track
 */
:host {
  --bar-color: var(--ux-scrollbar-bar-color, transparent);
  --bg-color: var(--ux-scrollbar-bg-color, transparent);
  --control-color: var(--ux-scrollbar-control-color, #000);
  --control-active-color: var(--ux-scrollbar-control-active-color, #000);
  --control-disabled-color: var(--ux-scrollbar-control-disabled-color, #a1a1a1);
  --control-hover-color: var(--ux-scrollbar-control-hover-color, #000);
  --control-height: var(--ux-scrollbar-control-height, 24px);
  --control-width: var(--ux-scrollbar-control-width, 24px);
  --handle-length: var(--ux-scrollbar-handle-length, 25%);
  --handle-size: var(--ux-scrollbar-handle-size, 2px);
  --icon-size: var(--ux-scrollbar-icon-size, 16px);
  --scrollbar-gap: var(--ux-scrollbar-gap, 10px);
  --scrollbar-inset: var(--ux-scrollbar-inset, 0);
  --scrollbar-padding: var(--ux-scrollbar-padding, 10px);
  --scrollbar-shadow: var(--ux-scrollbar-shadow, none);
  --scrollbar-size: var(--ux-scrollbar-size, 24px);
  --track-color: var(--ux-scrollbar-track-color, #f2f2f2);
  --track-size: var(--ux-scrollbar-track-size, 2px);
  box-sizing: border-box;
  display: block;
  width: var(--scrollbar-size);
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  height: auto;
  touch-action: none;
  background-color: var(--bg-color);
  pointer-events: auto;
}

.inner {
  display: flex;
  position: absolute;
  width: auto;
  height: auto;
  flex-flow: column nowrap;
  inset: var(--scrollbar-inset);
  background-color: var(--bar-color);
  box-shadow: var(--scrollbar-shadow);
  gap: var(--scrollbar-gap);
}

.controls {
  flex: 0 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--scrollbar-gap);
}
.controls .ux-icon {
  font-size: var(--icon-size);
  color: currentColor;
  transform-origin: 50% 50%;
}
.controls--disabled {
  pointer-events: none;
}
.controls--disabled .btn {
  color: var(--control-disabled-color);
  cursor: auto;
}
.controls--middle {
  flex: 1 1 auto;
  gap: 0;
}

.bar {
  display: block;
  position: absolute;
  inset: 0;
  cursor: pointer;
  overflow: hidden;
}
.bar:hover .handle {
  background-color: var(--control-hover-color);
}
.bar:active .handle {
  background-color: var(--control-active-color);
}

.btn {
  appearance: none;
  background: transparent;
  border: 0 none;
  border-radius: 0;
  color: var(--control-color);
  width: var(--control-width);
  height: var(--control-height);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: 0 none;
}
.btn:focus-visible {
  outline: var(--ux-button-outline-width) solid var(--ux-button-focus-border-color);
  outline-offset: calc(-1 * var(--ux-button-outline-width));
}
.btn:hover {
  color: var(--control-hover-color);
}
.btn:active {
  color: var(--control-active-color);
}

.track,
.handle {
  box-sizing: border-box;
  display: block;
  margin: auto;
  position: absolute;
  pointer-events: none;
}

.track {
  background-color: var(--track-color);
}

.handle {
  background-color: var(--control-color);
}

:host(:not([direction=horizontal])) .inner,
:host(:not([direction=horizontal])) .controls {
  flex-flow: column nowrap;
}
:host(:not([direction=horizontal])) .controls--start .ux-icon {
  transform: rotate(180deg);
}
:host(:not([direction=horizontal])) .controls--end .ux-icon {
  transform: none;
}
:host(:not([direction=horizontal])) .inner {
  padding: var(--scrollbar-padding) 0;
}
:host(:not([direction=horizontal])) .track,
:host(:not([direction=horizontal])) .handle {
  top: 0;
  left: 50%;
  margin-top: auto;
}
:host(:not([direction=horizontal])) .track {
  width: var(--track-size);
  height: 100%;
  margin-left: calc(-0.5 * var(--track-size));
}
:host(:not([direction=horizontal])) .handle {
  width: var(--handle-size);
  height: var(--handle-length);
  margin-left: calc(-0.5 * var(--handle-size));
  top: var(--handle-offset);
}

:host([direction=horizontal]) {
  width: auto;
  height: var(--scrollbar-size);
  left: 0;
  top: auto;
  bottom: 0;
  right: 0;
}
:host([direction=horizontal]) .inner {
  padding: 0 var(--scrollbar-padding);
}
:host([direction=horizontal]) .controls,
:host([direction=horizontal]) .inner {
  flex-flow: row nowrap;
}
:host([direction=horizontal]) .btn {
  width: var(--control-height);
  height: var(--control-width);
}
:host([direction=horizontal]) .controls--start .ux-icon {
  transform: rotate(90deg);
}
:host([direction=horizontal]) .controls--end .ux-icon {
  transform: rotate(-90deg);
}
:host([direction=horizontal]) .track,
:host([direction=horizontal]) .handle {
  left: 0;
  top: 50%;
  margin-left: auto;
}
:host([direction=horizontal]) .track {
  width: 100%;
  height: var(--track-size);
  margin-top: calc(-0.5 * var(--track-size));
}
:host([direction=horizontal]) .handle {
  width: var(--handle-length);
  height: var(--handle-size);
  margin-top: calc(-0.5 * var(--handle-size));
  left: var(--handle-offset);
}

:host(:not([direction=horizontal]).ux-scrollbar--multiple) .inner {
  bottom: var(--scrollbar-size);
}

:host([direction=horizontal].ux-scrollbar--multiple) {
  right: var(--scrollbar-size);
}