You could use blocks:
#let thorem_counter = counter("thorem")
#let thorem_level = state("thorem_level", 1)
#let thorem(numbering: "1.1", text: ("Thorem", "Lemma"), level: thorem_level, thorem_state: none, ..args) = {
level.update(v => v + 1)
for i in args.pos() {
context block(spacing: 0.65em)[
#thorem_counter.step(level: level.get() - 1)
#strong(text.at(level.get() - 2))
#context [#thorem_counter.display(numbering)]
:#h(0.5em)#i
]
}
v(1.2em, weak: true)
level.update(v => v - 1)
}
0.65emis the defaultpar.leading, i.e. line spacing1.2emis the defaultpar.spacing, i.e. space between paragraphs.
You might also be happy with one of the theorem packages on universe. From a quick glance at the readmes, it seems like theorion – Typst Universe, great-theorems – Typst Universe (via rich counters) or ctheorems – Typst Universe support nested numbering like you want.
