// ark-legal.jsx — Privacy Policy + Terms of Use pages

const LEGAL_UI = {
  EN: { back: '← DeveloperArk', label: 'LEGAL DOCUMENT', meta: "Developer's Ark · June 2026 · Pilot",
    privacy_title: 'Privacy Policy', terms_title: 'Terms of Use',
    back_home: 'Back to home', trust_faq: 'Trust & FAQ',
    lang_notice: null },
  DE: { back: '← DeveloperArk', label: 'RECHTSDOKUMENT', meta: "Developer's Ark · Juni 2026 · Pilot",
    privacy_title: 'Datenschutzerklärung', terms_title: 'Nutzungsbedingungen',
    back_home: 'Zurück zur Startseite', trust_faq: 'Vertrauen & FAQ',
    lang_notice: 'Dieses Dokument ist derzeit nur auf Englisch verfügbar. Eine Übersetzung kann auf Anfrage bereitgestellt werden.' },
  FR: { back: '← DeveloperArk', label: 'DOCUMENT LÉGAL', meta: "Developer's Ark · Juin 2026 · Pilote",
    privacy_title: 'Politique de confidentialité', terms_title: "Conditions d'utilisation",
    back_home: "Retour à l'accueil", trust_faq: 'Confiance & FAQ',
    lang_notice: "Ce document est actuellement disponible en anglais uniquement. Une traduction peut être fournie sur demande." },
  IT: { back: '← DeveloperArk', label: 'DOCUMENTO LEGALE', meta: "Developer's Ark · Giugno 2026 · Pilota",
    privacy_title: 'Informativa sulla privacy', terms_title: 'Termini di utilizzo',
    back_home: 'Torna alla home', trust_faq: 'Fiducia & FAQ',
    lang_notice: 'Questo documento è attualmente disponibile solo in inglese. Una traduzione può essere fornita su richiesta.' },
  ES: { back: '← DeveloperArk', label: 'DOCUMENTO LEGAL', meta: "Developer's Ark · Junio 2026 · Piloto",
    privacy_title: 'Política de privacidad', terms_title: 'Términos de uso',
    back_home: 'Volver al inicio', trust_faq: 'Confianza & FAQ',
    lang_notice: 'Este documento está disponible actualmente solo en inglés. Se puede proporcionar una traducción bajo petición.' },
  PT: { back: '← DeveloperArk', label: 'DOCUMENTO LEGAL', meta: "Developer's Ark · Junho 2026 · Piloto",
    privacy_title: 'Política de privacidade', terms_title: 'Termos de uso',
    back_home: 'Voltar ao início', trust_faq: 'Confiança & FAQ',
    lang_notice: 'Este documento está disponível apenas em inglês por enquanto. Uma tradução pode ser fornecida mediante solicitação.' },
  UA: { back: '← DeveloperArk', label: 'ПРАВОВИЙ ДОКУМЕНТ', meta: "Developer's Ark · Червень 2026 · Пілот",
    privacy_title: 'Політика конфіденційності', terms_title: 'Умови використання',
    back_home: 'На головну', trust_faq: 'Довіра та FAQ',
    lang_notice: 'Цей документ наразі доступний лише англійською. Переклад може бути надано за запитом.' },
};

const getLegalUI = (lang) => LEGAL_UI[lang] || LEGAL_UI.EN;

const LegalPage = ({ title, sections, navigate, lang }) => {
  const ui = getLegalUI(lang);
  return (
  <div>
    <section style={{ background: T.bg, borderBottom: `1px solid ${T.border}` }}>
      <div style={{ maxWidth: 780, margin: '0 auto', padding: '64px 40px 40px' }}>
        <button onClick={() => navigate('home')} style={{ background: 'none', border: 'none', cursor: 'pointer', fontFamily: T.mono, fontSize: 11.5, color: T.muted, padding: '0 0 24px', display: 'flex', alignItems: 'center', gap: 6, letterSpacing: '0.04em' }}>
          {ui.back}
        </button>
        <div style={{ fontFamily: T.mono, fontSize: 10.5, color: T.accent, letterSpacing: '0.1em', textTransform: 'uppercase', marginBottom: 12 }}>
          {ui.label}
        </div>
        <h1 style={{ fontFamily: T.sans, fontSize: 40, fontWeight: 700, color: T.text, letterSpacing: '-0.03em', margin: '0 0 12px' }}>{title}</h1>
        <div style={{ fontFamily: T.mono, fontSize: 11.5, color: T.dim, letterSpacing: '0.04em' }}>
          {ui.meta}
        </div>
        {ui.lang_notice && (
          <div style={{ marginTop: 16, padding: '10px 14px', borderRadius: 6, background: T.warningSubtle, border: `1px solid ${T.warning}33`, fontFamily: T.sans, fontSize: 13, color: T.muted, lineHeight: 1.65 }}>
            {ui.lang_notice}
          </div>
        )}
      </div>
    </section>

    <section style={{ background: T.surface, borderBottom: `1px solid ${T.border}` }}>
      <div style={{ maxWidth: 780, margin: '0 auto', padding: '48px 40px' }}>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 40 }}>
          {sections.map((sec, i) => (
            <div key={i} style={{ borderBottom: `1px solid ${T.border}`, paddingBottom: 40 }}>
              <h2 style={{ fontFamily: T.sans, fontSize: 20, fontWeight: 700, color: T.text, margin: '0 0 16px', letterSpacing: '-0.02em' }}>
                <span style={{ fontFamily: T.mono, fontSize: 11, color: T.accent, marginRight: 10, verticalAlign: 'middle' }}>
                  {String(i + 1).padStart(2, '0')}
                </span>
                {sec.title}
              </h2>
              {sec.content.map((block, j) => {
                if (block.type === 'p') return (
                  <p key={j} style={{ fontFamily: T.sans, fontSize: 14.5, color: T.muted, lineHeight: 1.78, margin: '0 0 14px' }}>{block.text}</p>
                );
                if (block.type === 'list') return (
                  <ul key={j} style={{ margin: '0 0 14px', padding: '0 0 0 0', listStyle: 'none', display: 'flex', flexDirection: 'column', gap: 8 }}>
                    {block.items.map((item, k) => (
                      <li key={k} style={{ display: 'flex', gap: 10, alignItems: 'flex-start' }}>
                        <span style={{ color: block.negative ? T.red : T.accent, fontFamily: T.mono, fontSize: 11, flexShrink: 0, marginTop: 4 }}>{block.negative ? '\u2715' : '\u2713'}</span>
                        <span style={{ fontFamily: T.sans, fontSize: 14, color: T.muted, lineHeight: 1.65 }}>{item}</span>
                      </li>
                    ))}
                  </ul>
                );
                if (block.type === 'note') return (
                  <div key={j} style={{ background: T.accentSubtle, border: `1px solid ${T.accentDim}`, borderRadius: 8, padding: '12px 16px', fontFamily: T.sans, fontSize: 13.5, color: T.muted, lineHeight: 1.65, margin: '0 0 14px' }}>
                    {block.text}
                  </div>
                );
                if (block.type === 'warning') return (
                  <div key={j} style={{ background: T.warningSubtle, border: `1px solid ${T.warning}33`, borderRadius: 8, padding: '12px 16px', fontFamily: T.mono, fontSize: 12, color: T.warning, lineHeight: 1.65, margin: '0 0 14px', letterSpacing: '0.02em' }}>
                    {block.text}
                  </div>
                );
                return null;
              })}
            </div>
          ))}
        </div>
      </div>
    </section>

    <section style={{ background: T.bg, borderBottom: `1px solid ${T.border}` }}>
      <div style={{ maxWidth: 780, margin: '0 auto', padding: '40px 40px' }}>
        <div style={{ fontFamily: T.sans, fontSize: 12.5, color: T.dim, lineHeight: 1.65 }}>
          Launch Ark is a bounded continuity documentation package. It is not legal advice, compliance certification, security certification, DevOps implementation, uptime guarantee, payment approval, or delivery authorization. No secrets required. Unknowns stay visible.
        </div>
        <div style={{ marginTop: 20, display: 'flex', gap: 12 }}>
          <Btn size="sm" variant="secondary" onClick={() => navigate('home')}>{ui.back_home}</Btn>
          <Btn size="sm" variant="secondary" onClick={() => navigate('faq')}>{ui.trust_faq}</Btn>
        </div>
      </div>
    </section>
  </div>
  );
};

// ── Privacy Policy ──────────────────────────────────────────────────────────
const PRIVACY_SECTIONS = [
  {
    title: 'What this document covers',
    content: [
      { type: 'p', text: "This Privacy Policy describes how Developer's Ark collects, uses, and handles information provided through the Launch Ark project fit check form and any related communications." },
      { type: 'warning', text: "\u26a0 PILOT STATUS \u00b7 Launch Ark is in concierge pilot. No automated data processing is active. All requests are handled manually." },
    ],
  },
  {
    title: 'What we collect',
    content: [
      { type: 'p', text: 'When you submit a project fit check request, we collect:' },
      { type: 'list', items: [
        'Your email address (required — used only to respond to your request)',
        'A high-level project description (name, type, stage, tech stack, team size)',
        'Boolean operational indicators (CI/CD exists, backup plan exists, security baseline exists)',
        'Optional free-text notes you choose to include',
      ]},
      { type: 'note', text: 'We collect the minimum information necessary to assess whether your project is a good fit for Launch Ark and to assemble your package if you proceed.' },
    ],
  },
  {
    title: 'What we never collect',
    content: [
      { type: 'p', text: 'The intake form is explicitly designed to exclude the following. You must not send them, and we will reject any intake that contains them:' },
      { type: 'list', negative: true, items: [
        'Passwords or authentication credentials of any kind',
        'API keys, tokens, secrets, or connection strings',
        'Private repository URLs or repository access credentials',
        'Production system credentials or deployment pipeline access',
        'Customer data, personally identifiable information about third parties',
        'Source code or binary files',
        'Database dumps or exports',
      ]},
    ],
  },
  {
    title: 'How we use your data',
    content: [
      { type: 'p', text: 'Information you provide is used exclusively to:' },
      { type: 'list', items: [
        'Assess whether your project is a good fit for Launch Ark',
        'Confirm scope and pricing with you before any work begins',
        'Assemble your continuity documentation package if you confirm',
        'Communicate with you about your request',
      ]},
      { type: 'p', text: 'We do not use your data for marketing, advertising, profiling, or any purpose beyond fulfilling your request.' },
    ],
  },
  {
    title: 'Data retention and deletion',
    content: [
      { type: 'p', text: 'Raw intake data is deleted after your package is delivered. We retain only minimal metadata needed for order tracking:' },
      { type: 'list', items: [
        'A reference ID',
        'Delivery status',
        'Date of request and delivery',
      ]},
      { type: 'p', text: 'If your request does not proceed to delivery, raw intake data is deleted within 30 days of the last communication.' },
      { type: 'p', text: 'You may request deletion of your intake data at any time by emailing hello@developerark.com. We will process your request and provide a Deletion Receipt.' },
    ],
  },
  {
    title: 'Deletion receipts',
    content: [
      { type: 'p', text: 'When you request deletion of your intake data, we generate a DELETION_RECEIPT.md — a structured document confirming:' },
      { type: 'list', items: [
        'What input data was received',
        'What was deleted',
        'What minimal metadata was retained (reference ID, dates)',
        'The timestamp of deletion',
      ]},
      { type: 'note', text: 'Deletion receipts are process records, not cryptographic deletion certificates. They confirm that our manual deletion process was performed, not that data is cryptographically unrecoverable.' },
    ],
  },
  {
    title: 'Third parties',
    content: [
      { type: 'p', text: 'We do not sell, share, or transfer your data to third parties.' },
      { type: 'p', text: 'We do not use third-party analytics, tracking scripts, or advertising networks on this site.' },
      { type: 'p', text: 'If we use a third-party service to handle email communication, we will update this policy to name that provider before it becomes active.' },
    ],
  },
  {
    title: 'Cookies and tracking',
    content: [
      { type: 'p', text: 'This site uses no tracking cookies, analytics scripts, or advertising pixels.' },
      { type: 'p', text: 'localStorage is used only to remember your language preference and theme selection (light/dark mode). This data never leaves your browser.' },
    ],
  },
  {
    title: 'Your rights',
    content: [
      { type: 'p', text: 'You have the right to:' },
      { type: 'list', items: [
        'Request access to the data we hold about you',
        'Request correction of inaccurate data',
        'Request deletion of your data (with Deletion Receipt)',
        'Withdraw your fit check request at any time before scope is confirmed',
      ]},
      { type: 'p', text: 'To exercise any of these rights, email hello@developerark.com.' },
    ],
  },
  {
    title: 'Contact',
    content: [
      { type: 'p', text: "For privacy questions or data requests, contact Developer's Ark at hello@developerark.com." },
      { type: 'p', text: "This policy was last updated in June 2026. We will update the effective date when material changes are made. Continued use of the site constitutes acceptance of the current policy." },
    ],
  },
];

// ── Terms of Use ────────────────────────────────────────────────────────────
const TERMS_SECTIONS = [
  {
    title: 'What Launch Ark is',
    content: [
      { type: 'p', text: "Launch Ark is a structured continuity documentation package for solo-built and AI-built software projects. It maps what exists, what is missing, what is uncertain, and what another person would need to know to understand how your project survives a bad week." },
      { type: 'p', text: "Launch Ark is offered by Developer's Ark as a concierge pilot service. All requests are handled manually. Scope and price are confirmed by email before any work begins." },
      { type: 'warning', text: "\u26a0 PILOT STATUS \u00b7 Payment, checkout, and automated delivery are not yet enabled. No payment will be requested before scope is confirmed." },
    ],
  },
  {
    title: 'What Launch Ark is not',
    content: [
      { type: 'p', text: 'By using this site and submitting a fit check request, you acknowledge that Launch Ark is:' },
      { type: 'list', negative: true, items: [
        'Not legal advice of any kind',
        'Not compliance certification (SOC2, ISO, GDPR, HIPAA, or other)',
        'Not a security audit or penetration test',
        'Not a guarantee that your application is secure',
        'Not DevOps implementation or infrastructure management',
        'Not a guarantee of uptime, recovery, or operational continuity',
        'Not a complete audit of your codebase or architecture',
        'Not a substitute for professional legal, compliance, or security advice',
      ]},
    ],
  },
  {
    title: 'Pilot status and delivery',
    content: [
      { type: 'p', text: "Launch Ark is currently in concierge pilot. This means:" },
      { type: 'list', items: [
        'No automated intake processing is active',
        'No payment or checkout system is enabled',
        'No automated delivery is active',
        'All requests are reviewed manually before any scope or price is confirmed',
        'We reserve the right to decline any request at our discretion',
      ]},
      { type: 'p', text: "You will never be charged before you explicitly confirm scope and price by email. No payment is requested at the fit check stage." },
    ],
  },
  {
    title: 'Your obligations',
    content: [
      { type: 'p', text: 'By submitting a fit check request, you agree to:' },
      { type: 'list', items: [
        'Provide only high-level, non-sensitive project information',
        'Not include passwords, API keys, tokens, secrets, or credentials in any field',
        'Not include private repository URLs or production system access information',
        'Not include personal data of third parties (customers, employees) without authorization',
        'Represent that you are authorized to share the project information you provide',
      ]},
      { type: 'note', text: 'Any intake containing credential-like values will be rejected. This is enforced by both our intake validator and our manual review process.' },
    ],
  },
  {
    title: 'Intellectual property',
    content: [
      { type: 'p', text: "The documentation package we assemble for you is based on information you provide. You retain ownership of all information you supply." },
      { type: 'p', text: "The templates, schemas, structure, and methodology used to assemble the package are proprietary to Developer's Ark. You receive a licensed copy of the assembled output for your own internal use." },
      { type: 'p', text: "You may not resell, redistribute, or claim authorship of the assembled package structure or templates." },
    ],
  },
  {
    title: 'Gaps and visible unknowns',
    content: [
      { type: 'p', text: "Every package includes an ARK_GAPS_REPORT.md that explicitly lists all missing, ambiguous, or unverifiable fields in your intake. These gaps are a feature of the product, not a defect." },
      { type: 'p', text: "We never invent answers. If information is missing from your intake, it will appear as a clearly marked placeholder or gap — not as a fabricated fact." },
      { type: 'note', text: 'A package with gaps is not a complete operational record. It is a structured representation of what is known and what must still be verified or documented.' },
    ],
  },
  {
    title: 'Limitation of liability',
    content: [
      { type: 'p', text: "To the maximum extent permitted by applicable law, Developer's Ark and its operators are not liable for:" },
      { type: 'list', negative: true, items: [
        'Any operational failure, data loss, or security incident affecting your project',
        'Any decision made based on the documentation package we produce',
        'Any gap, error, or omission in the assembled package',
        'Any loss arising from your reliance on the package as a complete or certified record',
        'Any consequence of secrets or credentials you include despite our explicit instructions not to',
      ]},
      { type: 'p', text: "The package is provided as-is, for informational and planning purposes only. It is not a warranty, certification, or guarantee of any kind." },
    ],
  },
  {
    title: 'Governing law',
    content: [
      { type: 'p', text: "These terms are governed by the laws of Switzerland. Any disputes shall be resolved in the courts of Switzerland, to the extent permitted by applicable law." },
      { type: 'p', text: "If any provision of these terms is found to be unenforceable, the remaining provisions continue in full force." },
    ],
  },
  {
    title: 'Changes to these terms',
    content: [
      { type: 'p', text: "We may update these terms as the service evolves from pilot to active delivery. Material changes will be noted with an updated effective date." },
      { type: 'p', text: "For questions about these terms, contact hello@developerark.com." },
    ],
  },
];

const PrivacyPage = ({ navigate, lang }) => {
  const ui = getLegalUI(lang);
  return <LegalPage title={ui.privacy_title} sections={PRIVACY_SECTIONS} navigate={navigate} lang={lang} />;
};

const TermsPage = ({ navigate, lang }) => {
  const ui = getLegalUI(lang);
  return <LegalPage title={ui.terms_title} sections={TERMS_SECTIONS} navigate={navigate} lang={lang} />;
};

window.PrivacyPage = PrivacyPage;
window.TermsPage   = TermsPage;
