Global stability properties of the climate: Melancholia states, invariant measures, and phase transitions