import type { Metadata } from 'next';
import Link from 'next/link';

export const metadata: Metadata = {
  title: 'Terms of Service',
  description: 'Terms governing use of MapleBrief and its synthesized news briefs.',
  alternates: { canonical: '/terms-of-service' },
};

function Section({ title, children }: { title: string; children: React.ReactNode }) {
  return (
    <section className="mt-8">
      <h2 className="font-display text-xl font-bold text-ink-900">{title}</h2>
      <div className="mt-3 space-y-3 text-[15px] leading-relaxed text-ink-700">{children}</div>
    </section>
  );
}

export default function TermsPage() {
  return (
    <div className="mx-auto max-w-3xl px-4 py-10 sm:px-6">
      <h1 className="font-display text-4xl font-bold text-ink-950">Terms of Service</h1>
      <p className="mt-3 text-sm text-ink-500">
        Last updated: {new Date().toISOString().slice(0, 10)}
      </p>

      <Section title="1. Acceptance of terms">
        <p>
          By accessing or using MapleBrief (&ldquo;the Site&rdquo;), you agree to be
          bound by these Terms of Service. If you do not agree, discontinue use.
        </p>
      </Section>

      <Section title="2. Nature of the service">
        <p>
          MapleBrief provides automated, AI-assisted summaries of publicly
          available news from third-party Canadian publishers. Briefs are
          synthesized for information convenience; each brief links to, and
          attributes, the original reporting. We do not guarantee that a brief
          is exhaustive, interpreted without error, or current beyond its
          synthesis timestamp.
        </p>
        <p>
          Nothing on the Site constitutes professional, legal, financial,
          medical, or investment advice.
        </p>
      </Section>

      <Section title="3. Intellectual property and attribution">
        <p>
          The original articles remain the exclusive property of their
          respective publishers. MapleBrief&apos;s briefs are independently
          authored; links to original sources are provided with{' '}
          <code className="rounded bg-ink-100 px-1 text-sm">rel=&quot;nofollow&quot;</code>{' '}
          and are intended as outbound referrals, not endorsements.
        </p>
        <p>
          You may share brief links for personal, non-commercial reference. You
          may not scrape, mirror, resell, or systematically redistribute the
          Site&apos;s content.
        </p>
      </Section>

      <Section title="4. Acceptable use">
        <p>
          You agree not to: (a) interfere with or disrupt the Site or its
          infrastructure; (b) attempt to bypass rate limits or access controls;
          (c) use the Site for unlawful purposes; (d) attempt to extract the
          underlying raw feed content in bulk.
        </p>
      </Section>

      <Section title="5. Termination">
        <p>
          We may modify or terminate any part of the Site at any time, with or
          without notice.
        </p>
      </Section>

      <Section title="6. Limitation of liability">
        <p>
          To the maximum extent permitted by law, MapleBrief shall not be
          liable for indirect, incidental, special, consequential, or punitive
          damages arising from your use of (or inability to use) the Site.
        </p>
      </Section>

      <Section title="7. Governing law">
        <p>
          These terms are governed by the laws of Ontario, Canada, without
          regard to conflict-of-law principles, and the exclusive remedy venue
          is the courts of Ontario.
        </p>
      </Section>

      <Section title="8. Contact">
        <p>
          For questions about these terms, see our{' '}
          <Link href="/contact" className="font-medium text-maple-700 underline">
            contact page
          </Link>
          .
        </p>
      </Section>
    </div>
  );
}
