// ─────────────────────────────────────────────────────────────
// legal-content.jsx — copy for the four ComposerOS legal pages.
//
// ⚠ DRAFT COPY. Written composer-friendly from the product brief
// (local-first, optional V1.5 cloud, API keys in Keychain, Anthropic
// as a subprocessor, data ownership). Have counsel review before
// publishing. Structure is data-driven so copy edits never touch layout.
//
// Block types the renderer understands:
//   {t:'p',  html}                     paragraph (may contain <strong>/<em>/<a>)
//   {t:'lead', term, html}             bold lead-in term + sentence
//   {t:'ul', items:[html…]}            bullet list
//   {t:'quote', html}                  emphasis blockquote (moss rule)
//   {t:'h3', text}                     sub-heading inside a section
// ─────────────────────────────────────────────────────────────

const LEGAL_UPDATED = 'June 16, 2026';
const SEC_EMAIL = 'security@composeros.studio';
const HELLO_EMAIL = 'hello@composeros.studio';

const mail = (e) => `<a href="mailto:${e}">${e}</a>`;

// ── 1 · PRIVACY ──────────────────────────────────────────────
const PRIVACY = {
  key: 'privacy',
  eyebrow: 'Legal · Privacy',
  title: ['Privacy ', 'Policy'],
  updated: LEGAL_UPDATED,
  intro: `ComposerOS is built local-first: your work lives on your Mac, not on our servers. This policy explains, in plain language, what that means for your data — what stays on your machine, what (optionally) syncs, and the few things we ever see.`,
  sections: [
    { id:'principle', title:'The short version', blocks:[
      { t:'quote', html:'Composers own their data. ComposerOS is a tool you run, not a service that holds your work hostage.' },
      { t:'p', html:'Your cues, sessions, contacts, invoices, and notes are stored on your own device. We do not have a copy. We cannot read them. If you never turn on optional cloud sync, your creative data never leaves your Mac through ComposerOS at all.' },
    ]},
    { id:'what-we-store', title:'What stays on your device', blocks:[
      { t:'p', html:'Effectively everything you create in the app. ComposerOS uses a <strong>local database</strong> on your machine for:' },
      { t:'ul', items:[
        'Projects, cues, spotting notes, and revisions',
        'Sessions, bookings, and contractor details',
        'Contacts, tasks, calendar items, and documents',
        'Invoicing, splits, and PRO/society information you enter',
        'App preferences and window layouts',
      ]},
      { t:'p', html:'This data is yours. You can export it, back it up with your own Time Machine or drive, and delete it at any time by removing the app data — no request to us required.' },
    ]},
    { id:'api-keys', title:'API keys: your choice', blocks:[
      { t:'lead', term:'You bring your own key.', html:'Aria, the assistant in ComposerOS, runs on Anthropic\u2019s Claude. To use it you provide your own Anthropic API key.' },
      { t:'p', html:'Your key is stored in the <strong>macOS Keychain</strong> — the same encrypted vault macOS uses for your passwords. It is not stored in our database, never transmitted to NEMM servers, and never logged. When Aria answers, your Mac talks to Anthropic directly using your key.' },
      { t:'p', html:`What you send to Aria (for example, a spotting note you ask it to turn into cues) is processed under <strong>your</strong> agreement with Anthropic. We recommend reading Anthropic\u2019s privacy terms. We do not receive or retain those prompts.` },
    ]},
    { id:'cloud', title:'Optional cloud sync (V1.5)', blocks:[
      { t:'p', html:'ComposerOS today is fully local. A future release (<strong>V1.5</strong>) will add <em>optional</em> cloud sync so you can mirror a project across your own devices. It is off by default and opt-in per project.' },
      { t:'ul', items:[
        '<strong>Opt-in only.</strong> Nothing syncs unless you turn it on.',
        '<strong>Encrypted in transit and at rest.</strong> Synced data is encrypted before it leaves your device.',
        '<strong>Scoped.</strong> You choose which projects sync; the rest stay local.',
        '<strong>Revocable.</strong> Turn it off and remove the cloud copy at any time.',
      ]},
      { t:'p', html:'When V1.5 ships, this policy will be updated with the specific sub-processor and storage region details before the feature is enabled.' },
    ]},
    { id:'what-we-see', title:'What we actually see', blocks:[
      { t:'p', html:'Very little, and only with your consent:' },
      { t:'lead', term:'Waitlist & contact.', html:'If you email us or join the waitlist, we receive what you send — your name, email, and message — so we can reply. That\u2019s handled by our form provider and email, not the app.' },
      { t:'lead', term:'Diagnostics.', html:'If you opt in to send a crash report, it contains technical details about the failure. It does not include your projects or cues. Diagnostics are off unless you choose to share.' },
      { t:'lead', term:'Licensing.', html:'To validate your purchase we process a license check through the Mac App Store / our licensing provider. This confirms entitlement; it does not expose your content.' },
    ]},
    { id:'no-selling', title:'What we never do', blocks:[
      { t:'ul', items:[
        'We do not sell your data. Ever.',
        'We do not use your projects, cues, or prompts to train models.',
        'We do not run third-party advertising or tracking pixels.',
        'We do not build advertising profiles of you.',
      ]},
    ]},
    { id:'your-rights', title:'Your rights', blocks:[
      { t:'p', html:'Because your creative data lives on your device, you already hold it directly — you can access, export, and delete it yourself. For the limited information we do hold (waitlist/contact records), you may request access, correction, or deletion at any time by writing to '+mail(HELLO_EMAIL)+'.' },
      { t:'p', html:'Depending on where you live, you may have additional rights under laws such as the GDPR or PIPEDA. We honour those requests regardless of location.' },
    ]},
    { id:'children', title:'Children', blocks:[
      { t:'p', html:'ComposerOS is a professional tool and is not directed to children under 13 (or the minimum age in your jurisdiction). We do not knowingly collect information from children.' },
    ]},
    { id:'changes', title:'Changes to this policy', blocks:[
      { t:'p', html:'If we change how data is handled — particularly when optional cloud sync arrives — we\u2019ll update this page and the date above. Material changes will be announced in-app or by email where appropriate.' },
    ]},
    { id:'contact', title:'Contact', blocks:[
      { t:'p', html:'Questions about privacy? Write to '+mail(HELLO_EMAIL)+'. For anything security-specific, reach '+mail(SEC_EMAIL)+'.' },
    ]},
  ],
};

// ── 2 · TERMS ────────────────────────────────────────────────
const TERMS = {
  key: 'terms',
  eyebrow: 'Legal · Terms',
  title: ['Terms of ', 'Service'],
  updated: LEGAL_UPDATED,
  intro: `These terms are the agreement between you and NEMM Group Ltd for using ComposerOS. We\u2019ve kept them readable. Using the app means you accept them.`,
  sections: [
    { id:'license', title:'Your licence', blocks:[
      { t:'lead', term:'A licence, not a sale.', html:'When you buy ComposerOS you get a personal, non-exclusive, non-transferable licence to install and use the app on devices you own or control, for your own composing work.' },
      { t:'ul', items:[
        'You may use ComposerOS for personal and commercial composing.',
        'You may not resell, redistribute, sublicense, or rent the app.',
        'You may not reverse-engineer or attempt to extract source code, except where that restriction is prohibited by law.',
        'The app, its name, and its design remain the property of NEMM Group Ltd.',
      ]},
    ]},
    { id:'your-content', title:'Your content is yours', blocks:[
      { t:'quote', html:'We claim no ownership over anything you create in ComposerOS. Your music, cues, and project data belong to you.' },
      { t:'p', html:'You are responsible for your own content and for having the rights to any material you bring into the app. Because your data is stored locally, keeping your own backups is your responsibility.' },
    ]},
    { id:'third-party', title:'Third-party services', blocks:[
      { t:'lead', term:'Aria runs on Anthropic.', html:'Aria\u2019s intelligence is provided by Anthropic\u2019s Claude, accessed with your own API key. Your use of Aria is also subject to Anthropic\u2019s terms and usage policies.' },
      { t:'p', html:'We don\u2019t control Anthropic\u2019s service, availability, pricing, or output, and we\u2019re not responsible for it. Aria can make mistakes — always review its output before relying on it for deliverables, contracts, or financial decisions.' },
      { t:'p', html:'ComposerOS may also rely on Apple services (the Mac App Store, Keychain, system frameworks). Your use of those is governed by Apple\u2019s terms.' },
    ]},
    { id:'payment', title:'Payment & refunds', blocks:[
      { t:'p', html:'Purchases made through the Mac App Store are billed and refunded by <strong>Apple</strong> under Apple\u2019s policies — refund requests for App Store purchases go through Apple, not us.' },
      { t:'p', html:'For any purchase made directly from us, contact '+mail(HELLO_EMAIL)+' and we\u2019ll work with you in good faith. You also keep any non-waivable refund rights under your local consumer law.' },
    ]},
    { id:'acceptable-use', title:'Acceptable use', blocks:[
      { t:'p', html:'Use ComposerOS lawfully. Don\u2019t use it to break the law, infringe others\u2019 rights, or attempt to disrupt or compromise the app or the services it connects to.' },
    ]},
    { id:'warranty', title:'Disclaimer of warranties', blocks:[
      { t:'p', html:'ComposerOS is provided <strong>\u201Cas is\u201D</strong> and <strong>\u201Cas available\u201D</strong>, without warranties of any kind, to the fullest extent permitted by law. We don\u2019t warrant that the app will be uninterrupted, error-free, or fit for a particular purpose. Some jurisdictions don\u2019t allow certain disclaimers, so parts of this may not apply to you.' },
    ]},
    { id:'liability', title:'Limitation of liability', blocks:[
      { t:'p', html:'To the maximum extent permitted by law, NEMM Group Ltd is not liable for indirect, incidental, special, or consequential damages, or for lost data, lost profits, or lost work, arising from your use of ComposerOS.' },
      { t:'lead', term:'Keep backups.', html:'Because your work lives on your device, regular backups are the single best protection — and they\u2019re your responsibility.' },
      { t:'p', html:'Where liability cannot be excluded, our total liability is limited to the amount you paid for the app in the 12 months before the claim.' },
    ]},
    { id:'termination', title:'Termination', blocks:[
      { t:'p', html:'You may stop using ComposerOS at any time. We may suspend or end your licence if you materially breach these terms. On termination, your local data remains on your device — ending the licence doesn\u2019t delete your files.' },
    ]},
    { id:'disputes', title:'Governing law & disputes', blocks:[
      { t:'p', html:'These terms are governed by the laws of the Province of British Columbia and the applicable laws of Canada, without regard to conflict-of-laws rules. The courts located in British Columbia will have jurisdiction, subject to any mandatory consumer protections in your home jurisdiction.' },
      { t:'p', html:'Before any formal dispute, please contact us at '+mail(HELLO_EMAIL)+' — most things are resolved with a conversation.' },
    ]},
    { id:'changes', title:'Changes to these terms', blocks:[
      { t:'p', html:'We may update these terms as the product evolves. We\u2019ll revise the date above and, for material changes, give notice in-app or by email. Continuing to use ComposerOS after a change means you accept the updated terms.' },
    ]},
    { id:'contact', title:'Contact', blocks:[
      { t:'p', html:'Questions about these terms? Write to '+mail(HELLO_EMAIL)+'.' },
    ]},
  ],
};

// ── 3 · SECURITY ─────────────────────────────────────────────
const SECURITY = {
  key: 'security',
  eyebrow: 'Legal · Security',
  title: ['Security'],
  updated: LEGAL_UPDATED,
  intro: `Security in ComposerOS starts with a simple architectural choice: keep your work on your machine. Less data in transit and less data on servers means less to protect. Here\u2019s how we handle the rest.`,
  sections: [
    { id:'local-first', title:'Local-first by design', blocks:[
      { t:'quote', html:'The most private data is the data that never leaves your device.' },
      { t:'p', html:'ComposerOS stores your projects in a local database on your Mac. There\u2019s no central server holding your cues and sessions, which removes an entire category of breach risk. Your studio is yours.' },
    ]},
    { id:'keychain', title:'Keychain & credentials', blocks:[
      { t:'lead', term:'Keys live in the Keychain.', html:'Your Anthropic API key is stored in the macOS Keychain — Apple\u2019s hardware-backed, encrypted credential store — not in our database or preferences files.' },
      { t:'p', html:'The key is never transmitted to NEMM, never written to logs, and is used only by your Mac to talk to Anthropic directly. You can remove it from Keychain at any time.' },
    ]},
    { id:'encryption', title:'Encryption', blocks:[
      { t:'ul', items:[
        '<strong>At rest:</strong> your local data sits inside your macOS user account, protected by FileVault when you enable it (strongly recommended).',
        '<strong>In transit:</strong> all network connections the app makes — to Anthropic, to licensing — use TLS.',
        '<strong>Cloud sync (V1.5):</strong> when optional sync arrives, synced data will be encrypted in transit and at rest, with details published before launch.',
      ]},
    ]},
    { id:'permissions', title:'Permissions & sandboxing', blocks:[
      { t:'p', html:'ComposerOS is a sandboxed Mac app and requests only the system permissions it needs to do its job. It asks before touching files, the calendar, or other protected resources, and you can review or revoke any permission in <strong>System Settings → Privacy &amp; Security</strong> at any time.' },
    ]},
    { id:'subprocessors', title:'Third parties we rely on', blocks:[
      { t:'lead', term:'Anthropic', html:'powers Aria, using your own API key. Prompts you send go from your Mac to Anthropic under your agreement with them.' },
      { t:'lead', term:'Apple', html:'provides the Mac App Store, Keychain, and the OS security model the app builds on.' },
      { t:'p', html:'We keep the list of sub-processors deliberately short. New ones — for example, the cloud-sync provider in V1.5 — will be disclosed here before they go live.' },
    ]},
    { id:'incident', title:'Incident response', blocks:[
      { t:'p', html:'If we become aware of a security issue that affects you, we\u2019ll investigate promptly, take steps to contain it, and notify affected users without undue delay where we\u2019re able to identify them, alongside any notifications required by law.' },
      { t:'lead', term:'Found something?', html:'We welcome responsible disclosure. Email '+mail(SEC_EMAIL)+' with details and steps to reproduce. Please give us reasonable time to fix an issue before disclosing it publicly. We\u2019ll credit researchers who want it.' },
    ]},
    { id:'certifications', title:'Certifications & audits', blocks:[
      { t:'p', html:'As an independent studio shipping a local-first Mac app, we don\u2019t currently hold formal certifications such as SOC 2 — there\u2019s no multi-tenant cloud holding your data to certify. As ComposerOS introduces cloud features, we\u2019ll pursue and publish the appropriate independent assessments. We\u2019re happy to discuss our practices with enterprise customers directly.' },
    ]},
    { id:'your-part', title:'Your part', blocks:[
      { t:'ul', items:[
        'Turn on <strong>FileVault</strong> so your disk is encrypted at rest.',
        'Keep <strong>regular backups</strong> (Time Machine or a drive) — your data is local.',
        'Keep macOS and ComposerOS up to date.',
        'Protect your Anthropic API key like a password.',
      ]},
    ]},
    { id:'contact', title:'Contact', blocks:[
      { t:'p', html:'Security questions or reports: '+mail(SEC_EMAIL)+'. General questions: '+mail(HELLO_EMAIL)+'.' },
    ]},
  ],
};

// ── 4 · COOKIES ──────────────────────────────────────────────
const COOKIES = {
  key: 'cookies',
  eyebrow: 'Legal · Cookies',
  title: ['Cookie ', 'Policy'],
  updated: LEGAL_UPDATED,
  intro: `Short version: the ComposerOS app doesn\u2019t use cookies. It\u2019s a native Mac app, not a website that tracks you. Here\u2019s the slightly longer version.`,
  sections: [
    { id:'app', title:'The app uses no cookies', blocks:[
      { t:'quote', html:'No cookies. No tracking pixels. No advertising identifiers.' },
      { t:'p', html:'ComposerOS is a native macOS application. It doesn\u2019t run a browser engine to serve you content, and it doesn\u2019t set cookies or use cross-site trackers. Your settings are saved on your own device, not in a cookie.' },
    ]},
    { id:'local-storage', title:'Local storage instead', blocks:[
      { t:'p', html:'Where a website would use cookies, ComposerOS uses ordinary on-device storage:' },
      { t:'ul', items:[
        '<strong>App preferences</strong> — your settings and layout, stored in standard macOS preferences.',
        '<strong>Your data</strong> — projects and cues in the local database described in our Privacy Policy.',
        '<strong>Credentials</strong> — your API key in the macOS Keychain.',
      ]},
      { t:'p', html:'None of this is shared across sites or sent to us. It exists only to make the app remember your work and preferences.' },
    ]},
    { id:'website', title:'This website', blocks:[
      { t:'p', html:'The composeros.studio marketing site aims to stay essentially cookie-free. It uses no advertising or cross-site tracking cookies. If we ever add a strictly necessary cookie (for example, to remember a preference), we\u2019ll describe it here first.' },
      { t:'p', html:'When you join the waitlist or contact us, the form provider may set a strictly-necessary cookie to process your submission and prevent spam. That\u2019s used only to deliver your message.' },
    ]},
    { id:'third-party', title:'Apple & Anthropic', blocks:[
      { t:'lead', term:'Apple', html:'When you buy or download through the Mac App Store, Apple\u2019s own systems and policies apply to that transaction.' },
      { t:'lead', term:'Anthropic', html:'When Aria contacts Anthropic with your API key, that connection is governed by Anthropic\u2019s policies. We don\u2019t place cookies on their behalf.' },
      { t:'p', html:'These third parties operate under their own privacy and cookie policies, which we encourage you to read.' },
    ]},
    { id:'choices', title:'Your choices', blocks:[
      { t:'p', html:'Because the app sets no cookies, there\u2019s nothing to opt out of inside ComposerOS. In your browser, you can clear or block cookies for composeros.studio at any time without affecting the app.' },
    ]},
    { id:'contact', title:'Contact', blocks:[
      { t:'p', html:'Questions about cookies or tracking? Write to '+mail(HELLO_EMAIL)+'.' },
    ]},
  ],
};

window.LEGAL_PAGES = { privacy: PRIVACY, terms: TERMS, security: SECURITY, cookies: COOKIES };
window.LEGAL_META = { updated: LEGAL_UPDATED, secEmail: SEC_EMAIL, helloEmail: HELLO_EMAIL };
