/* Content pages — Privacy, Terms, Cookies, Methodology, AI engine,
   Editorial standards, Press, Careers, About.
   One generic <ContentPage kind="…" /> driven by a content map. */

const CONTENT = {
  privacy: {
    eyebrow: 'Legal · Privacy',
    title: 'Privacy policy',
    updated: 'Last updated 12 May 2026',
    intro: 'SpecEagle reads phone spec sheets, not your inbox. This policy explains exactly what we collect, why, where it lives, and how to take it back.',
    sections: [
      {
        h: 'What we collect',
        body: [
          'Account data — only if you sign in. Email and a hashed password are all we require. Names and avatars are optional and you can leave them blank.',
          'Usage telemetry — coarse-grained pageview counts (which comparison pages get hit, which languages are most-used) via a single first-party analytics endpoint. We never set third-party cookies and we never load Google Analytics, Meta Pixel, or any of their cousins.',
          'Affiliate referrer — when you click through to a retailer, we record the destination and a 30-day session ID so we can attribute commission. We never sell or share that data.',
        ],
      },
      {
        h: 'What we do not collect',
        body: [
          'We do not fingerprint your browser, harvest your contact list, or build behavioral profiles. We do not enrich your account with data from third parties. We do not track you across other sites.',
        ],
      },
      {
        h: 'Where data lives',
        body: [
          'Account data sits in encrypted Postgres clusters in Frankfurt (EU) and Ashburn (US-East). Telemetry sits in a separate analytics database in the same regions, retained for 90 days then aggregated. Affiliate logs are retained for 18 months for accounting.',
        ],
      },
      {
        h: 'Your rights',
        body: [
          'You can export, correct, or delete your data at any time from Account → Privacy. Deletion is permanent; we keep no shadow copies. Requests are typically completed within an hour and always within 30 days.',
        ],
      },
      {
        h: 'Contact',
        body: ['Email privacy@speceagle.com — a real human reads every message within two business days.'],
      },
    ],
  },

  terms: {
    eyebrow: 'Legal · Terms of service',
    title: 'Terms of service',
    updated: 'Last updated 12 May 2026',
    intro: 'These terms govern your use of SpecEagle. They are written in plain English on purpose. If anything here is unclear, write us — we will fix it for everyone.',
    sections: [
      {
        h: 'Use of the service',
        body: [
          'SpecEagle is free to use for personal, non-commercial research. You agree not to attempt to scrape the database at industrial scale, abuse the AI Verdict endpoint, or use the service to impersonate another person.',
          'API access for commercial use is available under a separate Developer Agreement — see /press for contact.',
        ],
      },
      {
        h: 'Editorial independence',
        body: [
          'Every verdict, ranking, and recommendation on SpecEagle is produced editorially. We do not accept payment, free hardware, or other consideration in exchange for coverage. Affiliate commissions are disclosed and never affect ranking — see Editorial standards for the full disclosure.',
        ],
      },
      {
        h: 'Accuracy of specifications',
        body: [
          'We work hard to keep specs accurate, cross-checked against manufacturer datasheets and independent benchmark databases. Errors do happen. If you find one, hit the "Report an error" link on any spec page and we will correct it (typically within 24 hours).',
        ],
      },
      {
        h: 'Liability',
        body: [
          'SpecEagle helps you make a buying decision. The decision is yours. We are not liable for purchase outcomes, retailer disputes, or hardware defects. We are liable for editorial accuracy and we own that obligation.',
        ],
      },
      {
        h: 'Changes',
        body: ['We may update these terms. Material changes are emailed to account holders 14 days before they take effect. Continued use after that constitutes acceptance.'],
      },
    ],
  },

  cookies: {
    eyebrow: 'Legal · Cookies',
    title: 'Cookies & local storage',
    updated: 'Last updated 12 May 2026',
    intro: 'SpecEagle sets exactly three first-party cookies and uses one localStorage key. No third-party cookies. No tracking pixels. No "Accept all 187 cookies" wall.',
    sections: [
      {
        h: 'Cookies we set',
        body: [
          'auth — set only when you sign in. Holds a signed session token. Expires after 30 days of inactivity.',
          'lang — your selected language. Expires after 1 year.',
          'theme — light or dark preference. Expires after 1 year.',
        ],
      },
      {
        h: 'Local storage',
        body: [
          'saved-phones — the list of phones you have bookmarked. Stored only in your browser. Cleared when you sign out.',
        ],
      },
      {
        h: 'What we do not do',
        body: [
          'No Google Analytics, no Hotjar, no Meta Pixel, no ad-network cookies. Our analytics endpoint sees only a coarse pageview count and the URL — no cookie required, no IP retained beyond 24 hours.',
        ],
      },
    ],
  },

  methodology: {
    eyebrow: 'About · Methodology',
    title: 'How we score phones',
    updated: 'Last updated 02 May 2026',
    intro: 'Every phone receives a 0–100 SpecEagle score. The number combines 14 weighted spec categories, four independent benchmark suites, and editorial consensus from 23 trusted outlets. This page tells you exactly how.',
    sections: [
      {
        h: 'The 60-20-20 split',
        body: [
          'Spec score (60%) — fourteen categories weighted to 2026 flagship buyer priorities: display, performance, camera hardware, battery, charging, build, software longevity, connectivity, audio, and four sub-categories within camera and performance.',
          'Benchmark score (20%) — median of twelve runs per device on AnTuTu v10, Geekbench 6 (single and multi), and 3DMark Solar Bay. We weight sustained performance and thermal headroom higher than peak.',
          'Editorial score (20%) — averaged scores from 23 outlets we have weighted by historical calibration accuracy. The list of outlets and their weights is published and updated quarterly.',
        ],
      },
      {
        h: 'Why scores change',
        body: [
          'Scores drift over time. A flagship released in January 2025 is scored relative to its peers at launch and re-scored against the moving class average every 14 days. A phone that scores 91 at launch may drift to 88 a year later — that is the score working correctly.',
        ],
      },
      {
        h: 'What we do not weight',
        body: [
          'Brand reputation, "premium feel," manufacturer cooperation, and affiliate revenue have zero weight. We do not adjust for review-unit availability.',
        ],
      },
    ],
  },

  'ai-engine': {
    eyebrow: 'About · AI Verdict engine',
    title: 'How the AI Verdict engine works',
    updated: 'Last updated 02 May 2026',
    intro: 'The AI Verdict is the one thing SpecEagle does that GSMArena cannot. Here is how it is built and what it does — and does not — do.',
    sections: [
      {
        h: 'Inputs',
        body: [
          'Every verdict starts from the same structured inputs: the two phones\' full spec sheets (14 categories, 142 fields each), benchmark medians from four suites, the editorial consensus from 23 outlets, and the buying use case (photography, gaming, battery, daily driver, four more).',
        ],
      },
      {
        h: 'Generation',
        body: [
          'A retrieval-augmented language model produces a draft verdict, anchored to the structured inputs and prevented from inventing facts not present in the data. Drafts are then verified by a deterministic fact-check pass against the source spec sheets.',
          'Every published verdict is reviewed by an editor before going live. The editor can rewrite, reject, or annotate; they cannot, however, change the structured score that drives the verdict — that requires updating the underlying spec data.',
        ],
      },
      {
        h: 'Confidence',
        body: [
          'Each verdict carries a confidence indicator (Low / Medium / High) based on three signals: how complete the spec data is, how much benchmark agreement there is across suites, and how much editorial consensus exists. High confidence means at least 95% spec completeness, ≥0.85 benchmark correlation, and ≥0.75 editorial agreement.',
        ],
      },
      {
        h: 'What it will not do',
        body: [
          'Generate verdicts for phones we have not verified the specs of. Make claims that contradict the source data. Recommend the affiliate-paying option when the data points elsewhere. Predict pricing or availability.',
        ],
      },
    ],
  },

  editorial: {
    eyebrow: 'About · Editorial standards',
    title: 'Editorial standards',
    updated: 'Last updated 02 May 2026',
    intro: 'SpecEagle is editorially independent. These are the standards every page on the site is held to.',
    sections: [
      {
        h: 'Independence',
        body: [
          'No payment, free hardware, or other consideration is accepted in exchange for coverage, rankings, or verdicts. Review hardware is purchased at retail or returned within 14 days of receipt; loaner units are disclosed inline on the review.',
          'Affiliate commissions are disclosed on every product page and never affect editorial rankings or verdicts.',
        ],
      },
      {
        h: 'Corrections',
        body: [
          'Errors are corrected within 24 hours of discovery. Substantive corrections (affecting a verdict or score) are flagged with a dated correction note at the top of the page and kept there indefinitely.',
        ],
      },
      {
        h: 'Sources',
        body: [
          'Every spec sheet cites its primary source (manufacturer datasheet, FCC filing, certified retailer listing). Every benchmark cites the database and run methodology. Every editorial claim cites its outlet and date.',
        ],
      },
      {
        h: 'Conflicts of interest',
        body: [
          'Writers and editors disclose phone ownership in the byline of any review or comparison they contribute to. Editors recuse themselves from coverage of phones they have ownership in.',
        ],
      },
    ],
  },

  press: {
    eyebrow: 'About · Press',
    title: 'Press & partnerships',
    updated: '',
    intro: 'Working on a story, podcast, or product launch? Here is how to reach us.',
    sections: [
      {
        h: 'For journalists',
        body: ['press@speceagle.com — we respond within two business days. We can supply data, charts, and commentary under quote attribution. We do not provide off-the-record briefings.'],
      },
      {
        h: 'For manufacturers',
        body: ['launches@speceagle.com — for embargo coordination, product briefings, and spec verification. Review units are purchased at retail; we do not accept seeded units.'],
      },
      {
        h: 'For API partners',
        body: ['developers@speceagle.com — for commercial API access. Pricing starts at $2,500/mo for the spec database; AI Verdict API access is by application.'],
      },
      {
        h: 'For affiliates',
        body: ['affiliates@speceagle.com — we work with major retailers, brand stores, and select regional partners. Verdicts and rankings are not for sale; that is non-negotiable.'],
      },
    ],
  },

  careers: {
    eyebrow: 'About · Careers',
    title: 'Build SpecEagle with us',
    updated: '',
    intro: 'A small team, distributed across six countries, building the phone-research site we wanted to use. We hire slowly and pay at the 75th percentile of the markets we operate in.',
    sections: [
      {
        h: 'Open roles · 4',
        body: [
          'Senior Editor, Asia-Pacific — Singapore / Jakarta · Lead coverage across SEA and East Asia. 6+ years of devices journalism required.',
          'ML Engineer, Verdict Engine — Remote (UTC −5 to +3) · Own the retrieval and fact-check pipeline. Strong RAG, evaluation, and Python required.',
          'Localization Lead — Remote · Hire and manage translators across 30 languages; own the localization QA pipeline. Native-level English plus two others required.',
          'Senior Backend Engineer — Remote (UTC −5 to +3) · Spec ingestion pipeline + comparison API. Strong Postgres and Go required.',
        ],
      },
      {
        h: 'How we hire',
        body: [
          'Three conversations, two practical exercises, no whiteboard puzzles. Final-round candidates spend a paid day with the team. We tell every applicant a yes-or-no decision within 14 days of first contact.',
        ],
      },
      {
        h: 'Compensation',
        body: [
          'Cash salaries benchmarked quarterly. Meaningful equity for the first 25 hires. Full healthcare wherever we hire. Six weeks of paid leave from year one. No "unlimited PTO" sleight-of-hand.',
        ],
      },
    ],
  },

  about: {
    eyebrow: 'About SpecEagle',
    title: 'The eagle-eyed phone research site we wanted to use.',
    updated: '',
    intro: 'SpecEagle is built by a small team that spent a decade frustrated with the state of phone research. The data is good. The reading experience is from 2003. The verdicts are missing. We are fixing all three.',
    sections: [
      {
        h: 'What we believe',
        body: [
          'Specifications are the product. Data presentation is the experience. The reader should leave every page with a decision, not a worksheet.',
          'Speed is editorial — a five-second load is a worse review than a one-second load with the same words. We treat performance as a content quality issue.',
          'Editorial independence is binary. There is no "mostly independent." Either verdicts are for sale or they are not. Ours are not.',
        ],
      },
      {
        h: 'Where we are',
        body: [
          'Headquartered in Singapore; editorial offices in Jakarta, Mumbai, Lisbon, São Paulo, and Berlin. 38 full-time staff across 14 countries as of May 2026.',
        ],
      },
      {
        h: 'Backing',
        body: [
          'Initial seed round closed Q3 2024. Profitable on affiliate + API revenue since Q1 2026. We do not need to grow on someone else\'s timeline.',
        ],
      },
    ],
  },
};

const ContentPage = ({ kind, setPage }) => {
  const c = CONTENT[kind];
  if (!c) {
    return (
      <main className="pb-32 mx-auto max-w-3xl px-4 sm:px-6 lg:px-8 pt-16">
        <SectionEyebrow>404</SectionEyebrow>
        <SectionTitle className="mt-3">Page not found</SectionTitle>
        <p className="mt-5 text-[15px] text-ink-soft dark:text-d-muted">
          We couldn't find a page for "<span className="num">{kind}</span>". <button onClick={() => setPage('home')} className="text-amber-brand dark:text-amber-warm font-medium underline underline-offset-2">Back to home</button>.
        </p>
      </main>
    );
  }

  const related = Object.keys(CONTENT).filter((k) => k !== kind).slice(0, 5);

  return (
    <main className="pb-32">
      <section className="mx-auto max-w-6xl px-4 sm:px-6 lg:px-8 pt-12 sm:pt-16">
        <div className="grid grid-cols-1 lg:grid-cols-12 gap-10 lg:gap-16">
          {/* Article */}
          <div className="lg:col-span-8">
            <SectionEyebrow>{c.eyebrow}</SectionEyebrow>
            <h1 className="mt-3 font-display font-bold tracking-tightest text-ink dark:text-white text-[36px] sm:text-[52px] lg:text-[64px] leading-[1] text-wrap-pretty">
              {c.title}
            </h1>
            {c.updated && (
              <div className="mt-5 text-[11px] font-mono uppercase tracking-[0.14em] text-ink-soft dark:text-d-muted">
                {c.updated}
              </div>
            )}
            <p className="mt-6 text-[16px] sm:text-[18px] leading-relaxed text-ink dark:text-white max-w-2xl text-wrap-pretty">
              {c.intro}
            </p>

            <div className="mt-12 space-y-12">
              {c.sections.map((s, i) => (
                <section key={i} className="border-t border-line dark:border-d-border pt-8">
                  <div className="grid grid-cols-12 gap-4">
                    <div className="col-span-12 sm:col-span-3 text-[11px] font-mono uppercase tracking-[0.14em] text-ink-soft dark:text-d-muted">
                      <span className="num text-amber-brand dark:text-amber-warm">{String(i + 1).padStart(2, '0')}</span> · {s.h}
                    </div>
                    <div className="col-span-12 sm:col-span-9 space-y-4">
                      {s.body.map((p, j) => (
                        <p key={j} className="text-[15px] leading-relaxed text-ink dark:text-white text-wrap-pretty">{p}</p>
                      ))}
                    </div>
                  </div>
                </section>
              ))}
            </div>
          </div>

          {/* Sidebar */}
          <aside className="lg:col-span-4">
            <div className="sticky top-20 space-y-5">
              <div className="rounded-2xl border border-line dark:border-d-border bg-paper dark:bg-d-surface p-5">
                <div className="text-[10px] font-mono uppercase tracking-[0.16em] text-ink-soft dark:text-d-muted">On this page</div>
                <ol className="mt-3 space-y-2">
                  {c.sections.map((s, i) => (
                    <li key={i} className="flex items-start gap-2 text-[12.5px]">
                      <span className="num text-[10px] text-ink-soft dark:text-d-muted shrink-0 pt-0.5">{String(i + 1).padStart(2, '0')}</span>
                      <a href={`#section-${i}`} className="text-ink dark:text-white hover:text-amber-brand dark:hover:text-amber-warm">{s.h}</a>
                    </li>
                  ))}
                </ol>
              </div>

              <div className="rounded-2xl border border-line dark:border-d-border bg-paper-soft dark:bg-d-surface p-5">
                <div className="text-[10px] font-mono uppercase tracking-[0.16em] text-ink-soft dark:text-d-muted">More from SpecEagle</div>
                <div className="mt-3 space-y-2">
                  {related.map((k) => (
                    <button
                      key={k}
                      onClick={() => setPage(`content.${k}`)}
                      className="block w-full text-left text-[13px] text-ink dark:text-white hover:text-amber-brand dark:hover:text-amber-warm"
                    >
                      {CONTENT[k].title}
                    </button>
                  ))}
                </div>
              </div>
            </div>
          </aside>
        </div>
      </section>
    </main>
  );
};

Object.assign(window, { CONTENT, ContentPage });
