Variable scoping. I was planning to write an explainer as soon as I get my head around it myself.
EDIT: is variable scoping behaviour due to the design of Hugo, or is it due to the Go html/template engine?
Also, the fact that nested shortcodes render from the inside out, so you can’t use a Scratch var to pass a flag from the outside shortcode to the inner shortcode. See Passing Scratch flags between shortcodes - support - HUGO