Exclusive

Lil Nas X had clearly been thinking about coming out as gay for a long time, and the best evidence of that is the cover of his debut album ... a cover that was in the works for weeks.

Lorenzo Sozzi, who designed the cover with the rapper, tells TMZ ... Lil Nas X had a vision of the art for the album -- the rapper leaving a dystopian world for a futuristic world -- so X actually put out an open call to artists to come up with his vision, and Sozzi is the one who nailed it.

Lil Nas had some edits, though, and sometime during the creative process ... he instructed Sozzi to add a rainbow flourish to one of the buildings on the album cover. Nas never told Sozzi why he wanted to add the rainbow, but he was adamant about it.

Now, here's what's really interesting ... Nas released the album cover art on June 15 -- 2 weeks ago, but he didn't come out until June 30. Looking back, it's clear, at the very least, the cover of X's "7" was a big clue he was gay, but he never explained further until his Glastonbury concert this past Sunday.

TMZ broke the story ... Nas was so moved by the crowd -- 180,000 strong -- showing him so much love, he went back stage, picked up his phone, and told the world he is gay.