Distance to the circumference of a circle from an inscribed point

Originally my question is rooted in neutrino physics where neutrinos are produced at a height h above the earth (which has radius r). Here one would like to know the distance L from the source to a specific point on the earth's surface as a function of zenith angle $\phi$, r and h. I have drawn this in the picture below to make it more comprehensible:

Now I have found through some research that the answer should be

$L=-rcos(\phi)+\sqrt{r^2 cos^2(\phi)+h^2+2rh}$

But I cant get the trigonometry right to derive this solution.

By cosine formula, we have

$$L^2+r^2-2(L)(r)\cos(\pi-\phi)=(r+h)^2$$

Solving, we have

$$L=-r\cos\phi+\sqrt{2rh+h^2+r^2\cos^2\phi}$$