I mentioned in the climate fingerprinting post that if you have more greenhouse gases in the atmosphere, we expect the stratosphere -- the upper atmosphere -- to get colder. That, naturally, brought on the question 'why'.
I'm far from the first person to make the comment, or to attempt to write up a description of how it works on a blog. Recently the Stoat took a swipe, or rather referenced a prior attempt and one by Realclimate, and the Rabett has also had a go. Plus, I'm sure, there are a raft of other efforts in existence. Yet the questioner is still asking. That being the case, and having seen prior efforts make the attempt to describe the full situation that you have, I'll aim for a simpler version.
This will be a heuristic description. It will be capable of being made rigorous, in the sense that you can take the heuristic and put solid math behind it. But it will be incorrect in many of its details. The merit of such heuristics is that even though they are incorrect in details, they lead your intuition in the right directions, such that you can then work with and understand the version of the argument that is completely correct in its details.
The simplest heuristic for surface warming in the face of an increase in greenhouse gases is our starting point. For this, start with the surface at some temperature in balance with the atmosphere at its temperature, and with the incoming solar energy. Now wave your hand and magically add some greenhouse gas to the atmosphere. We will say, heuristically, that if more photons come back to the surface than used to, that the surface warms. The surface emits some photons, same as usual. But, thanks to the extra greenhouse gas in the atmosphere, some more get absorbed by the atmosphere. Some of them get tossed out of the atmosphere (where they'd have gone before), but some get thrown back to the surface -- which then warms up. The real analysis is much more involved than this, but this does give you a correct starting intuition. It also points to the importance, yet again, of the first law of thermodynamics -- conservation of energy.
For looking at what happens in the atmosphere, let's again track photons. (Remember those are the packets of energy carried by light). Again, we'll start with an atmosphere and surface which are in energy balance with solar input. Add a little bit of greenhouse gas in every layer of the atmosphere. These cause more photons to be emitted from that layer -- half go towards space, and half towards the ground. We'll take the heuristic approach that if most of the photons wind up in space, the layer cools. If most wind up at the surface, the layer warms. The heuristic also suggests that if almost all photons go to space (eventually), then the layer cools 'a lot' (it doesn't tell us how much, just a relative sense), and if half go to space and half to the surface, then it stays the same temperature.
We need to think a bit about those 'layers'. They're being caused by energy emission from greenhouse gases. But greenhouse gases don't emit all photon energies (or wavelengths -- short wavelengths, like blue, are higher energy than longer wavelengths, like red) equally well. In a band (a small range of energies or wavelengths) that the gas is a strong emitter, it can easily be 1000 times better an emitter than at a wavelength a little bit different. There is a converse to this. By Kirchoff's law, any wavelength that the gas emits well, it also absorbs well. So consider a strong band (15 microns, for instance, for CO2). That strength means that a photon emitted here will very likely be absorbed before travelling very far. That 'not very far' means that through the depth of the atmosphere, the photon will be absorbed many times. So we can turn around and let the number of layers represent how strongly the wavelength is absorbed. If the gas is a very strong absorber at a wavelength, then we have, say, 1000 layers. If it's a poor absorber, it might only be one or two.
There's another feature we need in our layers, for the heuristic explanation. Consider layer 28 (out of, say, 100). Like all our layers, half the photons it emits go up (towards space) and half go down (towards the ground). But ... the layers are so thick that photons will be absorbed in the next layer. So the photons from layer 28 get absorbed in 27 or 29, rather than going to the surface or space immediately. Now that some are in 27, we can again ask where they go -- and the answer is half go to 26 and half to 28.
I certainly wouldn't try this by hand for 1000 layers, but give yourself 3 layers. Start with 1024 photons in the top layer (which I'm calling layer 3), send half upwards (space) and half down (layer 2, now has 512 photons). Send half the photons up and half down, again. Keep repeating this until all the photons are either in the bucket for space, or for the surface. Then count up the totals in each bucket. Repeat the process, starting with photons in layer 2, and then starting with layer 1, and compare your tallies. You could carry this out with a stack of chips, or coins, whatever. Or just do it on paper and copy the numbers across (it takes very good writing to carry this out, I discovered). Or, of course, my solution of writing a short program.
It's a good idea to draw yourself a diagram here, or [Update] take a look at jg's graphic.
The outcome is, when you have several layers, the photons from the top layer mostly wind up in space. Photons from the bottom layer mostly wind up in the ground. The more layers (try the program, or write your own), the more this is the case. With 100 layers, over 99% of the photons go to space from the top layer (or to the ground from the bottom layer).
So there's our heuristic answer -- the top of the atmosphere cools with an increase in greenhouse gas levels because most photons from the upper atmosphere go to space. At the same time, the lower atmosphere warms as most photons from the lower atmosphere get caught by the surface.
That said, here's one of the limits to our heuristic description: Most of the photons don't get absorbed and re-emitted immediately, even though that's what our heuristic model says. Most of the time, a CO2 molecule (or any other greenhouse gas) collides with an oxygen or nitrogen molecule, and hands off the energy to those molecules instead of radiating it away. This is why nitrogen and oxygen have the same temperature as CO2. But it also means our heuristic model is incomplete. In addition to radiation, we should be considering what happens to the temperatures of the layers. What saves the heuristic model is that after we let the energy slosh around, the now-warm oxygen and nitrogen molecules sometimes crash in to a CO2 molecule. And sometimes, even if it's rare it does happen, that CO2 molecule emits a photon before it collides with another oxygen or nitrogen molecule.
There are a ton of elaborations that can be made to this heuristic. One direction of change is to start doing Monte Carlo modeling of radiation. This is particularly common in dealing with earth radiation in clouds. The second is the more obvious one of tracking the full conservation of energy. This, as you get more rigorous, becomes Radiative-Convective Modeling.