Mutational collapse of fitness in marginal habitats and the evolution of ecological specialisation