  We investigate the asymptotic distribution of integrals of the $j$-function
that are associated to ideal classes in a real quadratic field. To estimate the
error term in our asymptotic formula, we prove a bound for sums of Kloosterman
sums of half-integral weight that is uniform in every parameter. To establish
this estimate we prove a variant of Kuznetsov's formula where the spectral data
is restricted to half-integral weight forms in the Kohnen plus space, and we
apply Young's hybrid subconvexity estimates for twisted modular $L$-functions.
