1.5 · Selectors & structure
Count only what matters: :nth-child(… of S)
Count only the siblings that match a selector, so stripes survive filtering.
:nth-child(even) counts every sibling, including hidden
ones. Hide a few rows and the zebra stripes fall out of step.
Add of and a selector, and only matching siblings are
counted: :nth-child(even of :not([hidden])). The same
works for “the first three featured items” with
:nth-child(-n + 3 of .featured).
// Re-stripe in JS after every filter
rows.filter(visible).forEach((row, i) =>
row.classList.toggle('even', i % 2))
li:nth-child(even of :not([hidden])) {
background: …;
}