stacked && setExpanded(true)}
onMouseLeave={() => stacked && setExpanded(false)}
onFocus={() => stacked && setExpanded(true)}
onBlur={(e) => {
if (!stacked) return;
// Only collapse when focus leaves the viewport entirely.
if (!e.currentTarget.contains(e.relatedTarget as Node | null)) {
setExpanded(false);
}
}}
className={cn(
'pointer-events-none fixed z-[90] flex w-full max-w-[min(24rem,calc(100vw-2rem))] flex-col gap-2 p-0',
POSITION_CLASS[position],
)}
>
{ordered.map((t, i) => {
// Depth = how far behind the front this card is (0 = front).
const depth = frontIndex - i;
const visible = !stacked || expanded || depth <= stackVisible;
const offsetPx = stacked && !expanded ? depth * 8 : 0;
const scale = stacked && !expanded ? Math.max(0.92, 1 - depth * 0.04) : 1;
const translateY = bottom ? -offsetPx : offsetPx;
return (
onDismiss(t.id)} surface={surface} />
);
})}
,
document.body,
);
}