Certainly cultural anxiety played a role, but I think it was more gay/trans issues than black issues which predominated.
Yes, blacks and Hispanics are in a more precarious economic position than Trump voters, but studies have linked perception of economics to the questions: "are you better off than your father at the same age? Do you expect your children to be better off than you?" This rather than absolute situation was found to be the driver of satisfaction/dissatisfaction. Blacks and Hispanics were optimistic, because they thought their position/opportunities were better than their parents'. Just the opposite for non-college whites, whose parents had high-paid manufacturing and union construction jobs.
I think the cultural issues predominated. Abortion, gays, immigration. The economy was pretty good for most of us, although not in many areas which swung Trump. Still, the studies I've read say there was not a surge of non-college whites who hadn't voted in the Obama elections, rather there was a drop-off in black and Hispanic votes compared to 2008 and 2012. Obama was inspirational. HRC just wasn't. That's how we lost in 2010 -- not voters changing their positions, based upon opposition to Obamacare, but the young and minorities staying home. A lot of Dems need the inspiration of a presidential election with an inspiring candidate to come out and vote. We are notorious for poor turnout in off-year elections, even worse than the Rs show.
Where Trump got more votes than McCain or Romney was among evangelical voters. Part of that might be racism, but more is religious issues, like abortion and gays and Obamacare requirements.
Absent a crap economy, like Obama and FDR inherited, older voters tend to fear societal change, crime, etc. They are easily spooked, by ISIS for example.
My problem with assigning this defeat to racism is that Trump carried quite a few counties which Obama carried twice. People unhappy with a black president in general or Obama in particular would not have voted Obama in 2012. The GWB damage had already been largely undone. People did not have to vote D to escape an awful economy. Same true in 2016. I don't have to look far to see this effect -- Trump won Northampton county, PA, right next door to me. Obama won it twice. Dems have just about always won it during my political life. I think it much likelier Trump stole Obama votes or had them stay home out of sexism, than out of racism. I remember a poll during the last year with "would you vote for an X for president". Atheists came out worst, but women came out second worst -- a lot better than they had done a decade ago, with well over half of voters saying they would consider voting for the right woman, but still something like 40% saying they wouldn't consider voting for a woman. It is partly the commander-in-chief thing, but I think more so all the religions viewing women as subservient: very directly for evangelicals and Mormons, by the structure of church hierarchy and even roles for laypersons in Catholicism, orthodox Judaism, and some Protestant denominations.
I believe the SC nomination drove a lot of voters.
Some states swung because of population movement. One heck of a lot of people have left Detroit. That had to hurt Dems in Michigan.
No explanation is complete without a consideration of what a truly awful candidate HRC was and the impact of the DNC e-mail release, showing the DNC had a big fat thumb on the scale to help HRC defeat Bernie. The Bernie folks were angry. I know of quite a few who didn't vote for HRC. I held my nose to vote for her. My most liberal friend in the 65+ crowd held his nose and did not make up his mind until he was standing in front of the voting machine. A week earlier he was telling me he'd just write in Bernie.