window.addEventListener("DOMContentLoaded", (event) => {
	const figcaptionToggle = document.querySelector(
		".homegrade-blocks-focused-thematique__figcaption-toggle"
	);
	const figcaptionContent = document.querySelector(
		".homegrade-blocks-focused-thematique figcaption"
	);

	function toggleFigcaption() {
		if (isCaptionVisible()) {
			figcaptionContent.setAttribute("aria-hidden", "true");
			figcaptionToggle.setAttribute("aria-expanded", "false");
		} else {
			figcaptionContent.setAttribute("aria-hidden", "false");
			figcaptionToggle.setAttribute("aria-expanded", "true");
		}
	}

	function isCaptionVisible() {
		return figcaptionContent.getAttribute("aria-hidden") === "false";
	}

	figcaptionToggle.addEventListener("click", toggleFigcaption);
});
