Variational formulation of the electromagnetic radiation-reaction problem