Implement :root pseudo-class. Fix #1263, fix #1265

Rebase/squash of @therealglazou’s #1265