Cross correlation to compute delay between two lines does not work
If you plot the cross correlation instead of taking the maximum, then I expect you'd see the problem.

The cause is that your signals aren't centered around zero.  They have an offset.  The cross correlation of two signals with an offset is a kind of triangle looking thing with the peak at zero.

As far as the cross correlation is concerned, your two signal are identical except for the offset - and you normally use a high pass filter or subtract the average of the data points to remove the offset.

Your result is correct and to be expected, it's just not what you wanted.