Heritable learning phenotypes drive collective cognition