/**
 * Legal documents are maintained in English only; the English text is the
 * authoritative version (a localized notice says so on the page). Keeping
 * legal copy out of the i18n catalogues avoids meaning drift in translation.
 *
 * TODO before launch: confirm the operator/legal-entity details below.
 */

export interface LegalSection {
  heading: string;
  paragraphs: string[];
  bullets?: string[];
}

export interface LegalDoc {
  title: string;
  metaDescription: string;
  lastUpdated: string;
  intro: string[];
  sections: LegalSection[];
}

export const SUPPORT_EMAIL = 'support@perfect-postcode.co.uk';

export const TERMS: LegalDoc = {
  title: 'Terms of Service',
  metaDescription:
    'The terms that govern your use of Perfect Postcode, including lifetime access, acceptable use, data accuracy, payments and refunds.',
  lastUpdated: '10 June 2026',
  intro: [
    `These terms govern your use of perfect-postcode.co.uk ("Perfect Postcode", "the service", "we", "us"). By creating an account or purchasing access you agree to them. If you have any questions, contact ${SUPPORT_EMAIL}.`,
  ],
  sections: [
    {
      heading: '1. The service',
      paragraphs: [
        'Perfect Postcode is a research tool that combines public datasets about England — property transactions, energy certificates, schools, crime, noise, broadband, transport and more — on an interactive map, so you can shortlist areas that fit your needs before booking viewings.',
        'We are not an estate agent, mortgage broker, surveyor or financial adviser, and the service does not provide financial, legal or investment advice.',
      ],
    },
    {
      heading: '2. Accounts',
      paragraphs: [
        'You need an account to use the service beyond the free demo area. Provide a valid email address, keep your credentials secure, and do not share your account. Accounts are for one person each.',
        'We may suspend or close accounts that breach these terms, abuse the service, or attempt to circumvent access restrictions. If we close your account without cause, we will refund the price you paid.',
      ],
    },
    {
      heading: '3. Free demo and lifetime access',
      paragraphs: [
        'Free accounts can explore all features within the demo area (inner London). Lifetime access is a one-time payment that gives your account ongoing access to the paid map — every postcode, every filter — for as long as the service runs. It is not a subscription, and routine data updates are included.',
        'Lifetime access is personal and non-transferable, and is for personal, non-commercial property research. If you would like to use Perfect Postcode commercially (for example in lettings, relocation or research services), contact us first.',
      ],
    },
    {
      heading: '4. Acceptable use',
      paragraphs: ['You agree not to:'],
      bullets: [
        'scrape, crawl or bulk-download data outside the export tools we provide;',
        'resell, republish or redistribute the data or substantial extracts of it;',
        'probe, disrupt or place unreasonable load on the service;',
        'use the AI search or other features to process content you have no right to submit.',
      ],
    },
    {
      heading: '5. Data accuracy',
      paragraphs: [
        'The maps and figures are built from public datasets (HM Land Registry, EPC register, ONS, Ofsted, DfT, police.uk and others) combined with modelling and estimation. Sources can be incomplete, out of date or wrong at the level of an individual property, and our estimates — including estimated current prices — are statistical indications, not valuations.',
        'Always verify anything that matters in person and through professional advice (surveys, solicitors, mortgage advisers) before making offers or financial decisions. We provide the service "as is" and do not warrant that any figure is accurate, complete or current.',
      ],
    },
    {
      heading: '6. Payments and refunds',
      paragraphs: [
        'Payments are processed by Stripe; we never see or store your card details. Prices are shown in pounds sterling at checkout. Early-access pricing tiers can change as tiers fill; the price shown at the moment you pay is the price you get.',
        `If Perfect Postcode is not for you, email ${SUPPORT_EMAIL} within 14 days of purchase and we will refund you in full.`,
      ],
    },
    {
      heading: '7. Third-party content',
      paragraphs: [
        'Street View imagery, listing-portal links and similar embedded content are provided by third parties and governed by their own terms. We are not responsible for their availability or accuracy.',
      ],
    },
    {
      heading: '8. Liability',
      paragraphs: [
        'To the extent permitted by law, we are not liable for decisions made in reliance on the data, for indirect or consequential losses, or for interruptions to the service; our total liability to you is limited to the amount you paid us. Nothing in these terms excludes liability that cannot legally be excluded, and nothing affects your statutory rights as a consumer.',
      ],
    },
    {
      heading: '9. Changes to the service or these terms',
      paragraphs: [
        'We are a small product that improves continuously; features and data sources may change. We may update these terms, and will note the date of the latest revision above. If a change is material we will flag it on the site or by email. Continued use after a change means you accept the updated terms.',
      ],
    },
    {
      heading: '10. Governing law and contact',
      paragraphs: [
        `These terms are governed by the law of England and Wales, and disputes are subject to the jurisdiction of the courts of England and Wales (consumers keep any mandatory protections of their country of residence). Questions and complaints: ${SUPPORT_EMAIL} — we typically respond within 24 hours.`,
      ],
    },
  ],
};

export const PRIVACY: LegalDoc = {
  title: 'Privacy Policy',
  metaDescription:
    'How Perfect Postcode collects, uses and protects your data: account details, payments, saved searches, AI queries, analytics and your UK GDPR rights.',
  lastUpdated: '10 June 2026',
  intro: [
    `This policy explains what personal data Perfect Postcode ("we", "us") collects, why, and your rights over it. We handle personal data under UK data-protection law (UK GDPR and the Data Protection Act 2018). Contact: ${SUPPORT_EMAIL}.`,
  ],
  sections: [
    {
      heading: '1. What we collect',
      paragraphs: [],
      bullets: [
        'Account data: your email address, a hashed password (or your Google account identifier if you sign in with Google), newsletter preference and access status.',
        'Purchase records: what you bought and when. Payments are processed by Stripe; we never receive your card details.',
        'Things you create: saved searches, shared links and their settings.',
        'AI search queries: the text you type into the AI search is processed to generate filters and logged with your account so we can debug and improve the feature.',
        'Usage data: which pages and features are used, collected as events for product analytics, and standard server logs (IP address, user agent) kept for security.',
      ],
    },
    {
      heading: '2. How we use it',
      paragraphs: [],
      bullets: [
        'To provide and secure the service, including signing you in and remembering your saved work (performance of contract).',
        'To process payments and keep the records tax law requires (legal obligation).',
        'To answer support requests (performance of contract).',
        'To send the newsletter, only if you opted in — every email includes an unsubscribe link (consent).',
        'To understand how features are used and improve them, using aggregated analytics and logged AI queries (legitimate interests).',
      ],
    },
    {
      heading: '3. Who we share it with',
      paragraphs: [
        'We do not sell personal data. We use a small number of processors to run the service:',
      ],
      bullets: [
        'Stripe — payment processing.',
        'Google — sign-in (if you choose Google OAuth), embedded Maps/Street View imagery, and the Gemini API which processes the text of AI searches.',
        'Hosting and infrastructure providers that run our servers and store backups.',
      ],
    },
    {
      heading: '4. International transfers',
      paragraphs: [
        'Some processors (such as Stripe and Google) process data outside the UK. Where that happens, transfers rely on UK adequacy decisions or standard contractual clauses.',
      ],
    },
    {
      heading: '5. Cookies and local storage',
      paragraphs: [
        'We do not use advertising cookies or third-party trackers. Your browser’s local storage holds your sign-in token and preferences (theme, language, tutorial progress, last map view). Embedded Google content (Street View, sign-in) may set its own cookies under Google’s policies.',
      ],
    },
    {
      heading: '6. Retention',
      paragraphs: [
        'Account data is kept while your account exists and deleted when you ask us to close it. Server logs are kept for a short period for security. Purchase records are kept for as long as tax law requires (typically six years).',
      ],
    },
    {
      heading: '7. Your rights',
      paragraphs: [
        `You can ask for a copy of your data, have it corrected or deleted, restrict or object to processing, and receive your data in a portable format. Email ${SUPPORT_EMAIL} and we will respond promptly. If you are unhappy with how we handle your data you can complain to the Information Commissioner’s Office (ico.org.uk).`,
      ],
    },
    {
      heading: '8. Children',
      paragraphs: [
        'The service is aimed at home buyers and renters and is not directed at children under 16.',
      ],
    },
    {
      heading: '9. Changes to this policy',
      paragraphs: [
        'We will post any changes here and update the date at the top. Material changes will be flagged on the site or by email.',
      ],
    },
  ],
};
