Influence of conduction electrons on the magnetism of cobalt grains in a copper matrix studied by density-functional theory