12.2.7 ** As shown in the figure, in the tetrahedron $P-ABC$, $PA \perp$ the base $ABC$, $\angle ACB=90^{\circ}$, $AE \perp PB$ at $E$, $AF \perp PC$ at $F$. If $PA=AB=2$, $\angle BPC=\theta$, then when the area of $\triangle AEF$ is maximized, the value of $\tan \theta$ is ( ).
(A) 2
(B) $\frac{1}{2}$
(C) $\sqrt{2}$
(D) $\frac{\sqrt{2}}{2}$
Since $P A \perp$ plane $A B C$, then $P A \perp B C$. Also, $B C \perp A C$, so $B C \perp$ plane $P A C$. Therefore, plane $P B C \perp$ plane $P A C$. Since $A F \perp P C$, then $A F \perp$ plane $P B C$, which implies $A F \perp E F$. Given $P A = A B = 2, A E \perp P B$, so $A E = \sqrt{2}$. In the right triangle $\triangle A E F$, since $A F^{2} + E F^{2} = A E^{2} = (\sqrt{2})^{2} = 2$, it follows that $A F \cdot E F \leqslant \frac{A F^{2} + E F^{2}}{2} = 1$. Therefore, $S_{\triangle A E F} = \frac{1}{2} A F \cdot E F \leqslant \frac{1}{2} \times 1 = \frac{1}{2}$.
The equality holds if and only if $A F = E F$, in which case $S_{\triangle A E F}$ reaches its maximum value $\frac{1}{2}$. At this point, $A E \cdot E F = E F^{2} = 1$, so $E F = 1$. Since $A F \perp$ plane $P B C$ and $A E \perp P B$, by the converse of the three perpendiculars theorem, we get $F E \perp P B$.
In the right triangle $\triangle P E F$, given $P E = \sqrt{2}, E F = 1$, we have $\tan \theta = \frac{1}{\sqrt{2}} = \frac{\sqrt{2}}{2}$. Therefore, the answer is D.