Spatial heterogeneity stabilizes livestock productivity in a changing climate