// Privacy Policy and EULA pages — shared legal layout

const LegalLayout = ({ title, updated, toc, children }) => (
  <div className="ee-scope" style={{ width: '100%', background: 'var(--ink-1)', minHeight: '100%' }}>
    <EENav />

    {/* Masthead */}
    <section style={{ padding: '60px 48px 40px', borderBottom: '1px solid var(--hair)', background: 'var(--ink-0)' }}>
      <div style={{ maxWidth: 1100, margin: '0 auto' }}>
        <div className="mono" style={{ fontSize: 11, letterSpacing: '0.2em', color: 'var(--gold)', marginBottom: 14 }}>
          ◉ LEGAL · GADSDEN LLC
        </div>
        <h1 style={{ fontSize: 64, fontWeight: 800, letterSpacing: '-0.035em', lineHeight: 0.95, marginBottom: 20 }}>{title}</h1>
        <div style={{ display: 'flex', gap: 32, flexWrap: 'wrap' }}>
          <div>
            <div className="mono" style={{ fontSize: 10, letterSpacing: '0.14em', color: 'var(--bone-4)' }}>LAST UPDATED</div>
            <div style={{ fontFamily: 'var(--f-mono)', fontSize: 13, marginTop: 4 }}>{updated}</div>
          </div>
          <div>
            <div className="mono" style={{ fontSize: 10, letterSpacing: '0.14em', color: 'var(--bone-4)' }}>APPLIES TO</div>
            <div style={{ fontFamily: 'var(--f-mono)', fontSize: 13, marginTop: 4 }}>EaglEye Ballistics — iOS &amp; Android</div>
          </div>
          <div>
            <div className="mono" style={{ fontSize: 10, letterSpacing: '0.14em', color: 'var(--bone-4)' }}>CONTACT</div>
            <div style={{ fontFamily: 'var(--f-mono)', fontSize: 13, marginTop: 4 }}>hello@gadsden.io</div>
          </div>
        </div>
      </div>
    </section>

    {/* Body with TOC */}
    <section style={{ padding: '60px 48px 100px' }}>
      <div style={{ maxWidth: 1100, margin: '0 auto', display: 'grid', gridTemplateColumns: '240px 1fr', gap: 64 }}>
        {/* TOC */}
        <aside style={{ position: 'sticky', top: 24, alignSelf: 'flex-start' }}>
          <div className="mono" style={{ fontSize: 10, letterSpacing: '0.16em', color: 'var(--bone-4)', marginBottom: 14 }}>CONTENTS</div>
          <nav style={{ display: 'flex', flexDirection: 'column', gap: 0 }}>
            {toc.map((item, i) => (
              <a key={i} href={`#s${i+1}`} style={{
                fontSize: 13, color: 'var(--bone-2)', textDecoration: 'none',
                padding: '9px 12px', borderLeft: '1px solid var(--hair)',
                fontFamily: 'var(--f-mono)', letterSpacing: '0.02em',
                transition: 'all 0.15s',
              }}
              onMouseEnter={e => { e.currentTarget.style.color = 'var(--gold)'; e.currentTarget.style.borderLeftColor = 'var(--gold)'; }}
              onMouseLeave={e => { e.currentTarget.style.color = 'var(--bone-2)'; e.currentTarget.style.borderLeftColor = 'var(--hair)'; }}
              >
                <span style={{ color: 'var(--bone-4)', marginRight: 10 }}>{String(i+1).padStart(2, '0')}</span>{item}
              </a>
            ))}
          </nav>
        </aside>

        {/* Content */}
        <article style={{ fontSize: 15, lineHeight: 1.75, color: 'var(--bone)', maxWidth: 720 }}>
          {children}
        </article>
      </div>
    </section>

    <EEFooter />
  </div>
);

// Common legal typography helpers
const Sec = ({ n, title, children }) => (
  <section id={`s${n}`} style={{ marginBottom: 48, scrollMarginTop: 24 }}>
    <div style={{ display: 'flex', alignItems: 'baseline', gap: 14, marginBottom: 18, paddingBottom: 14, borderBottom: '1px solid var(--hair)' }}>
      <span className="mono" style={{ fontSize: 12, color: 'var(--gold)', letterSpacing: '0.14em' }}>§ {String(n).padStart(2, '0')}</span>
      <h2 style={{ fontSize: 26, letterSpacing: '-0.01em' }}>{title}</h2>
    </div>
    <div style={{ color: 'var(--bone-2)' }}>{children}</div>
  </section>
);
const P = ({ children }) => <p style={{ margin: '0 0 14px', lineHeight: 1.75 }}>{children}</p>;
const Ul = ({ children }) => <ul style={{ paddingLeft: 20, margin: '8px 0 18px', color: 'var(--bone-2)', lineHeight: 1.7 }}>{children}</ul>;
const Strong = ({ children }) => <strong style={{ color: 'var(--bone)', fontWeight: 600 }}>{children}</strong>;

// ── Privacy Policy ─────────────────────────────────────────
const PrivacyPage = () => (
  <LegalLayout
    title="Privacy Policy"
    updated="April 23, 2026"
    toc={['Summary', 'What we don\'t collect', 'What the app processes locally', 'Optional weather integration', 'App store analytics', 'Data retention & deletion', 'Children', 'Changes', 'Contact']}
  >
    <div style={{
      padding: 20, background: 'var(--ink-2)', border: '1px solid var(--hair)',
      borderLeft: '3px solid var(--gold)', marginBottom: 36, fontSize: 14, lineHeight: 1.7,
    }}>
      <div className="mono" style={{ fontSize: 10, letterSpacing: '0.14em', color: 'var(--gold)', marginBottom: 10 }}>◉ AT A GLANCE</div>
      EaglEye Ballistics does not collect, store, or transmit any personal data. There are
      no analytics, no trackers, no advertising SDKs, no user accounts, and no cloud sync.
      Your ballistic profiles live on your device and nowhere else.
    </div>

    <Sec n={1} title="Summary">
      <P>
        Gadsden LLC ("we", "us", "our") publishes EaglEye Ballistics ("the app"). We designed
        the app to be privacy-first by default. This policy describes what the app does and does
        not do with data generated or used during operation.
      </P>
      <P>
        This policy applies to the iOS and Android versions of the app, distributed through the
        Apple App Store and Google Play Store respectively.
      </P>
    </Sec>

    <Sec n={2} title="What we don't collect">
      <P>The app does <Strong>not</Strong> collect or transmit any of the following:</P>
      <Ul>
        <li>Names, email addresses, or other personally identifiable information</li>
        <li>Device identifiers, advertising IDs, or persistent identifiers of any kind</li>
        <li>Usage analytics, session recordings, or crash telemetry sent to third parties</li>
        <li>Photos, contacts, calendar entries, or other system data</li>
        <li>Ballistic profiles, dope cards, handload recipes, or any user-entered content</li>
        <li>Firing solutions, range cards, or usage history</li>
      </Ul>
      <P>
        There are no user accounts to create, no passwords to manage, and no cloud backends
        operated by us. The app is fully functional without any network connection.
      </P>
    </Sec>

    <Sec n={3} title="What the app processes locally">
      <P>
        All ballistic data you enter — rifle profiles, scope configurations, ammunition and
        handload recipes, zero settings, dope cards, range cards, and environmental inputs —
        is stored exclusively in the app's private container on your device. This data never
        leaves your device unless you explicitly export it (for example, exporting a range
        card as a PDF and sharing it via the system share sheet).
      </P>
      <P>
        Exported files are handled by your operating system, not by us. We have no visibility
        into where you send them.
      </P>
    </Sec>

    <Sec n={4} title="Optional weather integration">
      <P>
        If you enable live weather, the app makes an HTTPS request to the Open-Meteo public
        weather API (<span className="mono" style={{ color: 'var(--gold)' }}>open-meteo.com</span>). This request includes your approximate GPS
        coordinates, which are necessary to return local atmospheric data.
      </P>
      <P>
        Open-Meteo is a third-party service operated independently of Gadsden LLC. Their
        privacy terms apply to that request. The app does not send any user-identifying
        information alongside the coordinates, and the request is made directly from your
        device — we do not proxy, log, or observe it.
      </P>
      <P>
        Weather integration is optional. The solver is fully functional with manual
        atmospheric entry, and you can disable GPS and live weather in Settings at any time.
      </P>
    </Sec>

    <Sec n={5} title="App store analytics">
      <P>
        Apple and Google provide aggregate, non-personal statistics to developers about app
        downloads, crashes, and store-page impressions. These statistics are generated by the
        store platforms themselves and are not attributable to individual users by us. We do
        not operate our own analytics or telemetry on top of them.
      </P>
    </Sec>

    <Sec n={6} title="Data retention & deletion">
      <P>
        Because we do not collect user data, there is no retained data for us to delete.
        All app-local data is removed when you delete the app from your device. To erase a
        specific profile or load without deleting the app, use the in-app controls in the
        profile manager.
      </P>
    </Sec>

    <Sec n={7} title="Children">
      <P>
        The app is not directed at children under 13. We do not knowingly collect any data from
        any user, including children.
      </P>
    </Sec>

    <Sec n={8} title="Changes to this policy">
      <P>
        If we make material changes to this policy, we will publish a new version at the URL
        where you found this one and update the "last updated" date above. Continued use of
        the app after a change constitutes acceptance of the updated policy.
      </P>
    </Sec>

    <Sec n={9} title="Contact">
      <P>For questions or concerns about this policy:</P>
      <div style={{ padding: 18, background: 'var(--ink-2)', border: '1px solid var(--hair)', fontFamily: 'var(--f-mono)', fontSize: 13, lineHeight: 1.8 }}>
        Gadsden LLC<br/>
        <span style={{ color: 'var(--gold)' }}>hello@gadsden.io</span>
      </div>
    </Sec>
  </LegalLayout>
);

// ── EULA ───────────────────────────────────────────────────
const EulaPage = () => (
  <LegalLayout
    title="End User License Agreement"
    updated="April 23, 2026"
    toc={['Acceptance', 'License grant', 'Restrictions', 'Pro unlock & purchases', 'Ownership', 'Third-party data', 'Disclaimer of warranty', 'Limitation of liability', 'Safety & lawful use', 'Termination', 'Governing law', 'Contact']}
  >
    <div style={{
      padding: 20, background: 'var(--ink-2)', border: '1px solid var(--hair)',
      borderLeft: '3px solid var(--gold)', marginBottom: 36, fontSize: 14, lineHeight: 1.7,
    }}>
      <div className="mono" style={{ fontSize: 10, letterSpacing: '0.14em', color: 'var(--gold)', marginBottom: 10 }}>◉ NOTICE</div>
      This is a legal agreement between you and Gadsden LLC governing your use of EaglEye
      Ballistics. By installing or using the app, you agree to its terms. The app computes
      ballistic solutions for informational purposes and is not a substitute for proper
      training, judgment, or live-fire verification.
    </div>

    <Sec n={1} title="Acceptance of terms">
      <P>
        This End User License Agreement ("Agreement") is entered into between you ("you" or
        "Licensee") and Gadsden LLC, a Utah limited liability company ("Licensor", "we", "us"),
        governing your installation and use of the EaglEye Ballistics software application
        ("Software"). By downloading, installing, or using the Software, you accept the terms
        below. If you do not accept, do not install or use the Software.
      </P>
    </Sec>

    <Sec n={2} title="License grant">
      <P>
        Subject to your compliance with this Agreement, Licensor grants you a personal,
        non-exclusive, non-transferable, revocable license to install and use the Software on
        devices you own or control, solely for your lawful personal or professional use.
      </P>
    </Sec>

    <Sec n={3} title="Restrictions">
      <P>You agree that you will not:</P>
      <Ul>
        <li>Reverse engineer, decompile, or disassemble the Software, except to the extent
          such activity is expressly permitted by applicable law;</li>
        <li>Modify, adapt, translate, or create derivative works based on the Software;</li>
        <li>Rent, lease, loan, sell, sublicense, distribute, or otherwise transfer rights to
          the Software;</li>
        <li>Remove, obscure, or alter any proprietary notices, labels, or marks on the Software;</li>
        <li>Use the Software in violation of any law, regulation, or export-control restriction.</li>
      </Ul>
    </Sec>

    <Sec n={4} title="Pro unlock & purchases">
      <P>
        The Software is distributed as a free download with an optional one-time in-app
        purchase ("Pro") that unlocks additional features, including range card PDF export,
        handload recipe tracking, MV truing, and suppressor ballistic modeling. The Pro
        purchase is processed by the Apple App Store or Google Play Store under their
        respective terms. All refund requests must be directed to the applicable store.
      </P>
      <P>
        The Software does not use subscriptions. Your Pro purchase is a single transaction.
      </P>
    </Sec>

    <Sec n={5} title="Ownership">
      <P>
        The Software is licensed, not sold. Licensor retains all right, title, and interest in
        and to the Software, including all copyrights, trademarks, trade secrets, and other
        intellectual property rights. No rights are granted to you except as expressly set
        forth in this Agreement.
      </P>
    </Sec>

    <Sec n={6} title="Third-party data">
      <P>
        The Software may incorporate reference data and catalog entries (calibers, factory
        loads, optics specifications) sourced from third-party manufacturers and public data
        sets. Such data is provided for reference and is not warranted to be error-free.
        Always verify critical values against manufacturer documentation before use.
      </P>
      <P>
        Live weather integration, when enabled, uses the Open-Meteo public API. Your use of
        that service is additionally subject to Open-Meteo's terms.
      </P>
    </Sec>

    <Sec n={7} title="Disclaimer of warranty">
      <P>
        THE SOFTWARE IS PROVIDED "AS IS" AND "AS AVAILABLE," WITHOUT WARRANTY OF ANY KIND,
        EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, OR NON-INFRINGEMENT. BALLISTIC
        CALCULATIONS PRODUCED BY THE SOFTWARE ARE ESTIMATES. REAL-WORLD RESULTS ARE
        AFFECTED BY NUMEROUS FACTORS INCLUDING BUT NOT LIMITED TO AMMUNITION LOT
        VARIATION, BARREL CONDITION, SHOOTER TECHNIQUE, AND ENVIRONMENTAL MEASUREMENT
        ACCURACY.
      </P>
    </Sec>

    <Sec n={8} title="Limitation of liability">
      <P>
        TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT WILL LICENSOR BE LIABLE FOR ANY
        INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR ANY LOSS OF
        PROFITS OR REVENUES, ARISING OUT OF OR RELATED TO YOUR USE OF THE SOFTWARE. LICENSOR'S
        TOTAL LIABILITY UNDER THIS AGREEMENT WILL NOT EXCEED THE AMOUNT YOU PAID FOR THE
        SOFTWARE.
      </P>
    </Sec>

    <Sec n={9} title="Safety & lawful use">
      <P>
        You are solely responsible for the safe and lawful handling of firearms, ammunition,
        and related equipment. The Software is a decision-support tool and does not replace
        proper training, range verification, or compliance with applicable laws and
        regulations. Always verify your solutions with live-fire data at the range before
        relying on them in the field or at a match.
      </P>
    </Sec>

    <Sec n={10} title="Termination">
      <P>
        This Agreement is effective until terminated. Your rights under it will terminate
        automatically without notice if you fail to comply with any of its terms. Upon
        termination, you must cease all use of the Software and delete all copies from your
        devices.
      </P>
    </Sec>

    <Sec n={11} title="Governing law">
      <P>
        This Agreement is governed by the laws of the State of Utah, United States of America,
        without regard to its conflict-of-laws principles. The exclusive venue for any
        dispute arising out of this Agreement will be the state or federal courts located in
        Salt Lake County, Utah.
      </P>
    </Sec>

    <Sec n={12} title="Contact">
      <div style={{ padding: 18, background: 'var(--ink-2)', border: '1px solid var(--hair)', fontFamily: 'var(--f-mono)', fontSize: 13, lineHeight: 1.8 }}>
        Gadsden LLC<br/>
        <span style={{ color: 'var(--gold)' }}>hello@gadsden.io</span>
      </div>
    </Sec>
  </LegalLayout>
);

window.PrivacyPage = PrivacyPage;
window.EulaPage = EulaPage;
