/* global React, Nav, Footer, useReveal */

const LEGAL = {
  privacy: {
    eyebrow: "Legal",
    title: "Privacy Policy.",
    updated: "Last updated 18 May 2026",
    lede: "How Rose Family Properties Ltd collects, uses and protects the information you share with us.",
    sections: [
    {
      h: "1. Who we are",
      p: ["Rose Family Properties Ltd is a Chester-based property development and investment company (\"we\", \"us\", \"our\"). For the purposes of UK GDPR and the Data Protection Act 2018 we are the data controller for the personal information described in this notice.",
      "If you have any questions about this policy or want to exercise any of your rights, please get in touch via the contact details on our home page."]
    },
    {
      h: "2. What we collect",
      p: ["We only collect information that helps us do business well: your name, contact details, and information about a property you've asked us to look at or that you've offered to sell. If you fill in our Sell Your Property form we'll receive what you typed into it. If you email us, we'll have the contents of your email and any reply thread."]
    },
    {
      h: "3. How we use it",
      p: ["We use your information to reply to enquiries, to assess properties offered to us, to keep accurate records of the deals we do, and to comply with anti-money-laundering, tax and other legal obligations. We don't sell your information to anyone. We don't use it to target you with marketing from third parties.",
      "Where we rely on consent (for example for occasional updates about our work), you can withdraw it at any time."]
    },
    {
      h: "4. How long we keep it",
      p: ["We keep records for as long as we need them for the purpose we collected them, or for as long as the law tells us to. For most enquiries that's around two years. For completed transactions, tenancies and accounting records it can be six years or more."]
    },
    {
      h: "5. Who sees it",
      p: ["The only people who see your information are Rose Family Properties. Where we use software providers (for email, document storage, accounting), those providers act on our instructions under a data-processing agreement.",
      "Some of these providers may store data outside the UK. Where they do, we make sure appropriate safeguards are in place."]
    },
    {
      h: "6. Your rights",
      p: ["You have the right to ask us what we hold about you, to correct it if it's wrong, to ask us to delete it (within the limits the law allows us), to object to certain processing, and to receive a copy of it in a portable format."]
    }]

  },

  cookies: {
    eyebrow: "Legal",
    title: "Cookies Policy.",
    updated: "Last updated 18 May 2026",
    lede: "A short, plain-language explanation of how cookies are (and aren't) used on this website.",
    sections: [
    {
      h: "1. What cookies are",
      p: ["Cookies are small text files that a website can store on your device. They're how a site remembers things between visits - what language you wanted, whether you're signed in, what was in your basket. Some are essential to the site working. Others exist so the site can measure how it's being used or so advertisers can follow you around the internet."]
    },
    {
      h: "2. What this site uses",
      p: ["This is a brochure site. It exists so people can read about our work and get in touch. We don't run an account system, a shop or a tracking pixel. As a result the cookies on this site are minimal and limited to the essential category - they remember things like your preferences during a single browsing session.",
      "We do not use third-party advertising cookies. We do not share browsing data with social networks. We do not build a profile of you for marketing purposes."]
    },
    {
      h: "3. Analytics",
      p: ["From time to time we may use a privacy-respecting analytics tool to understand which pages get read and which don't. Where we do, the data is aggregated, IP addresses are truncated and no individual visitor is identifiable. We will update this notice if we add anything that goes beyond that."]
    },
    {
      h: "4. Managing cookies",
      p: ["You can clear and block cookies through your browser's settings. Doing so will not break this site. If you reach the site via a link in an email or social post, the originating platform may add its own tracking parameters to the URL; those are outside our control and not stored by us once you've landed here."]
    }]

  },

  acceptable: {
    eyebrow: "Legal",
    title: "Acceptable Use.",
    updated: "Last updated 18 May 2026",
    lede: "The handful of common-sense rules that apply when you use this website.",
    sections: [
    {
      h: "1. Reading the site",
      p: ["You're welcome to browse, link to and quote from this site for personal, non-commercial purposes. We ask that any quotation is short and properly credited, and that links go to the original page rather than passing our content off as your own."]
    },
    {
      h: "2. Contacting us",
      p: ["When you use the contact form or any of the email addresses on this site, please tell us the truth, use your own details, and don't pretend to be someone else. Don't send us unsolicited marketing, automated messages or anything illegal."]
    },
    {
      h: "3. What you must not do",
      p: ["You must not use this site in a way that breaks any law, breaches anyone's rights, or interferes with how the site works. That includes attempting to gain unauthorised access to any part of the site or the servers it runs on, introducing malicious code, harvesting data, or putting an unreasonable load on the site through automated requests.",
      "If you do any of these things we'll cooperate fully with law enforcement and, where appropriate, pursue civil remedies."]
    },
    {
      h: "4. Content you provide",
      p: ["Anything you send us - by form, email or otherwise - should be your own to send. By sending it you give us permission to use it for the purpose you sent it for (typically: looking at a property, replying to your enquiry, considering a working relationship). It should not be defamatory, obscene, or infringe anyone else's intellectual property."]
    }]

  },

  terms: {
    eyebrow: "Legal",
    title: "Terms of Use.",
    updated: "Last updated 18 May 2026",
    lede: "The terms on which we make this website available to you.",
    sections: [
    {
      h: "1. About these terms",
      p: ["By using rosefamilyproperties.co.uk you agree to these terms. If you don't accept them, please don't use the site. We may update the terms from time to time; the version published here is always the one in force."]
    },
    {
      h: "2. About the site",
      p: ["This site is provided free of charge as a window into our work. The information on it - including property descriptions, photographs and figures - is given in good faith and believed accurate at the time of publication. It is not a formal offer, prospectus or financial promotion, and it should not be relied upon for any investment decision.",
      "Nothing on this site constitutes legal, tax, financial or property-investment advice. If you are considering a transaction with us or anyone else, take your own professional advice first."]
    },
    {
      h: "3. Intellectual property",
      p: ["The site's design, text, photographs, logo, name and brand belong to Rose Family Properties Ltd or are used under licence. You may not copy, republish or use them commercially without our written permission. The Rose Family Properties name and logo are not to be used in a way that suggests endorsement, partnership or agency that doesn't exist."]
    },
    {
      h: "4. Links to other sites",
      p: ["Where we link to third-party sites we do so for convenience. We don't control those sites and we're not responsible for their content or for what they do with your data. Following a link is at your own discretion."]
    },
    {
      h: "5. Liability",
      p: ["To the extent permitted by law, we exclude liability for any loss or damage arising from your use of the site or from your reliance on its contents. Nothing in these terms excludes or limits our liability for death or personal injury caused by negligence, for fraud, or for anything else that cannot be excluded by law."]
    },
    {
      h: "6. Governing law",
      p: ["These terms are governed by the laws of England and Wales. Any dispute arising out of or in connection with them or this site is subject to the exclusive jurisdiction of the English courts."]
    }]

  }
};

function LegalPage({ slug, onNavigate }) {
  useReveal();
  const doc = LEGAL[slug] || LEGAL.privacy;

  return (
    <div>
      <Nav route={null} onNavigate={onNavigate} mode="light" />
      <header className="legal-hero">
        <div className="legal-hero__inner">
          <div className="legal-hero__crumb" onClick={() => onNavigate("home")}>
            ← Back to Rose Family Properties
          </div>
          <div className="eyebrow">{doc.eyebrow}</div>
          <h1 className="legal-hero__title">{doc.title}</h1>
          <p className="legal-hero__lede">{doc.lede}</p>
          <div className="legal-hero__updated">{doc.updated}</div>
        </div>
      </header>

      <section className="legal-body">
        <div className="legal-body__inner">
          <aside className="legal-toc" aria-label="On this page">
            <div className="legal-toc__label">On this page</div>
            <ul>
              {doc.sections.map((s) =>
              <li key={s.h}>
                  <a href={"#" + slugify(s.h)} onClick={(e) => {
                  e.preventDefault();
                  const el = document.getElementById(slugify(s.h));
                  if (el) window.scrollTo({ top: el.offsetTop - 100, behavior: "smooth" });
                }}>
                    {s.h}
                  </a>
                </li>
              )}
            </ul>
            <div className="legal-toc__sibling">
              <div className="legal-toc__label">Also</div>
              <ul>
                {Object.entries(LEGAL).
                filter(([k]) => k !== slug).
                map(([k, v]) =>
                <li key={k}>
                      <a href="#" onClick={(e) => {e.preventDefault();onNavigate(k);}}>
                        {v.title.replace(".", "")}
                      </a>
                    </li>
                )}
              </ul>
            </div>
          </aside>

          <article className="legal-prose">
            {doc.sections.map((s) =>
            <section key={s.h} id={slugify(s.h)}>
                <h2>{s.h}</h2>
                {s.p.map((para, i) => <p key={i}>{para}</p>)}
              </section>
            )}
          </article>
        </div>
      </section>

      <Footer onNavigate={onNavigate} />
    </div>);

}

function slugify(s) {
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
}

Object.assign(window, { LegalPage, LEGAL });
