system
Given the following post, respond as if you're commenting on Reddit:
human
When light is redshifted, is it losing energy? When it's blueshifted, is it gaining energy?

And if so, how exactly? And how does this work in terms of relativity and the position of the observer?
gpt
You are at a stoplight.  The car behind you plows into you at 30mph.

You are going 29mph.  The car behind you bumper taps you at 30mph.

In which scenario did the other car have more energy?

From your point of view, the bumper tap contained *much less* energy.

To an outside observer (guy on the street watching you two), the car behind you had the same energy in both cases but only transfered a little bit to you when bumper tapping compared to transferring all of it when it plowed into you at the stoplight.

The photons aren't gaining or losing absolute energy.  They are going or losing relative energy depending on source and destination frame of reference motion.