In Sara Seager's book "Exoplanet atmospheres", she uses the spherical cosine law to derive the surface flux. The figure is as follows:

From the figure, $\hat n \cdot \hat k = \cos \Theta_n$ (where $\hat k$ is in direction of $F$ ($x$-axis)). Using the spherical cosine law, we have $$ \hat n \cdot \hat k = \cos \Theta_n = \cos \theta_n \cos \phi_n$$ How was it derived? any suggestion?
From the figure, the projection of $\hat n$ onto the he $x-y$ plane has lenght $|\cos \theta_n|$ and its projection onto the $z$-axis has component $\sin \theta_n$), therefore the components of the unitary vector $\hat n$ with respect to $x$, $y$, $z$ are:
$$\hat n =(\cos \theta_n\cos \phi_n,-\cos \theta_n\sin \phi_n, \sin \theta_n )$$
and then by dot product:
$$\hat n \cdot \hat k =(\cos \theta_n\cos \phi_n,-\cos \theta_n\sin \phi_n, \sin \theta_n )\cdot(1,0,0)=\cos \theta_n\cos \phi_n$$