Although it may not be exactly what you're looking for, this concept can provide you with some inspiration. With a few adjustments, you can customize it to fit your needs. (Please note that achieving conditional and click events using only CSS is not possible; JavaScript is required for that.)
If you want to trigger an action on text click itself, there's a simple method to achieve it. By using a hidden checkbox and displaying the text inside a label element, you can easily switch between different texts using just CSS:
#example {
position: relative;
}
#example-checkbox {
display: none;
}
#example-checkbox:checked + #example:after {
content: "Hide";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: white;
}
<input id="example-checkbox" type="checkbox">
<label for="example-checkbox" id="example">Show</label>
Reference Take a look at the CSS-only approach.
I hope this information proves helpful for you.