/* @svelte-lean/styles — hover card (Tier 1 where interest invokers are missing; the card shows on
 * hover or keyboard focus of a trigger). Markup: <a href interestfor="c">…</a> and
 * <div id="c" popover="hint" data-slean="hover-card">, the card anywhere in the document. Imports
 * popover.css: the surface, anchor positioning (the trigger is the card's implicit anchor, through
 * interestfor natively or showPopover({ source }) from the behavior), the side and align options
 * and the open transition live there. This file sizes the card and aligns it with the trigger's
 * inline start when it has no data-slean-align (any align value is popover.css's).
 * State: :popover-open. */
@layer slean.reset, slean.tokens, slean.base, slean.components, slean.compositions, slean.utilities;
@import './popover.css';

@layer slean.compositions {
	:where([data-slean='hover-card']) {
		inline-size: max-content;
		max-inline-size: min(20rem, calc(100vw - 2 * var(--slean-space-4)));
		padding: var(--slean-space-4);
		box-shadow: var(--slean-elevation-4);
		font-family: var(--slean-font-sans);
		font-size: var(--slean-typography-body2-size);
		font-weight: var(--slean-typography-body2-weight);
		line-height: var(--slean-typography-body2-line-height);
		text-align: start;
	}

	/* Without data-slean-align the card starts where the trigger starts; an explicit align is
	 * popover.css's. */
	:where([data-slean='hover-card']:not([data-slean-align])) {
		position-area: bottom span-x-end;
	}

	:where([data-slean='hover-card'][data-slean-side='top']:not([data-slean-align])) {
		position-area: top span-x-end;
	}

	:where([data-slean='hover-card'][data-slean-side='left']:not([data-slean-align])) {
		position-area: left span-bottom;
	}

	:where([data-slean='hover-card'][data-slean-side='right']:not([data-slean-align])) {
		position-area: right span-bottom;
	}

	:where([data-slean='hover-card'] > :first-child) {
		margin-block-start: 0;
	}

	:where([data-slean='hover-card'] > :last-child) {
		margin-block-end: 0;
	}
}
