At the moment, CSS rules are evaluated strictly in the order they appear in the source code. This makes ordering the CSS a challenge. In addition, it prevents any sort of recursion.
I would propose parsing all the CSS rules, then evaluating each of them, marking each element as having completed each rule internally. The rules are iterated, and whenever --body is evaluated, all the rules (up to and including the currently processed rule) are run on its child structure recursively too.
At the moment, CSS rules are evaluated strictly in the order they appear in the source code. This makes ordering the CSS a challenge. In addition, it prevents any sort of recursion.
I would propose parsing all the CSS rules, then evaluating each of them, marking each element as having completed each rule internally. The rules are iterated, and whenever
--body
is evaluated, all the rules (up to and including the currently processed rule) are run on its child structure recursively too.