// Buyer Agreement / Deal Terms page

function TermsPage({ onNav }) {
  const sections = [
    {
      id: "eligibility",
      title: "01 · Buyer eligibility",
      body: `Access to the Clearspace Solutions bidding platform is restricted to approved buyer companies. Approval requires verification of resale channel, logistics capacity, and creditworthiness at Clearspace's sole discretion. Clearspace reserves the right to revoke access at any time without cause.

Approved buyers may not share login credentials or allow third parties to place bids on their behalf without written authorization from Clearspace.`,
    },
    {
      id: "bids",
      title: "02 · Binding bids",
      body: `All bids placed on the Clearspace platform are legally binding commitments to purchase. By placing a bid, the buyer agrees to complete the transaction at the bid price if they are the winning bidder when the auction closes.

The minimum bid increment is $100 above the current leading bid. Quick-bid and custom-bid amounts are both subject to this floor. Bids cannot be retracted once placed.

Buy Now purchases close the auction immediately and are final.`,
    },
    {
      id: "payment",
      title: "03 · Payment terms",
      body: `Payment is due within 7 business days of auction close (net 7) unless alternate terms are pre-approved in writing. Accepted methods: ACH transfer, wire transfer, company check, or invoice (net 15, requires approved credit).

Failure to remit payment within the agreed window constitutes a breach and may result in forfeiture of the lot, suspension of buyer access, and pursuit of the outstanding balance by any available legal means.

A platform fee is included in the listed starting bid. No additional buyer's premium applies.`,
    },
    {
      id: "logistics",
      title: "04 · Logistics & pickup",
      body: `Winning buyers must arrange removal of purchased inventory within 10 business days of auction close unless otherwise agreed in writing. Clearspace offers white-glove delivery at an additional quoted cost.

Buyer pickup is available Monday through Friday, 8am–4pm, from the lot's listed location. Buyers must provide their own labor, transport, and any required equipment (lifts, dollies, strapping). Clearspace staff are not responsible for load-out assistance.

Risk of loss transfers to the buyer upon physical pickup or delivery acceptance.`,
    },
    {
      id: "condition",
      title: "05 · Inventory condition & as-is",
      body: `All inventory is sold as-is, where-is. Clearspace provides condition grades, unit counts, and photography as a good-faith representation based on on-site intake. These are not warranties. Minor discrepancies in quantity (±5%) or condition are not grounds for dispute.

Buyers are encouraged to request a site visit prior to bidding on whole lots. Clearspace will accommodate scheduled tours subject to project access.

No returns, refunds, or credits are issued post-close.`,
    },
    {
      id: "confidentiality",
      title: "06 · Bidder confidentiality",
      body: `Bidder identities are not disclosed to other participants during or after an auction. Clearspace does not share buyer company names, bid amounts, or contact information with competing bidders.

Buyers agree not to attempt to identify or contact competing bidders, and not to disclose platform access, lot details, or pricing to non-approved parties.`,
    },
    {
      id: "disputes",
      title: "07 · Disputes & governing law",
      body: `Any dispute arising from a transaction on the Clearspace platform shall first be submitted to Clearspace's internal resolution process. Unresolved disputes shall be governed by the laws of the State of California and subject to the exclusive jurisdiction of courts in San Francisco County.

Clearspace's liability in any dispute is limited to the transaction value of the lot in question. Clearspace is not liable for consequential, incidental, or punitive damages.`,
    },
    {
      id: "modifications",
      title: "08 · Modifications",
      body: `Clearspace reserves the right to modify these terms at any time. Continued use of the platform following notice of changes constitutes acceptance of the revised terms. Material changes will be communicated via email to the buyer's registered address.`,
    },
  ];

  return (
    <div>
      {/* Header */}
      <section style={{ borderBottom: "1px solid var(--line)", background: "var(--bg-sunken)" }}>
        <div className="container" style={{ padding: "48px 32px 40px" }}>
          <button onClick={() => onNav("home")} className="btn btn-ghost btn-sm" style={{ marginBottom: 20 }}>
            ← Back
          </button>
          <div className="eyebrow" style={{ marginBottom: 12 }}>Clearspace Solutions</div>
          <h1 className="display" style={{ fontSize: 48, margin: 0, marginBottom: 12 }}>Buyer agreement</h1>
          <p style={{ color: "var(--ink-3)", fontSize: 14, margin: 0 }}>
            Effective April 1, 2026 · All approved buyers are bound by these terms.
          </p>
        </div>
      </section>

      <div className="container" style={{ padding: "48px 32px 80px", display: "grid", gridTemplateColumns: "1fr 240px", gap: 56, alignItems: "start" }}>
        {/* Body */}
        <div style={{ display: "flex", flexDirection: "column", gap: 40 }}>
          {sections.map((s) => (
            <div key={s.id} id={s.id}>
              <h2 style={{ fontSize: 20, fontWeight: 600, letterSpacing: "-0.01em", margin: 0, marginBottom: 14 }}>{s.title}</h2>
              {s.body.split("\n\n").map((para, i) => (
                <p key={i} style={{ fontSize: 15, color: "var(--ink-2)", lineHeight: 1.7, margin: 0, marginBottom: 12 }}>{para}</p>
              ))}
            </div>
          ))}

          <div style={{ paddingTop: 24, borderTop: "1px solid var(--line)", display: "flex", flexDirection: "column", gap: 10 }}>
            <div style={{ fontSize: 14, color: "var(--ink-3)" }}>
              Questions about these terms? Contact us at{" "}
              <a href="mailto:clearspace.sols@gmail.com" style={{ color: "var(--ink)" }}>clearspace.sols@gmail.com</a>
            </div>
            <div className="row gap-12">
              <button className="btn btn-primary" onClick={() => onNav("access-request")}>
                Request buyer access <IcArrow size={15} />
              </button>
              <button className="btn btn-secondary" onClick={() => onNav("home")}>
                Return home
              </button>
            </div>
          </div>
        </div>

        {/* Sticky TOC */}
        <nav style={{ position: "sticky", top: 88 }}>
          <div style={{
            background: "var(--bg-elev)", border: "1px solid var(--line)",
            borderRadius: 12, padding: "18px 20px",
          }}>
            <div className="stat-kicker" style={{ marginBottom: 12 }}>Contents</div>
            <div style={{ display: "flex", flexDirection: "column", gap: 2 }}>
              {sections.map((s) => (
                <a key={s.id} href={`#${s.id}`}
                  style={{
                    fontSize: 13, color: "var(--ink-3)", textDecoration: "none",
                    padding: "5px 8px", borderRadius: 6,
                    display: "block",
                  }}
                  onMouseEnter={(e) => e.currentTarget.style.color = "var(--ink)"}
                  onMouseLeave={(e) => e.currentTarget.style.color = "var(--ink-3)"}>
                  {s.title}
                </a>
              ))}
            </div>
          </div>
        </nav>
      </div>
    </div>
  );
}

Object.assign(window, { TermsPage });
