Structure and sharpness of phase transitions and mantle discontinuities