You could use CSS adjacent sibling selector in order to select the first li
element which doesn't have the .hide
class:
li:first-child:not(.hide),
li.hide + li:not(.hide) {
background-color: gold;
}
Also consider checking the first list item (the first child) for existence of .hide
class name.