  Metallicity offers a unique window into the baryonic history of the cosmos,
being instrumental in probing evolutionary processes in galaxies between
different cosmic environments. We aim to quantify the contribution of these
environments to the scatter in the mass-metallicity relation (MZR) of galaxies.
By analysing the galaxy distribution within the cosmic skeleton of the Horizon
Run 5 cosmological hydrodynamical simulation at redshift $z = 0.625$, computed
using a careful calibration of the T-ReX filament finder, we identify galaxies
within three main environments: nodes, filaments and voids. We also classify
galaxies based on the dynamical state of the clusters and the length of the
filaments in which they reside. We find that the cosmic environment
significantly contributes to the scatter in the MZR; in particular, both the
gas metallicity and its average relative standard deviation increase when
considering denser large-scale environments. The difference in the average
metallicity between galaxies within relaxed and unrelaxed clusters is $\approx
0.1 \text{ dex}$, with both populations displaying positive residuals, $\delta
Z_{g}$, from the averaged MZR. Moreover, the difference in metallicity between
node and void galaxies accounts for $\approx 0.14 \, \text{dex}$ in the scatter
of the MZR at stellar mass $M_{\star} \approx 10^{9.35}\,\text{M}_{\odot}$.
Finally, both the average [O/Fe] in the gas and the galaxy gas fraction
decrease when moving to higher large-scale densities in the simulation,
suggesting that the cores of cosmic environments host, on average, older and
more massive galaxies, whose enrichment is affected by a larger number of Type
Ia Supernova events.
