What is the grammatical role of “al-majnūn” in “wa-idhā afāqa al-majnūn”?

Kitab al-Sawm: Unconsciousness, Recovery, Menstruation and Abstention