function selectLevel(element) {
  const allCards = document.querySelectorAll(".option-card-figma");
  const errorMsg = document.getElementById("level-error");

  allCards.forEach((card) => {
    card.classList.remove("selected");
  });

  element.classList.add("selected");

  if (errorMsg) {
    errorMsg.style.display = "none";
    errorMsg.classList.add("hidden");
  }

  const selectedLevel = element.querySelector("span").textContent;
  console.log("Selected Experience Level:", selectedLevel);
}

document.addEventListener("DOMContentLoaded", () => {
  const continueBtn = document.getElementById("continueBtn");
  const errorMsg = document.getElementById("level-error");

  if (continueBtn) {
    continueBtn.addEventListener("click", () => {
      const isSelected = document.querySelector(".option-card-figma.selected");

      if (!isSelected) {
        errorMsg.style.display = "block";
        errorMsg.classList.remove("hidden");
      } else {
        window.location.href = "./purpose.html";
      }
    });
  }
});
