import type { Metadata } from "next";
import { PageHero } from "@/components/PageHero";
import { LegalContents } from "@/components/legal/LegalContents";
import { site } from "@/lib/site";

const description = `Read what information ${site.name} may collect, how it may be used, and the choices available to you.`;

export const metadata: Metadata = {
  title: "Privacy Policy",
  description,
  openGraph: { title: `Privacy Policy | ${site.name}`, description },
  twitter: { title: `Privacy Policy | ${site.name}`, description },
};

type PrivacySection = {
  id: string;
  heading: string;
  intro: readonly string[];
  bullets?: readonly string[];
  outro?: readonly string[];
  email?: string;
};

const domain = site.domain.toLowerCase();

const sections: readonly PrivacySection[] = [
  {
    id: "introduction",
    heading: "Introduction",
    intro: [
      `${site.name} (\u201Cwe,\u201D \u201Cour,\u201D or \u201Cus\u201D) respects your privacy and is committed to protecting your personal information. Privacy is of great importance at ${site.name}. Our Privacy Policy provides information on what data may be collected during your visits to our website, as well as the ways it may be used and what options are available to you.`,
      `Using the ${site.name} website and our services means that you accept our Privacy Policy practices.`,
    ],
  },
  {
    id: "information-we-collect",
    heading: "Information We Collect",
    intro: [
      `The data that we obtain is dependent on the way in which you use the ${site.name} website. You may choose to provide us with data yourself, such as when you:`,
    ],
    bullets: [
      `Join a ${site.name} mailing list or early access list`,
      "Provide information using a website form",
      "Contact us with a query or request for assistance",
    ],
    outro: [
      "The type of data obtained could include your name and email address, among others, depending on the website form used or interaction.",
    ],
  },
  {
    id: "automatically-collected-data",
    heading: "Automatically Collected Data",
    intro: [
      "During your visit to the website, certain technical and usage data will be automatically collected. This type of data collected may include the following:",
    ],
    bullets: [
      "IP Address",
      "Web Browser and Device Data",
      "Operating System",
      "Pages Visited and Website Interactions",
      "General Usage and Performance Data",
      "Website Activity Date and Time",
    ],
    outro: [
      "This data may be collected using cookies and other similar technologies. See our Cookie Policy for further details.",
    ],
  },
  {
    id: "how-we-use-your-information",
    heading: "How We Use Your Information",
    intro: [
      `The information gathered from the ${site.name} website can be used to:`,
    ],
    bullets: [
      "Enable and support the functioning of the website",
      "Answer any questions and queries",
      "Manage website registrations and submissions",
      "Enhance website content and user experience",
      "Analyze the behavior of users on the website",
      "Track website performance and security",
      "Determine and address any misuse or problems with the website",
      `Communicate any information about your interaction with the ${site.name} website`,
    ],
    outro: [
      "We will only use information for legitimate reasons related to its collection and associated services/functions.",
    ],
  },
  {
    id: "how-we-protect-information",
    heading: "How We Protect Information",
    intro: [
      "We have taken reasonable precautions to safeguard information from any form of unauthorized access, use, modification, or disclosure.",
      "But it is impossible to ensure complete security of any website, online service, or system for transmitting information electronically. Be careful with the information you transmit online.",
    ],
  },
  {
    id: "how-we-share-information",
    heading: "How We Share Information",
    intro: [
      "Personal information will not be disclosed to any third parties, except where such disclosure is required for the operation of the website, delivery of requested services, compliance with laws, protection of our rights or other legitimate business purposes.",
      "Third-party service providers that we may use in connection with our website may process information on our behalf under their terms and policies.",
    ],
  },
  {
    id: "your-choices",
    heading: "Your Choices",
    intro: [
      `In accordance with the nature of your interaction with ${site.name}, you might have different options relating to the information that you are providing us.`,
      "For example, you can opt-in to provide information by using optional website forms. You might also have the ability to manage some of your communications or cookies using the options on the website.",
      "Options in privacy rights can differ according to your location.",
    ],
  },
  {
    id: "third-party-websites",
    heading: "Third-Party Websites",
    intro: [
      `${site.name} might have links to websites or services that are operated by third parties.`,
      "The current Privacy Policy is only applicable to our site and not to those third-party sites. Their privacy policies will be applicable, and we advise you to read them first before sharing any information with them.",
    ],
  },
  {
    id: "updates-to-this-privacy-policy",
    heading: "Updates to This Privacy Policy",
    intro: [
      "We reserve the right to update this Privacy Policy at any time due to changes in our website, service, information handling practices, or other requirements. When we do so, we will update the Last updated date at the top of this page.",
    ],
  },
  {
    id: "contact-us",
    heading: "Contact Us",
    intro: [
      `If you have questions about this Privacy Policy or how ${site.name} handles information, please contact us at:`,
    ],
    email: `privacy@${domain}`,
  },
];

export default function PrivacyPolicyPage() {
  return (
    <>
      <PageHero
        title="Our Privacy"
        accent="Policy"
        lead={
          <>
            Last updated: September 30, 2026
            <br className="d-none d-md-block" />
            This Privacy Policy explains what information may be collected when
            you visit the {site.name} website, how that information may be used,
            and the choices available to you.
          </>
        }
      />

      <section className="webContent py-4 py-lg-5">
        <div className="container">
          <div className="row g-4 g-xl-5">
            <div className="d-none d-lg-block col-12 col-lg-4 col-xl-3">
              <LegalContents
                sections={sections.map(({ id, heading }) => ({
                  id,
                  heading,
                  body: [],
                }))}
              />
            </div>

            <div className="col-12 col-lg-8 col-xl-9">
              {sections.map((section) => (
                <article className="legal-section" id={section.id} key={section.id}>
                  {(() => {
                    const bullets = section.bullets;
                    return (
                      <>
                  <div className="legal-section-head">
                    <h2 className="text-xl fw-600 mb-0">{section.heading}</h2>
                  </div>
                  {section.intro.map((paragraph, index) => (
                    <p className="text-md fw-400 mb-0" key={`${section.id}-intro-${index}`}>
                      {paragraph}
                    </p>
                  ))}
                  {bullets ? (
                    <ul className="legal-list text-md fw-400">
                      {bullets.map((item, index) => (
                        <li key={`${section.id}-bullet-${index}`}>{item}</li>
                      ))}
                    </ul>
                  ) : null}
                  {section.outro?.map((paragraph, index) => (
                    <p className="text-md fw-400 mb-0" key={`${section.id}-outro-${index}`}>
                      {paragraph}
                    </p>
                  ))}
                  {section.email ? (
                    <p className="text-md fw-400 mb-0">
                      <a href={`mailto:${section.email}`}>{section.email}</a>
                    </p>
                  ) : null}
                      </>
                    );
                  })()}
                </article>
              ))}
            </div>
          </div>
        </div>
      </section>
    </>
  );
}
