JSFiddle - React, Tailwind, and code Playground

HTML

<div class="background"></div>
<h1 data-content="Gradient text with text shadow, but without the problem that z-index brings"></h1>
<div class="foreground"></div>

CSS

h1 {
    position: relative;
}

h1::after {
    background-image: linear-gradient(#f00, #fcc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    content: attr(data-content);
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

h1::before {
    text-shadow: 2px 2px 4px #000;
    content: attr(data-content);
    position: absolute;
    top: 0;
    left: 0;
}

div {
    position: absolute; 
    left: 0; 
    top: 0; 
    width: 400px; 
    height: 100px; 
}

.background {
    background-color: #ff0;
}
.foreground {
    background-color: #0006;
}