Here's a simple example
of course, you'll need to figure out how to get the right rule to change by changing
var declaration = document.getElementById('x').sheet.rules[0].style;
Seeing as you've written no javascript yourself, and shown absolutely nothing except a single style rule, that's one thing at least you'll need to figure out for yourself
but ... it works
function changecolors() {
const changeit = style => {
let p = style.getPropertyValue('color').replace(/\d/, x => x%3 + 1);
style.setProperty('color', p);
}
var declaration = document.getElementById('x').sheet.rules;
changeit(declaration[0].style)
changeit(declaration[1].style)
changeit(declaration[2].style)
}
setInterval(changecolors, 1000);
:root {
--color1: #E11F28;
--color2: #F8981D;
--color3: #1DAD4B;
}
<style id="x">
h1 {
color: var(--color1);
}
h2 {
color: var(--color1);
}
h3 {
color: var(--color1);
}
</style>
<h1>H1</h1>
<h2>H2</h2>
<h3>H3</h3>