Time-domain formulation of electromagnetic scattering based on a polarization-mode expansion and the principle of least action