/* global window */
/* =========================================================
   ATLAS DATA — the ImmunoShield Demand Discovery session,
   seeded as evidence. Sourced from the P1–P7 working notes.
   ========================================================= */

const LOCATIONS = [
  { id: "observatory",   idx: "I",   roman: "01", phase: "Listening",      name: "The Observatory",          coord: "FIELD 01 · 51.477° N",  prompt: "What are we hearing — before we decide what it means?" },
  { id: "cartographer",  idx: "II",  roman: "02", phase: "Framing",        name: "The Cartographer’s Table", coord: "FIELD 02 · 48.858° N",  prompt: "Which observations belong together — and what challenge do they describe?" },
  { id: "horizon",       idx: "III", roman: "03", phase: "Envisioning",    name: "The Horizon Room",         coord: "FIELD 03 · 64.135° N",  prompt: "If this future became true, what would be different?", dark: true },
  { id: "iceberg",       idx: "IV",  roman: "04", phase: "Assumptions",    name: "The Iceberg Archive",      coord: "FIELD 04 · 78.221° N",  prompt: "What must be true that we are currently taking for granted?" },
  { id: "river",         idx: "V",   roman: "05", phase: "Transformation", name: "The River Crossing",       coord: "FIELD 05 · 45.502° N",  prompt: "What must change, what must remain, and what disappears?" },
  { id: "pass",          idx: "VI",  roman: "06", phase: "Crux",           name: "The Mountain Pass",        coord: "FIELD 06 · 46.534° N",  prompt: "Which single challenge, if solved, unlocks the rest?" },
  { id: "constellation", idx: "VII", roman: "07", phase: "Integration",    name: "The Constellation Chamber",coord: "FIELD 07 · 27.988° N",  prompt: "What now feels obvious that wasn’t obvious before?", dark: true },
];

/* ---------- OBSERVATORY · Listening ---------- */
const LISTENING = {
  intro: "Field notes pinned to the wall. Picked up from the deck, the site, and Matthew’s outreach. Not yet organized. Not yet interpreted.",
  notes: [
    { id: "n1", src: "DECK · SLIDE 04", kind: "quote", coord: "Q-01",
      body: "A cure for some — not for most.",
      prov: ["heard in listening"] },
    { id: "n2", src: "DECK · THESIS", kind: "quote", coord: "Q-02",
      body: "Winning ≠ best cells alone. Winning = working therapy in a better product format.",
      prov: ["heard in listening"] },
    { id: "n3", src: "DECK · MARKET", kind: "stat", coord: "S-01",
      body: "Only ~300K of 1.8M U.S. T1D patients are eligible today. 80% are disqualified by immune-suppression risk.",
      prov: ["heard in listening"] },
    { id: "n4", src: "SITE · ACCESS", kind: "stat", coord: "S-02",
      body: "Immune rejection limits access to ~20% of patients. Removing the barrier could expand the market 5×.",
      prov: ["heard in listening"] },
    { id: "n5", src: "DECK · POSITION", kind: "quote", coord: "Q-03",
      body: "An enabling player, not another full-stack cell bet.",
      prov: ["heard in listening"] },
    { id: "n6", src: "DECK · STRATEGY", kind: "quote", coord: "Q-04",
      body: "The category is de-risked. The product model is not.",
      prov: ["heard in listening"] },
    { id: "n7", src: "DECK · PIPELINE", kind: "quote", coord: "Q-05",
      body: "One company, two linked programs.",
      prov: ["heard in listening"] },
    { id: "n8", src: "OBSERVATION", kind: "signal", coord: "O-01",
      body: "Safety is the wedge. Retrievability matters because reversibility lowers fear — for regulators, clinicians, investors, patients.",
      prov: ["heard in listening"] },
    { id: "n9", src: "SITE · GTM", kind: "quote", coord: "Q-06",
      body: "ImmunoShield is uniquely positioned to make competitors into potential cell-therapy partners.",
      prov: ["heard in listening"] },
    { id: "n10", src: "OBSERVATION", kind: "signal", coord: "O-02",
      body: "Manufacturing is not a back-office issue. It is central to the value proposition.",
      prov: ["heard in listening"] },
    { id: "n11", src: "EMAIL · MATTHEW", kind: "quote", coord: "Q-07",
      body: "Raise against de-risked milestones rather than promise alone.",
      prov: ["heard in listening"] },
    { id: "n12", src: "OBSERVATION", kind: "signal", coord: "O-03",
      body: "T1D is the beachhead, not the boundary. The platform is described as disease-agnostic.",
      prov: ["heard in listening"] },
  ],
  prompts: ["What surprises us?", "What feels important?", "What doesn’t fit?"],
  reflect: "What we hear is that ImmunoShield is not trying to build a better encapsulation device. It is trying to solve the productization problem in allogeneic cell therapy — protected, retrievable, scalable, partner-ready, and eventually free of chronic immune suppression.",
};

/* ---------- CARTOGRAPHER · Framing ---------- */
const FRAMING = {
  intro: "The notes return as objects. We don’t cluster everything at once. We make local decisions — two at a time — and let groups emerge.",
  pairs: [
    { id: "p1",
      a: { src: "Q-03", text: "An enabling player, not another full-stack cell bet." },
      b: { src: "Q-06", text: "Make competitors into potential cell-therapy partners." },
      belong: true,
      because: "Both describe a position, not a product: value accrues to the enabling layer, and rivals become the customer base." },
    { id: "p2",
      a: { src: "S-01", text: "300K of 1.8M eligible — 80% disqualified by immune suppression." },
      b: { src: "Q-02", text: "Winning = working therapy in a better product format." },
      belong: true,
      because: "Eligibility is a product-format problem, not a cell-quality problem. The format is what expands the funnel." },
    { id: "p3",
      a: { src: "O-01", text: "Retrievability lowers fear for regulators and investors." },
      b: { src: "Q-07", text: "Raise against de-risked milestones rather than promise." },
      belong: true,
      because: "Both are about removing uncertainty. Value is created by de-risking, not by claims." },
    { id: "p4",
      a: { src: "Q-05", text: "One company, two linked programs." },
      b: { src: "S-02", text: "Removing the barrier could expand the market 5×." },
      belong: false,
      because: "A pipeline-structure note and a market-sizing note point at different questions. Keep them apart for now." },
  ],
  problems: [
    { n: "01", title: "The access problem", text: "Allogeneic cell therapies can cure — but immune suppression disqualifies most patients. How do we expand eligibility from a small high-risk group to the broader disease population?", visible: true },
    { n: "02", title: "The productization problem", text: "The cells are becoming good enough. The bottleneck is protection, delivery, manufacturing, retrievability, immune management. Not “who has the best cells” but “who turns good cells into scalable products.”", visible: true },
    { n: "03", title: "The partner-adoption problem", text: "Even if it works scientifically, partners must choose to adopt it. How do we become easier to adopt than building a competing solution internally?", visible: false },
    { n: "04", title: "The platform-credibility problem", text: "We ask partners to believe protection, tolerance, retrievability, and manufacturing matter — before human proof exists. How much evidence makes us infrastructure rather than experiment?", visible: false },
  ],
  visibleChallenge: "How do we eliminate immune suppression from allogeneic cell therapies?",
  deeperChallenge: "How do we become the indispensable enabling layer in an emerging cell-therapy ecosystem — before larger players solve the same problem internally?",
};

/* ---------- HORIZON · Envisioning ---------- */
const ENVISIONING = {
  intro: "A dark room. Three possible futures sit on the horizon as distant lights. Each expands when you approach it.",
  futures: [
    { id: "f1", label: "Therapeutic company", bearing: "BEARING 312°",
      line: "Build a T1D cell therapy end-to-end.",
      consequences: ["Highest control over outcome.", "Highest capital requirement.", "Slowest path to value.", "You compete with Vertex, Sana, Lilly head-on."],
      verdict: "High control, high burn." },
    { id: "f2", label: "Device / platform company", bearing: "BEARING 047°", recommended: true,
      line: "Lead with spiral macroencapsulation.",
      consequences: ["Win through protection, retrievability, manufacturability, partner fit.", "Lower capital, faster to a fundable inflection.", "Competitors can become customers.", "Near-term value driver with a clear wedge."],
      verdict: "The clearest, most fundable vision." },
    { id: "f3", label: "Full immune-tolerance platform", bearing: "BEARING 184°",
      line: "Push pregnancy-inspired tolerance as the core.",
      consequences: ["Potentially the largest prize.", "More biologically and clinically complex.", "Asks partners to believe the whole thesis early.", "Best held as longer-term upside."],
      verdict: "The upside — not the wedge." },
  ],
  vision: "ImmunoShield wins when the industry stops asking, “Can they build a cell therapy?” and starts asking, “Which cell therapies become more viable if they use ImmunoShield?”",
  signals: [
    "A pharma or cell-therapy company funds feasibility work.",
    "A partner supplies cells for platform testing.",
    "FDA feedback clarifies the approval path.",
    "Large-animal data supports safety, function, retrievability.",
    "Financing shifts from belief to milestone.",
  ],
};

/* ---------- ICEBERG · Assumptions ---------- */
const ASSUMPTIONS = {
  intro: "Each idea floats above the waterline. Pull it down to surface the assumption it rests on — and the counterfactual that would sink it.",
  items: [
    { id: "a1", idea: "Immune suppression is the decisive adoption bottleneck.",
      assumption: "Partners rank immune suppression above efficacy, durability, CMC, reimbursement, and surgical burden.",
      counter: "Partners care more about efficacy or reimbursement.",
      test: "Interview 10 pharma/biotech buyers. Force-rank the adoption blockers.",
      weight: "HIGHEST" },
    { id: "a2", idea: "Partners want an enabling layer, not another full-stack therapy.",
      assumption: "Cell-therapy developers would rather license protection than own it internally.",
      counter: "Partners prefer to build delivery and protection in-house.",
      test: "Ask target accounts: license, co-develop, build, acquire, or ignore?",
      weight: "HIGHEST" },
    { id: "a3", idea: "Manufacturing fit is a differentiator.",
      assumption: "CMC teams see hydrogel injection molding as transferable to their process.",
      counter: "CMC teams see it as another process risk.",
      test: "Independent CMC audit → partner-facing process map + top-5 gaps.",
      weight: "HIGH" },
    { id: "a4", idea: "The FDA path is manageable.",
      assumption: "Combination-product questions won’t add major time or evidence burden.",
      counter: "Combination-product uncertainty delays partner adoption.",
      test: "Prepare an INTERACT question package; seek early FDA feedback.",
      weight: "HIGH" },
    { id: "a5", idea: "NHP data will unlock partner confidence.",
      assumption: "Large-animal endpoints are decision-grade for partners, not just scientifically positive.",
      counter: "Data proves science but not adoption.",
      test: "Pre-align NHP endpoints with 3 partners before study lock.",
      weight: "HIGH" },
    { id: "a6", idea: "Partners will pay for feasibility.",
      assumption: "$150–250K partner-readiness sprints are sellable today.",
      counter: "They praise the science but wait for more data.",
      test: "Offer the priced package. Record: accept, reject, or re-scope.",
      weight: "MEDIUM" },
  ],
  framing: "The riskiest assumptions are not scientific. They sit at the junction of partner behavior, CMC adoption, regulatory interpretation, and milestone financing.",
};

/* ---------- RIVER · Transformation (placeholder, on-thesis) ---------- */
const TRANSFORMATION = {
  placeholder: true,
  intro: "Two banks. Today on the near side, tomorrow on the far. We place what crosses, what stays, and what is left behind. The bridge is the transformation itself.",
  today: { label: "TODAY — THE NEAR BANK", items: [
    "Judged as a science company.",
    "Value measured by the quality of the cells.",
    "A promising preclinical device.",
    "Raising against the story.",
  ]},
  tomorrow: { label: "TOMORROW — THE FAR BANK", items: [
    "Judged as partner-ready infrastructure.",
    "Value measured by risk removed for the partner.",
    "The operating layer that makes good cells viable products.",
    "Raising against de-risked milestones.",
  ]},
  bridge: [
    { q: "What must change?", a: "The unit of value — from the elegance of the device to the behavior of a partner. Evidence must become decision-grade, not just positive." },
    { q: "What must remain?", a: "Scientific credibility, retrievability as the safety wedge, and the disease-agnostic ambition underneath T1D." },
    { q: "What disappears?", a: "“Praise as progress.” The full-stack temptation. Selling the whole platform before the wedge is proven." },
  ],
  note: "Transformation has no working note from this session yet — this bank is staged as placeholder and is one of the steps the facilitator may activate live.",
};

/* ---------- PASS · Crux ---------- */
const CRUX = {
  intro: "The landscape narrows. Evidence from every prior field converges on the pass. Only a few paths remain. We compare candidate cruxes one at a time.",
  pivotalReminder: "Which challenge, if solved, makes the others easier?",
  candidates: [
    { id: "c1", rank: 1, from: "Promising science", to: "Partner-ready infrastructure",
      why: "Captures the real buyer question. Partners adopt when a technology improves the fate of their program — not because it is elegant.",
      crit: "Less inspiring than “curing T1D,” but more strategic.", recommended: true },
    { id: "c2", rank: 2, from: "Best cells", to: "Best product format",
      why: "Uses ImmunoShield’s strongest line. A strong market narrative.",
      crit: "Still needs proof that partners agree." },
    { id: "c3", rank: 3, from: "T1D cure story", to: "Eligibility expansion",
      why: "Ties to “cure for some — not for most” and the 300K→1.8M thesis.",
      crit: "Overreaches unless eligibility is validated clinically and commercially." },
    { id: "c4", rank: 4, from: "Device company", to: "De-risking company",
      why: "Supports the partner-readiness sprint, CMC audit, and FDA package.",
      crit: "May underplay the proprietary technology if used too bluntly." },
    { id: "c5", rank: 5, from: "Competitor landscape", to: "Partner ecosystem",
      why: "Converts competitive pressure into strategic optionality.",
      crit: "Politically hard; rivals may prefer internal solutions." },
    { id: "c6", rank: 6, from: "Tolerance breakthrough", to: "Macroencapsulation wedge",
      why: "Avoids forcing partners to believe the whole vision too early.",
      crit: "Could make the company look narrower if tolerance isn’t visible as upside." },
  ],
  statement: "ImmunoShield’s crux is to prove that its spiral macroencapsulation platform is the fastest, least disruptive way for allogeneic cell-therapy developers to make their cells safer, retrievable, scalable, and partner-ready — before partners decide to build, buy, wait, or stay with immunosuppression.",
  moves: [
    { n: "01", t: "Partner proof", d: "Secure an LOI, cells / data access, or paid feasibility." },
    { n: "02", t: "CMC proof", d: "Produce a partner-facing manufacturing-integration map." },
    { n: "03", t: "Regulatory proof", d: "Prepare the FDA INTERACT / Pre-IND question package." },
  ],
};

/* ---------- CONSTELLATION · Integration ---------- */
const INTEGRATION = {
  intro: "The room darkens. Nothing new appears — only relationships. The insights we gathered light up, and the lines between them become visible.",
  truth: "Praise is not proof. Interest is not adoption. A meeting is not momentum.",
  stars: [
    { id: "s1", label: "The crux is partner behavior", x: 22, y: 30, mag: 3,
      note: "Before every question, ask: what behavior would prove this?" },
    { id: "s2", label: "Data must become decision-grade", x: 48, y: 22, mag: 2,
      note: "For every milestone: who changes what if this passes?" },
    { id: "s3", label: "Lead with the wedge, preserve the upside", x: 70, y: 38, mag: 3,
      note: "Separate the macroencapsulation story from the tolerance story." },
    { id: "s4", label: "Strategy is the smallest solvable crux", x: 36, y: 60, mag: 2,
      note: "Find one action that forces a real yes / no." },
    { id: "s5", label: "Competitors may become customers", x: 80, y: 66, mag: 1,
      note: "The market question is: how many of them might need us?" },
    { id: "s6", label: "Value is created by uncertainty removal", x: 58, y: 74, mag: 2,
      note: "Not by claims. De-risk, then raise." },
  ],
  links: [["s1","s2"],["s2","s3"],["s1","s4"],["s4","s6"],["s2","s5"],["s3","s5"],["s4","s2"]],
  identity: "I am now someone who looks past the elegance of the idea and asks what concrete behavior would prove the strategy is real.",
  closing: "The proof is partner behavior. A good meeting is not progress unless someone commits cells, budget, data, or a next step.",
};

/* ---------- FRICTION GATES (between stages) ---------- */
const GATES = {
  // shown before entering target location id
  cartographer: { eyebrow: "BEFORE THE TABLE", q: "Which note most changed how you’re thinking?",
    opts: ["A cure for some — not for most.", "Winning = a better product format.", "Make competitors into partners.", "Retrievability lowers fear."] },
  pass: { eyebrow: "BEFORE THE PASS", q: "Which observation most changed your thinking on this expedition?",
    opts: ["Eligibility is a product problem, not a cell problem.", "Value accrues to the enabling layer.", "Praise is not the same as commitment.", "De-risking is the thing being sold."] },
  constellation: { eyebrow: "BEFORE THE CHAMBER", q: "To enter, you must abandon one idea you arrived with.",
    opts: ["“Better science will win on its own.”", "“A good meeting means momentum.”", "“We must prove the whole platform first.”", "“Competitors are only competitors.”"] },
};

window.ATLAS_DATA = { LOCATIONS, LISTENING, FRAMING, ENVISIONING, ASSUMPTIONS, TRANSFORMATION, CRUX, INTEGRATION, GATES };
