<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>EVOLVE Core Harness</title>

  <!-- Core Styles -->
  <link rel="stylesheet" href="evolve-core/evolve-core.css">

  <!-- Module Styles -->
  <link rel="stylesheet" href="evolve-core/sentinel.css">
  <link rel="stylesheet" href="evolve-core/devsuite.css">
  <link rel="stylesheet" href="evolve-core/recovery.css">
</head>

<body>

  <!-- ============================================================
       EVOLVE ORB (Corrected Structure)
       ============================================================ -->
  <div id="evolve-orb" data-evolve-orb>
    <div class="evolve-orb-logo-mask"></div>
  </div>


  <!-- ============================================================
       EVOLVE CORE
       ============================================================ -->
  <script src="evolve-core/evolve-core.patched.js"></script>

  <!-- Orb State Engine (B) -->
  <script>
    (function () {
      if (!window.EVOLVE) return;

      const ORB_STATES = ["idle", "active", "warning", "critical", "scanning"];
      EVOLVE.orbState = "idle";

      EVOLVE.setOrbState = function (state) {
        if (!ORB_STATES.includes(state)) state = "idle";
        this.orbState = state;
        updateOrbVisual(state);
      };

      EVOLVE.resetOrb = function () {
        this.setOrbState("idle");
      };

      EVOLVE.startScan = function () {
        this.setOrbState("scanning");
      };

      EVOLVE.endScan = function (hasIssues) {
        this.setOrbState(hasIssues ? "warning" : "active");
      };

      function getOrbElement() {
        return document.querySelector("[data-evolve-orb]");
      }

      function updateOrbVisual(state) {
        const orb = getOrbElement();
        if (!orb) return;

        ORB_STATES.forEach(s => orb.classList.remove("evolve-orb--" + s));
        orb.classList.add("evolve-orb--" + state);
      }

      window.addEventListener("evolve:ready", function () {
        EVOLVE.setOrbState("idle");
      });
    })();
  </script>


  <!-- ============================================================
       Harness Overrides
       ============================================================ -->
  <script>
    EVOLVE.loadManifest = function () {
      this.logStep("Harness: skipping manifest load");
      this.manifest = { version: "test" };
      return Promise.resolve();
    };

    EVOLVE.loadModulesFromManifest = function () {
      this.logStep("Harness: skipping module script loading");
      this.initModules();
    };
  </script>


  <!-- ============================================================
       Production Modules
       ============================================================ -->
  <script src="evolve-core/modules/devsuite.js"></script>
  <script src="evolve-core/modules/recovery.js"></script>
  <script src="evolve-core/modules/sentinel.js"></script>

</body>
</html>
