The initiation of metamorphosis as an ancient polyphenic trait and its role in metazoan life-cycle evolution