I'm trying to deduce the intensity distribution resulting from the interference of reflected and transmitted light in a medium with a non-uniform refractive index, as shown in the image below. The refractive index depends on $z$, such that $n(z)=n_0-cz$, where $n_0$ and $c$ are positive constants. The medium is surrounded by air and $n(z)>n_{air}$ at all its points.
I know that I must calculate the optical path length of followed by the second ray inside the medium in order to get the phase difference. However, as n is not uniform, I see that the path won't be straight. How could this distance be calculated?