Thermal hadron production in relativistic nuclear collisions: The hadron mass spectrum, the horn, and the QCD phase transition