Greenhouse gases keep the planets warmer than they normally would. But, as with electrons trapping photons, I feel that thermodynamics is violated here. Is the violation allowed if energy is trapped for a short period?
Thermodynamics does not prevent the trapping of heat. Here are limitations that thermodynamics does impose on the energy balance of the Earth:
- The Earth's surface can not be (passively) warmed hotter than the temperature of the sun
- The Earth's surface can not be (passively) cooled colder than the temperature of space
- Those living on the Earth can not get more useful work out of the temperature differential than the theoretical upper limit of the Carnot efficiency will allow
The temperature of the sun is comfortably above $3,000 K$ and the temperature of space is about $2.7 K$, so there is plenty of wiggle room, and we do, indeed, fall in between those two.
Greenhouse gases absorb more long wavelength light than short wavelength. The long wavelength is what we emit into space and the short wavelength is what we receive from the sun. By changing the ratio of what we absorb/emit, these gases can act as a sort of thermostat. This would not be possible if not for the abundant energy and high $T$ differential that our location in space gave us.