The origin of the fractionation of platinum-group elements in terrestrial magmas