// pages-legal.jsx — Privacy + Terms (long-form readable docs)

function LegalShell({ label, title, updated, children, screenLabel }) {
  return (
    <main className="page" data-screen-label={screenLabel}>
      <section style={{ padding: "56px 0 0" }}>
        <div className="wrap">
          <div className="eyebrow" style={{ marginBottom: 28 }}>
            <span className="dot"></span><span>{label}</span>
            <span style={{ flex: 1 }} />
            <span className="mono" style={{ color: "var(--mist)" }}>Last updated · {updated}</span>
          </div>

          <h1 className="hero-title" style={{ maxWidth: 920, marginBottom: 8 }}>
            {title}
          </h1>
          <div style={{ display: "flex", alignItems: "center", gap: 14, marginTop: 18, marginBottom: 56 }}>
            <Hanko size={48}>律</Hanko>
            <div className="mono" style={{ fontSize: 12, color: "var(--mist)", letterSpacing: ".14em", textTransform: "uppercase" }}>
              Kaiju Labs Inc. · Ontario, Canada
            </div>
          </div>

          <div style={{ display: "grid", gridTemplateColumns: "220px 1fr", gap: 64, alignItems: "start" }}>
            <aside style={{ position: "sticky", top: 88, fontSize: 13 }}>
              <span className="label" style={{ display: "block", marginBottom: 14 }}>On this page</span>
              <TOC />
            </aside>
            <div className="prose" style={{ maxWidth: 720 }}>
              {children}
            </div>
          </div>
        </div>
      </section>
    </main>
  );
}

function TOC() {
  // Reads h2s out of the prose container after mount
  const [items, setItems] = React.useState([]);
  React.useEffect(() => {
    const headers = document.querySelectorAll(".prose h2");
    const arr = [...headers].map(h => {
      if (!h.id) h.id = h.textContent.toLowerCase().replace(/[^a-z0-9]+/g, "-");
      return { id: h.id, text: h.textContent };
    });
    setItems(arr);
  }, []);
  return (
    <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "flex", flexDirection: "column", gap: 8 }}>
      {items.map(i => (
        <li key={i.id}>
          <a href={"#" + i.id} style={{ color: "var(--ink-2)", borderBottom: "1px solid transparent" }}
             onMouseEnter={e => e.currentTarget.style.color = "var(--vermillion)"}
             onMouseLeave={e => e.currentTarget.style.color = "var(--ink-2)"}>
            {i.text}
          </a>
        </li>
      ))}
    </ul>
  );
}

// -------------------------------------------------------------- PRIVACY
function PrivacyPage() {
  return (
    <LegalShell label="Privacy Policy" title="What we do, and don't, collect." updated="May 18, 2026" screenLabel="05 Privacy">
      <p style={{ fontSize: 18, color: "var(--ink)", padding: 18, border: "1px solid var(--line)", borderLeft: "3px solid var(--vermillion)", background: "color-mix(in oklab, var(--vermillion) 4%, transparent)", borderRadius: 4 }}>
        <strong>The short version:</strong> Kaiju Labs Inc. does not collect personal information
        through our mobile apps. No accounts. No analytics. No third-party SDKs. Your data stays
        on your device.
      </p>

      <h2>Who we are</h2>
      <p>
        This Privacy Policy applies to mobile applications and websites operated by
        <strong> Kaiju Labs Inc.</strong> ("Kaiju Labs", "we", "us"), a corporation
        registered in Ontario, Canada. It explains how — and how little — we handle
        information when you use our apps and visit our sites.
      </p>

      <h2>Information we don't collect</h2>
      <p>
        Our flagship app, <strong>Toronto Events</strong>, is built around a strict
        no-collection principle. Specifically, our apps do not:
      </p>
      <ul>
        <li>Require you to create an account or log in</li>
        <li>Ask for, or transmit, your name, email, phone number, or any personal identifier</li>
        <li>Track your precise location, IP address, or device identifiers</li>
        <li>Include third-party analytics SDKs (e.g. Firebase, Mixpanel, Amplitude)</li>
        <li>Include advertising SDKs or behavioural ad networks</li>
        <li>Send telemetry, crash reports, or usage data to our servers (we don't run any)</li>
      </ul>

      <h2>Information stored on your device</h2>
      <p>
        Some information is stored locally on your device using iOS-native storage APIs, so the
        app can function across launches. This includes:
      </p>
      <ul>
        <li><strong>Saved favourites:</strong> events you've starred</li>
        <li><strong>Filter preferences:</strong> the categories you've selected</li>
        <li><strong>Scheduled reminders:</strong> registered with the iOS notification system</li>
      </ul>
      <p>
        This information is stored only on your device. It is never transmitted to us or to any
        third party. Deleting the app removes all of it.
      </p>

      <h2>Network requests</h2>
      <p>
        Toronto Events fetches event listings from the <strong>City of Toronto Open Data
        portal</strong> (<code>open.toronto.ca</code>) over standard HTTPS. These requests are
        anonymous — we do not attach any identifiers to them, and the request goes directly from
        your device to the City of Toronto's servers. We do not proxy or log these requests.
      </p>

      <h2>Children</h2>
      <p>
        Our apps are suitable for general audiences. Because we collect no personal information
        whatsoever, we are not in a position to knowingly collect information from anyone,
        including children under 13.
      </p>

      <h2>Your rights</h2>
      <p>
        Under PIPEDA (Canada) and GDPR (EU), you have rights to access, correct, and delete
        personal information we hold about you. Because we hold none, these rights are
        effectively satisfied by default. If you believe we are holding personal information
        about you, please email <a href="mailto:privacy@kaijulabs.ca">privacy@kaijulabs.ca</a> —
        we'll investigate and confirm.
      </p>

      <h2>Changes to this policy</h2>
      <p>
        If we ever change our practices, we will update this page and bump the "Last updated"
        date at the top. If a change is material — for example, if a future app ever needs to
        collect any personal information — we will say so prominently in the app and in the
        relevant App Store listing before that app is released.
      </p>

      <h2>Contact</h2>
      <p>
        Privacy questions, access requests, or anything else related to this policy:
        <br/><a href="mailto:privacy@kaijulabs.ca">privacy@kaijulabs.ca</a>
      </p>
      <p style={{ color: "var(--mist)", fontSize: 14, marginTop: 36 }}>
        Kaiju Labs Inc. · Ontario, Canada · 怪獣研究所
      </p>
    </LegalShell>
  );
}

// -------------------------------------------------------------- TERMS
function TermsPage() {
  return (
    <LegalShell label="Terms of Service" title="The agreement, in plain English." updated="May 18, 2026" screenLabel="07 Terms">
      <p style={{ fontSize: 18, color: "var(--ink)", padding: 18, border: "1px solid var(--line)", borderLeft: "3px solid var(--vermillion)", background: "color-mix(in oklab, var(--vermillion) 4%, transparent)", borderRadius: 4 }}>
        <strong>The short version:</strong> Use our apps responsibly. Event information comes
        from public sources and might be wrong — always check before showing up. Ontario law
        governs this agreement.
      </p>

      <h2>1. Acceptance</h2>
      <p>
        These Terms of Service ("Terms") govern your access to and use of the mobile apps and
        websites operated by <strong>Kaiju Labs Inc.</strong> ("Kaiju Labs", "we", "us"). By
        downloading, installing, or using our apps, you agree to these Terms.
      </p>

      <h2>2. The service</h2>
      <p>
        Our apps — including <strong>Toronto Events</strong> — provide a software interface to
        publicly available information, such as the City of Toronto's Open Data event listings.
        The apps are provided free of charge and without an account.
      </p>

      <h2>3. Event data accuracy</h2>
      <p>
        Event information displayed in Toronto Events is sourced from the City of Toronto's
        Open Data portal and other publicly available feeds. We re-render that information
        faithfully, but we do not produce, verify, or guarantee any of it.
      </p>
      <p>
        Event times, locations, prices, and availability may change without notice — including
        cancellation. <strong>Please always confirm event details with the official source or
        venue before travelling.</strong> Kaiju Labs is not responsible for inaccurate,
        out-of-date, or missing event information, or for any consequences of relying on it.
      </p>

      <h2>4. Acceptable use</h2>
      <p>
        You agree to use our apps and websites in good faith. You will not:
      </p>
      <ul>
        <li>Reverse engineer, decompile, or modify our apps except as permitted by law</li>
        <li>Use automated tools to scrape data from our apps in a way that interferes with normal use</li>
        <li>Misrepresent our apps as your own or remove copyright notices</li>
        <li>Use our apps for any illegal purpose</li>
      </ul>

      <h2>5. Intellectual property</h2>
      <p>
        The Kaiju Labs name, the Kaiju Labs logo, the design of our apps, and the source code
        we author are the property of Kaiju Labs Inc. Event data is the property of its
        respective sources (e.g. the City of Toronto). The City of Toronto's Open Data is
        provided under the City's Open Data licence; nothing in these Terms grants you any
        rights to that data beyond what that licence already provides.
      </p>

      <h2>6. No warranty</h2>
      <p>
        Our apps are provided <strong>"as is"</strong> and <strong>"as available"</strong>,
        without warranty of any kind, express or implied. To the maximum extent permitted by
        applicable law, we disclaim all warranties including merchantability, fitness for a
        particular purpose, and non-infringement.
      </p>

      <h2>7. Limitation of liability</h2>
      <p>
        To the maximum extent permitted by applicable law, Kaiju Labs Inc., its directors,
        employees, and contractors will not be liable for any indirect, incidental, special,
        consequential, or punitive damages — including lost profits, lost data, or lost
        time — arising out of or related to your use of our apps, even if we have been advised
        of the possibility of such damages.
      </p>

      <h2>8. Changes</h2>
      <p>
        We may update these Terms from time to time. We'll post the updated version here and
        bump the "Last updated" date. Continued use of our apps after a change constitutes
        acceptance of the updated Terms.
      </p>

      <h2>9. Governing law</h2>
      <p>
        These Terms are governed by the laws of the <strong>Province of Ontario, Canada</strong>
        and the federal laws of Canada applicable therein, without regard to conflict of law
        principles. You agree to submit to the exclusive jurisdiction of the courts of Ontario
        for any dispute arising under these Terms.
      </p>

      <h2>10. Contact</h2>
      <p>
        Questions about these Terms? Write to <a href="mailto:hello@kaijulabs.ca">hello@kaijulabs.ca</a>.
      </p>
      <p style={{ color: "var(--mist)", fontSize: 14, marginTop: 36 }}>
        Kaiju Labs Inc. · Ontario, Canada · 怪獣研究所
      </p>
    </LegalShell>
  );
}

Object.assign(window, { PrivacyPage, TermsPage });
