Mean ecological conditions modulate the effects of group living and communal rearing on offspring production and survival