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("terms");
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 TermsPage() {
  const email = siteConfig.contactEmail || "contact@jenado-unlimited.com";
  const phone = siteConfig.contactPhone;
  const name = siteConfig.name;

  return (
    <>
      <ParallaxHero
        image={page?.heroImage || "/images/hero-terms.jpg"}
        alt={
          page?.heroAlt ||
          "Leather-bound book with brass paperweight on a warm wooden desk"
        }
        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="Terms of service 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">
              {[
                ["agreement", "Agreement to terms"],
                ["about", "About our services"],
                ["eligibility", "Eligibility"],
                ["acceptable-use", "Acceptable use"],
                ["inquiries", "Inquiries & communications"],
                ["intellectual-property", "Intellectual property"],
                ["offerings", "Products & offerings"],
                ["disclaimers-health", "Health, food & safety"],
                ["no-advice", "No professional advice"],
                ["third-parties", "Third-party links"],
                ["disclaimers", "Disclaimers"],
                ["liability", "Limitation of liability"],
                ["indemnification", "Indemnification"],
                ["governing-law", "Governing law"],
                ["changes", "Changes"],
                ["contact", "Contact"],
              ].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">
              These Terms of Service (“Terms”) govern your access to and use of
              the website operated by {name} (“we,” “us,” or “our”), including
              content, features, and contact forms available on the site. By
              accessing or using the website, you agree to these Terms and our{" "}
              <Link
                href="/privacy"
                className="font-medium text-[var(--color-heading)] underline-offset-4 hover:underline"
              >
                Privacy Policy
              </Link>
              . If you do not agree, do not use the website.
            </p>

            <Section id="agreement" title="1. Agreement to terms">
              <p>
                These Terms form a binding agreement between you and {name}. We
                may update these Terms from time to time. The “Last updated”
                date at the top of this page will change when we do. Continued
                use of the website after changes become effective constitutes
                acceptance of the revised Terms, except where applicable law
                requires additional consent.
              </p>
            </Section>

            <Section id="about" title="2. About our services">
              <p>
                {name} is a multi-vertical brand. Through this website we
                describe and invite inquiries about offerings that may include,
                without limitation:
              </p>
              <BulletList
                items={[
                  "Honey bees — local honey and related bee products",
                  "Personal training — fitness coaching and related programs",
                  "Sourdough breads — artisan baked goods",
                  "Farm-to-table — seasonal dining and local ingredients experiences",
                  "Recreation apps — digital tools for mindful recreation",
                  "Laser engraving and 3D printing — custom craft and fabrication services",
                ]}
              />
              <p>
                Not every offering is available at all times. Some may be listed
                as soft-launch, coming soon, or otherwise limited. Website
                descriptions are informational and do not guarantee
                availability, pricing, or specific results.
              </p>
            </Section>

            <Section id="eligibility" title="3. Eligibility">
              <p>
                You must be able to form a binding contract under applicable law
                to use this website. If you use the site on behalf of an
                organization, you represent that you have authority to bind that
                organization to these Terms. Certain offerings (for example,
                training programs or food products) may have additional age,
                health, or guardian requirements communicated at the time of
                booking or sale.
              </p>
            </Section>

            <Section id="acceptable-use" title="4. Acceptable use">
              <p>
                You agree to use the website only for lawful purposes. You will
                not:
              </p>
              <BulletList
                items={[
                  "Violate any applicable law, regulation, or third-party right",
                  "Submit spam, malware, automated bulk requests, or abuse the contact form",
                  "Attempt to gain unauthorized access to our systems, accounts, or data",
                  "Scrape, harvest, or index the site in a way that overloads or harms our infrastructure, except for standard search-engine indexing",
                  "Impersonate any person or entity, or misrepresent your affiliation",
                  "Interfere with or disrupt the website or related networks",
                  "Use the site to harass, threaten, or harm others",
                  "Copy, modify, or create derivative works from our content except as expressly allowed",
                ]}
              />
              <p>
                We may suspend or terminate access, refuse service, or take
                other appropriate action if we reasonably believe you have
                violated these Terms.
              </p>
            </Section>

            <Section id="inquiries" title="5. Inquiries & communications">
              <p>
                Submitting a contact form, email, or phone inquiry does not
                create a client, student, patient, or sales contract. We will
                use commercially reasonable efforts to respond, but we do not
                guarantee response times or that every inquiry will result in
                engagement.
              </p>
              <p>
                You represent that information you provide is accurate and that
                you have the right to share it. You agree not to submit
                unlawful, defamatory, or infringing content. Messages may be
                monitored for spam, security, and quality.
              </p>
              <p>
                Any quotes, schedules, or agreements for products or services
                will be confirmed separately in writing (including email) or
                through another process we designate. Website content does not
                modify those separate terms unless expressly stated.
              </p>
            </Section>

            <Section
              id="intellectual-property"
              title="6. Intellectual property"
            >
              <p>
                The website and its contents — including text, graphics, logos,
                photographs, layouts, and software — are owned by {name} or our
                licensors and are protected by copyright, trademark, and other
                laws. “Jenado Unlimited” and related marks are used to identify
                our brand.
              </p>
              <p>
                We grant you a limited, non-exclusive, non-transferable,
                revocable license to access and view the website for personal,
                non-commercial use. You may not reproduce, distribute, publicly
                display, sell, or exploit site content without our prior written
                permission, except for fair use or other rights that cannot be
                waived under law.
              </p>
              <p>
                If you believe content on the site infringes your copyright,
                contact us at{" "}
                <a
                  href={`mailto:${email}`}
                  className="font-medium text-[var(--color-heading)] underline-offset-4 hover:underline"
                >
                  {email}
                </a>{" "}
                with sufficient detail for us to locate the material and
                respond.
              </p>
            </Section>

            <Section id="offerings" title="7. Products, services & custom work">
              <p>
                Descriptions of honey products, breads, training, craft
                services, apps, and other offerings are provided for general
                information. Features, ingredients, availability, lead times,
                and pricing may change. Images are representative and may not
                depict the exact item you receive.
              </p>
              <p>
                Custom laser engraving, 3D printing, and similar work may
                require your review of proofs, material choices, and usage
                rights for any designs or files you provide. You are responsible
                for ensuring you have rights to content you ask us to produce
                and that the requested work does not violate law or third-party
                rights.
              </p>
              <p>
                Digital or app offerings, if made available, may be subject to
                additional end-user license terms, store policies, or platform
                rules.
              </p>
            </Section>

            <Section
              id="disclaimers-health"
              title="8. Health, food & safety notices"
            >
              <p className="font-medium text-[var(--color-heading)]">
                Food products (including honey and sourdough)
              </p>
              <p>
                Our food products may contain or be produced near allergens such
                as gluten, dairy, nuts, seeds, or bee products. Honey is not
                recommended for infants under one year of age. If you have
                allergies, dietary restrictions, or medical conditions, review
                ingredients carefully and consult a qualified professional as
                needed. We cannot guarantee a completely allergen-free
                environment for artisan or small-batch production.
              </p>

              <p className="pt-2 font-medium text-[var(--color-heading)]">
                Personal training & fitness
              </p>
              <p>
                Physical activity involves risk of injury. Training content or
                programs described on this site are not a substitute for medical
                advice, diagnosis, or treatment. Consult a physician before
                beginning any exercise program, especially if you have health
                conditions, are pregnant, or have been inactive. You assume
                responsibility for knowing your limits and following safety
                guidance provided in any formal training engagement.
              </p>

              <p className="pt-2 font-medium text-[var(--color-heading)]">
                Farm-to-table & events
              </p>
              <p>
                Seasonal menus, ingredient sourcing, and event details may vary.
                Notify us of allergies or restrictions when booking or
                inquiring. We will make reasonable efforts to accommodate but
                cannot eliminate all cross-contact risks.
              </p>
            </Section>

            <Section id="no-advice" title="9. No professional advice">
              <p>
                Content on this website — including wellness, fitness,
                nutrition, craft, or lifestyle information — is for general
                educational and marketing purposes only. It is not medical,
                legal, financial, or other professional advice. Always seek the
                advice of qualified professionals regarding your specific
                situation.
              </p>
            </Section>

            <Section id="third-parties" title="10. Third-party links & tools">
              <p>
                The website may link to third-party sites, platforms, or tools
                (for example, social media or app stores). We do not control and
                are not responsible for their content, policies, or practices.
                Your use of third-party services is at your own risk and subject
                to their terms.
              </p>
            </Section>

            <Section id="disclaimers" title="11. Disclaimers">
              <p>
                THE WEBSITE AND ALL CONTENT ARE PROVIDED “AS IS” AND “AS
                AVAILABLE.” TO THE FULLEST EXTENT PERMITTED BY LAW, WE DISCLAIM
                ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING MERCHANTABILITY,
                FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT.
              </p>
              <p>
                We do not warrant that the site will be uninterrupted, secure,
                error-free, or free of viruses or other harmful components, or
                that content will be accurate, complete, or current. You are
                responsible for implementing appropriate safeguards when using
                the Internet.
              </p>
              <p>
                Some jurisdictions do not allow certain warranty disclaimers; in
                those places, disclaimers apply to the maximum extent permitted.
              </p>
            </Section>

            <Section id="liability" title="12. Limitation of liability">
              <p>
                TO THE FULLEST EXTENT PERMITTED BY LAW, {name.toUpperCase()} AND
                ITS OWNERS, EMPLOYEES, CONTRACTORS, AND AGENTS WILL NOT BE
                LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL,
                EXEMPLARY, OR PUNITIVE DAMAGES, OR ANY LOSS OF PROFITS, DATA,
                GOODWILL, OR BUSINESS OPPORTUNITY, ARISING OUT OF OR RELATED TO
                YOUR USE OF (OR INABILITY TO USE) THE WEBSITE OR RELIANCE ON
                SITE CONTENT, WHETHER BASED ON WARRANTY, CONTRACT, TORT
                (INCLUDING NEGLIGENCE), STATUTE, OR ANY OTHER LEGAL THEORY, EVEN
                IF WE HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
              </p>
              <p>
                TO THE FULLEST EXTENT PERMITTED BY LAW, OUR TOTAL LIABILITY FOR
                ANY CLAIM ARISING OUT OF OR RELATING TO THE WEBSITE OR THESE
                TERMS WILL NOT EXCEED THE GREATER OF (A) THE AMOUNT YOU PAID US,
                IF ANY, FOR THE SPECIFIC PRODUCT OR SERVICE GIVING RISE TO THE
                CLAIM IN THE TWELVE MONTHS BEFORE THE CLAIM, OR (B) ONE HUNDRED
                U.S. DOLLARS (US $100).
              </p>
              <p>
                Nothing in these Terms limits liability that cannot be limited
                under applicable law (for example, certain liability for
                personal injury caused by negligence, or fraud). Separate
                written agreements for products or services may specify
                different allocations of risk for those engagements.
              </p>
            </Section>

            <Section id="indemnification" title="13. Indemnification">
              <p>
                You agree to defend, indemnify, and hold harmless {name} and its
                owners, employees, contractors, and agents from and against any
                claims, damages, losses, liabilities, costs, and expenses
                (including reasonable attorneys’ fees) arising out of or related
                to: (a) your use of the website; (b) your violation of these
                Terms; (c) your violation of any law or third-party right; or
                (d) content or materials you submit to us (including designs or
                files for custom work), except to the extent caused by our
                willful misconduct.
              </p>
            </Section>

            <Section id="governing-law" title="14. Governing law & disputes">
              <p>
                These Terms are governed by the laws of the State of Wisconsin,
                United States, without regard to conflict-of-law principles,
                except where mandatory consumer protection laws of your place of
                residence provide otherwise.
              </p>
              <p>
                You agree that exclusive venue for any dispute arising out of or
                relating to these Terms or the website will be the state or
                federal courts located in Wisconsin, and you consent to personal
                jurisdiction there, unless applicable law requires otherwise. If
                you are a consumer, you may also have rights to bring claims in
                your local courts.
              </p>
              <p>
                Before filing a formal claim, please contact us so we can try to
                resolve the issue informally.
              </p>
            </Section>

            <Section id="miscellaneous" title="15. Miscellaneous">
              <BulletList
                items={[
                  <>
                    <strong className="font-medium text-[var(--color-heading)]">
                      Entire agreement.
                    </strong>{" "}
                    These Terms, together with the Privacy Policy and any
                    additional terms we present for specific services, are the
                    entire agreement between you and us regarding the website.
                  </>,
                  <>
                    <strong className="font-medium text-[var(--color-heading)]">
                      Severability.
                    </strong>{" "}
                    If any provision is held unenforceable, the remaining
                    provisions will continue in effect.
                  </>,
                  <>
                    <strong className="font-medium text-[var(--color-heading)]">
                      Waiver.
                    </strong>{" "}
                    Failure to enforce a provision is not a waiver of the right
                    to enforce it later.
                  </>,
                  <>
                    <strong className="font-medium text-[var(--color-heading)]">
                      Assignment.
                    </strong>{" "}
                    You may not assign these Terms without our consent. We may
                    assign them in connection with a reorganization, merger, or
                    sale of assets.
                  </>,
                  <>
                    <strong className="font-medium text-[var(--color-heading)]">
                      Force majeure.
                    </strong>{" "}
                    We are not liable for delays or failures due to causes
                    beyond our reasonable control.
                  </>,
                ]}
              />
            </Section>

            <Section id="changes" title="16. Changes to the website">
              <p>
                We may modify, suspend, or discontinue any part of the website
                at any time, with or without notice. We are not liable if the
                site is unavailable for any period.
              </p>
            </Section>

            <Section id="contact" title="17. Contact">
              <p>Questions about these Terms of Service:</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="/privacy"
                  className="underline-offset-4 hover:text-[var(--color-heading)] hover:underline"
                >
                  Privacy Policy
                </Link>
                .
              </p>
            </Section>
          </div>
        </div>
      </section>
    </>
  );
}

export const metadata: Metadata = {
  title: "Terms of Service | Jenado Unlimited",
  description:
    "Jenado Unlimited Terms of Service — rules for using our website, content, and related offerings.",
};
