/* The site's cursor stands in for the system's everywhere, over whatever
   would ask for a pointer of its own (a disclosure's summary, the code's
   line numbers). */
@media (pointer: fine) and (prefers-reduced-motion: no-preference) {
	* {
		cursor: none !important;
	}

	/* cursor.js sets the box's size, corners, and position every frame it
	   moves; --ring is the outline's width and --fill how much of the
	   accent fills it. */
	/* Both are manual popovers, in the top layer (cursor.js), so the
	   popover defaults are undone. */
	#cursor,
	#cursor-ghost {
		position: fixed;
		inset: 0 auto auto 0;
		margin: 0;
		padding: 0;
		border: 0;
		overflow: visible;
		width: 18px;
		height: 18px;
		border-radius: 5px;
		pointer-events: none;
		z-index: 9999;
		opacity: 0;
		transform-origin: 50% 50%;
		background: color-mix(in srgb, var(--accent) var(--fill, 0%), transparent);
		box-shadow: inset 0 0 0 var(--ring, 2px) var(--accent);
		will-change: transform, width, height;
	}

	#cursor-ghost {
		display: none;
		z-index: 9998;
		--fill: 0%;
		--ring: 2px;
	}

	/* The cursor draws the hover state layer of the small controls it fills,
	   so their own hover layers stay off. Focus and press layers remain. */
	html.custom-cursor :is(.icon-button, .page-button):hover:not(:focus-visible, :active)::before,
	html.custom-cursor .page-tab:hover:not(:focus-visible, :active) > span::before {
		opacity: 0;
	}

	html.custom-cursor :is(.code-download, .tree-toggle, .diff-toggle, .projects-retry):hover:not(:focus-visible, :active) {
		background: none;
	}
}

@media (prefers-reduced-motion: reduce), (pointer: coarse) {
	html,
	body,
	a,
	button,
	[role="button"],
	input,
	textarea,
	select {
		cursor: auto !important;
	}

	#cursor {
		display: none !important;
	}
}
