import type { Metadata } from 'next'

export const metadata: Metadata = {
  title: 'Privacy Policy | Greywall',
  description: 'How Greywall handles your data.',
  alternates: {
    canonical: 'https://greywall.io/privacy',
  },
}

export default function PrivacyPage() {
  return (
    <main className="min-h-screen pt-24 pb-16 px-4 sm:px-6">
      <article className="mx-auto max-w-2xl">
        <h1 className="font-serif text-3xl sm:text-4xl font-semibold tracking-tight mb-2">
          Privacy Policy
        </h1>
        <p className="text-sm text-muted-foreground font-sans mb-12">
          Last updated: March 19, 2026
        </p>

        <div className="space-y-10 text-muted-foreground font-serif text-base leading-relaxed">
          <section>
            <h2 className="font-serif text-xl font-semibold text-foreground mb-3">Greywall (the CLI tool)</h2>
            <p>
              Greywall runs entirely on your machine. It does not phone home, collect telemetry,
              or transmit any data. No analytics, no crash reports, no usage tracking. The source
              code is open and auditable
              at <a href="https://github.com/GreyhavenHQ/greywall" target="_blank" rel="noopener noreferrer" className="text-primary hover:text-primary/80 transition-colors">github.com/GreyhavenHQ/greywall</a>.
            </p>
          </section>

          <section>
            <h2 className="font-serif text-xl font-semibold text-foreground mb-3">This website (greywall.io)</h2>
            <p className="mb-4">
              The Greywall landing page is a static site hosted on Vercel. We do not use cookies,
              analytics scripts, or tracking pixels. Vercel may collect minimal server logs
              (IP address, user agent, timestamp) as part of standard web hosting.
              See <a href="https://vercel.com/legal/privacy-policy" target="_blank" rel="noopener noreferrer" className="text-primary hover:text-primary/80 transition-colors">Vercel&apos;s privacy policy</a> for
              details.
            </p>
          </section>

          <section>
            <h2 className="font-serif text-xl font-semibold text-foreground mb-3">Greyscan</h2>
            <p className="mb-4">
              When you use Greyscan at <a href="/greyscan" className="text-primary hover:text-primary/80 transition-colors">/greyscan</a>,
              the following happens:
            </p>
            <ul className="list-disc pl-6 space-y-2">
              <li>
                Your browser fetches the public file tree, dependency list, and README from GitHub&apos;s
                API directly. This data never passes through our servers during collection.
              </li>
              <li>
                To generate the threat report, a summary of the repo structure (file names,
                detected stack, dependency names, and up to 8,000 characters of the README) is
                sent to our server and forwarded to a third-party LLM provider for analysis.
              </li>
              <li>
                Results are cached in server memory for up to 24 hours to avoid redundant
                LLM calls for the same repository, then discarded. We do not persist scan
                results to disk or a database.
              </li>
              <li>
                No repository source code is read or transmitted. Only file paths, dependency
                names, and the public README are included.
              </li>
            </ul>
          </section>

          <section>
            <h2 className="font-serif text-xl font-semibold text-foreground mb-3">Third-party services</h2>
            <ul className="list-disc pl-6 space-y-2">
              <li>
                <span className="text-foreground font-medium">GitHub API</span> &mdash; Greyscan
                calls the GitHub REST API from your browser to fetch public repository metadata.
                Subject to <a href="https://docs.github.com/en/site-policy/privacy-policies/github-general-privacy-statement" target="_blank" rel="noopener noreferrer" className="text-primary hover:text-primary/80 transition-colors">GitHub&apos;s privacy statement</a>.
              </li>
              <li>
                <span className="text-foreground font-medium">LLM provider</span> &mdash; Repo
                summaries sent through Greyscan are processed by a third-party LLM to generate
                threat reports. The provider may retain data per their own policies.
              </li>
              <li>
                <span className="text-foreground font-medium">Vercel</span> &mdash; Hosting
                infrastructure. See <a href="https://vercel.com/legal/privacy-policy" target="_blank" rel="noopener noreferrer" className="text-primary hover:text-primary/80 transition-colors">Vercel&apos;s privacy policy</a>.
              </li>
            </ul>
          </section>

          <section>
            <h2 className="font-serif text-xl font-semibold text-foreground mb-3">Security</h2>
            <p>
              If you discover a security issue in Greywall or this website, please report it
              via <a href="https://github.com/GreyhavenHQ/greywall/security" target="_blank" rel="noopener noreferrer" className="text-primary hover:text-primary/80 transition-colors">GitHub Security Advisories</a>.
              We will respond promptly.
            </p>
          </section>

          <section>
            <h2 className="font-serif text-xl font-semibold text-foreground mb-3">Contact</h2>
            <p>
              For questions about this policy,
              reach us at <a href="https://greyhaven.co/contact" target="_blank" rel="noopener noreferrer" className="text-primary hover:text-primary/80 transition-colors">greyhaven.co/contact</a>.
            </p>
          </section>
        </div>

        <div className="mt-16 pt-8 border-t border-border/30">
          <a href="/" className="text-sm text-muted-foreground hover:text-foreground transition-colors font-sans">
            &larr; Back to Greywall
          </a>
        </div>
      </article>
    </main>
  )
}
