/* Scrollbars. The browser's own, in the theme's colours, for touch and for
   reduced motion; elsewhere scrollbars.js draws its own over each scroll
   container, and the browser's are hidden. */
* {
	scrollbar-color: var(--border) transparent;
	scrollbar-width: thin;
}

@media (pointer: fine) and (prefers-reduced-motion: no-preference) {
	html.custom-scrollbars,
	html.custom-scrollbars * {
		scrollbar-width: none;
	}

	html.custom-scrollbars::-webkit-scrollbar,
	html.custom-scrollbars *::-webkit-scrollbar {
		display: none;
	}
}

/* A track is a 14px hit area along the container's edge; the bar drawn in
   it is --bar wide (6px at rest, 10px with the pointer near), and the thumb
   --thumb long at --offset, all set by scrollbars.js each frame it moves. */
.scrollbar {
	position: fixed;
	z-index: 9990;
	margin: 0;
	padding: 0;
	touch-action: none;
	user-select: none;
	contain: layout style;
}

.scrollbar[hidden] {
	display: none;
}

.scrollbar::before,
.scrollbar-thumb {
	position: absolute;
	border-radius: 999px;
}

/* The track: a faint hairline, firmer once the pointer is near. */
.scrollbar::before {
	content: "";
	background: color-mix(in srgb, var(--hairline) calc(40% + (var(--bar, 6px) - 6px) / 4px * 60%), transparent);
}

.scrollbar-vertical::before,
.scrollbar-vertical .scrollbar-thumb {
	top: 0;
	right: 2px;
	width: var(--bar, 6px);
}

.scrollbar-vertical::before {
	bottom: 0;
}

.scrollbar-vertical .scrollbar-thumb {
	height: var(--thumb, 28px);
	translate: 0 var(--offset, 0px);
}

.scrollbar-horizontal::before,
.scrollbar-horizontal .scrollbar-thumb {
	left: 0;
	bottom: 2px;
	height: var(--bar, 6px);
}

.scrollbar-horizontal::before {
	right: 0;
}

.scrollbar-horizontal .scrollbar-thumb {
	width: var(--thumb, 28px);
	translate: var(--offset, 0px) 0;
}

/* The thumb: the theme's border colour at rest, brighter while the content
   scrolls or the pointer is on it, the accent while dragged. */
.scrollbar-thumb {
	background: var(--border);
	transition: background-color 600ms cubic-bezier(0.34, 0.8, 0.34, 1);
}

.scrollbar.scrolling .scrollbar-thumb,
.scrollbar-thumb:hover {
	background: color-mix(in srgb, var(--muted) 85%, var(--border));
	transition-duration: 150ms;
}

.scrollbar.dragging .scrollbar-thumb {
	background: var(--accent);
	transition-duration: 100ms;
}
