/* @svelte-lean/styles — findable (Tier 1 attribute primitive; hidden="until-found" + beforematch).
 * Markup: <span data-slean-findable="…4d4d38"><span data-slean-part="full" hidden="until-found">
 * tx-0123456789abcdef4d4d38</span></span>. The short form is drawn here from the attribute, so the
 * whole value is the only text in the document and find counts it once. The whole value is out of
 * the flow whether folded or open: folded, the browser renders it with content-visibility: hidden
 * (which needs the block box absolute positioning gives it) or, where hidden="until-found" is
 * unknown, display: none from the user agent's [hidden] rule, which this file never overrides (no
 * display is set on the part). Open (find reached it, the attribute is gone), it is drawn over the
 * short form, starting where the short form starts, so the row keeps its height. The behavior
 * shifts it sideways with an inline translate to keep it inside a clipping ancestor, and marks the
 * root data-slean-found while it is open. Open, it looks like the page's own surface, not like a
 * match: the browser draws its own highlight on the matched text, and that highlight goes away
 * when the find text no longer matches, so nothing stays marked as found. Wider than the room it
 * has, the behavior wraps it (data-slean-wrap) instead of letting it run past a clipping edge. */
@layer slean.reset, slean.tokens, slean.base, slean.components, slean.compositions, slean.utilities;

@layer slean.components {
	:where([data-slean-findable]) {
		position: relative;
	}

	:where([data-slean-findable])::after {
		content: attr(data-slean-findable);
		white-space: nowrap;
	}

	:where([data-slean-findable] > [data-slean-part='full']) {
		position: absolute;
		inset-block-start: 0;
		inset-inline-start: 0;
		white-space: nowrap;
	}

	/* The padding and border sit outside the text, so the whole value's first character lands on
	   the short form's. Above the pinned cells of a table (z-index 3), below its sticky header. */
	:where([data-slean-findable] > [data-slean-part='full']:not([hidden])) {
		z-index: 4;
		box-sizing: border-box;
		margin-block: -2px;
		margin-inline: calc(-1 * var(--slean-space-1) - 1px);
		padding-block: 1px;
		padding-inline: var(--slean-space-1);
		border: 1px solid var(--slean-border);
		border-radius: var(--slean-radius-sm);
		background: var(--slean-surface);
		color: var(--slean-fg);
		box-shadow: var(--slean-elevation-3);
	}

	:where([data-slean-findable] > [data-slean-part='full'][data-slean-wrap]) {
		white-space: normal;
		overflow-wrap: anywhere;
	}

	@media (forced-colors: active) {
		:where([data-slean-findable] > [data-slean-part='full']:not([hidden])) {
			border-color: CanvasText;
			background: Canvas;
			color: CanvasText;
		}
	}
}
