道具がどんなに進化しても、「どこに何を書くか」という設計判断は人間がやるしかない。
@layer tokens, theme, foundation, layout, component, project, animation, utility;
この 1 行で、8つの層の優先順位がブラウザに明示的に固定されます。
セレクタの詳細度に関係なく、後に宣言された層ほど優先度が高くなります。
!important に頼る必要は、もうありません。
.card .button { background: #28a745; } /* (0, 2, 0) */
.card .button.is-featured { background: #ff6600; } /* (0, 3, 0) で対抗… */
@layer component {
.c-card .c-button.-accent { background: var(--color-accent); } /* (0, 3, 0) */
}
@layer project {
.p-hero .c-button { background: var(--color-hero); } /* (0, 2, 0) */
}
/* project の詳細度が低くても、layer 宣言順で project が勝つ */