A biogeochemical framework for metal detoxification in sulfidic systems