A: The visible spectrum of light goes from the infrared to the ultraviolet. The waves of the infrared are stretched out and move slower than the compressed and faster-moving light on the ultraviolet side. When sunlight (which is slightly yellow) hits our atmosphere, it is scattered by the gases in the air. This compression of the light waves shifts it towards the ultraviolet and gives it the blue color.
When the sun is setting, the light has farther to travel through the atmosphere. The compressed (blue) waves hit the atmosphere and scatter, but the stretched (red) waves continue through. By the time the light reaches your eyes, the sky has filtered the blue part of the spectrum and slowly filters out all of the colors until you’re left with orange, red, and eventually the blackness of night.