The only concept that went back thousands of years was the use of "gender" as describing M and R sex (biological) and also as it was used in the study of science or languages.
It wasn't until the 70's when "gender" became a social construct when describing M and F, i.e., the word can mean as "we think fashionable".
Notice also the trend is now to refer to an individual's sex not in terms of biological but in terms of, "assigned sex at birth"...how cute.
The idea that some people do not fit into just two sexual or gender categories that are attracted to the opposite one does go back thousands of years, all over the world, and long before science existed.
Why would religions invented thousands of years makes rules restricting behavior that didn’t exist?