Leaf phenology as an optimal strategy for carbon gain in plants