The ecology and evolution of endophytes