// /#/terms — Terms of Service. Living document; current revision is the
// only source of truth. Sections are loosely modeled on standard B2B
// data-publishing TOS (Bloomberg-lite), tuned to Shipping Clarity's actual
// posture: public-record sourcing, two-tier disclosure for driver intel,
// editorial-grade verdicts with explicit "not advice" carveouts.

const { useEffect: useEffectT } = React;

function TermsPage({ onNav }) {
  useEffectT(() => {
    try { window.scrollTo({ top: 0, behavior: "instant" }); } catch (_) { window.scrollTo(0, 0); }
  }, []);

  return (
    <div style={pageT}>
      <div style={wrapT}>
        <a href="#/" style={backT} onClick={(e) => { e.preventDefault(); onNav && onNav("home"); }}>← Back to Shipping Clarity</a>

        <div style={eyebrowT}>LEGAL</div>
        <h1 style={h1T}>Terms of Service</h1>
        <p style={metaT}>Effective <strong>May 3, 2026</strong> · Last updated May 3, 2026</p>

        <SectionT n="1" title="Who we are">
          Shipping Clarity is an independent freight-data journalism + intelligence
          platform operated under <strong>shippingclarity.com</strong> (the
          "Service"). We aggregate public-record information (SEC filings, FMCSA
          registrations, court dockets, news), curate editorial commentary, and
          surface signals about the U.S. freight network. Contact:
          <a href="mailto:legal@shippingclarity.com" style={linkT}> legal@shippingclarity.com</a>.
        </SectionT>

        <SectionT n="2" title="Acceptance">
          By accessing or using the Service you agree to these Terms and to our
          <a href="#/privacy" style={linkT} onClick={(e) => { e.preventDefault(); onNav && onNav("privacy"); }}> Privacy Policy</a>.
          If you do not agree, do not use the Service.
        </SectionT>

        <SectionT n="3" title="What we publish, and what it isn't">
          <p>The Service publishes a mix of:</p>
          <ul style={ulT}>
            <li><strong>Public-record facts</strong> — SEC EDGAR filings, FMCSA SAFER snapshots,
              CourtListener dockets, EPA ECHO compliance records, OSHA injury reports,
              state WARN notices, and similar government-published data. Cited inline.</li>
            <li><strong>Editorial estimates</strong> — fleet sizes, revenue figures, freight
              spend, and similar where the company is private or where exact figures aren't
              publicly disclosed. Always labeled as estimates with sources cited where
              available.</li>
            <li><strong>Heuristic verdicts</strong> — labels like "○ No flags," "⚠ Watch," or
              "▲ Distress" derived from a curated note field via keyword scanning. These
              are <strong>editorial summaries</strong>, not formal credit ratings, not
              regulated financial advice, and not a substitute for the user's own due
              diligence.</li>
            <li><strong>Synthesized visualizations</strong> — when real per-state operational
              data isn't available, hex-map distributions are illustrative and labeled as
              such.</li>
          </ul>
          <p>
            <strong>Nothing on the Service is investment advice, legal advice, or a
            credit report.</strong> The Service is not a "consumer reporting agency" within
            the meaning of the Fair Credit Reporting Act. Information is provided
            "as is" for informational and editorial purposes only.
          </p>
        </SectionT>

        <SectionT n="4" title="Accuracy and corrections">
          We work to be factually accurate and to label estimates honestly. If you
          believe a specific claim about you or your company is inaccurate, please
          contact <a href="mailto:corrections@shippingclarity.com" style={linkT}>corrections@shippingclarity.com</a> with:
          <ul style={ulT}>
            <li>The URL of the page</li>
            <li>The specific text you dispute</li>
            <li>The correction you propose, with supporting public-record citations</li>
          </ul>
          <p>
            We commit to reviewing correction requests within 5 business days and
            updating, annotating, or retracting where warranted. Trade-press standard.
          </p>
        </SectionT>

        <SectionT n="5" title="User accounts and content">
          <p>
            Some features require a verified account (magic-link sign-in via
            Supabase Auth). When you complete the welcome flow you provide
            information about yourself and your role; we use this to vet account
            authenticity and to gate features like the load board and reach-out
            requests. We auto-verify carrier and broker accounts against the FMCSA
            registry where possible; other roles are reviewed manually.
          </p>
          <p>
            User-generated content (load board postings, broker reach-outs, driver
            tips) belongs to you. By submitting content to the Service you grant us
            a non-exclusive, royalty-free, worldwide license to host, display, and
            (where applicable) anonymize and aggregate it for the operation of the
            Service. You represent that you have the right to submit the content
            and that it doesn't violate any third-party rights.
          </p>
          <p>
            <strong>Driver-source intel ("two-tier disclosure rule"):</strong> drivers
            who submit operational tips do so under an explicit visibility-choice
            policy. Identifying driver information is <em>sealed</em> by default and
            never republished. Aggregate signal counts and severity tiers may be
            displayed; raw words and identities are not. Drivers may delete their
            submissions at any time.
          </p>
        </SectionT>

        <SectionT n="6" title="Acceptable use">
          You agree not to:
          <ul style={ulT}>
            <li>Use the Service to impersonate any person or entity</li>
            <li>Scrape, mass-download, or mirror the Service without written permission
              (rate-limited public access for legitimate research is fine; ask via
              ops@shippingclarity.com if you need bulk data)</li>
            <li>Interfere with the Service's operation or attempt to circumvent
              authentication, access controls, or rate limits</li>
            <li>Use the Service to harass, defame, or threaten any individual</li>
            <li>Submit user content that is unlawful, deceptive, infringing, or
              violates the privacy or intellectual-property rights of others</li>
          </ul>
        </SectionT>

        <SectionT n="7" title="Intellectual property">
          The Service's editorial content, code, designs, and aggregated signal
          datasets are owned by Shipping Clarity. Public-record source data
          (SEC, FMCSA, court records, etc.) is in the public domain or used under
          fair-use principles for journalistic commentary; original sources are
          cited where appropriate.
        </SectionT>

        <SectionT n="8" title="Third-party links and data">
          The Service links to and displays summaries of information from third
          parties (SEC EDGAR, FMCSA SAFER, CourtListener, news outlets, etc.).
          We don't control those sources and aren't responsible for their accuracy
          or availability. When in doubt, click through to the cited source.
        </SectionT>

        <SectionT n="9" title="Paid products">
          <p>
            Paid offerings (Carrier Risk Report at $499 one-time, Carrier Verified
            subscription at $99/month, broker verification API, etc.) are subject
            to the same disclaimers above. Specifically:
          </p>
          <ul style={ulT}>
            <li>Risk Reports are <strong>editorial syntheses</strong> of public-record
              information, not formal credit reports or audits</li>
            <li>The "Verified ✓" badge for carrier subscribers attests to FMCSA
              authority status at the time of verification, not to the carrier's
              broader operational quality, financial condition, or future behavior</li>
            <li>Refund policy: contact <a href="mailto:billing@shippingclarity.com" style={linkT}>billing@shippingclarity.com</a> within 14 days
              of purchase for a full refund if a Risk Report has not been delivered;
              prorated refunds available for subscriptions cancelled mid-cycle</li>
          </ul>
        </SectionT>

        <SectionT n="10" title="Disclaimers">
          THE SERVICE IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTIES
          OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO MERCHANT-
          ABILITY, FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR
          NON-INFRINGEMENT. We do not warrant that the Service will be
          uninterrupted, error-free, or free of harmful components.
        </SectionT>

        <SectionT n="11" title="Limitation of liability">
          TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, SHIPPING CLARITY
          AND ITS AFFILIATES, OFFICERS, EMPLOYEES, AND AGENTS WILL NOT BE LIABLE
          FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE
          DAMAGES, OR ANY LOSS OF PROFITS, REVENUES, DATA, OR GOODWILL, ARISING
          OUT OF OR IN CONNECTION WITH YOUR USE OF (OR INABILITY TO USE) THE
          SERVICE. OUR TOTAL CUMULATIVE LIABILITY FOR ANY CLAIM RELATING TO THE
          SERVICE WILL NOT EXCEED THE AMOUNT YOU PAID US IN THE TWELVE MONTHS
          PRECEDING THE CLAIM, OR USD $100, WHICHEVER IS GREATER.
        </SectionT>

        <SectionT n="12" title="Indemnification">
          You agree to indemnify and hold harmless Shipping Clarity from any
          claims, damages, liabilities, and expenses (including reasonable
          attorneys' fees) arising out of (a) your use of the Service in violation
          of these Terms, (b) your user content, or (c) your violation of any
          third-party rights.
        </SectionT>

        <SectionT n="13" title="DMCA / copyright">
          If you believe content on the Service infringes your copyright, send a
          DMCA notice to <a href="mailto:dmca@shippingclarity.com" style={linkT}>dmca@shippingclarity.com</a> with: (i) physical or electronic
          signature; (ii) identification of the copyrighted work; (iii) the URL
          of the allegedly infringing material; (iv) your contact info; (v) a
          good-faith statement; and (vi) a statement under penalty of perjury
          that the information is accurate.
        </SectionT>

        <SectionT n="14" title="Termination">
          We may suspend or terminate your access to the Service, in whole or in
          part, at any time, with or without notice, for conduct we determine
          violates these Terms or is harmful to other users, us, or third parties.
          You may stop using the Service at any time. Sections 3, 5 (last
          paragraph), 7, 10, 11, 12, and 16 survive termination.
        </SectionT>

        <SectionT n="15" title="Changes to these Terms">
          We may update these Terms from time to time. The "Effective" date at the
          top reflects the current revision. Material changes will be communicated
          via on-site notice or email to account holders where possible.
        </SectionT>

        <SectionT n="16" title="Governing law and disputes">
          These Terms are governed by the laws of the State of Delaware, without
          regard to its conflict-of-laws principles. Any dispute will be resolved
          exclusively in the state or federal courts located in Delaware. You and
          Shipping Clarity each waive any right to a jury trial.
        </SectionT>

        <SectionT n="17" title="Contact">
          <ul style={ulT}>
            <li>General: <a href="mailto:ops@shippingclarity.com" style={linkT}>ops@shippingclarity.com</a></li>
            <li>Corrections: <a href="mailto:corrections@shippingclarity.com" style={linkT}>corrections@shippingclarity.com</a></li>
            <li>Legal / DMCA: <a href="mailto:legal@shippingclarity.com" style={linkT}>legal@shippingclarity.com</a></li>
            <li>Billing: <a href="mailto:billing@shippingclarity.com" style={linkT}>billing@shippingclarity.com</a></li>
          </ul>
        </SectionT>

        <p style={footT}>
          These Terms are intended to be read alongside our
          <a href="#/privacy" style={linkT} onClick={(e) => { e.preventDefault(); onNav && onNav("privacy"); }}> Privacy Policy</a>,
          which describes what information we collect, how it's used, and your rights regarding it.
        </p>
      </div>
    </div>
  );
}

function SectionT({ n, title, children }) {
  return (
    <section style={sectionT}>
      <h2 style={h2T}><span style={numT}>{n}</span> {title}</h2>
      <div style={bodyT}>{children}</div>
    </section>
  );
}

const pageT = {
  background: "var(--paper, #fafaf7)",
  minHeight: "100vh",
  color: "var(--ink, #1a1a1a)",
  fontFamily: '"Helvetica Neue", Helvetica, Arial, sans-serif',
};
const wrapT  = { maxWidth: 760, margin: "0 auto", padding: "32px 24px 80px" };
const backT  = { fontFamily: "ui-monospace, Menlo, monospace", fontSize: 12, letterSpacing: "0.10em", textTransform: "uppercase", color: "var(--ink-soft, #666)", textDecoration: "none", display: "inline-block", marginBottom: 32 };
const eyebrowT = { fontSize: 11, letterSpacing: "0.32em", textTransform: "uppercase", color: "var(--ink-soft, #666)", marginBottom: 14, fontWeight: 600 };
const h1T    = { fontFamily: 'Georgia, "Times New Roman", serif', fontSize: 48, fontWeight: 600, lineHeight: 1.1, letterSpacing: "-0.02em", margin: "0 0 8px" };
const metaT  = { fontSize: 14, color: "var(--ink-soft, #666)", margin: "0 0 40px" };
const sectionT = { marginBottom: 32, paddingBottom: 4 };
const h2T    = { fontSize: 20, fontWeight: 700, margin: "0 0 12px", letterSpacing: "-0.005em" };
const numT   = { fontSize: 14, color: "var(--ink-soft, #666)", marginRight: 10, fontFamily: "ui-monospace, Menlo, monospace" };
const bodyT  = { fontSize: 15, lineHeight: 1.65, color: "var(--ink, #1a1a1a)" };
const ulT    = { paddingLeft: 22, margin: "10px 0" };
const linkT  = { color: "oklch(0.50 0.18 250)", textDecoration: "underline" };
const footT  = { fontSize: 13, color: "var(--ink-soft, #666)", lineHeight: 1.55, marginTop: 40, paddingTop: 20, borderTop: "1px solid var(--rule, #e0e0d8)" };

window.TermsPage = TermsPage;
