component "Weft — a verified frontend language" on browser
observer north
observer south
state choice: u1 = 0 private
state reviewed: u1 = 0 public
state sealed: u1 = 0 public
view selected "Choice" = choice
view editing "Editing" = not reviewed and not sealed
view ready "Reviewed" = reviewed
view complete "Sealed" = sealed
view empty "Awaiting shares" = not sealed
channel north on seal only when reviewed and not sealed
channel south on seal only when reviewed and not sealed
action change "Flip choice" when not reviewed and not sealed
  set choice = not choice
end
action review "Review" when not reviewed and not sealed
  set reviewed = 1
end
action back "Edit" when reviewed and not sealed
  set reviewed = 0
end
action seal "Seal ballot" when reviewed and not sealed
  split choice to north, south
  set reviewed = 0
  set sealed = 1
  ensures final_choice = choice == old(choice)
end
action restart "Start again" when sealed
  set choice = 0
  set sealed = 0
end
claim exclusive_stages = not (reviewed and sealed)
claim consent_required = enabled(seal) == shown(ready)
claim frozen_choice = not shown(complete) or not enabled(change)

page "Weft is a frontend language for writing interface behavior and information-flow rules in one component, then checking the WebAssembly it ships."
  a "Skip to content" href "#main" class "skip"
  header class "mast frame"
    a href "#main" class "brand" label "Weft home"
      span class "mark"
      span "Weft"
    nav label "Main navigation"
      a "Language" href "#language"
      a "Documentation" href "/docs/"
      a "Get Weft ↗" href "#download" class "navcta"
  main id main
    section class "intro frame" label "Introduction"
      div class "introcopy"
        p "Weft / Frontend language" class "eyebrow"
        h1
          span "Interfaces with "
          em "provable behavior."
        p "Write what a user can do and what each recipient can learn. Weft checks both, then checks the WebAssembly it ships." class "lede"
        div class "links"
          a "Get the compiler ↓" href "#download" class "primary"
          a "Read the manual →" href "/docs/" class "underlink"
      figure class "instrument" label "Interactive private ballot demonstration"
        figcaption
          span "Private ballot" class "figtitle"
          span "LIVE WASM" class "live"
        div class "instrumentbody"
          div class "ballothead"
            p "Your choice" class "micro"
            p "Editing" when editing class "phase"
            p "In review" when ready class "phase"
            p "Sealed" when complete class "phase"
          div class "signal"
            read selected "0" class "digit" label "Current choice"
            div class "wave" label "Woven line illustration"
          div class "controls"
            press change when editing
            press review "Review →" when editing class "solid"
            press back "← Edit" when ready
            press seal when ready class "solid"
            press restart when complete class "solid"
          div class "receivers"
            div
              span "North share" class "micro"
              span "—" when empty
              message north when complete label "North share"
            div
              span "South share" class "micro"
              span "—" when empty
              message south when complete label "South share"
        p "Flip the bit, review it, then seal. The two shares appear here in your browser. XOR them to recover your choice." class "caption"
    section id language class "language"
      div class "frame split"
        div class "prose"
          p "The language" class "eyebrow"
          h2 "The rule lives beside the action."
          p "The ballot’s review state drives the button and guards the transition. A separate channel rule says exactly when each recipient may receive a share."
          p "Remove the review guard and the channel rule still applies. The build fails with a counterexample."
          a "Inspect this page’s Weft ↗" href "./site.weft" class "underlink"
        div class "listing"
          div class "filehead"
            span "site.weft"
            span "BALLOT EXCERPT"
          pre
            code "channel north on seal only when reviewed and not sealed" class "commentcode"
          pre
            code "action " class "kw"
            code "seal "
            code "\"Seal ballot\"" class "str"
            code " when reviewed and not sealed\n"
            code "  split " class "kw"
            code "choice to north, south\n"
            code "  set " class "kw"
            code "reviewed = 0\n"
            code "  set " class "kw"
            code "sealed = 1\n"
            code "  ensures " class "kw"
            code "final_choice = choice == old(choice)\n"
            code "end" class "kw"
    section id verification class "frame proof"
      div class "sectionhead"
        p "Verification" class "eyebrow"
        h2 "What a build checks"
      div class "proofgrid"
        article
          h3 "Interaction"
          p "State invariants hold initially and after every legal action. Guards determine which controls are enabled, and postconditions constrain what an action can change."
        article
          h3 "Information flow"
          p "Each recipient’s modeled observations include the value of a message and whether one arrived. A protection rule can also cover recipients who combine their observations."
        article
          h3 "Compiled output"
          p "An independent decoder reads the emitted WASM. The verifier checks that each exported function returns the same state, view, and messages as the source."
      p "The proofs cover the component model. The browser, DOM adapter, entropy source, and transport are trusted. Timing and visual layout are outside the confidentiality proof." class "boundary"
      a "Learn to prove UI behavior and information flow →" href "/docs/behavior/" class "underlink"
    section id download class "download"
      div class "frame split"
        div class "prose"
          p "Toolchain" class "eyebrow"
          h2 "Run Weft locally."
          p "The C11 toolchain uses Z3 and Wasmtime. The Apple Silicon archive includes the compiler and its native dependencies."
          div class "links"
            a "Apple Silicon build ↓" href "./weft-macos-arm64.zip" class "primary"
            a "Download source ↓" href "./weft-source.zip" class "underlink"
        div class "runbox"
          p "From the extracted directory" class "micro"
          pre
            code "bin/weft build examples/ballot.weft\nbin/weft check examples/ballot.weft\nbin/weft serve examples/ballot.weft"
          a "Read the quick start ↗" href "./quickstart.txt" class "underlink"
  footer class "frame foot"
    a "Weft" href "#main" class "brand"
    span "Written in Weft."
    a "Language manual" href "/docs/"
    a "Build receipt ↗" href "./verification.json"
end
style "*"
  box_sizing "border-box"
end
style "html"
  scroll_padding_top "20px"
end
style "body"
  margin "0"
  background "#f7f5ec"
  color "#20291e"
  font_family "\"DM Sans\", \"Helvetica Neue\", Arial, sans-serif"
  line_height "1.55"
end
style "a"
  color "inherit"
  text_decoration "none"
end
style "a:focus-visible, button:focus-visible"
  outline "3px solid #056c73"
  outline_offset "4px"
end
style ".skip"
  position "absolute"
  top "-80px"
  left "1rem"
  background "white"
  padding ".65rem"
  z_index "10"
end
style ".skip:focus"
  top "8px"
end
style ".frame"
  width "min(1256px, 90%)"
  margin "0 auto"
end
style ".mast, .mast nav, .brand, .links, .foot, .ballothead, .controls, .filehead, .instrument figcaption"
  display "flex"
  align_items "center"
end
style ".mast"
  min_height "76px"
  justify_content "space-between"
  border_bottom "1px solid #c9cbbb"
end
style ".brand"
  font_size "1.58rem"
  font_weight "750"
  letter_spacing "-.065em"
  gap ".62rem"
end
style ".mark"
  width "27px"
  height "29px"
  display "inline-block"
  background "repeating-linear-gradient(128deg,transparent 0 3px,#263622 3px 6px),repeating-linear-gradient(48deg,transparent 0 5px,#617859 5px 8px)"
  transform "skewY(-6deg)"
end
style ".mast nav"
  gap "clamp(1rem,3vw,2.6rem)"
  font_size ".89rem"
  font_weight "550"
end
style ".navcta"
  border "1px solid #4c5848"
  padding ".42rem .95rem"
  border_radius "50px"
end
style ".mast nav a:hover, .foot a:hover, .underlink:hover"
  color "#9d421d"
end
style ".intro, .split"
  display "grid"
  grid_template_columns "1.03fr 1fr"
  gap "clamp(2rem,6vw,6rem)"
  align_items "center"
end
style ".intro"
  padding "clamp(3rem,6vw,6.3rem) 0 clamp(4rem,7vw,7rem)"
end
style "h1, h2, h3, p, figure, pre"
  margin "0"
end
style ".eyebrow, .micro, .live, .phase, .filehead, code, .caption, .foot span"
  font_family "\"IBM Plex Mono\", ui-monospace, Menlo, monospace"
end
style ".eyebrow"
  font_size ".72rem"
  letter_spacing ".12em"
  text_transform "uppercase"
  color "#465d43"
  font_weight "650"
end
style "h1, h2, .digit"
  font_family "\"Instrument Serif\", \"Iowan Old Style\", Georgia, serif"
  font_weight "400"
end
style "h1"
  font_size "clamp(3.8rem,6.8vw,7.2rem)"
  line_height ".99"
  letter_spacing "-.066em"
  margin "1.25rem 0 1.4rem"
  max_width "11.3ch"
end
style "h1 em"
  color "#486443"
  font_weight "400"
end
style ".lede"
  max_width "42ch"
  font_size "clamp(1.05rem,1.6vw,1.27rem)"
  color "#465044"
end
style ".links"
  flex_wrap "wrap"
  gap "1.2rem 1.5rem"
  margin_top "1.8rem"
end
style ".primary, .controls button"
  background "#293d29"
  color "#fffef5"
  font "inherit"
  font_size ".9rem"
  font_weight "600"
  border "1px solid #293d29"
  border_radius "5px"
  padding ".8rem 1.1rem"
  cursor "pointer"
end
style ".primary:hover, .controls .solid:hover"
  background "#3d553c"
end
style ".underlink"
  font_size ".92rem"
  font_weight "600"
  text_decoration "underline"
  text_underline_offset ".35em"
  text_decoration_thickness "1px"
end
style ".instrument"
  min_width "0"
  background "#eef0dd"
  border "1px solid #506345"
  border_radius "10px"
  overflow "hidden"
  box_shadow "7px 7px 0 #d8ddc6"
end
style ".instrument figcaption, .filehead"
  padding ".85rem 1.3rem"
  justify_content "space-between"
  border_bottom "1px solid #aeb99d"
end
style ".figtitle"
  font_weight "650"
  font_size ".97rem"
end
style ".live, .micro, .filehead"
  font_size ".68rem"
  letter_spacing ".07em"
  text_transform "uppercase"
  font_weight "600"
end
style ".live"
  display "flex"
  align_items "center"
  gap ".4rem"
end
style ".live::before"
  content "\"\""
  width ".48rem"
  height ".48rem"
  background "#578049"
  border_radius "50%"
end
style ".instrumentbody"
  padding "1.2rem 1.3rem 0"
  background "#e3e9cc"
end
style ".ballothead"
  justify_content "space-between"
end
style ".phase"
  font_size ".68rem"
  border "1px solid #9eaf88"
  border_radius "20px"
  padding ".1rem .55rem"
end
style ".signal"
  display "grid"
  grid_template_columns "1fr 2fr"
  align_items "center"
  gap "1.5rem"
  margin ".65rem 0 1.05rem"
end
style ".digit"
  font_size "clamp(4.5rem,7vw,6.3rem)"
  line_height "1"
  color "#2e452a"
  font_variant_numeric "tabular-nums"
end
style ".wave"
  height "74px"
  background "repeating-linear-gradient(135deg,transparent 0 5px,#82996c 5px 7px,transparent 7px 11px),repeating-linear-gradient(45deg,transparent 0 5px,#526b46 5px 7px,transparent 7px 11px)"
  clip_path "polygon(0 65%,14% 30%,28% 54%,45% 6%,60% 38%,76% 0,100% 41%,100% 84%,76% 45%,60% 82%,45% 50%,28% 96%,14% 74%,0 100%)"
end
style ".controls"
  gap ".6rem"
  min_height "2.75rem"
  margin_bottom "1.05rem"
end
style ".controls button"
  padding ".4rem .9rem"
  color "#20391e"
  background "transparent"
end
style ".controls .solid"
  background "#293d29"
  color "#fffef5"
end
style ".controls button:hover"
  background "#cbd9b7"
end
style ".receivers"
  display "grid"
  grid_template_columns "1fr 1fr"
  border_top "1px solid #a1b18f"
end
style ".receivers > div"
  display "flex"
  flex_direction "column"
  padding ".85rem 0"
  font_size "1.25rem"
  font_variant_numeric "tabular-nums"
end
style ".receivers > div + div"
  border_left "1px solid #a1b18f"
  padding_left "1.2rem"
end
style ".caption"
  font_size ".74rem"
  line_height "1.6"
  color "#3e5139"
  padding ".8rem 1.3rem"
  border_top "1px solid #a1b18f"
end
style ".language"
  background "#233a30"
  color "#f4f6e9"
  padding "clamp(3.5rem,6.5vw,6.5rem) 0"
end
style ".language .eyebrow"
  color "#bacc9f"
end
style "h2"
  font_size "clamp(2.65rem,4.65vw,4.6rem)"
  line_height "1.04"
  letter_spacing "-.055em"
end
style ".prose h2, .sectionhead h2"
  margin ".8rem 0 1.2rem"
end
style ".prose p:not(.eyebrow)"
  max_width "48ch"
  margin ".75rem 0"
  font_size "1.02rem"
end
style ".prose > .underlink"
  display "inline-block"
  margin_top "1rem"
end
style ".language .underlink:hover"
  color "#cde5a6"
end
style ".listing"
  background "#182a23"
  border "1px solid #647666"
  border_radius "8px"
  min_width "0"
end
style ".filehead"
  border_color "#4b6253"
  color "#bcd7ab"
end
style ".filehead span:first-child"
  text_transform "none"
  color "#e0ead6"
end
style "pre"
  white_space "pre-wrap"
  overflow_wrap "anywhere"
  tab_size "2"
end
style ".listing pre"
  padding ".95rem 1.3rem .4rem"
  line_height "1.45"
  font_size "clamp(.78rem,1.05vw,.94rem)"
end
style ".listing pre:last-child"
  padding_top ".45rem"
  padding_bottom "1.25rem"
end
style ".commentcode"
  color "#b5c2b3"
end
style ".kw"
  color "#aacbff"
end
style ".str"
  color "#e9d59b"
end
style ".proof"
  padding "clamp(3.5rem,7vw,7rem) 0"
end
style ".proofgrid"
  display "grid"
  grid_template_columns "repeat(3,minmax(0,1fr))"
  gap "clamp(1.4rem,4vw,3.5rem)"
  margin "2rem 0 1.65rem"
end
style ".proofgrid article"
  border_top "1px solid #7e9074"
  padding_top "1.2rem"
end
style "h3"
  font_size "1.28rem"
  letter_spacing "-.035em"
  margin_bottom ".6rem"
end
style ".proofgrid p, .boundary"
  color "#465044"
end
style ".boundary"
  border_top "1px solid #c6c9b9"
  padding_top "1rem"
  font_size ".93rem"
  max_width "90ch"
  margin_bottom ".65rem"
end
style ".download"
  background "#dbe4c7"
  padding "clamp(3.2rem,6vw,6.2rem) 0"
end
style ".runbox"
  border "1px solid #819575"
  border_radius "6px"
  padding "1.35rem"
  min_width "0"
end
style ".runbox pre"
  margin "1rem 0"
  font_size ".87rem"
  line_height "1.8"
end
style ".foot"
  gap "1.1rem"
  padding "1.4rem 0"
  font_size ".8rem"
end
style ".foot span"
  font_size ".75rem"
  color "#586052"
end
style ".foot a:last-child"
  margin_left "auto"
end
style ".intro, .split" below 780
  grid_template_columns "1fr"
  gap "2.25rem"
end
style "h1" below 780
  max_width "12ch"
  font_size "clamp(3.7rem,11vw,5.8rem)"
end
style ".introcopy .lede" below 780
  max_width "47ch"
end
style ".proofgrid" below 680
  grid_template_columns "1fr"
  gap "1.2rem"
end
style ".mast" below 520
  min_height "62px"
end
style ".mast nav" below 520
  gap ".8rem"
  font_size ".77rem"
end
style ".mast nav a:first-child" below 420
  display "none"
end
style ".frame" below 520
  width "89%"
end
style ".controls button" below 520
  min_height "44px"
end
style ".foot" below 420
  flex_wrap "wrap"
end
