Buffer-gas cooling, high-resolution spectroscopy, and optical cycling of barium monofluoride molecules