/* @svelte-lean/styles — copy (Tier 1 attribute primitive; navigator.clipboard.writeText).
 * Markup: data-slean-copy="value" on any element, preferably a <button type="button">. After a
 * successful copy the element carries data-slean-copied for 1.5 s: the hook for a check mark or
 * a colour change. With the button stylesheet the button keeps its own look; this file only adds
 * the pointer and, for a copy element that is not a button, the check mark mask on
 * [data-slean-part='icon'] while it is copied. */
@layer slean.reset, slean.tokens, slean.base, slean.components, slean.compositions, slean.utilities;

@layer slean.components {
	:where([data-slean-copy]) {
		cursor: pointer;
	}

	:where([data-slean-copy]:disabled),
	:where([data-slean-copy][aria-disabled='true']) {
		cursor: not-allowed;
	}

	/* A copied element swaps its icon part for a check mark while data-slean-copied is set. */
	:where([data-slean-copy][data-slean-copied] [data-slean-part='icon']) {
		color: var(--slean-success-main);
	}

	:where([data-slean-copy][data-slean-copied] [data-slean-part='icon'] > svg) {
		visibility: hidden;
	}

	:where([data-slean-copy] [data-slean-part='icon']) {
		display: inline-grid;
	}

	:where([data-slean-copy] [data-slean-part='icon'] > *) {
		grid-area: 1 / 1;
	}

	:where([data-slean-copy][data-slean-copied] [data-slean-part='icon'])::before {
		content: '';
		grid-area: 1 / 1;
		inline-size: 1em;
		block-size: 1em;
		background: currentColor;
		mask: var(--slean-icon-check) center / contain no-repeat;
	}

	@media (forced-colors: active) {
		:where([data-slean-copy][data-slean-copied] [data-slean-part='icon'])::before {
			background: CanvasText;
		}
	}
}
