Parkland school shooter Nikolas Cruz was obsessed with guns — and to the chagrin of his mother, also appeared to be a fan of President Donald Trump.

So when his mother, “a liberal anti-gun type,” died in 2017, Cruz used his own “Trump hat” to get a twisted final word on their political differences, a friend told police in a 425-page investigative report released on Thursday.

“Due to the fact that his mother hated Donald Trump he put it in her casket with her when she died and took a picture of her with the hat,” the friend, Hunter McCutcheon, told a detective, according to a report authored by the lead detective in the criminal case against the confessed mass murderer.

It’s yet one more unsettling detail about Cruz, an emotionally disturbed teen who walked into Marjory Stoneman Douglas High School on Feb. 14 and opened fire, killing 17 people and wounding 17 more. He is facing the death penalty for Florida’s deadliest school shooting, an incident that sparked a wave of student activism and even led to the passage of a gun-control law in Florida.

The Broward Sheriff’s Office report does not offer any major new revelations. But the document chronicles the staggering scope of the police investigation, from Cruz’s insistence during his confession that he was hearing demons in his head, to fellow classmates describing the gunman’s long history of troubling behavior, to in-depth analysis of video and phone evidence.

It was unclear just how devoted, if at all, Cruz was to the Republican president. After the shooting, at least one Instagram image purported to be of Cruz wearing a Trump “Make America Great Again” hat surfaced, and one video of him shooting a BB gun in his backyard appears to show him wearing a similar red cap. Cruz, while in jail awaiting trial, also registered to vote as a Republican.

Among the other revelations in BSO Detective John Curcio’s report: Stoneman Douglas school resource officer Scot Peterson, who has been vilified for standing outside the freshman building with his gun drawn during Cruz’s rampage, appeared to acknowledge in an interview with Curcio that he knew a gunman was indeed inside as students and staffers were being slaughtered.

Peterson and his attorneys have long maintained he could not tell where the gunshots were coming from.

In an interview two days after the shooting, Peterson told Curcio that soon after the gunshots began he approached the freshman building. Then Peterson said he “drew his service weapon and was waiting for the gunman to exit the [freshman] building,” according to Curcio’s written summary of their interview.

Police around the nation are trained to confront and stop active shooters as quickly as possible.

Peterson’s lawyer, however, pointed to a transcript of his client’s statement that shows the officer hedges, saying he covered the door “with an anticipation if maybe the ... shooter or whoever it was which someone maybe was going to come out of the door.”

“I don’t think Curcio’s gloss on the facts is accurate,” his lawyer, Joseph DiRuzzo, said an email.

Curcio wrote that surveillance footage of the shooting revealed discrepancies in how Peterson described his movement and actions.

The detective concluded that Peterson “would have been in position only a few yards away from the [freshman] building while over 60 AR-15 gunshots went off on the first, second and third floors of the [freshman] building.”

Peterson resigned after the shooting. He faces lawsuits over his conduct that day, and has continued to draw criticism. Last month, he refused to testify at the Marjory Stoneman Douglas High School Public Safety Commission.

The report also details a host of computer and phone evidence — everything from a log of text messages on Cruz’s phone to his extensive searches of stories about school shootings. One question he Googled: “How long does it take a cop to show up at a school shooting?” Among the evidence previously released were videos extracted from Cruz’s cellphone.

“Hello. My name is Nik and I’m going to be the next school shooter of 2018,” Cruz said calmly in video footage previously released in May. “My goal is at least 20 people with an AR-15. ... Location is Stoneman Douglas in Parkland, Florida.”

He also mentions his love for a girl. “I hope to see you in the afterlife,” he said.

The report reveals that girl lived near the Dollar Tree store where Cruz worked. She said they often texted each other, but never dated. Cruz appeared obsessed — her number was stored in his phone as “Warning Love of Your Life.”

Five days before the shooting, she agreed to meet with Cruz at a Coral Springs Target “because he seemed depressed.”

She “stated that she insisted that Cruz meet her in a public place because she was afraid of him,” the detective wrote.

The day before the massacre, Cruz sent her a text saying he “felt like killing people.” She said she deleted the text because she was angry with his behavior. That day, he flooded her with phone calls, insisting he wanted to be her boyfriend and her Valentine the next day, Feb. 14

When she rebuffed his desires, he said he was going to see a therapist and ended a call with an ominous sounding “goodbye.”

The day of the massacre, the girl was taking a test at her school, Deerfield Beach High, when Cruz began calling her. She did not answer. He also texted her repeatedly. Some of the messages were photos of “old scars” on Cruz’s arms.

The report also includes a host of accounts of Cruz’s bizarre behavior before the shooting. Among those interviewed:

▪ Joelle Guarino, a former neighbor who told police she reported that her son in 2016 had seen a social media post from Cruz threatening to “shoot up” a school. A Broward deputy, Edward Eason, arrived but cleared the case after Cruz’s mother insisted her “son was an angel.”

Eason, when interviewed by homicide, swore he didn’t remember the call.

▪ Santiago Cullar, a former classmate who said Cruz did computer searches about how to make a bomb and gushed about the Pulse nightclub massacre that killed 49 people. Cruz told him he “was glad they killed all those gay people.”

▪ Another student, unidentified in the report, told police she reported Cruz’s threat to shoot up the school to a peer counselor named Lauren Rubenstein. Several staff members are still being scrutinized for failing to act on repeated reports of Cruz’s threats of violence.

-- This story was written by David Ovalle and Nicholas Nehamas