A 29-year-old unemployed UK man who wanted to care for his baby son has lost a family court fight after a judge raised concerns about his lifestyle.
Recorder Carly Henley said the man had "sofa-surfed" at friends' homes for many months and done nothing to find a job.
The judge said his working and sleeping arrangements were chaotic and not conducive to caring for a child.
She ruled that the boy, aged around six months, should be brought up by relatives.
Recorder Henley had heard that the baby's mother had cognitive difficulties and was vulnerable. She concluded that the woman could not safely care for him.
The judge said both parents could stay in contact with their son.
Detail of the case emerged in a written ruling following a private family court hearing in Manchester.
No-one involved has been identified.
Social services staff at Salford City Council had asked the judge to make decisions about the boy's future.
They said he should be brought up by relatives after outlining concerns about his mother and father. Staff said his mother's vulnerability and behavioural difficulties meant she was unable to meet a baby's needs.
They said the father could not offer a stable home or provide for "material needs in a consistent manner".
Social workers had also been concerned about the man's sexual behaviour. They said he had met a number of women online for "the purposes of sexual intercourse", adding such behaviour was "risky".
But the judge said she did not condemn the man for "engaging in casual sex or for using the internet to meet women". She said "such practices" were not uncommon for men of his age.
The judge said the boy's parents had separated before he was born. She said they had met via social media.
The man had described the relationship as a "fling".