Briefly explain what determines the characteristic color of (a) a metal and (b) a transparent nonmetal.