With a G clef the pattern seems to be A B C D E F G repeated. Does it repeat for all octaves above/below the main lines as well? Is it the same pattern of semitones added recursively or how does it work?
Yes. Moving from a space to a line or a line to a space is one letter up or down. So the first line is an E. Right above it the space is an F. Next line up is a G.
Going down from that first line (E) is a D. And then below that you need to add a little line called a ledger line and it would be middle C. Below that first ledger line would be a B and then if you add another ledger line it’s an A.
Same thing works for going up. The top line of the staff is a F and then above that G. First ledger line above the staff is an A. And on and on.
Once you have too many ledger lines it becomes hard to read and there are ways around this that seem out of scope for this question.
The order just keeps continuing below and above the staff like on the staff itself, but have in mind that you shouldn't use too many ledger lines, because it can be hard to read for example a note that is 8 ledger lines above the staff... In this case you would write 8va or 8va to indicate that the notes are played an octave higher or lower than written. This would even work for two octaves, there you would then just write 15va. This can be helpful for very high instruments like the piccolo...
If you imagine there are eleven lines (and ten spaces) on the grand stave, it should help. Then take away the middle line - where middle C lives. Put that in only when you need a middle C, as a ledger line.
Now take away the bass clef, and if notes lower than C are needed, give them the appropriate ledger lines.
Consider the bass clef but no treble clef. An E above middle C would have been on the bottom line, treble clef. so it'll need the middle c ledger *and its own, above the bass clef.
Notes out of treble on the high side work the same, as do lower notes in the bass clef.