If you still believed President Donald Trump is just using tariffs as a clever negotiating tactic to get better trade deals for the United States, you got a rude awakening Thursday evening when the White House announced it would put tariffs on Mexican imports to stop illegal immigration.

Those tariffs, Trump tweeted, will start on June 10 and will add 5 percent to the cost of all imported goods from Mexico. They will "gradually increase until the illegal immigration problem is remedied," Trump wrote. The White House later outlined a plan to hike the tariffs from 5 percent to 25 percent by October.

This is a stunningly stupid idea on many levels.

Let's start with the most obvious: Tariffs are taxes on Americans. Making it more expensive to import goods from Mexico is a pretty roundabout way to get Mexico to change its border policies, but it's a very direct tax increase for American businesses and consumers. Last year, Americans imported more than $346 billion in goods from Mexico, so a 25 percent tariff would amount to an $87 billion tax increase.

Second, the number of undocumented immigrants coming to the United States from Mexico has been declining for years, and many have returned home already. In 2016, there were 1.5 million fewer unauthorized Mexicans living in the U.S. than there were in 2007, according to data from the Pew Research Center. Overall, the number of undocumented immigrants in the U.S. has declined from 12.2 million in 2007 to about 10 million last year, Pew says.

Perhaps Trump means that Mexico should curb the flow of migrants passing through the country on their way to the United States—specifically, the migrants fleeing violence in Central America. But those are not, by and large, illegal immigrants; they're coming here to legally present themselves as candidates for asylum.

Third, even if Mexico could be convinced to act, somehow, by the tariff threat, the White House's demands are absurd. The tariffs are set to ratchet up by 5 percent every month between June and October, but what sort of comprehensive immigration policy could be implemented in a matter of weeks? Trump says the tariffs will stay in place until the "problem is remedied," but what does that mean? Illegal immigration over the southern border is already near historic lows, and it's not at all clear what metric the Trump administration will use to judge whether Mexico has done as it is being told. Mexican officials are being told to fix a problem they didn't cause, to do it in a matter of weeks, and without knowing how their performance will be measured.

Fourth, if the tariffs work the way Trump think they will, they will make illegal immigration worse. Think about it like this: Trump believes tariffs harm the economy of the country exporting goods to the United States (which is true, though importers and consumers in the U.S. are hurt worse). So he's implementing a strategy that's designed to harm Mexico's economy, but what happens when Mexico's economy weakens? More Mexicans try to come to the United States!

Fifth, Trump's out-of-nowhere tariff threat is rattling the stock market, again.

Sixth, Trump is complicating the passage of his much touted United States–Mexico–Canada Agreement (USMCA) with these new tariff threats. Earlier this year, Sen. Chuck Grassley (R–Iowa) made it clear that the Senate Finance Committee, which handles trade issues and which he chairs, would not approve the USMCA deal until the Trump administration withdrew the tariffs on steel and aluminum imported from Canada and Mexico. Trump backed down and lifted those tariffs two weeks ago, apparently clearing the way for the USMCA to pass Congress.

Now the White House is threatening to impose tariffs on steel, aluminum, and literally everything else coming over the border from Mexico. Grassley's response? "This is a misuse of presidential tariff authority and counter to congressional intent," the senator tells Politico. "Following through on this threat would seriously jeopardize passage of USMCA, a central campaign pledge of President Trump's and what could be a big victory for the country."

Seventh, Trump just pulled the rug out from under his own defense of America's trade wars. Despite much evidence to the contrary, the president's defenders have stuck to the idea that Trump is using tariffs to extract better trade deals for the United States. With the exception of the USMCA, those deals have not yet emerged. But recently, there have been signs that the White House was starting to reorient its punitive trade policies with a singular focus on China—and while the strategy of using tariffs is still questionable, the hardball approach with China is a politically winning one for Trump.

All that goes out the window now. Trump is obviously not using this tariff threat against Mexico to achieve a better trade deal. Indeed, it's more likely to scuttle the trade deal that the U.S. and Mexico already reached. He's just trying to bully another country into doing what he wants. Lacking any diplomatic skills and having soured the relationships between America and many of its closest trading partners, Trump is grasping for one of the only tools he has—though it is a tool that he, clearly, does not understand.

Finally, it's not at all clear that Trump has the legal authority to impose these tariffs. Though the administration has successfully stretched the definition of "national security" enough to allow Trump to unilaterally impose the steel and aluminum tariffs under Section 232 of the Trade Expansion Act of 1962, that law is not useful to the president here.

Instead, he's reaching for the International Emergency Economic Powers Act, which requires the declaration of a national emergency. White House trade advisor Peter Navarro tells CNBC that illegal immigration across the southern border constitutes an emergency because "what we have in Mexico is the export, one of their high exports, of illegal aliens."

But the law granting Trump those emergency powers has never been used to impose tariffs before, and CNN reports that "privately, officials have conceded it's not clear the White House has the legal authority to impose tariffs on this scale."

There will almost certainly be legal challenges to Trump application of emergency powers in this case. There ought to be a congressional effort to revoke Trump's tariff powers too, but don't hold your breath.