import type { Metadata } from 'next';

export const metadata: Metadata = {
  title: 'Privacy Policy',
  description: 'How VYNDR handles your data. Plain English.',
};

// Session 2 (A1 board) — approval-pack draft. Entity details are placeholder
// tokens ([ENTITY NAME], [CONTACT EMAIL]) for Kev to fill before this ships
// as the legal document.

const SECTIONS: { title: string; body: string[]; emphasized?: boolean }[] = [
  {
    title: 'We never sell your personal data.',
    body: [
      '[ENTITY NAME], the company that operates VYNDR, does not sell, rent, or trade your personal data to anyone. Our business is a subscription to an analytics product — not a data resale operation.',
    ],
    emphasized: true,
  },
  {
    title: 'Data we collect',
    body: [
      'Account data: email, password hash (managed by Supabase Auth — we never see your plaintext password), age confirmation, signup timestamp.',
      'Usage data: reads you run (player, stat, line, sport, grade), parlays you build, page views.',
      'Payment data: Stripe processes all card data — we never see or store your card number, CVC, or any other payment instrument detail. We retain a Stripe customer ID, Stripe subscription ID, and your subscription status (active, canceled, grace period, expired) so we can gate paid features and respond to renewal and cancellation events from Stripe webhooks.',
      'Device data: IP address, browser type, basic device info (for fraud prevention, error monitoring, and analytics).',
    ],
  },
  {
    title: 'How we use your data',
    body: [
      'To provide the service: sign you in, gate reads by tier, deliver grades.',
      'To improve the model: aggregate, anonymized read data helps calibration. Individual reads are never used to identify you to third parties.',
      'Aggregate trend features: surfaces like "Most Read Tonight" use anonymized counts across all users. Your individual reads are not exposed.',
      'To communicate: account confirmation, payment receipts, renewal reminders, critical service notices.',
    ],
  },
  {
    title: 'What we do not do',
    body: [
      'We do not sell your personal data. Ever.',
      'We do not share your individual betting activity with sportsbooks, advertisers, or data brokers.',
      'We do not run ads. The business model is subscription, period.',
    ],
  },
  {
    title: 'Data retention',
    body: [
      'Account data: retained while your account is active. Deleted on request.',
      'Read history: retained indefinitely (anonymized after account deletion) for model calibration.',
      'Payment records: retained for 7 years per US tax and accounting requirements.',
    ],
  },
  {
    title: 'Cookies and analytics',
    body: [
      'Essential cookies: auth session, read counter (cannot be disabled — the service does not work without them).',
      'Analytics: PostHog, with autocapture disabled — we record only the product events we name (page views, feature usage), never keystrokes or form contents, and no third-party ad trackers. The cookie notice on first visit is a disclosure of this. To opt out of analytics entirely, contact us at [CONTACT EMAIL].',
    ],
  },
  {
    title: 'Sub-processors',
    body: [
      'We rely on a small set of third-party processors. They handle data on our behalf under their own privacy commitments; we do not give them permission to use your data for their own purposes.',
      'Stripe — payment processing and subscription management. Receives: name (if you provide it), email, billing address (if you provide it), and the card details you enter on their hosted checkout page. We never see your card number.',
      'Supabase — authentication, database, and file storage. Receives: everything in the "Data we collect" section above. Supabase is our primary backend.',
      'PostHog — product analytics. Receives: the named product events above (page views, feature usage) with basic device context. Autocapture is off.',
      'Resend — transactional email (account confirmations, payment receipts, renewal reminders). Receives: your email address and the message contents.',
      'Sentry — error monitoring. Receives: technical error reports (browser type, page, stack trace), which may include your IP address in transit. Used only to find and fix bugs.',
    ],
  },
  {
    title: 'Notifications',
    body: [
      'We send push notifications and emails based on your preferences in Settings. You can disable any notification type at any time. Transactional messages (receipts, password resets, security alerts) cannot be disabled while your account is active.',
    ],
  },
  {
    title: 'Your rights',
    body: [
      'Access: request a copy of your data at any time.',
      'Deletion: request account and data deletion at [CONTACT EMAIL] — we comply within 30 days.',
      'Correction: update your email and other profile data from the profile page.',
      'Export: request a JSON export of your read history.',
      'If you are in a jurisdiction with statutory privacy rights (for example the EEA, UK, or California), those rights apply to you and the requests above are how you exercise them with us.',
    ],
  },
  {
    title: 'Children',
    body: [
      'VYNDR is not for anyone under 21. We do not knowingly collect data from minors. If we discover an account belongs to a minor, we will delete it immediately.',
    ],
  },
  {
    title: 'Changes',
    body: [
      'If we make material changes to this policy, we will notify you by email at least 30 days before they take effect.',
    ],
  },
  {
    title: 'Contact',
    body: [
      '[ENTITY NAME]. Privacy questions or data requests: [CONTACT EMAIL].',
    ],
  },
];

export default function PrivacyPage() {
  return (
    <section style={{ maxWidth: 720, margin: '0 auto', padding: '48px 16px 120px' }}>
      <header style={{ marginBottom: 32 }}>
        <h1 style={{ fontSize: 36, fontWeight: 700, letterSpacing: '-0.03em', marginBottom: 8 }}>Privacy Policy</h1>
        <p className="mono" style={{ fontSize: 12, color: 'var(--text-tertiary)', letterSpacing: '0.05em' }}>
          DRAFT: JULY 2026
        </p>
      </header>
      {SECTIONS.map((s) => (
        <section
          key={s.title}
          style={{
            marginBottom: 32,
            ...(s.emphasized
              ? {
                  borderLeft: '3px solid var(--grade-a)',
                  background: 'rgba(0, 212, 160, 0.04)',
                  borderRadius: 4,
                  padding: '12px 16px',
                }
              : {}),
          }}
        >
          <h2 style={{ fontSize: s.emphasized ? 20 : 18, fontWeight: 700, marginBottom: 12 }}>{s.title}</h2>
          {s.body.map((p, i) => (
            <p
              key={i}
              style={{
                color: s.emphasized ? 'var(--text-0)' : 'var(--text-secondary)',
                fontSize: s.emphasized ? 16 : 15,
                lineHeight: 1.7,
                marginBottom: 12,
              }}
            >
              {p}
            </p>
          ))}
        </section>
      ))}
    </section>
  );
}
