The origin of adaptive phenotypes