/* @svelte-lean/styles — hint (Tier 1 attribute primitive; role="tooltip" + popover="manual").
 * Markup: data-slean-hint="Text" on any element. The behavior creates one bubble for the page,
 * <div id="slean-hint" data-slean="hint" role="tooltip" popover="manual" data-side="…">, places it
 * with inline left/top beside the element's content box and flips data-side when the asked side
 * has no room. Flags it copies from the element: data-slean-hint-mono (monospace, tabular
 * figures) and data-slean-hint-content (a rich hint: block content, start-aligned). The bubble is
 * in the top layer where the Popover API exists; elsewhere the fixed position and z-index here
 * keep it above the page. */
@layer slean.reset, slean.tokens, slean.base, slean.components, slean.compositions, slean.utilities;

@layer slean.components {
	:where([data-slean='hint']) {
		position: fixed;
		inset: auto;
		z-index: 2147483647;
		margin: 0;
		inline-size: max-content;
		max-inline-size: min(18rem, calc(100vw - 2 * var(--slean-space-2)));
		padding-block: var(--slean-space-1);
		padding-inline: var(--slean-space-2);
		overflow: visible;
		border: 0;
		border-radius: var(--slean-radius-sm);
		background: var(--slean-fg);
		color: var(--slean-bg);
		box-shadow: var(--slean-elevation-1);
		font-family: var(--slean-font-sans);
		font-size: var(--slean-text-xs);
		line-height: var(--slean-leading);
		text-align: center;
		text-wrap: balance;
		overflow-wrap: anywhere;
		opacity: 1;
		translate: none;
		transition:
			opacity var(--slean-duration-fast) var(--slean-ease),
			translate var(--slean-duration-fast) var(--slean-ease);
	}

	:where([data-slean='hint'][hidden]) {
		display: none;
	}

	@starting-style {
		:where([data-slean='hint']) {
			opacity: 0;
		}

		:where([data-slean='hint'][data-side='top']) {
			translate: 0 2px;
		}

		:where([data-slean='hint'][data-side='bottom']) {
			translate: 0 -2px;
		}

		:where([data-slean='hint'][data-side='left']) {
			translate: 2px 0;
		}

		:where([data-slean='hint'][data-side='right']) {
			translate: -2px 0;
		}
	}

	:where([data-slean='hint'][data-slean-hint-mono]) {
		font-family: var(--slean-font-mono);
		font-variant-numeric: tabular-nums;
	}

	:where([data-slean='hint'][data-slean-hint-content]) {
		padding-block: var(--slean-space-2);
		padding-inline: var(--slean-space-3);
		text-align: start;
		text-wrap: pretty;
	}

	:where([data-slean='hint'][data-slean-hint-content] > *) {
		margin: 0;
	}

	:where([data-slean='hint'][data-slean-hint-content] > *:not(:first-child)) {
		margin-block-start: var(--slean-space-1);
	}

	@media (forced-colors: active) {
		:where([data-slean='hint']) {
			border: 1px solid CanvasText;
			background: Canvas;
			color: CanvasText;
		}
	}
}
