Phase-separation physics underlies new theory for the resilience of patchy ecosystems