// /public/assets/js/fakecheck.js

document.addEventListener("DOMContentLoaded", () => {
    // Werte kommen aus globalen Variablen, die wir in PHP setzen:
    const baseUrl = window.fakecheckBaseUrl || "";
    const locale  = window.fakecheckLocale || "en";

    const startButton     = document.getElementById("startButton");
    const resultContainer = document.getElementById("resultContainer");
    const resultOutput    = document.getElementById("resultOutput");

    if (!startButton || !resultContainer || !resultOutput) return;

    startButton.addEventListener("click", () => {
        const now = new Date().toISOString();

        const demoReport = {
            meta: {
                tool: baseUrl,
                mode: "browser-demo",
                timestamp: now,
                locale: locale
            },
            tests: [
                { id: "quick_test",      label: "Quick-Test (Demo)",      status: "pending" },
                { id: "light_benchmark", label: "Light-Benchmark (Demo)", status: "pending" },
                { id: "write_verify",    label: "Write/Verify (Demo)",    status: "pending" }
            ],
            note: "Dies ist nur eine Platzhalter-Ausgabe. Die echte Web-Testlogik (File System Access, Fortschritt, realer JSON-Report) implementieren wir im nächsten Schritt."
        };

        resultOutput.textContent = JSON.stringify(demoReport, null, 2);

        resultContainer.classList.remove("hidden");
        resultContainer.scrollIntoView({ behavior: "smooth", block: "start" });
    });
});
