Ghost-imaging-enhanced non-invasive spectral characterization of stochastic x-ray free-electron-laser pulses