(defcomp
  (&key
    (py-sx-source :as string)
    (g0-output :as string)
    (g1-output :as string)
    (defines-matched :as number)
    (defines-total :as number)
    (g0-lines :as number)
    (g0-bytes :as number)
    (verification-status :as string))
  (~docs/page
    :title "Self-Hosting Bootstrapper (py.sx)"
    (div
      (~tw :tokens "space-y-8")
      (div
        (~tw :tokens "space-y-3")
        (p
          (~tw :tokens "text-stone-600")
          (code (~tw :tokens "text-violet-700 text-sm") "py.sx")
          " is an SX-to-Python translator written in SX. "
          "This page runs it live: loads py.sx into the evaluator, translates each spec file, "
          "and diffs the result against "
          (code (~tw :tokens "text-violet-700 text-sm") "bootstrap_py.py")
          ".")
        (div
          (~tw :tokens "rounded-lg p-4")
          :class (if
            (= verification-status "identical")
            "bg-green-50 border border-green-200"
            "bg-red-50 border border-red-200")
          (div
            (~tw :tokens "flex items-center gap-3")
            (span
              (~tw :tokens "inline-flex items-center rounded-full px-3 py-1 text-sm font-semibold")
              :class (if
                (= verification-status "identical")
                "bg-green-100 text-green-800"
                "bg-red-100 text-red-800")
              (if (= verification-status "identical") "G0 == G1" "MISMATCH"))
            (p
              (~tw :tokens "text-sm")
              :class (if
                (= verification-status "identical")
                "text-green-700"
                "text-red-700")
              defines-matched
              "/"
              defines-total
              " defines match. "
              g0-lines
              " lines, "
              g0-bytes
              " bytes."))))
      (div
        (~tw :tokens "space-y-3")
        (div
          (~tw :tokens "flex items-baseline gap-3")
          (h2 (~tw :tokens "text-2xl font-semibold text-stone-800") "py.sx Source")
          (span
            (~tw :tokens "text-sm text-stone-400 font-mono")
            "shared/sx/ref/py.sx"))
        (p
          (~tw :tokens "text-sm text-stone-500")
          "The SX-to-Python translator — 55 "
          (code "define")
          " forms. "
          "Name mangling (200+ RENAMES), expression emission, statement emission, "
          "cell variable detection for "
          (code "set!")
          " across lambda boundaries.")
        (div
          (~tw :tokens "not-prose bg-stone-100 rounded-lg p-5 max-h-96 overflow-y-auto border border-stone-200")
          (pre
            (~tw :tokens "text-xs leading-relaxed whitespace-pre-wrap break-words")
            (code (highlight py-sx-source "lisp")))))
      (div
        (~tw :tokens "space-y-3")
        (div
          (~tw :tokens "flex items-baseline gap-3")
          (h2 (~tw :tokens "text-2xl font-semibold text-stone-800") "G0 Output")
          (span
            (~tw :tokens "text-sm text-stone-400 font-mono")
            "bootstrap_py.py → sx_ref.py"))
        (p
          (~tw :tokens "text-sm text-stone-500")
          "Generated by the hand-written Python bootstrapper.")
        (div
          (~tw :tokens "not-prose bg-stone-100 rounded-lg p-5 max-h-96 overflow-y-auto border border-stone-200")
          (pre
            (~tw :tokens "text-xs leading-relaxed whitespace-pre-wrap break-words")
            (code (highlight g0-output "python")))))
      (div
        (~tw :tokens "space-y-3")
        (div
          (~tw :tokens "flex items-baseline gap-3")
          (h2 (~tw :tokens "text-2xl font-semibold text-stone-800") "G1 Output")
          (span
            (~tw :tokens "text-sm text-stone-400 font-mono")
            "py.sx → sx_ref.py"))
        (p
          (~tw :tokens "text-sm text-stone-500")
          "Generated by py.sx running on the Python evaluator. "
          (if
            (= verification-status "identical")
            (strong "Byte-for-byte identical to G0.")
            "Differs from G0 — see mismatch details."))
        (div
          (~tw :tokens "not-prose bg-stone-100 rounded-lg p-5 max-h-96 overflow-y-auto border")
          :class (if
            (= verification-status "identical")
            "border-green-200"
            "border-red-200")
          (pre
            (~tw :tokens "text-xs leading-relaxed whitespace-pre-wrap break-words")
            (code (highlight g1-output "python"))))))))
