import { ParallaxHero } from "@/components/ParallaxHero";
import { getPageContent } from "@/content/pages";
import { siteConfig } from "@/lib/content";
import type { Metadata } from "next";
import Link from "next/link";
import type { ReactNode } from "react";

const page = getPageContent("privacy");
const LAST_UPDATED = page?.lastUpdated || "August 12, 2026";

function Section({
  id,
  title,
  children,
}: {
  id: string;
  title: string;
  children: ReactNode;
}) {
  return (
    <section
      id={id}
      className="scroll-mt-28 border-t border-[var(--color-border)] pt-10"
    >
      <h2 className="mb-5 text-[11px] font-medium uppercase tracking-[0.3em] text-[var(--color-text-muted)]">
        {title}
      </h2>
      <div className="space-y-4 text-[15px] leading-relaxed text-[var(--color-text)]">
        {children}
      </div>
    </section>
  );
}

function BulletList({ items }: { items: ReactNode[] }) {
  return (
    <ul className="space-y-3">
      {items.map((item, i) => (
        <li key={i} className="flex gap-3">
          <span
            className="mt-2 h-1 w-1 shrink-0 rounded-full bg-[var(--color-heading)]"
            aria-hidden
          />
          <span>{item}</span>
        </li>
      ))}
    </ul>
  );
}

export default function PrivacyPage() {
  const email = siteConfig.contactEmail || "contact@jenado-unlimited.com";
  const phone = siteConfig.contactPhone;
  const name = siteConfig.name;

  return (
    <>
      <ParallaxHero
        image={page?.heroImage || "/images/hero-privacy.jpg"}
        alt={
          page?.heroAlt ||
          "Layered translucent glass panes with soft light, suggesting clarity and protection"
        }
        size={page?.heroSize || "sm"}
        priority={page?.heroPriority}
        align={page?.heroAlign}
        overlayClassName={
          page?.heroOverlay ||
          "bg-gradient-to-r from-black/85 via-black/60 to-black/35"
        }
        contentClassName={page?.heroContentClass}
      >
        <div className="max-w-2xl">
          <p className="mb-4 text-[11px] font-medium uppercase tracking-[0.3em] text-white/65">
            {page?.heroLabel}
          </p>
          <h1 className="mb-5 text-4xl font-semibold tracking-[-0.03em] text-white md:text-5xl">
            {page?.title}
          </h1>
          <p className="max-w-xl text-lg leading-relaxed text-white/80">
            {page?.heroDescription}
          </p>
        </div>
      </ParallaxHero>

      <section className="py-16 md:py-24">
        <div className="container-xl max-w-2xl">
          <p className="mb-4 text-sm text-[var(--color-text-muted)]">
            Last updated: {LAST_UPDATED}
          </p>

          <nav
            aria-label="Privacy policy sections"
            className="mb-12 border border-[var(--color-border)] bg-[var(--color-surface)] p-6"
          >
            <p className="mb-4 text-[11px] font-medium uppercase tracking-[0.25em] text-[var(--color-text-muted)]">
              On this page
            </p>
            <ol className="grid gap-2 text-sm text-[var(--color-text-muted)] sm:grid-cols-2">
              {[
                ["who-we-are", "Who we are"],
                ["scope", "Scope"],
                ["information-we-collect", "Information we collect"],
                ["how-we-use", "How we use information"],
                ["legal-bases", "Legal bases"],
                ["sharing", "How we share information"],
                ["cookies", "Cookies & analytics"],
                ["retention", "Data retention"],
                ["security", "Security"],
                ["your-rights", "Your rights"],
                ["children", "Children’s privacy"],
                ["changes", "Changes to this policy"],
                ["contact", "Contact us"],
              ].map(([id, label]) => (
                <li key={id}>
                  <a
                    href={`#${id}`}
                    className="underline-offset-4 hover:text-[var(--color-heading)] hover:underline"
                  >
                    {label}
                  </a>
                </li>
              ))}
            </ol>
          </nav>

          <div className="space-y-12">
            <p className="text-base leading-relaxed text-[var(--color-text)] md:text-lg">
              {name} (“we,” “us,” or “our”) respects your privacy. This Privacy
              Policy describes what information we collect when you use our
              website, how we use it, when we share it, and the choices
              available to you. By using our website, you agree to the practices
              described here. If you do not agree, please do not use the site.
            </p>

            <Section id="who-we-are" title="1. Who we are">
              <p>
                {name} is a multi-vertical brand offering products and services
                related to mind, body, and soul — including local honey and bee
                products, personal training, artisan sourdough, farm-to-table
                experiences, recreation apps, laser engraving, and 3D printing
                (availability varies by offering).
              </p>
              <p>
                For privacy questions, reach us at{" "}
                <a
                  href={`mailto:${email}`}
                  className="font-medium text-[var(--color-heading)] underline-offset-4 hover:underline"
                >
                  {email}
                </a>
                {phone ? <> or {phone}</> : null}. You can also use our{" "}
                <Link
                  href="/contact"
                  className="font-medium text-[var(--color-heading)] underline-offset-4 hover:underline"
                >
                  contact page
                </Link>
                .
              </p>
            </Section>

            <Section id="scope" title="2. Scope">
              <p>This policy applies to:</p>
              <BulletList
                items={[
                  "Our public website and pages linked from it under the Jenado Unlimited brand",
                  "Information you submit through our contact form or by email/phone",
                  "Technical data collected automatically when you browse the site",
                ]}
              />
              <p>
                This policy does not cover third-party websites, apps, or
                services we may link to. Their privacy practices are governed by
                their own policies. If you purchase products, book training, or
                work with us offline, additional terms or notices may apply and
                will be provided in that context.
              </p>
            </Section>

            <Section
              id="information-we-collect"
              title="3. Information we collect"
            >
              <p className="font-medium text-[var(--color-heading)]">
                Information you provide
              </p>
              <p>
                When you use our contact form or otherwise reach out, you may
                choose to provide:
              </p>
              <BulletList
                items={[
                  "Name and email address",
                  "Phone number (if you include one)",
                  "Topic or offering of interest (for example, Honey Bees, Personal Training, Sourdough)",
                  "Message content and any other details you voluntarily share",
                ]}
              />
              <p>
                You control what you put in a message. Please avoid sending
                sensitive personal information (such as government ID numbers,
                detailed medical records, or payment card numbers) through the
                contact form unless we specifically ask for it through a secure
                channel.
              </p>

              <p className="pt-2 font-medium text-[var(--color-heading)]">
                Information collected automatically
              </p>
              <p>
                Like most websites, we and our hosting or infrastructure
                providers may automatically receive:
              </p>
              <BulletList
                items={[
                  "IP address, general location derived from IP, browser type, and device information",
                  "Pages visited, referring URL, timestamps, and approximate usage patterns",
                  "Diagnostic logs needed to operate, secure, and troubleshoot the site",
                ]}
              />

              <p className="pt-2 font-medium text-[var(--color-heading)]">
                Cookies and similar technologies
              </p>
              <p>
                We may use cookies, local storage, or similar technologies for
                essential site functions (for example, remembering theme
                preference) and, if enabled, limited analytics or performance
                measurement. See{" "}
                <a
                  href="#cookies"
                  className="font-medium text-[var(--color-heading)] underline-offset-4 hover:underline"
                >
                  Cookies & analytics
                </a>{" "}
                below.
              </p>
            </Section>

            <Section id="how-we-use" title="4. How we use information">
              <p>We use the information we collect to:</p>
              <BulletList
                items={[
                  "Respond to inquiries and provide information about our offerings",
                  "Route messages to the right vertical (honey, training, craft services, and so on)",
                  "Operate, maintain, secure, and improve the website",
                  "Detect, prevent, and address spam, abuse, fraud, or technical issues",
                  "Comply with legal obligations and enforce our Terms of Service",
                  "Communicate with you about updates related to a request you initiated, when appropriate",
                ]}
              />
              <p>
                We do not sell your personal information. We do not use contact
                form submissions to build marketing lists without a clear,
                separate opt-in where required by law.
              </p>
            </Section>

            <Section id="legal-bases" title="5. Legal bases for processing">
              <p>
                Depending on where you live and how you interact with us, we may
                rely on one or more of the following bases to process personal
                information:
              </p>
              <BulletList
                items={[
                  "Your consent (for example, when you voluntarily submit a form)",
                  "Performance of a contract or steps prior to entering a contract (for example, responding to a service inquiry)",
                  "Our legitimate interests in operating a secure website, improving services, and communicating about requests you made — balanced against your rights",
                  "Compliance with legal obligations",
                ]}
              />
            </Section>

            <Section id="sharing" title="6. How we share information">
              <p>
                We share personal information only as needed to run our business
                and as described below:
              </p>
              <BulletList
                items={[
                  <>
                    <strong className="font-medium text-[var(--color-heading)]">
                      Service providers.
                    </strong>{" "}
                    Hosting, email delivery, form processing, security, and
                    similar vendors who process data on our behalf under
                    contractual obligations to protect it.
                  </>,
                  <>
                    <strong className="font-medium text-[var(--color-heading)]">
                      Legal and safety.
                    </strong>{" "}
                    When required by law, regulation, legal process, or
                    governmental request, or when we believe disclosure is
                    necessary to protect rights, safety, or property.
                  </>,
                  <>
                    <strong className="font-medium text-[var(--color-heading)]">
                      Business transfers.
                    </strong>{" "}
                    In connection with a merger, acquisition, financing, or sale
                    of assets, subject to appropriate confidentiality
                    safeguards.
                  </>,
                  <>
                    <strong className="font-medium text-[var(--color-heading)]">
                      With your direction.
                    </strong>{" "}
                    When you ask us to share information or interact with a
                    third party through us.
                  </>,
                ]}
              />
              <p>
                Team members or contractors working with a specific vertical may
                receive inquiry details needed to respond (for example, a
                training inquiry may be handled by our fitness team).
              </p>
            </Section>

            <Section id="cookies" title="7. Cookies & analytics">
              <p>
                <strong className="font-medium text-[var(--color-heading)]">
                  Essential.
                </strong>{" "}
                Some technologies are needed for the site to function (security,
                load balancing, remembering preferences such as light/dark
                mode).
              </p>
              <p>
                <strong className="font-medium text-[var(--color-heading)]">
                  Analytics (if used).
                </strong>{" "}
                We may use privacy-conscious analytics or server logs to
                understand aggregate traffic (for example, which pages are
                popular). Where required, we will provide additional notice or
                choice.
              </p>
              <p>
                You can control cookies through your browser settings. Blocking
                certain cookies may affect site functionality. Do Not Track
                signals are not consistently standardized; we treat personal
                information according to this policy regardless of DNT headers.
              </p>
            </Section>

            <Section id="retention" title="8. Data retention">
              <p>
                We keep personal information only as long as needed for the
                purposes described in this policy, unless a longer period is
                required or permitted by law. Typical practices include:
              </p>
              <BulletList
                items={[
                  "Contact form and email correspondence: retained for as long as needed to complete your request and for a reasonable follow-up period, then deleted or archived according to our records practices",
                  "Server and security logs: retained for a limited period for operations, security, and troubleshooting",
                  "Legal holds: retained longer when necessary for disputes, investigations, or compliance",
                ]}
              />
            </Section>

            <Section id="security" title="9. Security">
              <p>
                We implement reasonable administrative, technical, and
                organizational measures designed to protect personal information
                against unauthorized access, loss, misuse, or alteration. No
                method of transmission over the Internet or electronic storage
                is completely secure. We cannot guarantee absolute security, and
                you use the site at your own risk with respect to residual
                threats.
              </p>
              <p>
                If we become aware of a data incident that affects your personal
                information and notification is required by law, we will notify
                you and/or regulators as required.
              </p>
            </Section>

            <Section id="your-rights" title="10. Your rights & choices">
              <p>
                Depending on your location, you may have rights regarding your
                personal information, which can include:
              </p>
              <BulletList
                items={[
                  "Accessing the personal information we hold about you",
                  "Correcting inaccurate information",
                  "Requesting deletion, subject to legal exceptions",
                  "Objecting to or restricting certain processing",
                  "Withdrawing consent where processing is based on consent",
                  "Receiving a portable copy of information you provided, where applicable",
                ]}
              />
              <p>
                To exercise these rights, contact us at{" "}
                <a
                  href={`mailto:${email}`}
                  className="font-medium text-[var(--color-heading)] underline-offset-4 hover:underline"
                >
                  {email}
                </a>
                . We may need to verify your identity before fulfilling a
                request. Residents of certain U.S. states (including California
                and others with consumer privacy laws) may have additional
                rights; we will honor applicable state law. If you are in the
                EEA/UK, you may also lodge a complaint with your local data
                protection authority.
              </p>
            </Section>

            <Section id="children" title="11. Children’s privacy">
              <p>
                Our website is not directed to children under 13 (or the
                equivalent minimum age in your jurisdiction), and we do not
                knowingly collect personal information from children. If you
                believe a child has provided us personal information, contact us
                and we will take steps to delete it as appropriate.
              </p>
              <p>
                Personal training, food products, and other offerings may have
                additional age or guardian requirements when services are
                delivered in person; those will be communicated separately.
              </p>
            </Section>

            <Section id="international" title="12. International visitors">
              <p>
                We are based in the United States. If you access the site from
                outside the U.S., your information may be processed in the
                United States or other countries where our service providers
                operate. Those countries may have different data-protection
                rules than your home country. By using the site, you understand
                that your information may be transferred as described in this
                policy.
              </p>
            </Section>

            <Section id="changes" title="13. Changes to this policy">
              <p>
                We may update this Privacy Policy from time to time. When we do,
                we will revise the “Last updated” date at the top of this page
                and, if changes are material, we may provide additional notice
                (for example, a site banner or email when appropriate). Your
                continued use of the website after an update constitutes
                acceptance of the revised policy, to the extent permitted by
                law.
              </p>
            </Section>

            <Section id="contact" title="14. Contact us">
              <p>
                Questions about this Privacy Policy or our privacy practices:
              </p>
              <div className="border border-[var(--color-border)] bg-[var(--color-surface)] p-6">
                <p className="font-medium text-[var(--color-heading)]">
                  {name}
                </p>
                <p className="mt-3">
                  Email:{" "}
                  <a
                    href={`mailto:${email}`}
                    className="font-medium text-[var(--color-heading)] underline-offset-4 hover:underline"
                  >
                    {email}
                  </a>
                </p>
                {phone && (
                  <p className="mt-1">
                    Phone:{" "}
                    <a
                      href={`tel:${phone.replace(/[^\d+]/g, "")}`}
                      className="font-medium text-[var(--color-heading)] underline-offset-4 hover:underline"
                    >
                      {phone}
                    </a>
                  </p>
                )}
                <p className="mt-4 text-[var(--color-text-muted)]">
                  Prefer a form?{" "}
                  <Link
                    href="/contact"
                    className="font-medium text-[var(--color-heading)] underline-offset-4 hover:underline"
                  >
                    Contact us
                  </Link>
                  .
                </p>
              </div>
              <p className="text-sm text-[var(--color-text-muted)]">
                Related:{" "}
                <Link
                  href="/terms"
                  className="underline-offset-4 hover:text-[var(--color-heading)] hover:underline"
                >
                  Terms of Service
                </Link>
                .
              </p>
            </Section>
          </div>
        </div>
      </section>
    </>
  );
}

export const metadata: Metadata = {
  title: "Privacy Policy | Jenado Unlimited",
  description:
    "Jenado Unlimited Privacy Policy — how we collect, use, share, and protect your personal information.",
};
