Magnetic confinement of broad-line clouds in active galactic nuclei