The teenage killer of Ann Maguire winked at a friend as he walked over to the Spanish teacher’s desk, where he stabbed her seven times and returned to his seat “as if nothing happened”, a court heard .

William Cornick, known as Will, was 15 when he killed Maguire in front of terrified pupils during a lesson at Corpus Christi Catholic college in Leeds on 28 April, having talked about an attack on her for three years. Full details of the murder and his motivation can now be revealed for the first time.

As he pleaded guilty to murder, Leeds crown court heard that he had never expressed remorse and told doctors at one point he was proud of the attack: “In my eyes, everything I’ve done is fine and dandy.”

The boy can now be named after the judge lifted reporting restrictions that had banned his identification, given the serious nature of the admitted crime.

After sentencing him to a minimum of 20 years in prison, Mr Justice Coulson said the arguments for naming the boy were “finely balanced” but ruled: “There’s a public interest in naming a defendant who has been convicted of murder.”

The judge imposed an indeterminate sentence, saying Cornick was “highly dangerous” and may well never be released, after psychiatrists warned he had “psychopathic elements” to his personality and could kill again. Leeds crown court heard he hoped to kill two other teachers, including one who was pregnant. He told doctors his plan was to stab her in the stomach to kill her unborn child.

Cornick, now 16, pleaded guilty to murder on Monday, having accepted responsibility for the killing at an earlier hearing. Unusually, he was joined in the dock by his parents, Ian and Michelle, who were granted special permission from the judge to do so. “They are at a loss to understand how and why their son has turned out as he has,” said prosecuting barrister Paul Greaney QC.

Maguire’s husband, Don, and their two daughters, Emma and Kerry, were also in court. In a victim impact statement, Don, a former maths teacher turned gardener, said Cornick’s “callous cruelty … defies comprehension”.

In a reference to the reduced sentence Cornick received because he is under 18, Don Maguire wrote: “We shall never know why, but if age bars the full responsibility, who owns the missing part?”

Cornick’s personality seemed to change after he was diagnosed with diabetes following a collapse on a family holiday in Cornwall. He began to harbour a “deep-seated and irrational hatred” for Ann Maguire, who had taught him Spanish since Year 7. In Facebook messages to a friend last Christmas, he talked of “brutally killing Maguire” and spending the rest of his life in jail so he would not have to worry about life or money.

In February this year he had a run-in with Maguire after failing to do his Spanish homework, which resulted in his parents being called to school. On the morning of the murder he told some pupils he had come armed with knives and had brought a bottle of Jack Daniels whiskey to “celebrate” after murdering Maguire. Many didn’t take him seriously – “I just thought it was Will being Will” said one. He threatened to kill anyone who revealed his plan.

Shortly after 11.30am, Cornick was at a computer in his Spanish class when he showed a knife to the boy next to him, asking him to check it was sharp. The boy refused, scared, and watched as Cornick walked normally over to Maguire in the neighbouring room. “As he departed, he turned to [the other boy] and winked,” Greaney told the court.

Cornick stabbed Maguire in the back with a 21cm-long knife. Yet still the teacher managed to stagger out into the corridor as pupils screamed and fled. Susan Francis, head of languages at the school, heard the noise and found Maguire being chased by Cornick. She managed to barricade Maguire into a room – through a glass panel she was the boy’s “emotionless” face. He then returned to his classroom, sat down in his seat “as if nothing had happened”, said Greaney, and told his neighbour that he had stabbed Maguire “and it was a pity she was not dead”.

To the entire class he declared “good times!” and spoke of an adrenaline rush, before holding his arms up as if in surrender when more teachers arrived.

One later remarked on Cornick’s “bizarre calmness and air of normality”.

Some of the children who witnessed the murder later paid tribute to Maguire, who the judge said was “genuinely loved by her pupils”. In police video interviews played to court, one pupil describes her as “really caring … she sort of couldn’t do enough for people, she was just really lovely to everybody”. Another described her as “more of a friend than a teacher”. She spent her whole 40-year teaching career at Corpus Christi and was due to retire this summer. Earlier this year thousands of pupils past and present filled Leeds Town Hall for her memorial service.

Her husband added that a courtroom verdict could never be enough: “We shall be left with anniversaries of sadness. There will be no closure. Balance will not return. No level scales. No end.”