And here's a situation where discrimination would be on the basis of sex.
Two people apply for a job. Both are (on paper) female. But one is literally female and the other is male and identifies as female. The employer rejects the female who looks as though she might one day get pregnant and need maternity leave. He employs the 'female' who he can plainly see might father a child but won't ever get pregnant.
This isn't covered under pregnancy and maternity discrimination. That doesn't apply to women who aren't pregnant yet.
The employer can claim he sees no distinction between the two women. If 'women' and 'female' are terms of identity not sex then there has been no discrimination against women, and no discrimination against females.
The only recourse is to defend the need to recognise that the two applicants are of the opposite sex, despite there being no legal evidence of this, and that sex is the characteristic that has been unlawfully discriminated against.