CSS-driven JavaScript state changer