Decoherence and collective effects of quantum emitters near a medium at criticality