Manage element states by toggling specific classes based on interactions.