// ─────────────────────────────────────────────────────────
// ChefVerse · Legal pages (Privacy Policy + Terms & Conditions)
// i18n for en, de, id
// ─────────────────────────────────────────────────────────

const LEGAL_I18N = {
  en: {
    back: "Back",
    updated: "Last updated: May 2026",
    privacy: {
      title: "Privacy Policy",
      lead: "How Unilever Food Solutions handles your data inside ChefVerse — written for chefs, in plain language.",
      sections: [
        {
          h: "1. Who we are",
          p: "ChefVerse is operated by Unilever Food Solutions (\"UFS\"). We're the data controller for the personal information you give us when you sign up, learn, and submit briefs on this platform. Questions? Reach out to your local UFS chef-success rep or write to privacy@ufs.com.",
        },
        {
          h: "2. What we collect",
          p: "When you create an account we store your name, work email, region (US / DE / ID), role (sous chef, head chef, etc.), and the goals you set during onboarding. As you use ChefVerse we record which modules you start and complete, briefs you open and submit, and your reward points balance. We do not collect payment information; ChefVerse is free for invited chefs during pilot.",
        },
        {
          h: "3. Closed captions and uploaded media",
          p: "Videos you watch are hosted by UFS and protected with DRM — they cannot be downloaded or shared. When you submit a practice brief, the photos or short videos you upload are stored on UFS servers and reviewed by a chef on our team. Your media is never sold or shared with third parties, and is deleted within 90 days of the pilot ending unless you ask us to keep it as part of your portfolio.",
        },
        {
          h: "4. Why we use your data",
          p: "We use what you give us to (a) operate the platform — show your progress, unlock modules, award points; (b) measure pilot engagement at the region level (aggregate, anonymous); (c) reach out to you about new modules, briefs, and rewards relevant to your goals. We will never email you marketing from third parties.",
        },
        {
          h: "5. Cookies and local storage",
          p: "ChefVerse uses your browser's local storage to remember your saved items, language, and module progress. We do not run advertising trackers, fingerprinting scripts, or third-party analytics inside the chef-facing app.",
        },
        {
          h: "6. Your rights",
          p: "You can request a copy of your data, correct it, or have it deleted at any time — write to privacy@ufs.com and we'll respond within 30 days. If you're in the EU you also have the right to file a complaint with your local data-protection authority.",
        },
        {
          h: "7. Changes to this policy",
          p: "If we materially change how we handle your data we'll show you a notice the next time you log in, and you'll be able to read the updated version before continuing. Continued use of ChefVerse after that point means you accept the change.",
        },
      ],
    },
    terms: {
      title: "Terms & Conditions",
      lead: "The agreement between you and Unilever Food Solutions when you use ChefVerse during the pilot.",
      sections: [
        {
          h: "1. Who can use ChefVerse",
          p: "ChefVerse is invite-only during the pilot phase. You must be a working chef or food-service professional aged 18 or over, employed in one of our three pilot regions: United States, Germany, or Indonesia. By creating an account you confirm you meet these conditions.",
        },
        {
          h: "2. Your account",
          p: "Keep your login credentials private. You're responsible for activity on your account. If you suspect someone else has accessed it, write to your local UFS rep or to support@ufs.com so we can reset it.",
        },
        {
          h: "3. What you can and can't do",
          p: "You may watch modules, download the linked recipe PDFs, submit practice briefs, and claim earned rewards. You may not (a) download or screen-record the training videos; (b) share your login with anyone else; (c) submit briefs that contain content you don't own or have permission to use; (d) submit content that is unsafe, discriminatory, or that depicts dangerous food-handling practices.",
        },
        {
          h: "4. Briefs and payouts",
          p: "When you accept a brief, you commit to delivering by the stated deadline. UFS reviews submissions and pays out the listed amount via your country's standard pilot-payment method (US: ACH; DE: SEPA; ID: bank transfer) within 14 business days of approval. If a brief is rejected, you'll get specific feedback and one revision attempt.",
        },
        {
          h: "5. Your submitted work",
          p: "You keep ownership of photos, videos, and recipes you submit. By submitting, you grant UFS a non-exclusive, royalty-free licence to use that content in (a) the ChefVerse platform; (b) UFS internal materials; (c) UFS social channels with credit to you, only if you opt in. We will not sell your work to third parties.",
        },
        {
          h: "6. Rewards",
          p: "Points are earned for completed modules and approved briefs. Physical rewards ship to the address on your profile; digital rewards unlock instantly. Points expire 12 months after the pilot ends if not redeemed. Rewards have no cash value and cannot be transferred.",
        },
        {
          h: "7. Ending your participation",
          p: "You can leave the pilot at any time — write to your UFS rep and we'll close your account within 7 days. UFS may also remove access if you breach these terms, with notice and a chance to fix the issue where the breach allows for it.",
        },
        {
          h: "8. Liability",
          p: "ChefVerse is a learning tool. Recipes and techniques shown are guidance, not professional certification. UFS is not liable for kitchen accidents, allergens, or food-safety issues that result from applying what you watch. Always follow your local food-safety regulations.",
        },
        {
          h: "9. Governing law",
          p: "These terms are governed by the law of the country where you registered (US: California; DE: Hamburg; ID: Jakarta). Disputes go to the courts of that jurisdiction first; we'd much rather just call you and sort it out.",
        },
      ],
    },
  },
  de: {
    back: "Zurück",
    updated: "Zuletzt aktualisiert: Mai 2026",
    privacy: {
      title: "Datenschutzerklärung",
      lead: "Wie Unilever Food Solutions deine Daten in ChefVerse verarbeitet — verständlich für Köche.",
      sections: [
        {
          h: "1. Wer wir sind",
          p: "ChefVerse wird von Unilever Food Solutions („UFS\") betrieben. Wir sind der Verantwortliche für deine personenbezogenen Daten, die du bei Registrierung, Lernen und Briefing-Einreichungen auf dieser Plattform angibst. Fragen? Wende dich an deinen lokalen UFS-Chef-Success-Ansprechpartner oder schreibe an privacy@ufs.com.",
        },
        {
          h: "2. Was wir erfassen",
          p: "Bei der Kontoerstellung speichern wir deinen Namen, deine geschäftliche E-Mail, deine Region (USA / DE / ID), deine Rolle (Sous-Chef, Küchenchef, etc.) und die im Onboarding gesetzten Ziele. Während der Nutzung erfassen wir, welche Module du startest und abschließt, welche Briefings du öffnest und einreichst, sowie deinen Punktestand. Zahlungsdaten werden nicht erfasst — ChefVerse ist für eingeladene Köche während des Pilotbetriebs kostenlos.",
        },
        {
          h: "3. Untertitel und hochgeladene Medien",
          p: "Videos sind bei UFS gehostet und DRM-geschützt — sie können nicht heruntergeladen oder geteilt werden. Bei Briefing-Einreichungen werden deine Fotos oder Kurzvideos auf UFS-Servern gespeichert und von einem Koch aus unserem Team gesichtet. Deine Medien werden niemals verkauft oder an Dritte weitergegeben und 90 Tage nach Ende des Pilotbetriebs gelöscht, sofern du nicht ihre Aufbewahrung als Portfolio wünschst.",
        },
        {
          h: "4. Wofür wir deine Daten nutzen",
          p: "Wir nutzen deine Daten, um (a) die Plattform zu betreiben — Fortschritt anzeigen, Module freischalten, Punkte gutschreiben; (b) das Pilot-Engagement aggregiert und anonym auf Regionsebene zu messen; (c) dich über neue Module, Briefings und für dich relevante Belohnungen zu informieren. Wir senden niemals Marketing-Nachrichten Dritter.",
        },
        {
          h: "5. Cookies und lokaler Speicher",
          p: "ChefVerse nutzt den lokalen Speicher deines Browsers, um deine gespeicherten Inhalte, Sprache und den Modulfortschritt zu merken. Wir setzen keine Werbe-Tracker, kein Fingerprinting und keine externen Analytics in der Chef-App ein.",
        },
        {
          h: "6. Deine Rechte",
          p: "Du kannst jederzeit eine Kopie deiner Daten anfordern, sie korrigieren oder löschen lassen — schreibe an privacy@ufs.com, wir antworten innerhalb von 30 Tagen. In der EU kannst du zusätzlich bei deiner lokalen Datenschutzbehörde Beschwerde einlegen.",
        },
        {
          h: "7. Änderungen dieser Erklärung",
          p: "Bei wesentlichen Änderungen zeigen wir dir beim nächsten Login einen Hinweis und du kannst die aktualisierte Fassung vorher lesen. Eine weitere Nutzung gilt als Annahme der Änderungen.",
        },
      ],
    },
    terms: {
      title: "Allgemeine Geschäftsbedingungen",
      lead: "Die Vereinbarung zwischen dir und Unilever Food Solutions bei der Nutzung von ChefVerse im Pilotbetrieb.",
      sections: [
        {
          h: "1. Wer ChefVerse nutzen darf",
          p: "ChefVerse ist während der Pilotphase nur auf Einladung zugänglich. Du musst ein berufstätiger Koch oder Gastronomie-Profi ab 18 Jahren sein, beschäftigt in einem unserer drei Pilotmärkte: USA, Deutschland oder Indonesien. Mit der Kontoerstellung bestätigst du diese Bedingungen.",
        },
        {
          h: "2. Dein Konto",
          p: "Halte deine Zugangsdaten geheim. Du bist für die Aktivitäten in deinem Konto verantwortlich. Bei Verdacht auf unbefugten Zugriff schreibe an deinen UFS-Ansprechpartner oder an support@ufs.com — wir setzen das Passwort zurück.",
        },
        {
          h: "3. Was du tun darfst — und was nicht",
          p: "Du darfst Module ansehen, verlinkte Rezept-PDFs herunterladen, Briefings einreichen und verdiente Belohnungen einlösen. Du darfst nicht (a) Trainingsvideos herunterladen oder per Bildschirmaufnahme aufzeichnen; (b) deinen Login weitergeben; (c) Briefings mit Inhalten einreichen, an denen du keine Rechte hast; (d) Inhalte einreichen, die unsicher, diskriminierend oder gefährliche Handhabungspraktiken zeigen.",
        },
        {
          h: "4. Briefings und Auszahlungen",
          p: "Mit der Annahme eines Briefings verpflichtest du dich zur Lieferung bis zur angegebenen Frist. UFS prüft Einreichungen und zahlt den angegebenen Betrag innerhalb von 14 Werktagen nach Freigabe per landesüblicher Pilot-Auszahlungsmethode (US: ACH; DE: SEPA; ID: Banküberweisung). Bei Ablehnung erhältst du konkretes Feedback und einen Überarbeitungsversuch.",
        },
        {
          h: "5. Deine eingereichten Arbeiten",
          p: "Du behältst die Rechte an deinen Fotos, Videos und Rezepten. Mit der Einreichung gewährst du UFS eine nicht-exklusive, lizenzgebührenfreie Nutzungslizenz für (a) die ChefVerse-Plattform; (b) interne UFS-Materialien; (c) UFS-Social-Kanäle mit Namensnennung, sofern du zustimmst. Wir verkaufen deine Arbeit niemals an Dritte.",
        },
        {
          h: "6. Belohnungen",
          p: "Punkte erhältst du für abgeschlossene Module und genehmigte Briefings. Physische Belohnungen werden an die Adresse in deinem Profil versendet; digitale werden sofort freigeschaltet. Punkte verfallen 12 Monate nach Pilot-Ende, wenn sie nicht eingelöst werden. Belohnungen haben keinen Geldwert und sind nicht übertragbar.",
        },
        {
          h: "7. Beendigung der Teilnahme",
          p: "Du kannst den Pilotbetrieb jederzeit verlassen — schreibe deinem UFS-Ansprechpartner und wir schließen dein Konto innerhalb von 7 Tagen. UFS kann den Zugang ebenfalls entziehen, falls du gegen diese Bedingungen verstößt — mit Vorankündigung und Gelegenheit zur Behebung, sofern möglich.",
        },
        {
          h: "8. Haftung",
          p: "ChefVerse ist ein Lerntool. Gezeigte Rezepte und Techniken sind Anleitung, kein berufliches Zertifikat. UFS haftet nicht für Küchenunfälle, Allergene oder Lebensmittelsicherheitsprobleme, die aus der Umsetzung entstehen. Halte stets die örtlichen Vorschriften ein.",
        },
        {
          h: "9. Anwendbares Recht",
          p: "Diese Bedingungen unterliegen dem Recht des Landes, in dem du dich registriert hast (US: Kalifornien; DE: Hamburg; ID: Jakarta). Streitigkeiten kommen zunächst vor die Gerichte dieser Jurisdiktion; wir rufen dich aber lieber an und klären es direkt.",
        },
      ],
    },
  },
  id: {
    back: "Kembali",
    updated: "Pembaruan terakhir: Mei 2026",
    privacy: {
      title: "Kebijakan Privasi",
      lead: "Cara Unilever Food Solutions mengelola data Anda di ChefVerse — ditulis untuk koki, bahasa yang sederhana.",
      sections: [
        {
          h: "1. Tentang kami",
          p: "ChefVerse dioperasikan oleh Unilever Food Solutions (\"UFS\"). Kami adalah pengendali data pribadi yang Anda berikan saat mendaftar, belajar, dan mengirim brief. Ada pertanyaan? Hubungi perwakilan UFS Chef-Success setempat atau email privacy@ufs.com.",
        },
        {
          h: "2. Data yang kami kumpulkan",
          p: "Saat membuat akun, kami menyimpan nama, email kerja, wilayah (AS / DE / ID), peran (sous chef, chef de cuisine, dsb.), dan tujuan yang Anda set saat onboarding. Saat menggunakan ChefVerse kami mencatat modul yang dimulai dan diselesaikan, brief yang dibuka dan dikirim, serta saldo poin reward Anda. Kami tidak mengumpulkan informasi pembayaran — ChefVerse gratis untuk koki yang diundang selama pilot.",
        },
        {
          h: "3. Subtitel dan media yang diunggah",
          p: "Video di-host oleh UFS dan dilindungi DRM — tidak dapat diunduh atau dibagikan. Saat Anda mengirim brief praktik, foto atau video pendek yang Anda unggah disimpan di server UFS dan ditinjau oleh koki di tim kami. Media Anda tidak pernah dijual atau dibagikan ke pihak ketiga, dan dihapus dalam 90 hari setelah pilot berakhir kecuali Anda meminta kami menyimpannya sebagai portofolio.",
        },
        {
          h: "4. Mengapa kami menggunakan data Anda",
          p: "Kami menggunakan data untuk (a) menjalankan platform — menampilkan progres, membuka modul, memberikan poin; (b) mengukur engagement pilot pada tingkat wilayah (agregat, anonim); (c) menghubungi Anda tentang modul, brief, dan reward baru yang relevan. Kami tidak pernah mengirim email pemasaran pihak ketiga.",
        },
        {
          h: "5. Cookie dan penyimpanan lokal",
          p: "ChefVerse menggunakan penyimpanan lokal browser untuk mengingat item yang disimpan, bahasa, dan progres modul. Kami tidak menjalankan pelacak iklan, fingerprinting, atau analitik pihak ketiga di aplikasi koki.",
        },
        {
          h: "6. Hak Anda",
          p: "Anda dapat meminta salinan data, mengoreksi, atau menghapusnya kapan saja — email ke privacy@ufs.com dan kami akan merespons dalam 30 hari. Di Indonesia, Anda juga berhak mengajukan keluhan kepada otoritas perlindungan data setempat.",
        },
        {
          h: "7. Perubahan kebijakan",
          p: "Jika kami mengubah cara penanganan data secara material, kami akan menampilkan pemberitahuan pada login berikutnya, dan Anda dapat membaca versi terbaru sebelum melanjutkan. Penggunaan lanjut berarti Anda menerima perubahan.",
        },
      ],
    },
    terms: {
      title: "Syarat & Ketentuan",
      lead: "Perjanjian antara Anda dan Unilever Food Solutions saat menggunakan ChefVerse selama pilot.",
      sections: [
        {
          h: "1. Siapa yang dapat menggunakan ChefVerse",
          p: "ChefVerse hanya untuk undangan selama fase pilot. Anda harus koki bekerja atau profesional layanan makanan berusia 18 tahun ke atas, bekerja di salah satu dari tiga wilayah pilot kami: Amerika Serikat, Jerman, atau Indonesia. Dengan membuat akun, Anda menyatakan memenuhi syarat ini.",
        },
        {
          h: "2. Akun Anda",
          p: "Jaga kredensial login tetap pribadi. Anda bertanggung jawab atas aktivitas di akun Anda. Jika dicurigai ada akses tidak sah, hubungi perwakilan UFS atau support@ufs.com agar kami dapat me-reset.",
        },
        {
          h: "3. Apa yang boleh dan tidak boleh",
          p: "Anda boleh menonton modul, mengunduh PDF resep tertaut, mengirim brief praktik, dan mengklaim reward yang diperoleh. Anda tidak boleh (a) mengunduh atau merekam layar video pelatihan; (b) berbagi login; (c) mengirim brief berisi konten yang bukan milik atau izin Anda; (d) mengirim konten yang tidak aman, diskriminatif, atau menampilkan praktik penanganan makanan berbahaya.",
        },
        {
          h: "4. Brief dan pembayaran",
          p: "Saat menerima brief, Anda berkomitmen menyelesaikan sebelum tenggat. UFS meninjau pengiriman dan membayar jumlah yang tertera melalui metode pembayaran pilot standar negara Anda (AS: ACH; DE: SEPA; ID: transfer bank) dalam 14 hari kerja setelah disetujui. Jika brief ditolak, Anda akan menerima umpan balik spesifik dan satu kesempatan revisi.",
        },
        {
          h: "5. Karya yang Anda kirim",
          p: "Anda tetap pemilik foto, video, dan resep yang dikirim. Dengan mengirim, Anda memberi UFS lisensi non-eksklusif tanpa royalti untuk (a) platform ChefVerse; (b) materi internal UFS; (c) kanal sosial UFS dengan kredit kepada Anda, hanya jika Anda memilih ikut. Kami tidak akan menjual karya Anda kepada pihak ketiga.",
        },
        {
          h: "6. Reward",
          p: "Poin diperoleh dari modul yang diselesaikan dan brief yang disetujui. Reward fisik dikirim ke alamat di profil Anda; reward digital terbuka langsung. Poin kedaluwarsa 12 bulan setelah pilot berakhir jika tidak ditukar. Reward tidak memiliki nilai uang tunai dan tidak dapat dipindahtangankan.",
        },
        {
          h: "7. Mengakhiri partisipasi",
          p: "Anda dapat keluar dari pilot kapan saja — hubungi perwakilan UFS dan kami menutup akun dalam 7 hari. UFS juga dapat menghapus akses jika Anda melanggar ketentuan ini, dengan pemberitahuan dan kesempatan memperbaiki jika memungkinkan.",
        },
        {
          h: "8. Tanggung jawab",
          p: "ChefVerse adalah alat pembelajaran. Resep dan teknik yang ditampilkan adalah panduan, bukan sertifikasi profesional. UFS tidak bertanggung jawab atas kecelakaan dapur, alergen, atau masalah keamanan pangan akibat penerapan. Selalu patuhi regulasi keamanan pangan setempat.",
        },
        {
          h: "9. Hukum yang berlaku",
          p: "Ketentuan ini diatur oleh hukum negara tempat Anda mendaftar (AS: California; DE: Hamburg; ID: Jakarta). Sengketa pertama diajukan ke pengadilan yurisdiksi tersebut; tapi kami lebih suka menelepon dan menyelesaikan langsung.",
        },
      ],
    },
  },
};

// Quick Answers accordion — pulls relevant items from the FAQ data
// and renders them above the formal legal prose.
function LegalQuickAnswers({ kind, locale, faqs }) {
  const [openId, setOpenId] = React.useState(null);
  if (!faqs) return null;
  // Pull items from the terms-legal category. Could later filter by tags.
  const cat = faqs.categories.find(c => c.id === "terms-legal");
  if (!cat) return null;
  // Privacy page → privacy-related items (tl-5, tl-6). Terms page → ownership/rules (tl-1..tl-4).
  const subset = kind === "privacy"
    ? cat.items.filter(it => ["tl-5", "tl-6"].includes(it.id))
    : cat.items.filter(it => ["tl-1", "tl-2", "tl-3", "tl-4"].includes(it.id));
  if (subset.length === 0) return null;
  const title = locale === "de" ? "Häufige Fragen" : locale === "id" ? "Pertanyaan umum" : "Common questions";
  const sub = locale === "de"
    ? "Die wichtigsten Punkte zu diesem Dokument in klarer Sprache."
    : locale === "id"
      ? "Poin-poin utama dari dokumen ini dalam bahasa sederhana."
      : "The key points from this document in plain language.";
  return (
    <div className="legal-qa-block">
      <div className="legal-qa-head">
        <h2 className="legal-qa-title">{title}</h2>
        <p className="legal-qa-sub">{sub}</p>
      </div>
      <div className="legal-qa-list">
        {subset.map(it => {
          const isOpen = openId === it.id;
          return (
            <div key={it.id} className={"legal-qa-item " + (isOpen ? "open" : "")}>
              <button
                className="legal-qa-q"
                onClick={() => setOpenId(isOpen ? null : it.id)}
                aria-expanded={isOpen}>
                <span>{it.question[locale] || it.question.en}</span>
                <Icon name="chevron-down" size={16} className="legal-qa-chevron" />
              </button>
              {isOpen && (
                <div className="legal-qa-a">
                  {(it.answer[locale] || it.answer.en).split("\n").map((para, i) => (
                    <p key={i}>{para}</p>
                  ))}
                </div>
              )}
            </div>
          );
        })}
      </div>
    </div>
  );
}

// Reusable sticky header for standalone pages (legal + FAQ)
function LegalStandaloneHeader({ locale, onLocaleChange }) {
  return (
    <header className="legal-sticky-header">
      <div className="legal-sticky-inner">
        <div className="legal-sticky-brand">
          <img src="assets/UFS_Primary_logo.png" alt="UFS" />
          <span>ChefVerse</span>
        </div>
        <div className="legal-sticky-right">
          {onLocaleChange && (
            <div className="legal-locale-dd-wrap">
              <UFSLocaleDropdown
                value={locale}
                onChange={onLocaleChange}
                ariaLabel="Select language"
                options={["en", "de", "id"].map(k => {
                  const o = window.I18N[k];
                  return { value: k, flag: o.flag, label: o.locale.replace(/\s*\(.*\)$/, "") };
                })}
              />
            </div>
          )}
        </div>
      </div>
    </header>
  );
}
window.LegalStandaloneHeader = LegalStandaloneHeader;

function LegalPage({ kind, locale, onBack, onLocaleChange, standalone, faqs }) {
  const tl = LEGAL_I18N[locale] || LEGAL_I18N.en;
  const doc = kind === "privacy" ? tl.privacy : tl.terms;
  
  // Standalone mode: full website-style page with sticky header
  if (standalone) {
    return (
      <div className="legal-page-wrap">
        <header className="legal-sticky-header">
          <div className="legal-sticky-inner">
            <div className="legal-sticky-brand">
              <img src="assets/UFS_Primary_logo.png" alt="UFS" />
              <span>ChefVerse</span>
            </div>
            <div className="legal-sticky-right">
              {onLocaleChange && (
                <div className="legal-locale-dd-wrap">
                  <UFSLocaleDropdown
                    value={locale}
                    onChange={onLocaleChange}
                    ariaLabel="Select language"
                    options={["en", "de", "id"].map(k => {
                      const o = window.I18N[k];
                      return { value: k, flag: o.flag, label: o.locale.replace(/\s*\(.*\)$/, "") };
                    })}
                  />
                </div>
              )}
            </div>
          </div>
        </header>
        <main className="legal-standalone-main">
          <div className="legal-page-container">
            <div className="legal-title-row">
              <h1 className="legal-title">{doc.title}</h1>
              <div className="legal-updated">{tl.updated}</div>
            </div>
            <p className="legal-lead">{doc.lead}</p>
            
            <div className="legal-layout">
              {/* LEFT: sticky table of contents (desktop) */}
              <aside className="legal-toc">
                <details className="legal-toc-details" open={typeof window !== "undefined" ? window.innerWidth > 768 : true}>
                  <summary className="legal-toc-summary">
                    <span className="legal-toc-summary-label">
                      {locale === "de" ? "Inhalt" : locale === "id" ? "Daftar isi" : "Contents"}
                    </span>
                    <Icon name="chevron-down" size={16} className="legal-toc-summary-chevron" />
                  </summary>
                  <nav className="legal-toc-list">
                    {doc.sections.map((s, i) => (
                      <a key={i} href={"#legal-sec-" + i} className="legal-toc-link">
                        <span className="legal-toc-text">{s.h}</span>
                      </a>
                    ))}
                    {/* Common questions link at the end of TOC */}
                    <a href="#legal-common-q" className="legal-toc-link legal-toc-link-qa">
                      <Icon name="help-circle" size={14} className="legal-toc-qa-icon" />
                      <span className="legal-toc-text">
                        {locale === "de" ? "Häufige Fragen" : locale === "id" ? "Pertanyaan umum" : "Common questions"}
                      </span>
                    </a>
                  </nav>
                </details>
              </aside>
              
              {/* RIGHT: legal prose + common questions at the end */}
              <div className="legal-content">
                <div className="legal-body">
                  {doc.sections.map((s, i) => (
                    <section key={i} id={"legal-sec-" + i} className="legal-section">
                      <h2 className="legal-h2">{s.h}</h2>
                      <p className="legal-p">{s.p}</p>
                    </section>
                  ))}
                </div>
                
                {/* Common questions at the END of the page */}
                <div id="legal-common-q">
                  <LegalQuickAnswers kind={kind} locale={locale} faqs={faqs} />
                </div>
                
                <div className="legal-foot">
                  <p className="subtle">© 2026 Unilever Food Solutions. ChefVerse pilot.</p>
                </div>
              </div>
            </div>
          </div>
        </main>
      </div>
    );
  }
  
  // In-app mode (back to previous in-app screen)
  return (
    <div className="page page-legal">
      <div className="legal-head">
        <button className="link-btn legal-back" onClick={onBack}>
          <Icon name="chevron-left" size={16} /> {tl.back}
        </button>
        <div className="legal-updated">{tl.updated}</div>
      </div>
      <h1 className="legal-title">{doc.title}</h1>
      <p className="legal-lead">{doc.lead}</p>
      <div className="legal-body">
        {doc.sections.map((s, i) => (
          <section key={i} className="legal-section">
            <h2 className="legal-h2">{s.h}</h2>
            <p className="legal-p">{s.p}</p>
          </section>
        ))}
      </div>
      <div className="legal-foot">
        <p className="subtle">© 2026 Unilever Food Solutions. ChefVerse pilot.</p>
      </div>
    </div>
  );
}

window.LegalPage = LegalPage;
window.LEGAL_I18N = LEGAL_I18N;
