Automatic level shifting
This has been done for over half a century on TV sync pulses that are AC coupled and then DC clamped to the ground on the back porch to set the black level.

The way it works is the leading edge to your desired 0V level is differentiated to trigger a very short pulse and then AC coupled for this "active clamp circuit."  It shorts the input signal to ground with an open collector or open drain and charges up the cap with the DC offset voltage. (T=RdsON*C) to the achieve 0V out. then the FET switch is opened until the next leading edge. Obviously, any load current must be minimized by a low bias current, low input offset Buffer to prevent decay and reclamp charge current.