When Ahmed Khalil ran out of work as a van driver in the Iraqi city of Mosul three years ago, he signed up with the Islamic State group's police force, believing the salary would help keep his struggling family afloat.
But what he wound up providing was a legacy that would outlast his job, and his life.
In Mosul and elsewhere across Iraq, thousands of families - including Khalil's widow and children - face crushing discrimination because their male relatives were seen as affiliated with or supporting ISIS when the extremists held large swaths of the country.
The wives, widows and children have been disowned by their relatives and abandoned by the state. Registrars refuse to register births to women with suspected ISIS husbands, and schools will not enroll their children. Mothers are turned away from welfare, and mukhtars - community mayors - won't let the families move into their neighbourhoods.
The Islamic State group's "caliphate" that once spanned a third of both Iraq and Syria is now gone but as Iraq struggles to rebuilt after the militants' final defeat and loss of their last sliver of territory in Syria earlier this year, the atrocities and the devastation they wreaked has left deep scars.
"They say my father was Daesh," said Safa Ahmed, Khalil's 11-year old daughter, referring to ISIS by its Arabic name. "It hurts me."
Iraq has done little to probe the actions of the tens of thousands of men such as Khalil who, willingly or by force joined, worked and possibly fought for ISIS during its 2013-2017 rule. Instead, bureaucrats and communities punish families for the deeds of their relatives in a time of war.
Khalil was killed in an airstrike in Mosul, in February 2017, during the US-backed campaign to retake the city that ISIS seized in 2014. It was liberated in July 2017, at a tremendous cost - around 10 000 residents were believed to have been killed in the assault, and its historic districts now lie in ruins.
His widow, Um Yusuf, and their seven children were left to bear the stigma of his ISIS affiliation. She cannot get social assistance, and her teenage son Omar is being turned away from jobs.
They live in an abandoned schoolhouse, living on what they can make selling bread on the streets of the devastated city. Just three of the children are in school - the oldest two dropped out because of bullying about their father, and the youngest two cannot enroll because the civil registrar's office won't issue their IDs.
"It's true their father made a mistake," Um Yusuf said. "But why are these children being punished for his sin?"
Under Iraq's patrimonial family laws, a child needs a named father to receive a birth certificate and an identity card, to enroll in school and to claim citizenship, welfare benefits and an inheritance.
But in post-ISIS Iraq, virtually every bureaucratic procedure now includes a security check on a woman's male relatives, further frustrating mothers and children.
A UN report this year estimates there are 45 000 undocumented children in Iraq. Judges and human rights groups say an urgent resolution is needed or the country risks rearing a generation of children without papers or schooling.
"By punishing entire families, you marginalize them and you seriously undermine reconciliation efforts in Iraq," said Tom Peyre-Costa, a spokesperson for the Norwegian Refugee Council, which provides legal aid to Mosul mothers struggling to get their children ID papers.
At al-Iraqiya school in western Mosul, one of the city's first to reopen in 2017, principal Khalid Mohammad said he faces pressure from the community to deny enrollment to children whose fathers are in jail or missing - an absence many interpret as proof of ISIS affiliation.
"If anyone complains and someone is sent to investigate, I could lose my job," he said.
At a legal office and clinic supported by the Norwegian Refugee Council, Nour Ahmed was looking for a way to claim legal custody of her undocumented younger son, in order to collect food and fuel aid for the family.
Her husband, she said, was abducted two years ago in Mosul by a group of pro-government militiamen who likely thought he was an ISIS member. Ahmed insists he wasn't. He has been missing to this day.
Born in 2016 at a hospital run by ISIS, their son was given a birth certificate notarised by the Islamic State group. As Iraq doesn't recognise ISIS documents, the 3-year-old has no legal mother or father.
Ahmed was told she would need to find her husband to re-register her son's birth. If she submitted a missing person's report, it would raise questions about the child's parentage, jeopardising his right to citizenship.
"I just want to find him," said Nour.
Adnan Chalabi, an appeals court judge, said he sees more than a dozen cases each day related to civilian documentation, brought largely by the wives, widows or divorcees of ISIS suspects. There is little he can do to help, he said, without a change to the law first.
"Daesh held the city for three years. Did people stop getting married, divorced, and having children during those three years?" he said. "We need a legislative solution."
There is little appetite to change the country's family and patrimony laws, said Iraq's parliament speaker, Mohamad Halbousi, though there is a proposal to open civil registries for a limited period, to register undocumented children.
"These families need to be cared for. They cannot be left to melt away into society," he said.
Outside a mosque in Mosul, where Um Yusuf was selling bread with her children, the widowed mother of seven said she was losing the strength to look after her family.
"We are deprived of everything," she says. "The whole family is destroyed."