My textbook, Fundamentals of Photonics, Third Edition, by Saleh and Teich, says the following in a section on Planar Boundaries:
The relation between the angles of refraction and incidence, $\theta_2$ and $\theta_1$, at a planar boundary between two media of refractive indices $n_1$ and $n_2$ is governed by Snell's law (1.1-3). This relation is plotted in Fig. 1.2-8 for two cases:
$\blacksquare$ External Refraction ($n_1 < n_2$). When the ray is incident from the medium of smaller refractive index, $\theta_2 < \theta_1$ and the refracted ray bends away from the boundary.
$\blacksquare$ Internal Refraction ($n_1 > n_2$). If the incident ray is in a medium of higher refractive index, $\theta_2 > \theta_1$ and the refracted ray bends toward the boundary.
The refracted rays bend in such a way as to minimize the optical pathlength, i.e., to increase the pathlength in the lower-index medium at the expense of pathlength in the higher-index medium. In both cases, when the angles are small (i.e., the rays are paraxial), the relation between $\theta_2$ and $\theta_1$ is approximately linear, $n_1 \theta_1 \approx n_2 \theta_2$, or $\theta_2 \approx (n_1/n_2)\theta_1$.
Reading what the authors have said here, and comparing it to figure 1.2-8, when they say that the optical pathlength is minimized, they're referring to the pathlength from the origin of the ray to some imaginary vertical line on the $n_2$ medium side, right? is this a correct way to conceptualize the minimization of optical pathlength?