Scientists have solved a decades-long mystery about how carbon dioxide simultaneously cools the upper atmosphere while warming Earth's surface.