/* =====================================================================
   data.jsx — content + mock data layer for the Freedom Filled Pathway Audit
   (kept separate from logic + design, per the build brief)
   ===================================================================== */

const AUDIT = {
  name: "The Freedom Filled\u00ae Pathway Audit",
  shortName: "Pathway Audit",
  subhook: "Find where freedom is leaking in your business, and the next move that closes it.",
  auditVersion: "v0.1",
  scoringVersion: "2026-06-08-ffp-audit-v0.1",
  questionCount: 24,
};

/* ---- 8 internal dimensions + result-facing language ---- */
const DIMENSIONS = [
  { key: "offer_spine",         internal: "Offer Spine",         leak: "Offer Leak",            short: "Offer",       blurb: "Clarity, transformation, audience fit, pricing, buying pathway." },
  { key: "trust_production",    internal: "Trust Production",    leak: "Trust Leak",            short: "Trust",       blurb: "Proof, authority, credibility, point of view, cold-audience trust." },
  { key: "demand_engine",       internal: "Demand Engine",       leak: "Visibility Leak",       short: "Visibility",  blurb: "Content that works, lead capture, traffic focus, demand creation." },
  { key: "sales_leadership",    internal: "Sales Leadership",    leak: "Revenue Leak",          short: "Revenue",     blurb: "Follow-up, conversion confidence, leading a buying decision." },
  { key: "delivery_leverage",   internal: "Delivery Leverage",   leak: "Capacity Leak",         short: "Capacity",    blurb: "Founder dependency, delivery load, repeatability, boundaries." },
  { key: "life_integration",    internal: "Life Integration",    leak: "Freedom Leak",          short: "Freedom",     blurb: "Family presence, time cost, nervous-system load, ideal week." },
  { key: "ceo_identity",        internal: "CEO Identity",        leak: "Leadership Leak",       short: "Leadership",  blurb: "Decision rhythm, delegation, ownership, money identity." },
  { key: "expansion_readiness", internal: "Expansion Readiness", leak: "Scale & Market Leak",   short: "Expansion",   blurb: "Message travel, premium pathway, systems ready for more." },
];
const DIM = Object.fromEntries(DIMENSIONS.map(d => [d.key, d]));

/* ---- Result bands (names = content; thresholds = logic) ---- */
const BANDS = [
  { key: "leaking_heavily",   name: "Leaking Heavily",     min: 0,  max: 39, note: "Freedom is draining faster than the business can refill it. This is a foundations moment, not a failure." },
  { key: "patchwork_growth",  name: "Patchwork Growth",    min: 40, max: 59, note: "Real momentum, held together manually. A few structural fixes would change everything." },
  { key: "freedom_ready_build", name: "Freedom-Ready Build", min: 60, max: 79, note: "A genuinely good business with one or two clear leaks costing you more than you realise." },
  { key: "expansion_ready",   name: "Expansion-Ready",     min: 80, max: 100, note: "Stable, trusted and leverage-rich. The next move is premium expansion, not repair." },
];

/* ---- Archetypes (names = content; keys = logic) ---- */
const ARCHETYPES = {
  hidden_authority:      { key: "hidden_authority",      name: "The Hidden Authority" },
  offer_fog_founder:     { key: "offer_fog_founder",     name: "The Offer Fog Founder" },
  trust_rich_teacher:    { key: "trust_rich_teacher",    name: "The Trust-Rich Teacher" },
  manual_maxer:          { key: "manual_maxer",          name: "The Manual Maxer" },
  launch_tired_leader:   { key: "launch_tired_leader",   name: "The Launch-Tired Leader" },
  family_costing_ceo:    { key: "family_costing_ceo",    name: "The Family-Costing CEO" },
  almost_ready_authority:{ key: "almost_ready_authority",name: "The Almost-Ready Authority" },
  expansion_candidate:   { key: "expansion_candidate",   name: "The Expansion Candidate" },
};

/* ---- Profile field options ---- */
const COUNTRIES = ["Australia", "United States", "United Kingdom", "Canada", "New Zealand", "Other"];
const BUSINESS_STAGES = [
  { v: "idea",        label: "Idea or early foundations" },
  { v: "inconsistent",label: "Growing but inconsistent" },
  { v: "established", label: "Established with clients or students" },
  { v: "scaling",     label: "Scaling into more leverage" },
];
const OFFER_TYPES = [
  { v: "services",   label: "1:1 services or coaching" },
  { v: "group",      label: "Group program" },
  { v: "course",     label: "Course or digital product" },
  { v: "membership", label: "Membership" },
  { v: "mix",        label: "A mix of offers" },
];
const SOURCES = [
  { v: "podcast", label: "Podcast" },
  { v: "media",   label: "Article or media feature" },
  { v: "workshop",label: "Workshop or webinar" },
  { v: "partner", label: "Partner or referral" },
  { v: "organic", label: "Instagram, email, or organic search" },
];

/* =====================================================================
   24 SCORED QUESTIONS — 3 per dimension, 4 answers each.
   Answer order runs strongest -> weakest for readability; in production
   the scores object drives the engine, not the order.
   ===================================================================== */
const QUESTIONS = [
  // --- Offer Spine ---
  { id: "offer_clarity", dim: "offer_spine",
    text: "When someone lands on your page or profile, how quickly can they tell what you sell?",
    options: [
      { id: "instant", text: "Instantly. One line, one clear transformation, every time." },
      { id: "mostly",  text: "Mostly clear, though I describe it a few different ways." },
      { id: "depends", text: "It depends who's asking. I tailor it on the spot." },
      { id: "decode",  text: "They'd have to decode it. I explain it differently all the time." },
    ] },
  { id: "transformation", dim: "offer_spine",
    text: "Can you name the specific before-and-after your best offer creates?",
    options: [
      { id: "sharp",   text: "Yes, sharply. I can say it in a sentence and back it with results." },
      { id: "general", text: "Generally, but it comes out as features more than outcomes." },
      { id: "feel",    text: "I know the feeling I create, less the measurable change." },
      { id: "unsure",  text: "Honestly, I'm still working out what the real transformation is." },
    ] },
  { id: "pricing_confidence", dim: "offer_spine",
    text: "How does it feel to say your prices out loud?",
    options: [
      { id: "easy",    text: "Easy. The price matches the value and I don't flinch." },
      { id: "ok",      text: "Mostly fine, with the occasional wobble on bigger offers." },
      { id: "justify", text: "I tend to over-explain or justify the number." },
      { id: "avoid",   text: "I avoid it. I'd rather they find the price somewhere else." },
    ] },

  // --- Trust Production ---
  { id: "proof", dim: "trust_production",
    text: "If a stranger checked you out today, how much proof would they find?",
    options: [
      { id: "plenty",  text: "Plenty. Stories, results and a clear point of view everywhere." },
      { id: "some",    text: "Some. A handful of testimonials and a few good posts." },
      { id: "thin",    text: "Thin. I have results but I rarely show them." },
      { id: "none",    text: "Almost none they could find without asking me directly." },
    ] },
  { id: "authority", dim: "trust_production",
    text: "Do you have a clear, repeatable point of view people associate with you?",
    options: [
      { id: "known",   text: "Yes. People quote my framing back to me." },
      { id: "forming", text: "It's forming. I have themes but not a signature stance." },
      { id: "varies",  text: "It varies with whatever I'm reading or watching that month." },
      { id: "no",      text: "Not really. I sound like a lot of other people in my space." },
    ] },
  { id: "cold_trust", dim: "trust_production",
    text: "How well do people who've never met you warm up to you?",
    options: [
      { id: "fast",    text: "Fast. Cold audiences convert without me on a call." },
      { id: "warms",   text: "They warm up once they consume a bit of my content." },
      { id: "slow",    text: "Slowly. It really only works if someone refers me." },
      { id: "cold",    text: "Cold traffic mostly bounces. I rely on people who know me." },
    ] },

  // --- Demand Engine ---
  { id: "content_effect", dim: "demand_engine",
    text: "Does your content actually create demand, or just fill the feed?",
    options: [
      { id: "demand",  text: "It creates demand. Posts lead to enquiries I can trace." },
      { id: "some",    text: "Sometimes. The occasional post lands, but it's unpredictable." },
      { id: "presence",text: "It keeps me present more than it drives action." },
      { id: "void",    text: "I post into the void and hope something happens." },
    ] },
  { id: "lead_capture", dim: "demand_engine",
    text: "When someone's interested, where do they go?",
    options: [
      { id: "system",  text: "Onto a list or waitlist I own, with a clear next step." },
      { id: "freebie", text: "To a freebie, though I don't nurture them consistently." },
      { id: "dm",      text: "Into my DMs or comments, which I chase manually." },
      { id: "nowhere", text: "Nowhere structured. Interest evaporates if I'm not watching." },
    ] },
  { id: "traffic_focus", dim: "demand_engine",
    text: "How focused is your visibility effort?",
    options: [
      { id: "focused", text: "One or two channels, done consistently and well." },
      { id: "main",    text: "A main channel plus a few I dabble in." },
      { id: "spread",  text: "Spread thin across everything, consistent nowhere." },
      { id: "reactive",text: "Whatever I can manage that week. It's reactive." },
    ] },

  // --- Sales Leadership ---
  { id: "follow_up", dim: "sales_leadership",
    text: "What happens after someone says they're interested?",
    options: [
      { id: "lead",    text: "I lead them. Clear follow-up, clear invitation, clear decision." },
      { id: "soft",    text: "I follow up softly, then back off so I don't seem pushy." },
      { id: "wait",    text: "I wait for them to come back to me." },
      { id: "drop",    text: "It usually goes quiet and I let it drop." },
    ] },
  { id: "conversion_conf", dim: "sales_leadership",
    text: "How confident are you guiding a buying conversation?",
    options: [
      { id: "very",    text: "Very. I can hold the moment and ask for the decision." },
      { id: "ok",      text: "Okay on a good day, shaky when the stakes feel high." },
      { id: "hope",    text: "I present, then hope the offer sells itself." },
      { id: "avoid",   text: "I avoid the direct ask almost entirely." },
    ] },
  { id: "buying_path", dim: "sales_leadership",
    text: "How easy is it to actually buy from you?",
    options: [
      { id: "frictionless", text: "Frictionless. Clear path, clear yes." },
      { id: "fewsteps", text: "A few unnecessary steps, but it works." },
      { id: "manual",  text: "Manual. I assemble the path each time by hand." },
      { id: "unclear", text: "Even keen people aren't sure how to say yes." },
    ] },

  // --- Delivery Leverage ---
  { id: "founder_dependency", dim: "delivery_leverage",
    text: "If you stepped back for two weeks, what happens to delivery?",
    options: [
      { id: "runs",    text: "It runs. Systems and people carry it without me." },
      { id: "wobbles", text: "It wobbles but survives with some pre-planning." },
      { id: "stalls",  text: "It mostly stalls. I'm the engine." },
      { id: "stops",   text: "It stops. Everything routes through me." },
    ] },
  { id: "delivery_load", dim: "delivery_leverage",
    text: "How heavy is the actual delivery load right now?",
    options: [
      { id: "light",   text: "Light and leveraged. I deliver to many at once." },
      { id: "managed", text: "Manageable, though it's creeping up with each new client." },
      { id: "heavy",   text: "Heavy. More clients means proportionally more of me." },
      { id: "maxed",   text: "Maxed out. I can't take more without breaking something." },
    ] },
  { id: "repeatability", dim: "delivery_leverage",
    text: "How repeatable is the way you deliver?",
    options: [
      { id: "systemised", text: "Fully systemised. Same strong result every time." },
      { id: "partly",  text: "Partly. The shape is there, the detail lives in my head." },
      { id: "fresh",   text: "I reinvent it for almost every client." },
      { id: "winging", text: "I'm honestly winging the delivery each round." },
    ] },

  // --- Life Integration ---
  { id: "family_presence", dim: "life_integration",
    text: "Is the business letting you be present for the life around it?",
    options: [
      { id: "yes",     text: "Yes. Work fits the life, not the other way around." },
      { id: "mostly",  text: "Mostly, with the odd week that swallows everything." },
      { id: "often",   text: "Often it's the life that gets squeezed, not the work." },
      { id: "rarely",  text: "Rarely. My family gets the leftovers of me." },
    ] },
  { id: "nervous_system", dim: "life_integration",
    text: "How's your nervous system carrying the business right now?",
    options: [
      { id: "steady",  text: "Steady. I work from calm, not adrenaline." },
      { id: "okay",    text: "Okay-ish, with predictable spikes around launches." },
      { id: "wired",   text: "Wired and tired. I'm running on cortisol." },
      { id: "fried",   text: "Frankly fried. I can't switch off." },
    ] },
  { id: "ideal_week", dim: "life_integration",
    text: "How close is your real week to the week you actually want?",
    options: [
      { id: "close",   text: "Close. I designed it and I mostly protect it." },
      { id: "drifts",  text: "It drifts, but I can pull it back." },
      { id: "far",     text: "Far. The week runs me." },
      { id: "nothing", text: "There's no design at all. I react to whatever lands." },
    ] },

  // --- CEO Identity ---
  { id: "decision_rhythm", dim: "ceo_identity",
    text: "How do decisions get made in your business?",
    options: [
      { id: "rhythm",  text: "On a rhythm. I decide quickly and revisit on purpose." },
      { id: "mostly",  text: "Mostly fine, though big ones can sit for weeks." },
      { id: "stuck",   text: "I get stuck. Too many tabs open in my head." },
      { id: "avoid",   text: "I avoid deciding until something forces my hand." },
    ] },
  { id: "delegation", dim: "ceo_identity",
    text: "How does delegation actually feel for you?",
    options: [
      { id: "natural", text: "Natural. I hand off outcomes and trust the result." },
      { id: "learning",text: "I'm learning, but I still over-check the work." },
      { id: "faster",  text: "It feels faster to just do it myself." },
      { id: "cant",    text: "I can't seem to let go of almost anything." },
    ] },
  { id: "money_identity", dim: "ceo_identity",
    text: "How do you relate to money in the business?",
    options: [
      { id: "owner",   text: "Like an owner. I plan it, price for it, pay myself first." },
      { id: "improving", text: "Improving, though I still avoid the numbers some months." },
      { id: "anxious", text: "Anxiously. I react to the bank balance." },
      { id: "fog",     text: "It's a fog. I don't really know my numbers." },
    ] },

  // --- Expansion Readiness ---
  { id: "message_travel", dim: "expansion_readiness",
    text: "Does your message travel without you in the room?",
    options: [
      { id: "travels", text: "Yes. People share it and it converts while I sleep." },
      { id: "some",    text: "Somewhat, if I keep feeding it personally." },
      { id: "tethered",text: "It's tethered to me being live and present." },
      { id: "no",      text: "No. Nothing moves unless I'm actively pushing it." },
    ] },
  { id: "premium_path", dim: "expansion_readiness",
    text: "Do you have a premium pathway for people who want more of you?",
    options: [
      { id: "yes",     text: "Yes, a clear premium tier with a waitlist." },
      { id: "informal",text: "Informally. I create something when someone asks." },
      { id: "idea",    text: "It's an idea I haven't built or priced." },
      { id: "none",    text: "No. My best clients have nowhere to go next." },
    ] },
  { id: "systems_ready", dim: "expansion_readiness",
    text: "If demand doubled next month, could your systems hold it?",
    options: [
      { id: "ready",   text: "Yes. Onboarding, delivery and team could absorb it." },
      { id: "strained",text: "With strain, and a few late nights to patch the gaps." },
      { id: "break",   text: "Something would break. Probably me first." },
      { id: "no",      text: "No chance. I'm already at the edge." },
    ] },
];

/* =====================================================================
   SEEDED SAMPLE RESULT — Leah / The Family-Costing CEO
   (the prototype routes every completed flow to this fixed result)
   ===================================================================== */
const SAMPLE_RESULT = {
  firstName: "Leah",
  completedAt: "8 June 2026",
  overallScore: 74,
  bandKey: "freedom_ready_build",
  archetypeKey: "family_costing_ceo",
  headline: "Leah, your business is not broken. It is leaking freedom through life integration.",
  archetypeLine: "You have built something real and respected. The cost is quietly being paid by your evenings, your presence and your capacity, not your revenue.",
  executiveSummary: "Your audit puts you in a Freedom-Ready Build. The offer is clear, the trust is strong, and people buy. What's leaking is freedom: the business is running on your personal capacity, and the life around it is absorbing the overflow. This is a structural fix, not a hustle problem.",
  dimensionScores: {
    offer_spine: 80,
    trust_production: 88,
    demand_engine: 74,
    sales_leadership: 78,
    delivery_leverage: 49,
    life_integration: 37,
    ceo_identity: 70,
    expansion_readiness: 72,
  },
  primaryLeakKey: "life_integration",
  secondaryLeakKey: "delivery_leverage",
  primaryLeak: {
    meaning: "The business is progressing, but it is quietly taking too much from your energy, family presence, health and identity.",
    why: "A Freedom-Ready Build that leaks here doesn't fail loudly. It succeeds in a way that slowly costs you the exact life the business was meant to fund.",
    cost: "Evenings, nervous-system capacity, relationship presence, rest, and the feeling that the business supports your actual life.",
  },
  sevenDay: {
    action: "Choose one non-negotiable boundary for the next seven days, then remove or move the one business activity that usually breaks it.",
    why: "You don't have a discipline problem, you have a design problem. Protecting a single boundary proves the business can hold a limit, which is the first repair.",
  },
  thirtyDay: [
    { t: "Name the life cost", d: "Write down exactly what the business is currently costing you in time, presence and capacity. You cannot redesign a cost you won't look at." },
    { t: "Redesign the week first", d: "Build the week around energy, family and decision capacity, then fit the business into it, not the reverse." },
    { t: "Change the rhythm that overrides it", d: "Identify the offer, delivery or launch pattern that keeps breaking your boundaries, and restructure that one thing." },
  ],
  recommendedPathway: {
    key: "ffb_strategy_call",
    label: "Freedom Filled\u00ae Business strategy call",
    blurb: "A focused call to map the capacity and freedom repair, and the structural change that protects your week.",
    premiumLabel: "Apply for the Freedom Filled\u00ae Mastermind",
    premiumBlurb: "For established owners ready to build leverage and a premium pathway, by application.",
  },
  signals: ["freedom_leak", "founder_dependency", "strong_trust"],
  tags: [
    "ffp_audit_completed",
    "ffp_audit_band_freedom_ready_build",
    "ffp_audit_leak_freedom",
    "ffp_audit_archetype_family_costing_ceo",
    "ffp_audit_market_au",
    "ffp_audit_source_workshop",
    "ffp_audit_ready_call",
  ],
};

/* helpers */
function bandFor(score) { return BANDS.find(b => score >= b.min && score <= b.max) || BANDS[0]; }
function severityFor(score) {
  if (score < 50) return { key: "active", label: "Active leak", cls: "sev-active" };
  if (score < 70) return { key: "watch",  label: "Watch",       cls: "sev-watch" };
  return { key: "strong", label: "Strength", cls: "sev-strong" };
}
function rankedDims(scores) {
  return DIMENSIONS.map(d => ({ ...d, score: scores[d.key] })).sort((a, b) => a.score - b.score);
}

/* =====================================================================
   SEEDED ADMIN SUBMISSIONS
   ===================================================================== */
const SUBMISSIONS = [
  { id: "FFP-2041", name: "Leah Marsh", email: "leah@thequietbrand.com.au", date: "8 Jun 2026", country: "Australia", stage: "established", offer: "group", source: "workshop", score: 74, bandKey: "freedom_ready_build", archetypeKey: "family_costing_ceo", primary: "life_integration", secondary: "delivery_leverage", pathway: "FFB strategy call", ac: "synced", pdf: "generated", reviewed: false, sample: true },
  { id: "FFP-2040", name: "Priya Nair", email: "priya@nairconsulting.com", date: "8 Jun 2026", country: "United States", stage: "scaling", offer: "course", source: "podcast", score: 86, bandKey: "expansion_ready", archetypeKey: "expansion_candidate", primary: "expansion_readiness", secondary: "demand_engine", pathway: "FFM application", ac: "synced", pdf: "generated", reviewed: true },
  { id: "FFP-2039", name: "Hannah Whitlock", email: "hannah@hwstudio.co.uk", date: "7 Jun 2026", country: "United Kingdom", stage: "inconsistent", offer: "services", source: "media", score: 52, bandKey: "patchwork_growth", archetypeKey: "manual_maxer", primary: "delivery_leverage", secondary: "ceo_identity", pathway: "FFB workshop", ac: "failed", pdf: "generated", reviewed: false },
  { id: "FFP-2038", name: "Sofia Greco", email: "sofia@thegreco.studio", date: "7 Jun 2026", country: "Australia", stage: "established", offer: "membership", source: "partner", score: 68, bandKey: "freedom_ready_build", archetypeKey: "trust_rich_teacher", primary: "sales_leadership", secondary: "expansion_readiness", pathway: "FFB strategy call", ac: "synced", pdf: "failed", reviewed: false },
  { id: "FFP-2037", name: "Renee Adams", email: "renee@reneeadams.co", date: "6 Jun 2026", country: "New Zealand", stage: "idea", offer: "services", source: "organic", score: 34, bandKey: "leaking_heavily", archetypeKey: "offer_fog_founder", primary: "offer_spine", secondary: "life_integration", pathway: "Nurture sequence", ac: "synced", pdf: "generated", reviewed: true },
  { id: "FFP-2036", name: "Mei Tan", email: "mei@meitanhealth.com", date: "6 Jun 2026", country: "Canada", stage: "inconsistent", offer: "course", source: "podcast", score: 47, bandKey: "patchwork_growth", archetypeKey: "hidden_authority", primary: "demand_engine", secondary: "trust_production", pathway: "FFB workshop", ac: "retrying", pdf: "generated", reviewed: false },
  { id: "FFP-2035", name: "Bec Sullivan", email: "bec@sullivansocial.com.au", date: "5 Jun 2026", country: "Australia", stage: "scaling", offer: "mix", source: "workshop", score: 79, bandKey: "freedom_ready_build", archetypeKey: "almost_ready_authority", primary: "expansion_readiness", secondary: "ceo_identity", pathway: "Premium expansion call", ac: "synced", pdf: "generated", reviewed: true },
  { id: "FFP-2034", name: "Carla Mendez", email: "carla@mendezmethod.com", date: "5 Jun 2026", country: "United States", stage: "established", offer: "group", source: "media", score: 61, bandKey: "freedom_ready_build", archetypeKey: "launch_tired_leader", primary: "demand_engine", secondary: "life_integration", pathway: "FFB strategy call", ac: "synced", pdf: "generated", reviewed: false },
  { id: "FFP-2033", name: "Jodie Pearce", email: "jodie@pearcepilates.com.au", date: "4 Jun 2026", country: "Australia", stage: "inconsistent", offer: "membership", source: "organic", score: 43, bandKey: "patchwork_growth", archetypeKey: "manual_maxer", primary: "delivery_leverage", secondary: "demand_engine", pathway: "FFB workshop", ac: "failed", pdf: "pending", reviewed: false },
  { id: "FFP-2032", name: "Anaïs Dubois", email: "anais@studiodubois.fr", date: "4 Jun 2026", country: "Other", stage: "established", offer: "services", source: "partner", score: 71, bandKey: "freedom_ready_build", archetypeKey: "trust_rich_teacher", primary: "sales_leadership", secondary: "delivery_leverage", pathway: "FFB strategy call", ac: "synced", pdf: "generated", reviewed: true },
];

window.FFP = {
  AUDIT, DIMENSIONS, DIM, BANDS, ARCHETYPES,
  COUNTRIES, BUSINESS_STAGES, OFFER_TYPES, SOURCES,
  QUESTIONS, SAMPLE_RESULT, SUBMISSIONS,
  bandFor, severityFor, rankedDims,
};
