When we try to maximize/minimize the value of $f(x,y) = 2x + y$ on the unit circle $x^2 + y^2 = 1$, we look at the level curves of $2x + y$ and find the $z$ value at which the line is tangent to the circle.
How does this logic apply to a function of 3 variables? For example, if I want to find the minimum distance from the origin to the intersection of two planes, I would set $f = x^2+y^2+z^2$ and $g_1,g_2$ as the two planes. When we look at the level surfaces of $f$, do we want the expanding sphere to be tangent to both planes? Or do we want the sphere to just touch a point on the intersection of the two lines? Since we want $\nabla{f} = \nabla{g_1} + \nabla{g_2}$, I would think it's the former, but I can't visualize how that allows the sphere to also be on the line of intersection.