// Sefra - industry variants, selected by ?for= query param
// Meta ads deep-link to ?for=workers-comp / carriers / healthcare.
// No param (or unknown) → 'insurance' (the flagship, insurance-geared look).
// ────────────────────────────────────────────────────────────────

const INDUSTRIES = {
  // ── DEFAULT / MAIN - broad P&C insurance ──
  insurance: {
    key: 'insurance',
    label: 'Insurance',
    title: 'Sefra - Put Guidewire, Duck Creek & your legacy systems on autopilot',
    pill: 'A browser agent for Guidewire, Duck Creek & legacy insurance systems',
    headPre: 'Put Guidewire, Duck Creek, and every legacy system',
    headAccent: 'on autopilot.',
    sub: "Sefra is a browser agent that operates the policy and claims cores insurers actually run on - Guidewire, Duck Creek, Majesco, ImageRight - logging in, clicking through, keying data, finishing the task. Trigger it from an email, Slack, or a nightly job. No setup, nothing to install.",
    videoNoun: 'Guidewire / Duck Creek workflow',
    mock: {
      running: 'Guidewire ClaimCenter (v8, legacy)',
      winTitle: 'Guidewire ClaimCenter - Policy & Claims',
      menus: ['File', 'Desktop', 'Policy', 'Claims'],
      fields: [
        ['Policy No.', 'POL-2026-88231', true],
        ['Insured', 'NORTHGATE LOGISTICS', false],
        ['Coverage', 'COMMERCIAL AUTO', false],
        ['Endorsement', 'ADD VEHICLE', true],
        ['Premium', '$1,840.00', true],
      ],
      steps: [
        { t: '00:00', a: 'Trigger received', d: 'Email - "Add vehicle to POL-88231"', kind: 'trigger' },
        { t: '00:02', a: 'Signed in to Guidewire', d: 'ClaimCenter v8 · session opened', kind: 'act' },
        { t: '00:06', a: 'Opened policy POL-88231', d: 'Northgate Logistics · 3 menus deep', kind: 'act' },
        { t: '00:11', a: 'Keyed endorsement', d: 'Add vehicle · recalculated premium', kind: 'act' },
        { t: '00:15', a: 'Issued dec page', d: 'Endorsement bound · saved', kind: 'act' },
        { t: '00:17', a: 'Replied in Slack', d: '#policy-ops - "Bound. +$1,840 premium."', kind: 'done' },
      ],
    },
    useEyebrow: 'Built for Guidewire & Duck Creek shops',
    useHead: 'The cores your team fights every day.',
    usePrimary: [
      'Issue endorsements, renewals, and cancellations in Guidewire & Duck Creek',
      'Rekey broker submissions from email into your policy core',
      'Pull policy and claim status out of ImageRight and into your reports',
      'File forms and notices on state DOI and carrier portals',
    ],
  },

  // ── Workers' comp TPAs ──
  'workers-comp': {
    key: 'workers-comp',
    label: "Workers' Comp",
    title: "Sefra - Put RiskMaster, Origami & your claims system on autopilot",
    pill: 'A browser agent for RiskMaster, Origami & FileHandler',
    headPre: 'Put RiskMaster, Origami, and FileHandler',
    headAccent: 'on autopilot.',
    sub: "Sefra is a browser agent that operates the claims systems workers'-comp TPAs actually run on - RiskMaster, Origami Risk, DXC FileHandler, Mitchell - logging in, combing the report, keying the payment, firing the letter. Trigger it from an email, Slack, or a nightly job. No setup, nothing to install.",
    videoNoun: 'RiskMaster / Origami claim',
    mock: {
      running: 'RiskMaster Accelerator (legacy)',
      winTitle: 'RiskMaster - Claim Entry',
      menus: ['File', 'Edit', 'Claim', 'Payments'],
      fields: [
        ['Claim No.', 'WC-2026-04812', true],
        ['Claimant', 'VELASQUEZ, MARIA', false],
        ['Provider', 'BAY AREA ORTHO', false],
        ['Proc Code', '99214', true],
        ['Amount', '$248.00', true],
      ],
      steps: [
        { t: '00:00', a: 'Trigger received', d: 'Email - "Pay PT invoice, claim WC-04812"', kind: 'trigger' },
        { t: '00:02', a: 'Signed in to RiskMaster', d: 'Accelerator · session opened', kind: 'act' },
        { t: '00:06', a: 'Opened claim WC-04812', d: 'Velasquez, Maria · 4 menus deep', kind: 'act' },
        { t: '00:11', a: 'Keyed payment', d: 'Bay Area Ortho · $248.00 · code 99214', kind: 'act' },
        { t: '00:15', a: 'Posted to loss fund', d: 'Authorization matched · saved', kind: 'act' },
        { t: '00:17', a: 'Replied in Slack', d: '#claims-ops - "Paid. Conf #PT-88213."', kind: 'done' },
      ],
    },
    useEyebrow: 'Built for RiskMaster, Origami & FileHandler',
    useHead: 'The claims systems your adjusters fight every day.',
    usePrimary: [
      'Post payments into RiskMaster, Origami Risk, and DXC FileHandler',
      'Comb 60-to-200-page med reports for the 10 fields adjusters need',
      'Fire accept / delay / deny letters from one trigger',
      'File forms on state WC boards (DWC, WCAB) and chase the 48-hour clock',
    ],
  },

  // ── Insurance carriers - policy admin / underwriting ──
  carriers: {
    key: 'carriers',
    label: 'Carriers',
    title: 'Sefra - Put PolicyCenter & Duck Creek Policy on autopilot',
    pill: 'A browser agent for Guidewire PolicyCenter & Duck Creek',
    headPre: 'Put Guidewire PolicyCenter and Duck Creek',
    headAccent: 'on autopilot.',
    sub: 'Sefra is a browser agent that operates the policy admin and rating cores carriers run on - Guidewire PolicyCenter, Duck Creek Policy, Majesco - logging in, keying submissions, rating, binding. Trigger it from an email, Slack, or a nightly job. No setup, nothing to install.',
    videoNoun: 'PolicyCenter / Duck Creek workflow',
    mock: {
      running: 'Guidewire PolicyCenter (legacy)',
      winTitle: 'PolicyCenter - Policy Admin',
      menus: ['File', 'Account', 'Policy', 'Billing'],
      fields: [
        ['Policy No.', 'CP-2026-55190', true],
        ['Insured', 'HARBOR POINT LLC', false],
        ['Effective', '07/01/2026', false],
        ['Action', 'RENEWAL', true],
        ['Premium', '$12,400.00', true],
      ],
      steps: [
        { t: '00:00', a: 'Trigger received', d: 'Email - "Process renewal CP-55190"', kind: 'trigger' },
        { t: '00:02', a: 'Signed in to PolicyCenter', d: 'Guidewire · session opened', kind: 'act' },
        { t: '00:06', a: 'Opened policy CP-55190', d: 'Harbor Point LLC · 3 menus deep', kind: 'act' },
        { t: '00:11', a: 'Applied rate change', d: 'Renewal terms · recalculated premium', kind: 'act' },
        { t: '00:15', a: 'Posted to billing', d: 'Dec page regenerated · saved', kind: 'act' },
        { t: '00:17', a: 'Replied in Slack', d: '#uw-ops - "Renewed. $12.4k premium."', kind: 'done' },
      ],
    },
    useEyebrow: 'Built for PolicyCenter & Duck Creek',
    useHead: 'The policy cores your underwriters fight every day.',
    usePrimary: [
      'Process renewals, endorsements, and cancellations in PolicyCenter & Duck Creek',
      'Rekey broker submissions from email into your rating system',
      'Pull loss runs and clearance from legacy systems for faster first quotes',
      'Reconcile premium and commission across billing cores',
    ],
  },

  // ── Healthcare revenue cycle / health TPA ──
  healthcare: {
    key: 'healthcare',
    label: 'Healthcare RCM',
    title: 'Sefra - Put payer portals, QNXT & Availity on autopilot',
    pill: 'A browser agent for payer portals, QNXT & Availity',
    headPre: 'Put Availity, QNXT, and every payer portal',
    headAccent: 'on autopilot.',
    sub: 'Sefra is a browser agent that works the payer portals and core platforms billing teams fight every day - Availity, Optum, TriZetto QNXT/Facets, HealthEdge - logging in, checking status, posting, working denials. Trigger it from an email, Slack, or a nightly schedule. No setup, nothing to install.',
    videoNoun: 'payer-portal / QNXT workflow',
    mock: {
      running: 'TriZetto QNXT (legacy)',
      winTitle: 'QNXT - Claim Status',
      menus: ['File', 'Member', 'Claims', 'Billing'],
      fields: [
        ['Claim ID', 'CLM-2026-77403', true],
        ['Patient', 'OKAFOR, DANIEL', false],
        ['Payer', 'BLUE SHIELD', false],
        ['CPT', '99213', true],
        ['Charge', '$186.00', true],
      ],
      steps: [
        { t: '00:00', a: 'Trigger received', d: 'Scheduled - "Status check, denied-claims batch"', kind: 'trigger' },
        { t: '00:02', a: 'Signed in to Availity', d: 'Blue Shield payer portal · opened', kind: 'act' },
        { t: '00:06', a: 'Looked up CLM-77403', d: 'Okafor, Daniel · 3 screens deep', kind: 'act' },
        { t: '00:11', a: 'Read status: DENIED', d: 'CARC CO-97 · captured to worklist', kind: 'act' },
        { t: '00:15', a: 'Keyed denial into QNXT', d: 'Flagged for appeal', kind: 'act' },
        { t: '00:17', a: 'Replied in Slack', d: '#rcm-ops - "12 denials worked. 3 to appeal."', kind: 'done' },
      ],
    },
    useEyebrow: 'Built for Availity, QNXT & HealthEdge',
    useHead: 'The payer portals your billers fight every day.',
    usePrimary: [
      'Check claim status and eligibility across Availity, Optum, and payer portals',
      'Post payments and adjustments into TriZetto QNXT, Facets, and HealthEdge',
      'Work denials (CO-97, CO-45) and rekey them into appeal worklists',
      'Pull 835 remittance and EOB data into your reports',
    ],
  },
};

// Shared "beyond" grid - adapts which industries to show as "adjacent"
function beyondFor(key) {
  const all = {
    insurance: ['Insurance carriers', 'Renewals and binding in Guidewire PolicyCenter & Duck Creek.'],
    'workers-comp': ["Workers' comp TPAs", 'Payments and letters in RiskMaster, Origami & FileHandler.'],
    carriers: ['Carrier policy admin', 'Submissions and rating in PolicyCenter & Duck Creek.'],
    healthcare: ['Healthcare RCM', 'Status and denials on Availity, Optum & TriZetto QNXT.'],
    logistics: ['Logistics', 'Loads and status in McLeod, MercuryGate & carrier TMS portals.'],
    government: ['Government filing', 'Recurring filings on state agency portals with no modern way in.'],
    collections: ['Collections & AR', 'Ledgers and statements across legacy ERPs and AS/400 screens.'],
  };
  // show three industries other than the current one, plus a wildcard
  const order = ['insurance', 'workers-comp', 'carriers', 'healthcare', 'logistics', 'government', 'collections'];
  const picks = order.filter((k) => k !== key).slice(0, 4);
  return picks.map((k) => all[k]);
}

function getIndustry() {
  let key = 'insurance';
  try {
    const p = new URLSearchParams(window.location.search).get('for');
    if (p && INDUSTRIES[p]) key = p;
  } catch (e) {}
  return INDUSTRIES[key];
}

Object.assign(window, { INDUSTRIES, getIndustry, beyondFor });
