How drug-resistant bacteria build defences