Hours after Corey Walgren was called to the dean’s office at Naperville North High School about a video he’d made of himself having sex with a classmate, the 16-year-old walked to the top of a five-story parking deck and jumped.

The suicide of the honor-roll student underscores the difficulties school authorities face when confronting students suspected of recording and sharing sexual images:

Should they wait until parents arrive to question students and search their cellphones for illicit photos or video? Or do they have the authority to investigate crimes that might include child pornography?

There’s also a high-stakes legal question involved because many child porn laws predate the phenomenon of teenagers sharing sexual images by cellphone. And neither they nor their parents usually have any idea doing so can trigger serious penalties — including being labeled a sex offender for life.

RELATED: Naperville North High School suffers third student death of 2017

“It’s not that big a deal until it happens to your school,” says Joshua Herman, a lawyer who represents schools across Illinois. “Then, it’s a nightmare.”

Police reports, court filings, witness accounts, emails and other documents offer a behind-the-scenes look at how Naperville North and the police responded in the hours before Walgren’s death in January.

Walgren’s parents are suing the school for $5 million, accusing it of unnecessarily traumatizing their son by warning him the footage could lead to charges and being forced to register as a sex offender.

“They scared the hell out of the kid, and that’s what drove Corey to kill himself,” says Terry Ekl, the lawyer representing Maureen and Doug Walgren.

In the documents, officials at the 2,800-student school say that, while conveying the seriousness of the matter, they also reassured Walgren their goal was to keep it out of court.

A dean and police officer assigned to Naperville North High School questioned 16-year-old Corey Walgren about a sex video on his phone Jan. 11. Hours later, the honor student jumped to his death from a parking garage. | Sun-Times files

It all began around noon on Jan. 11 after the 16-year-old classmate Walgren had sex with filed a complaint at school. She said she learned of the video that day from a friend and was upset Walgren made it without her permission. At first, she said, she wasn’t sure the sex was consensual but then said it was.

She later attended Walgren’s wake.

As Walgren he entered the school office around 12:40 p.m., dean Steve Madden said he had never seen him under these circumstances because the teenager never had been in trouble, the documents show.

Walgren admitted what he’d done: He and the girl were in his car, parked on a secluded street at night, and he turned on the video-recording function and dropped his cellphone by his leg after the two of them talked and drank some alcohol.

Corey Walgren, 16, a straight-A student at Naperville North High School, killed himself hours after being called to the dean’s office about a video he made of himself having consensual sex with a classmate. | Courtesy of Walgren Family via AP

Neither teen was visible on the two minutes of footage during the sexual encounter. It was the audio that Walgren played for four friends, some at a school hockey practice. He never texted or emailed it.

Also in the dean’s office was Brett Heun, a Naperville police officer assigned to the school.

The recording was hidden on a cellphone app that looked like a calculator. When Walgren opened it for the officer, it revealed photos of other partially nude girls, as well as the video, according to accounts obtained by the Associated Press. Walgren said those images were sent to him by others.

Neither school officials nor the police responded to requests for comment.

The officer told Walgren the video “concerned child pornography, which is obviously illegal.” Heun later said he wanted to impress on him this was a serious matter but that he also told him it could be kept out of court if he cooperated.

There’s no universal agreement among school policies about how to respond after discovering sexual images have been shared. Still, there appears to be consensus that a student’s cellphone should be confiscated immediately and the police should be alerted. Illinois Association of School Boards guidelines say that not reporting explicit images of kids can be a crime.

Attorney Terry Ekl represents Corey Walgren’s parents. | Sun-Times files

Though some legal experts agree, the Walgren family’s lawyer does not. Ekl says a recording with no visible images of sex acts can’t qualify as child pornography.

There’s been considerable debate over the use of child pornography laws — which some say aimed to protect children from adults — to prosecute kids for sharing sexual images. One argument is that lawmakers who passed these laws couldn’t have foreseen how teens, perhaps acting on impulse or under peer pressure, someday would be able to create or send explicit images at the push of a button.

At least 20 states have revised their laws to provide alternatives to filing child porn charges. A 2015 Illinois law aimed at sexting — images being sent by text or other electronic means — lets judges sentence minors to supervision and community service.

Law enforcement authorities have discretion about how to handle such matters and often take into consideration that, in cases like Walgren’s, the sex was consensual and the recording wasn’t distributed.

Before Walgren’s parents were called, he was interviewed for at least 20 minutes. When contacted, Maureen Walgren guaranteed her son would fulfill any requirements to keep the matter out of court, according to the accounts obtained by the AP. She also asked whether the family needed an attorney, and school officials told her that was her decision.

Steve Madden. | Naperville North High School

Madden asked Walgren whether he understood what he did was wrong. “He said … he knew he made a mistake,” the dean said in documents.

“Corey was calm, cooperative and respectful,” according to Madden.

Though Walgren might not have shown it, what he heard must have caused him “psychological distress … humiliation and shame,” his parents’ lawsuit says.

The law has long recognized school officials as stand-in parents during the school day, with the power to investigate reports of wrongdoing and discipline students without consulting parents.

But the Walgrens’ lawsuit accuses the school of violating their son’s rights by not calling them first.

The school board association instructs schools to call parents — but doesn’t specify when.

Another key issue: Students have to be told they have a right to remain silent only if they are in custody. Walgren was never told he was under arrest. But, for all practical purposes, he was, his parents’ lawsuit argues, in part because he’d been told not to leave.

Naperville Deputy Police Chief Jason Arres. | LinkedIn

In January emails about Walgren, Jason Arres, deputy police chief in Naperville, and a prosecutor cited a 2012 Illinois appellate court decision that said being in custody doesn’t necessarily require a formal arrest but could come down to whether a child at school “felt he or she was not at liberty to terminate the interrogation or leave.”

In a subsequent internal report, though, Arres concluded that Heun handled things correctly and that Walgren hadn’t been in custody because, among other reasons, the dean — not the police — had initiated the questioning and because Heun made clear he “had no intention of bringing criminal charges.”

In general, courts have not held schools liable for student suicides off campus. In 2012, for instance, a federal court in Florida threw out a lawsuit in which the parents of 13-year-old Hope Witsell argued her school could have prevented her from hanging herself at home after taunts over a revealing photo texted to a boy. The court said schools have no duty to “insure against the grim but persistent prospect of a student’s suicide.”

After meeting with school authorities, Walgren was told to wait at a student-services office while his mother drove to the school. He sat behind a secretary. They chatted. But, when she looked back minutes later, he was gone.

Surveillance footage shows he walked up a parking-deck ramp less than a mile away. He paced at the top for several minutes.

A woman heading to her car glanced up to see someone sitting five floors above. She wasn’t alarmed, according to a police report, because the person “was calmly sitting on the ledge.”

But a minute later, at 2:40 p.m., she looked out a third-deck window and saw him on the ground below.

She ran down the stairs and performed CPR before an ambulance arrived.

Walgren’s mother was at the school after 3 p.m. when she was told someone who was injured downtown might be her son.

As Heun drove her to a hospital, Maureen Walgren asked about photos of the injured person sent to the officer’s phone. He told her the picture quality was poor. But she insisted, and he handed her his phone. She knew instantly it was her son.

She didn’t see him until after doctors pronounced him dead at 3:27 p.m. It was less than three hours since he’d been called to the dean’s office.