Around that time, Apple released its seventh iteration of the iPhone, that glossy black totem of progress. Inscribed on the back of every iPhone are the words “Designed in California. Assembled in China.” As if California is a separate country. And that’s how many in Trump country saw it — that instead of being part of the iPhone economy, they were living in a land that sent jobs overseas.

One thing that I, like many Europeans and other foreigners, had long seen as distinguishing the United States was its restless optimism and innate self-belief. Mr. Trump, though, traded on pessimism. His slogan, “Make America Great Again,” embodied a nativist vision that aimed to restore pride in the country’s military and business, but also scapegoated immigrants, minorities and Muslims.

At Mr. Trump’s rallies, most of the faces in the crowd were white. People flew Confederate flags. They spoke impatiently about “the blacks.” Broad-brush prejudice toward Muslims was openly expressed: Danny Popma, a factory owner in Michigan, told me that children in Dearborn, which has the country’s largest percentage of Muslims, had stayed home from school in droves on Sept. 11 because they had secretly received advanced warnings of the attacks.

The atmosphere at Trump rallies was permissive. If someone said something offensive or loutish, there was little fear of being hushed or contradicted. Yet in another confounding twist, a significant minority of Trump supporters were minorities themselves. I met people who defied neat categorization: a black woman in her 20s who worked at a record label in Miami; a Japanese Uber driver in Las Vegas; a Guyanese doorman in Queens, N.Y.

At a rally in the campaign’s final week in Michigan, a Rust Belt state that would prove central to Mr. Trump’s victory, I saw how the candidate connected with crowd. When he spoke, it was if he held an invisible tuning fork held to his ear, listening for the smallest murmur of applause, which he would seize upon and amplify. It reminded me of powerful preachers and populist politicians I’d seen during my years based in Pakistan.

What was hard to know was how far the electric energy inside this hall was radiating. Maybe these were just the hard-core loyalists. State-by-state polls suggested that Mr. Trump was behind in many places critical to Electoral College victory. Political professionals, including Republicans, dismissed the notion that Mr. Trump could win mainly by consolidating the support of white voters.

“It’s like the hunt for the lost tribes of the Amazon,” was how Stuart Stevens, a consultant who had worked for the 2012 Republican nominee, Mitt Romney, put it early on. “If you paddle your canoe far enough up the river, and bang your drum hard enough, they will come to the riverbank. But they’re just not there.”