@property --scrollbar-thumb-opacity {
  syntax: "<percentage>";
  inherits: true;
  initial-value: 0%;
}

/* Each scroll container has its own thumb, including nested lists. */
* {
  --scrollbar-thumb-opacity: 0%;
}

:where(.scrollbar-active, .scrollbar-fading) {
  transition: --scrollbar-thumb-opacity 180ms ease-out;
}

.scrollbar-active {
  --scrollbar-thumb-opacity: 40%;
}

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: color-mix(in srgb, currentColor var(--scrollbar-thumb-opacity, 0%), transparent);
  border-radius: 5px;
}

@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
  }

  :where(.scrollbar-active, .scrollbar-fading) {
    transition: scrollbar-color 180ms ease-out;
  }

  .scrollbar-active {
    scrollbar-color: color-mix(in srgb, currentColor 40%, transparent) transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  :where(.scrollbar-active, .scrollbar-fading) {
    transition-duration: 0s;
  }
}
