Flexible larval development and the timing of destructive feeding by a solitary endoparasitoid: an optimal foraging problem in evolutionary perspective