Inverse opal hydrogel sensor for the detection of pH and mercury ions