/* global React */
/* ============================================================
   page-privacy.jsx — RevField Privacy Policy.

   HIDDEN ROUTE: reachable only by direct URL (#privacy).
   It is intentionally NOT linked from the nav, footer, or
   sitemap, and is excluded from the search-index noscript
   mirror. Anyone who knows the slug can request it; ordinary
   visitors never see a link to it.
   ============================================================ */

(function () {

  // ---- Scoped styling injected once -----------------------------
  const STYLE_ID = '__privacy-styles';
  if (!document.getElementById(STYLE_ID)) {
    const s = document.createElement('style');
    s.id = STYLE_ID;
    s.textContent = `
      .legal {
        max-width: 760px;
        margin: 0 auto;
      }
      .legal-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 28px;
        margin-bottom: var(--space-4);
        padding-bottom: var(--space-3);
        border-bottom: 1px solid var(--line);
      }
      .legal-meta-item {
        display: flex;
        flex-direction: column;
        gap: 3px;
      }
      .legal-meta-item dt {
        font-family: var(--font-mono);
        font-size: 10.5px;
        text-transform: uppercase;
        letter-spacing: 0.14em;
        color: var(--muted);
      }
      .legal-meta-item dd {
        margin: 0;
        font-size: 14.5px;
        color: var(--charcoal);
      }
      .legal-meta-item dd code {
        font-family: var(--font-mono);
        font-size: 13px;
        color: var(--accent);
      }
      .legal-section { margin-top: var(--space-5); scroll-margin-top: 90px; }
      .legal-section:first-of-type { margin-top: var(--space-4); }
      .legal-section-num {
        font-family: var(--font-mono);
        font-size: 11.5px;
        letter-spacing: 0.16em;
        color: var(--accent);
        text-transform: uppercase;
        margin-bottom: 10px;
      }
      .legal-section h2 {
        font-family: var(--font-display);
        font-size: clamp(26px, 3.2vw, 38px);
        line-height: 1.08;
        letter-spacing: -0.01em;
        font-weight: 600;
        color: var(--charcoal);
        margin: 0 0 18px;
      }
      .legal-section h3 {
        font-family: var(--font-body);
        font-size: 16px;
        font-weight: 650;
        color: var(--charcoal);
        margin: 26px 0 10px;
        letter-spacing: -0.005em;
      }
      .legal-section p {
        font-size: 16px;
        line-height: 1.72;
        color: var(--charcoal-soft);
        margin: 0 0 16px;
        text-wrap: pretty;
      }
      .legal-section p:last-child { margin-bottom: 0; }
      .legal-section a {
        color: var(--accent);
        text-decoration: underline;
        text-underline-offset: 2px;
        text-decoration-thickness: 1px;
      }
      .legal-section strong { color: var(--charcoal); font-weight: 650; }
      .legal-list {
        list-style: none;
        padding: 0;
        margin: 0 0 16px;
        display: flex;
        flex-direction: column;
        gap: 12px;
      }
      .legal-list li {
        position: relative;
        padding-left: 22px;
        font-size: 15.5px;
        line-height: 1.66;
        color: var(--charcoal-soft);
        text-wrap: pretty;
      }
      .legal-list li::before {
        content: '';
        position: absolute;
        left: 2px;
        top: 10px;
        width: 6px;
        height: 6px;
        border-radius: 1px;
        background: var(--accent);
      }
      .legal-list li strong { color: var(--charcoal); }
      /* Data table for collected information */
      .legal-data-card {
        border: 1px solid var(--line);
        border-radius: var(--radius-lg);
        overflow: hidden;
        margin: 4px 0 16px;
        background: var(--paper);
      }
      .legal-data-row {
        display: grid;
        grid-template-columns: 0.85fr 1.4fr;
        gap: 0;
        border-bottom: 1px solid var(--line);
      }
      .legal-data-row:last-child { border-bottom: none; }
      .legal-data-row dt {
        padding: 16px 20px;
        font-size: 14.5px;
        font-weight: 650;
        color: var(--charcoal);
        background: var(--paper-warm);
        border-right: 1px solid var(--line);
      }
      .legal-data-row dd {
        margin: 0;
        padding: 16px 20px;
        font-size: 14.5px;
        line-height: 1.6;
        color: var(--charcoal-soft);
      }
      .legal-callout {
        border: 1px solid var(--line-strong);
        border-left: 3px solid var(--accent);
        border-radius: var(--radius-md, 8px);
        background: var(--paper-warm);
        padding: 20px 24px;
        margin: 4px 0 16px;
      }
      .legal-callout p { margin: 0; font-size: 15px; }
      .legal-contact-block {
        font-size: 15.5px;
        line-height: 1.8;
        color: var(--charcoal-soft);
      }
      .legal-contact-block strong { display: block; color: var(--charcoal); }
      @media (max-width: 600px) {
        .legal-data-row { grid-template-columns: 1fr; }
        .legal-data-row dt { border-right: none; border-bottom: 1px solid var(--line); }
      }
    `;
    document.head.appendChild(s);
  }

  window.PrivacyPage = function PrivacyPage({ setRoute }) {
    return (
      <>
        <header className="page-head">
          <div className="container-wide">
            <div className="crumbs">
              <a href="#" onClick={e => { e.preventDefault(); setRoute('home'); }}>Home</a>
              <span>/</span>
              <span>RevField</span>
              <span>/</span>
              <span>Privacy Policy</span>
            </div>
            <h1>RevField <em>privacy policy.</em></h1>
            <p className="lede">
              How the RevField field-scouting app collects, uses, stores and protects
              your personal information — and the rights you have over it. Written to
              comply with POPIA, the EU GDPR and the UK GDPR.
            </p>
          </div>
        </header>

        <section className="section">
          <div className="container-wide">
            <div className="legal">

              {/* Document meta */}
              <dl className="legal-meta">
                <div className="legal-meta-item">
                  <dt>Effective date</dt>
                  <dd>7 June 2026</dd>
                </div>
                <div className="legal-meta-item">
                  <dt>Application</dt>
                  <dd><code>com.revolutesystems.revfield</code></dd>
                </div>
                <div className="legal-meta-item">
                  <dt>Provider</dt>
                  <dd>Revolute Systems (Pty) Ltd</dd>
                </div>
                <div className="legal-meta-item">
                  <dt>Information Officer</dt>
                  <dd><a href="mailto:info@revolutesystems.com">info@revolutesystems.com</a></dd>
                </div>
              </dl>

              {/* 1. Overview */}
              <div className="legal-section">
                <div className="legal-section-num">01 — Overview</div>
                <h2>Overview</h2>
                <p>
                  RevField is a professional field data-collection app for agricultural
                  scouting. This policy explains what personal information the app collects,
                  why we collect it, how it is stored and protected, who we share it with, and
                  the rights you have over it.
                </p>
                <p>
                  It applies to all users worldwide and is written to comply with the South
                  African Protection of Personal Information Act (POPIA), the EU General Data
                  Protection Regulation (GDPR) and the UK GDPR.
                </p>
              </div>

              {/* 2. Who we are */}
              <div className="legal-section">
                <div className="legal-section-num">02 — Who we are</div>
                <h2>Who we are</h2>
                <p>
                  Revolute Systems (Pty) Ltd is the responsible party / data controller for
                  personal information processed through RevField. For privacy questions,
                  requests or complaints, contact our Information Officer at{' '}
                  <a href="mailto:info@revolutesystems.com"><strong>info@revolutesystems.com</strong></a>.
                </p>
              </div>

              {/* 3. Information we collect */}
              <div className="legal-section">
                <div className="legal-section-num">03 — What we collect</div>
                <h2>Information we collect</h2>
                <dl className="legal-data-card">
                  <div className="legal-data-row">
                    <dt>Precise location (GPS)</dt>
                    <dd>To geotag observations and show your position on the map. Stored on your device (encrypted); uploaded to our API with each observation.</dd>
                  </div>
                  <div className="legal-data-row">
                    <dt>Photos</dt>
                    <dd>Optional photos you attach to observations. Stored on your device; uploaded to Google Cloud Storage.</dd>
                  </div>
                  <div className="legal-data-row">
                    <dt>Account / identity</dt>
                    <dd>Email or username, user ID and observer name — to authenticate you and attribute observations. Managed by Descope and our API.</dd>
                  </div>
                  <div className="legal-data-row">
                    <dt>Observation content</dt>
                    <dd>Tags, notes, inspection type, intensity and dates — the core function of the app. Stored on your device (encrypted); uploaded to our API.</dd>
                  </div>
                  <div className="legal-data-row">
                    <dt>Crash logs &amp; diagnostics</dt>
                    <dd>To detect and fix faults. Sent to Sentry.</dd>
                  </div>
                </dl>
                <div className="legal-callout">
                  <p>
                    We do <strong>not</strong> use your information for advertising, we do{' '}
                    <strong>not</strong> sell it, and we do <strong>not</strong> share it with
                    third parties for their own purposes.
                  </p>
                </div>
              </div>

              {/* 4. How we use it */}
              <div className="legal-section">
                <div className="legal-section-num">04 — How we use it</div>
                <h2>How we use your information and our lawful basis</h2>
                <p>
                  We process the above information solely to provide and operate RevField — to
                  record, sync and review field observations, to authenticate users, and to
                  maintain reliability through crash diagnostics.
                </p>
                <h3>For users in the EU / UK, our lawful bases under the GDPR are:</h3>
                <ul className="legal-list">
                  <li><strong>Performance of a contract</strong> — providing the app's core functionality to you or your organisation.</li>
                  <li><strong>Legitimate interests</strong> — keeping the app secure and reliable (e.g. crash diagnostics), balanced against your interests.</li>
                </ul>
                <p>
                  For users in South Africa, processing is carried out in accordance with the
                  POPIA conditions for lawful processing, including processing necessary to
                  perform the service and to pursue our legitimate interests.
                </p>
              </div>

              {/* 5. Storage and security */}
              <div className="legal-section">
                <div className="legal-section-num">05 — Storage &amp; security</div>
                <h2>Storage and security</h2>
                <ul className="legal-list">
                  <li>On-device data is held in an <strong>encrypted local database</strong> (SQLCipher).</li>
                  <li>Data in transit is encrypted using <strong>HTTPS / TLS</strong>.</li>
                  <li>Backend data syncs to our infrastructure: our API runs on Google Cloud Run, our database is managed PostgreSQL hosted by DigitalOcean (London), and images are stored in Google Cloud Storage.</li>
                </ul>
              </div>

              {/* 6. Third parties */}
              <div className="legal-section">
                <div className="legal-section-num">06 — Sub-processors</div>
                <h2>Third parties (sub-processors / operators)</h2>
                <p>
                  We use the following providers, who process data on our behalf under
                  appropriate agreements and only on our instructions. They are{' '}
                  <strong>operators / processors</strong>, not independent recipients of your data:
                </p>
                <ul className="legal-list">
                  <li><strong>Descope</strong> — authentication.</li>
                  <li><strong>Sentry</strong> — crash reporting and diagnostics.</li>
                  <li><strong>Google Cloud Platform</strong> — API hosting and image storage.</li>
                  <li><strong>DigitalOcean</strong> — database hosting.</li>
                </ul>
              </div>

              {/* 7. International transfers */}
              <div className="legal-section">
                <div className="legal-section-num">07 — International transfers</div>
                <h2>International data transfers</h2>
                <p>
                  Revolute Systems (Pty) Ltd is based in South Africa, and our infrastructure
                  providers operate data centres in other countries (including the United
                  Kingdom and the European Union). Where personal information is transferred
                  across borders, we rely on appropriate safeguards and on the providers'
                  compliance frameworks to ensure your information receives an adequate level
                  of protection.
                </p>
              </div>

              {/* 8. Retention */}
              <div className="legal-section">
                <div className="legal-section-num">08 — Retention</div>
                <h2>Data retention</h2>
                <p>
                  We retain observation and account data for as long as your organisation's
                  account remains active, or as required to maintain the agronomic record,
                  after which it is deleted or anonymised. You may request earlier deletion at
                  any time (see “Your rights” below).
                </p>
              </div>

              {/* 9. Your rights */}
              <div className="legal-section">
                <div className="legal-section-num">09 — Your rights</div>
                <h2>Your rights</h2>
                <p>Subject to applicable law, you have the right to:</p>
                <ul className="legal-list">
                  <li><strong>Access</strong> the personal information we hold about you.</li>
                  <li>Request <strong>correction</strong> of inaccurate or incomplete information.</li>
                  <li>Request <strong>deletion</strong> of your personal information.</li>
                  <li><strong>Object to</strong> or request <strong>restriction</strong> of certain processing.</li>
                  <li>Request a copy of your data in a portable format (<strong>data portability</strong>).</li>
                  <li><strong>Withdraw consent</strong> where processing is based on consent.</li>
                </ul>
                <p>
                  To exercise any of these rights, email{' '}
                  <a href="mailto:info@revolutesystems.com"><strong>info@revolutesystems.com</strong></a>.
                  We will respond within the timeframes required by applicable law.
                </p>
                <p>You also have the right to lodge a complaint with a supervisory authority:</p>
                <ul className="legal-list">
                  <li><strong>South Africa:</strong> the Information Regulator.</li>
                  <li><strong>EU / UK:</strong> your local data protection authority, or the UK Information Commissioner's Office (ICO).</li>
                </ul>
              </div>

              {/* 10. Deleting your data */}
              <div className="legal-section">
                <div className="legal-section-num">10 — Deleting your data</div>
                <h2>Deleting your data</h2>
                <p>
                  To request deletion of your account and associated personal information,
                  email <a href="mailto:info@revolutesystems.com?subject=Data%20deletion%20request"><strong>info@revolutesystems.com</strong></a>{' '}
                  with the subject “Data deletion request”. We will verify the request and
                  delete the data, except where we are legally required to retain it.
                </p>
              </div>

              {/* 11. Location permission */}
              <div className="legal-section">
                <div className="legal-section-num">11 — Location permission</div>
                <h2>Location permission</h2>
                <p>
                  RevField requests <strong>precise location</strong> while you are using the
                  app, to geotag observations and display your position on the map. You can
                  revoke this permission at any time in your device settings; the app then
                  falls back to manual placement on the map.
                </p>
              </div>

              {/* 12. Children */}
              <div className="legal-section">
                <div className="legal-section-num">12 — Children</div>
                <h2>Children</h2>
                <p>
                  RevField is a professional tool intended for business use and is not directed
                  at children under 13 (or the equivalent minimum age in your jurisdiction).
                </p>
              </div>

              {/* 13. Changes */}
              <div className="legal-section">
                <div className="legal-section-num">13 — Changes</div>
                <h2>Changes to this policy</h2>
                <p>
                  We may update this policy from time to time. Material changes will be posted
                  at this URL with a revised effective date.
                </p>
              </div>

              {/* 14. Contact */}
              <div className="legal-section">
                <div className="legal-section-num">14 — Contact</div>
                <h2>Contact</h2>
                <div className="legal-contact-block">
                  <strong>Revolute Systems (Pty) Ltd</strong>
                  Information Officer —{' '}
                  <a href="mailto:info@revolutesystems.com">info@revolutesystems.com</a>
                </div>
              </div>

            </div>
          </div>
        </section>
      </>
    );
  };
})();
