Ecological determinants of Cope’s rule and its inverse