/*
 * vendored from dPanel (dev.dsub.net/dPanel), css/fader.css verbatim.
 * TODO: once dPanel is consumable as a shared dependency, drop this copy.
 *
 * .fader — a hardware-style slider, built on a real <input type="range">
 * so drag/touch/keyboard/focus all come from the platform for free.
 * No SVG, no drag library — ported from dChrono's Snap.svg + GSAP
 * Draggable version, which drew all of this by hand every frame.
 *
 * Structure (mirrors the original SVG layers):
 *   - tick marks live on the <input>'s own background (full height)
 *   - the groove is the native track pseudo-element, sized down and
 *     centered within that height
 *   - the cap is the native thumb pseudo-element, gradient-filled to
 *     match
 *
 * Configurable via custom properties — --fader-major/--fader-minor/
 * --fader-micro control tick spacing as a percentage of width. They
 * default to plain percentages (purely decorative, unrelated to
 * min/max/step), but since they're consumed through calc() anyway,
 * you can relate them to the input's actual value range by writing
 * the interval directly instead of guessing a percentage, e.g. for
 * an input with min=0 max=60:
 *   style="--fader-major: calc(15 / 60 * 100%); --fader-minor: calc(5 / 60 * 100%);"
 * — "a major tick every 15 units, minor every 5" — see index.html's
 * showcase for two worked examples, one of them ticking --fader-micro
 * to the input's actual step value. This does mean the range (60,
 * and the 0 it's implicitly relative to) is duplicated between the
 * min/max attributes and these calc() expressions, kept in sync by
 * hand — CSS has a newer attr(name type(<number>)) syntax that can
 * pull min/max straight from the attributes instead (confirmed
 * working, including nested inside calc(), in this project's
 * Chromium), removing that duplication. Not used here: an
 * unregistered custom property accepts any token sequence with zero
 * validation, so on a browser that doesn't understand attr(type())
 * the property doesn't come out unset (which var()'s fallback could
 * catch) — it comes out defined-but-garbage, which fails wherever
 * it's actually consumed instead, with no reliable way to catch
 * that failure and fall back in pure CSS. Confirmed there's no safe
 * fallback for this rather than assuming one exists. Revisit once
 * Safari's attr(type()) support is confirmed (untestable in this
 * sandbox — only headless Chromium available, see the Safari
 * testing note in project memory).
 *
 * --fader-micro is off by default (--fader-micro-color: transparent)
 * since a third tier this fine can squish into a solid block at
 * typical fader widths — turn it on deliberately, and check it at
 * the width it'll actually render at. Future home for major-tick
 * labels: a sibling row of positioned spans at the same
 * --fader-major interval, not built yet.
 */
.fader {
	--fader-h: 40px;	/* taller than the cap on purpose — see insets below */
	--fader-track-h: 7px;
	--fader-groove-h: 3px;
	--fader-cap-w: 31px;
	--fader-cap-h: 23px;
	--fader-major: 25%;
	--fader-minor: 5%;
	--fader-micro: 1.25%;
	--fader-major-color: rgb(235, 235, 235);
	--fader-minor-color: rgb(200, 200, 200);
	--fader-micro-color: transparent;	/* off by default — see note above */
	/* the cap is vertically centered in --fader-h, spanning
	   (fader-h - cap-h)/2 = 8.5px from each edge at the defaults above.
	   major/minor's insets are smaller than that on purpose, so they
	   poke out above/below the cap instead of hiding entirely behind
	   it; micro's is bigger, so it stays tucked behind (only
	   major/minor were asked to be visible past the cap). */
	--fader-major-inset: 4px;	/* top/bottom margin for major ticks — pokes ~4.5px past the cap */
	--fader-minor-inset: 6px;	/* top/bottom margin for minor ticks — pokes ~2.5px past the cap */
	--fader-micro-inset: 10px;	/* top/bottom margin for micro ticks — stays behind the cap */
	--fader-track-color: rgb(61, 61, 61);
	--fader-groove-color: rgb(0, 0, 0);
	--fader-cap-gradient: linear-gradient(
		to right,
		#595959 12%, #000000 31%, #000000 47%,
		#ffffff 48%, #ffffff 52%, #000000 53%,
		#595959 85%, #2d2d2d 94%, #000000 100%
	);

	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: var(--fader-h);
	margin: 0;
	background:
		repeating-linear-gradient(to right,
			var(--fader-major-color) -1px, var(--fader-major-color) 1px,
			transparent 1px, transparent calc(var(--fader-major) - 1px)),
		repeating-linear-gradient(to right,
			var(--fader-minor-color) -0.75px, var(--fader-minor-color) 0.75px,
			transparent 0.75px, transparent calc(var(--fader-minor) - 0.75px)),
		repeating-linear-gradient(to right,
			var(--fader-micro-color) -0.5px, var(--fader-micro-color) 0.5px,
			transparent 0.5px, transparent calc(var(--fader-micro) - 0.5px));
	/* the tick pattern is inset by the cap width and centered, so its
	   0%/25%/50%/75%/100% line up with where the thumb's CENTER can
	   actually travel — a native thumb's edges stay within the track,
	   so its center only ranges from half the cap width in from each
	   end, never the full 0-100% of the element.

	   background-repeat must be no-repeat, not repeat-x: a
	   repeating-linear-gradient() is already an infinite pattern by
	   definition, so background-size just picks a window onto it —
	   tiling that window AGAIN with repeat-x bled a sliver of the
	   next tile into the inset margins on each side.

	   Each tick is CENTERED on its position (stops straddle 0 via a
	   negative first stop, e.g. -1px to 1px for a 2px tick) rather
	   than starting at it (0 to 2px) — a tick drawn as "position to
	   position+width" has nowhere to render when position=100% lands
	   exactly on this no-repeat box's own edge, which is what was
	   making the max-value tick disappear entirely. Centering means
	   the tick at each edge only loses its outer half instead of the
	   whole thing. The transparent stop ends at (period - halfwidth),
	   not (period), so the repeat length stays exactly --fader-major/
	   minor/micro with no drift — widening background-size (the
	   previous, incorrect attempt at this fix) doesn't actually help:
	   the last tick is still exactly at whatever the box's own edge
	   is, no matter how wide the box is made. */
	background-position: center, center, center;
	background-size:
		calc(100% - var(--fader-cap-w)) calc(100% - (var(--fader-major-inset) * 2)),
		calc(100% - var(--fader-cap-w)) calc(100% - (var(--fader-minor-inset) * 2)),
		calc(100% - var(--fader-cap-w)) calc(100% - (var(--fader-micro-inset) * 2));
	background-repeat: no-repeat;
	cursor: col-resize;
}
.fader:focus {
	outline: none;
}

/* the groove: a rail that ends exactly at the min/max positions (same
   inset as the ticks) rather than running the full width — a physical
   fader's cap overhangs the ends of its slot, it doesn't stop short
   of them. This is a hard-edged fill via gradient, not a smaller
   clipped/rounded box: clip-path on this pseudo-element corrupts the
   thumb's rendering in Chromium (confirmed — the thumb and track
   apparently share a clipping context internally), so no clip-path
   here, ever. Trade-off: square ends instead of the original's
   slightly-rounded rail caps. */
.fader::-webkit-slider-runnable-track {
	height: var(--fader-track-h);
	background: linear-gradient(to right,
		transparent 0, transparent calc(var(--fader-cap-w) / 2),
		var(--fader-track-color) calc(var(--fader-cap-w) / 2), var(--fader-track-color) calc(100% - (var(--fader-cap-w) / 2)),
		transparent calc(100% - (var(--fader-cap-w) / 2)), transparent 100%);
}
.fader::-moz-range-track {
	height: var(--fader-track-h);
	background: linear-gradient(to right,
		transparent 0, transparent calc(var(--fader-cap-w) / 2),
		var(--fader-track-color) calc(var(--fader-cap-w) / 2), var(--fader-track-color) calc(100% - (var(--fader-cap-w) / 2)),
		transparent calc(100% - (var(--fader-cap-w) / 2)), transparent 100%);
}

/* the cap: brushed-metal gradient with a specular highlight stripe */
.fader::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: var(--fader-cap-w);
	height: var(--fader-cap-h);
	margin-top: calc((var(--fader-track-h) - var(--fader-cap-h)) / 2);
	border: 1px solid #000000;
	border-radius: 1px;
	background: var(--fader-cap-gradient);
	box-shadow: 1px 2px 2px rgba(0, 0, 0, 0.45);
}
.fader::-moz-range-thumb {
	width: var(--fader-cap-w);
	height: var(--fader-cap-h);
	border: 1px solid #000000;
	border-radius: 1px;
	background: var(--fader-cap-gradient);
	box-shadow: 1px 2px 2px rgba(0, 0, 0, 0.45);
}
