You can compose layering backgrounds in the way you described by using using custom properties:
@property --gradient-1 {
syntax: "<image> | none";
inherits: false;
initial-value: none;
}
@property --gradient-2 {
syntax: "<image> | none";
inherits: false;
initial-value: none;
}
.gradient-1, .gradient-2 {
background-image: var(--gradient-2), var(--gradient-1);
}
.gradient-1 {
--gradient-1: linear-gradient(60deg, red 0%, orange 50%, red 100%);
}
.gradient-2 {
--gradient-2: radial-gradient(at center, blue 10%, teal 50%, transparent 50%);
}
Using the @property syntax with ’inherits: false‘ prevents that the parents value for this property get inherited, so that arbitrary nesting is possible.