Overlays
Everything that renders above the page. Focus trapping, focus return, roving focus and the ARIA contracts are the expensive part to build and the invisible part when they are wrong, so all of these lean on a primitive that already has them.
Choosing between them
Dialog
The user must answer before continuing. It interrupts on purpose.
Drawer
Detail beside the list, without leaving it. Nothing is blocked.
Dropdown menu
A list of actions on one thing. Nothing is selected afterwards.
Tooltip
A label for something already visible. Never the only source of information.
Nesting
A Select inside a Dialog inside a Drawer, three portals deep. No component carries a z-index of its own: they share one layer and the order comes from the document, so the deepest popup is simply the last one in it. That is the only rule that survives arbitrary nesting, and a test fails if a second layer number appears anywhere in the package.