Thermodynamic description of bacterial metal-sensing: A cellular logic for metals