When a window is created, its position is 1 z unit closer to the camera. And if there are 2 they will both be that at that distance. They will overlap.
Each virtual window that spawns should become focused, and whenever a window gets focused it should be brought to the front. The amount of z units that they move should also depend on how many elements are inside the window.