Statistical mechanics of 1D self-gravitating systems: the core—halo distribution