In general, your assumptions are correct. If the text cannot be viewed by the user, then this is not meaningful text, and therefore it is not indexed. In the past, webmasters played the system by placing irrelevant keywords and text on their pages and hiding them, trying to get illegitimate searches.
In addition, the use of headings such as H1 and the positioning of text on a page (which may be affected by CSS) affects search rankings.
source share