Hello. I was wondering, if light from a star (for arguments sake take our sun) emits light, and the light passes through a planets atmosphere (again for arguments sake, take our own planet Earth), it slows down as it moves into the denser area of our atmosphere. Say then it left the atmosphere again, it has lost energy while slowing down, and that energy has been converted into heat energy. Once it leaves the atmosphere, does the light "re-accelerate" back to the speed of light in a vacuum or does it remain the same speed as it was in the denser area of the atmosphere? If it does, where does the additional energy for the acceleration come from?