fiber products of curves Let $X,Y,Z$ be three nonsingular curves over a field $k$ (not necessarily proper, ie, possibly affine). Let $f : X\rightarrow Z$ and $g : Y\rightarrow Z$ be finite morphisms.
We know the fiber product $X\times_k Y$ is a nonsingular surface.
The projection maps from $X\times_Z Y$ to $X$ and $Y$ induce a map $X\times_Z Y\rightarrow X\times_k Y$, which basically realizes it as the subset $\{(x,y) : f(x) = g(y)\}$.
Can someone explain to me, being as detailed and rigorous as possible, ideally using the language of schemes, why the point $(x,y)$ of $X\times_Z Y$ is singular if and only if $f$ is ramified at $x$ and $g$ is ramified at $y$?
I would appreciate some geometric intuition as well. I can "sort of" see it, but I feel like I'm missing the language. For example, what would the local ring look like? What kind of singularity is it?
 A: A tangent vector to $X\times_Z Y$ at $(x,y)$ can be identified with a morphism $u:\mathrm{Spec}\,k[\epsilon]/(\epsilon^2)\to X\times_Z Y$ taking the single closed point of $\mathrm{Spec}\,k[\epsilon]/(\epsilon^2)$ to $(x,y)$. By the universal property of $X\times_Z Y$, this is the same as a pair $(v,w)$, where $v$ is a tangent vector to $X$ at $x$, $w$ is a tangent vector to $Y$ at $y$, and $f_* v=g_*w$ as tangent vectors to $Z$ at $z:=f(x)=g(y)$. So the tangent space to $T_{(x,y)}X\times_Z Y$ is identified with the fibre product of vector spaces $T_{x}X \times_{T_z Z} T_y Y$. 
Since $X$ and $Y$ are smooth curves, $T_x X$ and $T_y Y$ are $1$-dimensional. It is easy to check that if $\varphi:A\to C$, $\phi:B\to C$ are linear maps of $1$-dimensional vector spaces, then $A\times_C B$ is $2$-dimensional if and only if $\varphi= 0$ and $\psi=0$, otherwise it is $1$-dimensional. In our case, $T_{x}X\to T_z Z$ is the $0$ map precisely if $f$ is ramified at $x$, and $T_{y}Y\to T_z Z$ is the $0$ map precisely if $g$ is ramified at $y$, so $T_{(x,y)}X\times_Z Y=T_{x}X \times_{T_z Z} T_y Y$ fails to be $1$-dimensional if and only if $f$ is ramified at $x$ and $g$ is ramified at $y$. Since $X\times_Z Y$ is a curve, it is singular at a point if and only if the tangent space at the point is not $1$-dimensional.
