I hate to over-simplify, but here's what I recommend for a #CSS architecture:
- use selectors for selecting (not for specificity)
- use data-attributes for grouped selector patterns
- use at-layer for layering selector priority (widely available)
- use at-scope for scoping selectors (newly available)
- use nesting for modifiers on a selector
@mia my ideal setup (once support is good enough):
- selectors for selecting
- data attributes for variations (like your data-size). But still specific to one selector/element, not shared or grouped
- at-layer only when dealing with 3rd party stylesheets. Specificity is a really nice tool if you master it and too much at-layer kinda clobbers it.
- at-scope for scoping
- nesting for conditions and states (any conditional at rule and any pseudo class like :hover)