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?