{{define "install-head"}}
<style>.step-num{width:2rem;height:2rem;border-radius:50%;background:rgba(34,197,94,0.1);color:var(--accent);font-size:0.875rem;font-weight:600;display:flex;align-items:center;justify-content:center;flex-shrink:0;font-family:var(--font-mono)}.step{display:flex;gap:1.25rem;margin-bottom:3rem}.step-body{flex:1;min-width:0}.step-body h2{margin-bottom:0.75rem}.step-body p{margin-bottom:1rem}.dl-links{display:flex;flex-wrap:wrap;gap:0.5rem;margin-top:0.75rem}</style>
{{end}}

{{define "install"}}
<div class="hero container">
    <p class="label mb-3">Open source &middot; MIT</p>
    <h1 class="mb-4">Self-host vault1984</h1>
    <p class="lead">One binary. No Docker. No Postgres. No Redis. Runs anywhere Go runs. You'll need a server with a public IP, DNS, and TLS if you want access from outside your network.</p>
</div>

<hr class="divider">

<div class="section container" style="max-width:800px">

    <div class="step">
        <div class="step-num">1</div>
        <div class="step-body">
            <h2>Download</h2>
            <p>The install script detects your OS and architecture, downloads the latest release, and puts it in your PATH.</p>
            <div class="code-block"><span class="prompt">$</span> curl -fsSL vault1984.com/install.sh | sh</div>
            <p class="mt-3" style="font-size:0.875rem">Or download directly:</p>
            <div class="dl-links">
                <a href="https://github.com/vault1984/vault1984/releases/latest/download/vault1984-linux-amd64" class="btn btn-ghost" style="font-family:var(--font-mono);font-size:0.75rem">linux/amd64</a>
                <a href="https://github.com/vault1984/vault1984/releases/latest/download/vault1984-darwin-arm64" class="btn btn-ghost" style="font-family:var(--font-mono);font-size:0.75rem">darwin/arm64</a>
                <a href="https://github.com/vault1984/vault1984/releases/latest/download/vault1984-darwin-amd64" class="btn btn-ghost" style="font-family:var(--font-mono);font-size:0.75rem">darwin/amd64</a>
            </div>
        </div>
    </div>

    <div class="step">
        <div class="step-num">2</div>
        <div class="step-body">
            <h2>Set your vault key</h2>
            <p>The vault key encrypts your Agent field data at rest. If you lose this key, Agent field data cannot be recovered.</p>
            <div class="code-block">
                <div><span class="comment"># Generate a random key</span></div>
                <div><span class="prompt">$</span> export VAULT_KEY=$(openssl rand -hex 32)</div>
                <div class="mt-2"><span class="comment"># Save it somewhere safe</span></div>
                <div><span class="prompt">$</span> echo $VAULT_KEY &gt;&gt; ~/.vault1984-key</div>
            </div>
        </div>
    </div>

    <div class="step">
        <div class="step-num">3</div>
        <div class="step-body">
            <h2>Run it</h2>
            <p>A SQLite database is created automatically in <code>~/.vault1984/</code>.</p>
            <div class="code-block">
                <div><span class="prompt">$</span> vault1984</div>
                <div class="comment">vault1984 running on http://localhost:1984</div>
                <div class="comment">Database: ~/.vault1984/vault.db</div>
            </div>
        </div>
    </div>

    <div class="step">
        <div class="step-num">4</div>
        <div class="step-body">
            <h2>Configure MCP</h2>
            <p>Point your AI assistant at the vault. Works with Claude Code, Cursor, Codex, or any MCP-compatible client.</p>
            <p class="label mb-3">~/.claude/mcp.json</p>
            <div class="code-block"><pre style="margin:0;color:var(--muted)">{
  "mcpServers": {
    "vault1984": {
      "url": "http://localhost:1984/mcp",
      "headers": {
        "Authorization": "Bearer <span style="color:var(--accent)">YOUR_MCP_TOKEN</span>"
      }
    }
  }
}</pre></div>
            <p class="mt-3" style="font-size:0.875rem">Generate an MCP token from the web UI at <code>http://localhost:1984</code> after first run.</p>
        </div>
    </div>

    <div class="step">
        <div class="step-num">5</div>
        <div class="step-body">
            <h2>Import your passwords</h2>
            <p>The LLM classifier automatically suggests Agent/Sealed assignments for each field. Review and confirm in the web UI.</p>
            <div class="code-block">
                <div><span class="comment"># Chrome, Firefox, Bitwarden, Proton Pass, 1Password</span></div>
                <div><span class="prompt">$</span> vault1984 import --format chrome passwords.csv</div>
                <div><span class="prompt">$</span> vault1984 import --format bitwarden export.json</div>
                <div><span class="prompt">$</span> vault1984 import --format 1password export.json</div>
            </div>
        </div>
    </div>

    <hr class="divider mb-8 mt-4">

    <h2 class="mb-4">Run as a service</h2>
    <p class="mb-4">For always-on availability, run vault1984 as a systemd service.</p>
    <p class="label mb-3">/etc/systemd/system/vault1984.service</p>
    <div class="code-block mb-4"><pre style="margin:0;color:var(--muted)">[Unit]
Description=vault1984
After=network.target

[Service]
Type=simple
User=vault1984
EnvironmentFile=/etc/vault1984/env
ExecStart=/usr/local/bin/vault1984
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target</pre></div>
    <div class="code-block mb-8"><span class="prompt">$</span> sudo systemctl enable --now vault1984</div>

    <h2 class="mb-4">Expose to the internet</h2>
    <p class="mb-4">Put vault1984 behind Caddy for TLS and remote access.</p>
    <p class="label mb-3">Caddyfile</p>
    <div class="code-block"><pre style="margin:0;color:var(--muted)">vault.yourdomain.com {
    reverse_proxy localhost:1984
}</pre></div>

</div>

<hr class="divider">

<div class="section container">
    <h2 class="mb-4">Rather not manage it yourself?</h2>
    <p class="lead mb-6">Same vault, same features. We handle updates, backups, and TLS. <s>$20</s> $12/yr.</p>
    <a href="/hosted" class="btn btn-primary">See hosted option &rarr;</a>
</div>
{{end}}
