// data.jsx — seed concept data
// Knife is the hero example; 11 others populate the library.
// Patterns/Essences reference perspectives by id so the solar system can wire orbits.

const SEED_CONCEPTS = [
  {
    id: "knife",
    title: "Knife",
    category: "Tool",
    consist: "A hardened steel blade with a ground edge, joined to a handle shaped to the hand. Sometimes a guard, sometimes a tang running the length of the grip.",
    function: "Concentrates force along a thin line so that material parts ahead of the edge instead of resisting it. The handle translates the body's intent into a controlled vector.",
    perspectives: [
      { id: "p1", title: "Cooking knife", body: "Slicing onions on a Sunday — the rhythm becomes meditative once the edge is sharp enough that I stop thinking about pressure.", patternId: "pat1" },
      { id: "p2", title: "Pocket knife", body: "Carrying my grandfather's folder when hiking. I almost never need it, but its presence in my pocket changes how I move through the world — more ready, more capable.", patternId: "pat1" },
      { id: "p3", title: "Letter opener", body: "The small ritual of opening a hand-written envelope. The blade isn't doing anything a finger couldn't, but it makes the moment feel deliberate.", patternId: "pat2" },
      { id: "p4", title: "Surgical scalpel (witnessed)", body: "Watching a documentary about surgery. The same object that scares me on the street becomes an instrument of healing in another context.", patternId: null }
    ],
    patterns: [
      { id: "pat1", title: "Extension of intent", body: "A knife is the body extended into the world with more precision than the body alone allows.", essenceId: "es1" },
      { id: "pat2", title: "Ritual of revealing", body: "A knife marks a threshold — what was sealed becomes open, what was hidden becomes accessible.", essenceId: "es1" }
    ],
    essences: [
      { id: "es1", body: "A focused force that separates with intent — the part of me that says 'this, not that' made tangible." }
    ],
    links: [
      { id: "lk1", targetId: "trust", type: "perspective" },
      { id: "lk2", targetId: "promise", type: "pattern" },
      { id: "lk3", targetId: "river", type: "essence" },
    ],
    updated: "2 days ago"
  },

  // Library fills below — varying levels of completeness so the dots feel real.
  {
    id: "money",
    title: "Money",
    category: "System",
    consist: "Numbers in a ledger, sometimes paper or metal tokens, mostly entries in databases owned by banks and the state.",
    function: "A shared agreement to defer value across time and across strangers — a memory of debt that anyone will honour.",
    perspectives: [
      { id: "p1", title: "First paycheck", body: "The number arriving felt enormous and then evaporated into rent and groceries within a week. I had imagined it as a thing I would hold; it was a brief permission.", patternId: "pat1" },
      { id: "p2", title: "Lending to a friend", body: "Money between us became a small unspoken weight. Even after she paid me back the weight didn't fully leave.", patternId: "pat1" },
      { id: "p3", title: "Currency exchange abroad", body: "Watching the same coffee cost three different numbers depending on which border I crossed. Made me feel the agreement is local.", patternId: null }
    ],
    patterns: [
      { id: "pat1", title: "Crystalised trust", body: "Money is trust given a unit so it can travel further than relationships do.", essenceId: "es1" }
    ],
    essences: [{ id: "es1", body: "A portable agreement — the strangers' version of a promise." }],
    links: [
      { id: "lm1", targetId: "trust", type: "essence" },
      { id: "lm2", targetId: "promise", type: "pattern" },
    ],
    updated: "1 week ago"
  },
  {
    id: "home",
    title: "Home",
    category: "Place",
    consist: "Walls, a roof, the objects you've chosen to keep, the smell of those objects together.",
    function: "Filters the world's signal down to a level your nervous system can rest inside.",
    perspectives: [
      { id: "p1", title: "Childhood kitchen", body: "Tile that I knew by sound. I could tell which corner of the room someone was standing in by the way their footsteps rang.", patternId: "pat1" },
      { id: "p2", title: "First apartment alone", body: "The strange relief of being able to leave dishes in the sink without it meaning anything about me.", patternId: "pat1" }
    ],
    patterns: [
      { id: "pat1", title: "Permission to be unobserved", body: "Home is the place where you don't have to perform yourself to anyone.", essenceId: null }
    ],
    essences: [],
    links: [{ id: "lh1", targetId: "silence", type: "pattern" }],
    updated: "3 weeks ago"
  },
  {
    id: "book",
    title: "Book",
    category: "Object",
    consist: "Pages of pressed fibre, ink in patterns, glue and thread holding the spine.",
    function: "Stores a structured sequence of thought outside its author so others can re-run it.",
    perspectives: [
      { id: "p1", title: "Reading at 2am", body: "A novel that wouldn't let me put it down. The room disappeared.", patternId: null },
      { id: "p2", title: "Textbook in school", body: "Knowing the answer was in there but not knowing where felt like a failure of search, not of understanding.", patternId: null }
    ],
    patterns: [],
    essences: [],
    links: [
      { id: "lb1", targetId: "memory", type: "essence" },
      { id: "lb2", targetId: "name", type: "pattern" },
    ],
    updated: "1 month ago"
  },
  {
    id: "river",
    title: "River",
    category: "Phenomenon",
    consist: "Moving water bounded by land, carrying sediment, fed by rain and snowmelt, going to a sea.",
    function: "Transports mass downhill while shaping its own channel through the friction of doing so.",
    perspectives: [
      { id: "p1", title: "Swimming in the Dnipro", body: "The pull surprised me. It was deciding for me where I would arrive.", patternId: "pat1" },
      { id: "p2", title: "Watching a river from a bridge", body: "The water that was beneath me has by now reached the sea.", patternId: "pat1" }
    ],
    patterns: [
      { id: "pat1", title: "Continuous arrival", body: "A river is a place that is never the same place.", essenceId: "es1" }
    ],
    essences: [{ id: "es1", body: "Time given a body — change you can stand beside." }],
    links: [
      { id: "lr1", targetId: "memory", type: "essence" },
      { id: "lr2", targetId: "silence", type: "perspective" },
    ],
    updated: "2 months ago"
  },
  {
    id: "silence",
    title: "Silence",
    category: "State",
    consist: "Absence of audible signal, or the brain's decision to stop attending to background sound.",
    function: "Creates room for internal signal to be heard above the noise floor of the world.",
    perspectives: [
      { id: "p1", title: "Power cut at night", body: "How loud the refrigerator had been only became obvious when it stopped.", patternId: null }
    ],
    patterns: [],
    essences: [],
    updated: "today"
  },
  {
    id: "trust",
    title: "Trust",
    category: "Feeling",
    consist: "A predictive model in the body that says: this person/system will behave consistently with what they have shown me before.",
    function: "Lowers the cost of cooperation by removing the need to re-verify at every step.",
    perspectives: [
      { id: "p1", title: "A friend keeping a secret", body: "I told her something and never once worried it had moved. The relief of not having to track it.", patternId: "pat1" },
      { id: "p2", title: "Boarding a plane", body: "I have no information about this pilot. I am giving them my life on the basis of the institution behind them.", patternId: "pat1" },
      { id: "p3", title: "After a betrayal", body: "Even small interactions had to be re-decided. The cost of cooperation went up everywhere, not just with him.", patternId: "pat1" }
    ],
    patterns: [
      { id: "pat1", title: "Earned by repetition", body: "Trust accumulates through small confirmations and collapses through one disconfirmation.", essenceId: "es1" }
    ],
    essences: [{ id: "es1", body: "A loan of certainty — given freely, expensive to replace." }],
    links: [
      { id: "lt1", targetId: "promise", type: "essence" },
      { id: "lt2", targetId: "money", type: "essence" },
    ],
    updated: "4 days ago"
  },
  {
    id: "fire",
    title: "Fire",
    category: "Phenomenon",
    consist: "Rapid oxidation, releasing heat and light, requiring fuel, oxygen, and an ignition above the fuel's flash point.",
    function: "Converts stored chemical energy into heat at a rate the surrounding material can no longer dissipate.",
    perspectives: [
      { id: "p1", title: "Campfire", body: "The way conversation gets quieter and slower the longer you look at it.", patternId: null },
      { id: "p2", title: "A burnt pan", body: "I forgot. The smoke was a small failure that smelled big.", patternId: null }
    ],
    patterns: [],
    essences: [],
    updated: "5 days ago"
  },
  {
    id: "promise",
    title: "Promise",
    category: "Act",
    consist: "A spoken or written commitment binding a future action of the speaker.",
    function: "Imports a piece of the future into present social reality so others can plan around it.",
    perspectives: [
      { id: "p1", title: "A promise kept under cost", body: "Showing up to help him move on a day I didn't have the energy. The promise had become heavier than the moving.", patternId: null }
    ],
    patterns: [],
    essences: [],
    updated: "3 days ago"
  },
  {
    id: "window",
    title: "Window",
    category: "Object",
    consist: "Transparent material framed in an opening of an opaque wall.",
    function: "Lets light and information pass while preventing weather and bodies from doing the same.",
    perspectives: [
      { id: "p1", title: "Train window", body: "I watched a landscape I will never visit pass at a speed I didn't choose.", patternId: "pat1" },
      { id: "p2", title: "Office window I never opened", body: "I could see weather but not feel it. The day looked like a screen.", patternId: "pat1" }
    ],
    patterns: [
      { id: "pat1", title: "Mediated proximity", body: "A window puts the world close without letting it touch you.", essenceId: null }
    ],
    essences: [],
    updated: "1 week ago"
  },
  {
    id: "memory",
    title: "Memory",
    category: "Process",
    consist: "Patterns of synaptic connections, repeatedly reinforced or pruned by recall and salience.",
    function: "Reconstructs the past from cues — not playback but rebuild, every time slightly different.",
    perspectives: [
      { id: "p1", title: "A song from school", body: "The room I was in came back before the lyrics did.", patternId: "pat1" },
      { id: "p2", title: "Disagreeing about an event", body: "We were both certain we remembered it correctly, and the certainties were incompatible.", patternId: "pat1" }
    ],
    patterns: [
      { id: "pat1", title: "Reconstruction, not recording", body: "Memory is the brain rebuilding the past from cues, biased by what it's become since.", essenceId: "es1" }
    ],
    essences: [{ id: "es1", body: "The self rewriting its own evidence." }],
    links: [{ id: "lme1", targetId: "name", type: "pattern" }],
    updated: "yesterday"
  },
  {
    id: "name",
    title: "Name",
    category: "Symbol",
    consist: "A short string of sounds or letters attached to a thing by convention.",
    function: "Lets a thing be referred to without being present.",
    perspectives: [],
    patterns: [],
    essences: [],
    updated: "moments ago"
  }
];

// Completeness: how many of the 5 levels have any content.
function levelsFilled(c) {
  return {
    consist: !!(c.consist && c.consist.trim()),
    function: !!(
      (c.functions && c.functions.some(f => f.body && f.body.trim())) ||
      (c.function && c.function.trim())
    ),
    perspective: (c.perspectives || []).length > 0,
    pattern: (c.patterns || []).length > 0,
    essence: (c.essences || []).length > 0,
  };
}
function fillCount(c) {
  const f = levelsFilled(c);
  return Object.values(f).filter(Boolean).length;
}

Object.assign(window, { SEED_CONCEPTS, levelsFilled, fillCount });
