hmm, this is actually quite interesting (you may not agree with that)
if he's offside when the ball is played - obviously offside, even
but he (or anyone) then comes back to onside before they then go for the ball & get the ball, you could probably make the decision either way
1 - he was offside when the ball was played & gained possession
or
2 - it's a new phase of play because the player goes back onside & makes a definite separate movement, no advantage was actually gained from being in the offside position in the first place
well...
let's say he is offside,
- (when the ball is headed)
he comes back onside to then move to go for the ball - and I now this sounds batshit, but by doing this he essentially creates his own new phase of play
possibly
I'm not sure about the VAR either - it really is incredibly marginal