The big thermos flask in a microwave

First thing to note is that what we call 'light' is part of a spectrum which includes not only light but other waves like radio waves microwaves ultraviolet and infrared waves. Each of these waves has different wavelengths like waves on water or sound waves gave different pitches.
Things get their temperature in three ways - conduction, convection (circulating), and radiation. Turns out only convection and radiation are relevant to gases like air.

Light comes from the sun which is awfully hot, that means it is mostly visible with some uv and a little infra red. It hits the surface and some if it is absorbed. That surface then remits light at a different frequency- more like infra red (think night vision).

So the key question is what should the temperature of the earth be, given the amount that is absorbed and reflected. Turns out roughly -15C, when the actual temperature is +15C. So what's going on.

Some of that mostly infra red 'light' that gets remitted is again absorbed by molecules that 'bend' - ie those with three atoms in them CO2, H2O. That bending has its own frequency just like a pendulum on a clock has its own frequency- that can make it vibrate. Turns out we can onserve that frequency in the lab - it's not conjecture. It's in the infra red. So it turns out that the earth's surface emits this radiation and we know that co2 and h2o will absorb it.

So then once they absorb and re-emit some of that stuff is sent back to the surface. So the surface is trying to send infra red into space but the atmosphere is sending some of that  stuff back to earth level. That back radiation acts a bit like a blanket around the earth.

So why does air get cooler as it rises? Because the pressure goes down because there is less air above pushing it down.

Eventually it actually gets warmer - higher than Everest the temperature starts to go up again because the Air is then so thin it never bumps into each other.

So how does the 'earth' get its temperature?? Turns out its all about radiation. The surface of the earth is in a radiative equilibrium with the sun, influenced by the greenhouse gas blanket. As the air gets thinner it gets cooler (due to reduced pressure) (and then hotter again). But it's the surface that matters. The law of pressure is relevant in regard to looking at how hot and cold Everest is relative to the surface but the question makes only limited sense because it's the surface of the earth which is the interface between our planet and the rest of the world through radiative (light) absorption. The top of the atmosphere is surrounded by a vacuum. It's like putting a thermos flask in the microwave - the earth can get heated up even though surrounded by a vacuum because there's radiation that can pass through the vacuum.