The role of large-scale environment in shaping the stellar mass-gas metallicity relation across time | Synapse