Now I have some time to address the most puzzling part of this: when the second turn happens, why don't we go back to -A?

We can go through the sequence of events as shown in the article's animation, with a bit more explanation at each step. Like the article, I will ignore both drag and the fact that the glider is alternately trading kinetic energy (speed) for potential energy (height) and vice-versa, as it rises and falls. In practice, both of these will have a effect, but if the wind gradient is sufficiently strong, they will be small enough to ignore.

For vectors (velocity and acceleration, but not speed), I will use the convention that rightwards is positive. There are two frames of reference that are relevant: the one moving with the upper airmass, and the one pinned to the lower one (which, as there is no wind in the lower region, is also the ground frame of reference.) At each step, I will calculate the glider's velocity in each frame of reference (we can always measure the glider's velocity in either frame, regardless of whether it is in the corresponding airmass.) A key point to bear in mind is that the glider's airspeed is, by definition, the magnitude of its velocity in the frame of reference in which the air surrounding it is not moving.

1) The animation starts with the glider ascending in the lower layer at some airspeed A₀. Here, its velocity in the lower, ground frame is -A₀, and in the upper frame, which moves with the wind and has a velocity W relative to the ground frame, the glider's velocity is -(A₀ + W).

2) It crosses the boundary between the two airmasses, encountering a headwind. We are ignoring drag, so it experiences no deceleration and still has the same velocities as before in either frame, but now the frame for calculating the airspeeed is the upper one, so its airspeed has increased to A₀ + W. There is nothing strange about this: it is just what we feel when we walk out of a sheltered doorway into a windy street.

3) The glider reverses direction. On the basis of what was said in the previous reply, the airspeed remains the same, and the velocity in the local (upper) frame is now A₀ + W. Applying a Galilean transformation, the velocity in the ground frame (which, from the glider's perspective, is pinned to a headwind) is now A₀ + 2W. Again, there is nothing strange here: if you watch birds circling in a strong wind, they appear to slow down as they turn into the wind, and pick up speed as they turn downwind. Note that, in either frame of reverence, the change in velocity in the turn is +2(A₀ + W).

4) The glider crosses the airmass boundary in the opposite direction. Because of the reversal of direction, this also feels like encountering a headwind with speed W, and its airspeed increases by that amount, becoming the magnitude of its velocity in the ground frame, A₀ + 2W.

This is the step that seems most like cheating, I think: why doesn't crossing back through the boundary reverse the effect of crossing it in the first place? It seems to violate some basic rule of symmetry, tit-for-tat or no-free-lunch. I don't think there is any everyday experience like it, but from working through the example in detail, we can see that this must be the case, and that our intuitions have been nullified by the glider's reversal of direction between the crossings.

5) The glider reverses direction again. As before, the airspeed remains the same: A₀ + 2W. The glider is back where it started, but going faster.

-------------------------- velocity --------------------------
Step ground frame upper airmass frame change from previous step airspeed

1 -A₀ -(A₀ + W) N/A A₀
2 cross windshear -A₀ -(A₀ + W) 0 A₀ + W
3 turn A₀ + 2W A₀ + W 2(A₀ + W) A₀ + W
4 cross windshear A₀ + 2W A₀ + W 0 A₀ + 2W
5 turn -(A₀ + 2W) -(A₀ + 3W) -2(A₀ + 2W) A₀ + 2W

A clarification for my previous post: in the solution for uniform circular motion, the fact that the speed remains constant can be seen as a conclusion, not a premise, if we adopt the premise that the centripetal force is always perpendicular to the tangential speed. Intuitively, because of this, the object neither speeds up nor slows down.

The way one turns a glider is to bank it in the direction one wishes to turn, which causes the lift to have a horizontal component perpendicular to the direction of motion of the glider. [1]

One problem with trying to calculate the path in the ground frame directly is that the glider is only pointing in the direction it is moving when going directly upwind or downwind. For example, suppose the glider is going westwards across the ground, in a wind from the north with a windspeed equal to the glider's ground speed. The glider will be pointing north-west (and encountering an airflow - the relative wind - from the north-west) and the horizontal component of the lift will be pointing south-west. This is inclined forwards with respect to the glider's direction of motion in the ground frame, and the acceleration it causes, while being the same in any frame of reference, will, in this frame, result in the glider speeding up - and this is what an observer on the ground will see: as the glider turns downwind, it picks up speed relative to the observer.

[1] https://www.boldmethod.com/learn-to-fly/aerodynamics/the-aer...