// Mosaic site — content data + palettes
// Exports: SENT_COLORS, NEUTRAL_PALETTE, FAVS, SITE_STORIES, SOURCE_DIR

const SENT_COLORS = { pos: "#00AA47", mix: "#FFC200", neg: "#FF601C" };
// Valence-free narrative palette (slate / camel / mauve). Token-driven so it flips to the
// brighter dark-theme values automatically (see mosaic-tokens.css --narr-a/b/c).
const NEUTRAL_PALETTE = ["var(--narr-a)", "var(--narr-b)", "var(--narr-c)"];

const FAVS = {
  dawn:    { n: "Dawn",                l: "D", bg: "#111827" },
  geo:     { n: "Geo News",            l: "G", bg: "#065f46" },
  tribune: { n: "Tribune",             l: "T", bg: "#b91c1c" },
  nation:  { n: "The Nation",          l: "N", bg: "#1f2937" },
  ary:     { n: "ARY News",            l: "A", bg: "#9f1239" },
  br:      { n: "Business Recorder",   l: "B", bg: "#92400e" },
  profit:  { n: "Profit / Pakistan Today", l: "P", bg: "#1e3a8a" },
  fbr:     { n: "FBR",                 l: "F", bg: "#374151" },
  nukta:   { n: "Nukta",               l: "n", bg: "#0f766e" },
  bol:     { n: "BOL News",            l: "B", bg: "#7c2d12" },
  irk:     { n: "Imran Riaz Khan",     l: "I", bg: "#4c1d95" },
  macro:   { n: "Macro Pakistani",     l: "M", bg: "#334155" },
  po:      { n: "Pakistan Observer",   l: "P", bg: "#14532d" },
  mea:     { n: "India / MEA",         l: "M", bg: "#7f1d1d" },
};

const SITE_STORIES = [
  {
    id: "gilgit", cat: "Politics", upd: "8th June", tags: "Politics · Elections",
    title: "Gilgit-Baltistan Elections 2026",
    standfirst: "Polling for 24 GB Assembly seats was held June 7. In unofficial results the PPP leads, PML-N second; the ECP began issuing certified forms. Counting was delayed overnight.",
    fault: "A close PPP win — or a result engineered once PTI pulled ahead? Coverage splits on whether the delay was process or manipulation.",
    facts: [
      "Polling for 24 GB Assembly seats was held June 7",
      "Unofficial results: PPP leads, PML-N second",
      "ECP began issuing certified forms; counting was delayed overnight",
    ],
    blind: "Turnout numbers and constituency-level data are thin across all framings — most coverage argues about legitimacy without publishing the count.",
    seed: "a",
    framings: [
      { t: "\u201cClean, legitimate result — PPP won\u201d", lean: "pos", n: 8,
        b: "Mainstream and establishment-aligned coverage treats it as a normal close election: PPP ahead, PML-N second, ECP issuing certified forms, irregularities noted but routine.",
        q: "\u201cPPP emerges as leading party as official results continue to pour in\u201d", a: "ARY News",
        srcs: ["geo", "tribune", "dawn", "nukta", "ary", "bol"] },
      { t: "\u201cRigged — and dissent criminalised\u201d", lean: "neg", n: 10,
        b: "Pro-PTI and independent voices say PTI & MWM led until counting was halted, then \u201cmanaged\u201d. Rigging complaints are being criminalised and protesters branded \u201cIndian agents\u201d.",
        q: "\u201cCaught red-handed: the dirty game being played in Gilgit-Baltistan\u201d", a: "Imran Riaz Khan",
        srcs: ["irk", "dawn", "macro"] },
      { t: "India: \u201can illegitimate vote in occupied territory\u201d", lean: "mix", n: 4,
        b: "India rejects the election itself — calling Gilgit-Baltistan occupied territory and lodging a formal protest, also stating its position at the UN.",
        q: "\u201cIndia reiterated that Gilgit-Baltistan is an integral part of India and protested the polls\u201d", a: "India / MEA",
        srcs: ["mea"] },
    ],
    history: [
      { d: "May", r: [20, 65, 15], l: "Campaign period" },
      { d: "7 Jun", r: [25, 45, 30], l: "Polling day" },
      { d: "7 Jun", r: [55, 30, 15], l: "Counting halted" },
      { d: "8 Jun", r: [45, 27, 28], l: "Now — certified forms" },
    ],
  },
  {
    id: "budget", cat: "Economy", upd: "8th June", tags: "Economy · Fiscal",
    title: "Budget 2026-27",
    standfirst: "Pakistan's federal budget for 2026-27 is imminent. Early coverage frames it as a \u201creformist\u201d turn, while stakeholders lobby hard: the PPP seeks a 50% hike in salaries and pensions.",
    fault: "A reformist, IMF-aligned budget — or a giveaway pulled in every direction by the coalition and business lobbies?",
    facts: [
      "The federal budget for 2026-27 is due ahead of the new fiscal year",
      "The IMF programme effectively co-authors the fiscal envelope",
      "PPP separately presses for a 50% salary-and-pension hike",
    ],
    blind: "Almost nobody models what the budget does to provincial transfers — the framings argue federal politics and household pain, not the NFC arithmetic.",
    seed: "b",
    framings: [
      { t: "Government: a \u201creformist,\u201d pro-business budget", lean: "pos", n: 4,
        b: "Islamabad and the business chambers (MCCI, textile council) frame it as reform-minded and IMF-aligned — pro-business, pro-export measures and duty relief.",
        q: "\u201cBudget 2026-27 signals reformist turn\u201d", a: "Tribune",
        srcs: ["nation", "bol", "tribune"] },
      { t: "The household squeeze: who actually pays?", lean: "neg", n: 5,
        b: "Independent economists and journalists focus on the cost to ordinary Pakistanis — a salaried class \u201cseverely squeezed\u201d, indirect taxes feeding inflation, an IMF-driven revenue push landing on households.",
        q: "\u201cWill Pakistan get an austerity-oriented budget?\u201d", a: "Uzair Younus",
        srcs: ["macro", "ary", "geo"] },
      { t: "The IMF lens: hit the fiscal targets", lean: "mix", n: 3,
        b: "Pakistan's budget is effectively co-authored by the IMF programme — a primary-surplus target (~2% of GDP), a ~Rs15.6tr FBR tax goal, and new revenue measures the government is resisting.",
        q: "\u201cIMF proposes Rs15.6tr tax target; Pakistan resists new measures\u201d", a: "Profit / IMF",
        srcs: ["profit", "br"] },
    ],
  },
  {
    id: "fixedtax", cat: "Economy", upd: "8th June", tags: "Economy · Taxation",
    title: "Fixed-tax scheme for small traders",
    standfirst: "The government launched a new fixed-tax \u201cAsaan Scheme\u201d for small traders ahead of the budget — a 1% tax on sales plus a Rs25,000 minimum, in return for POS and audit exemptions, targeting ~Rs50bn a year. It replaces the failed Tajir Dost Scheme.",
    fault: "A credible first step to formalise traders — a double-tax burden they'll resist — or another soft deal that won't broaden the base?",
    facts: [
      "Govt launched a fixed-tax \u201cAsaan Scheme\u201d for small retailers ahead of the budget",
      "Mechanics: 1% tax on sales + Rs25,000 minimum; single outlet, sales under Rs200m; POS & audit exemption",
      "Targets ~Rs50bn a year; replaces the failed Tajir Dost Scheme",
    ],
    blind: "What's still unclear is enforcement — whether shopkeepers actually register this time, after the last scheme drew almost no voluntary participation. The framings are well-covered; the on-the-ground take-up isn't.",
    seed: "c",
    framings: [
      { t: "Welcome — a credible first step", lean: "pos", n: 8,
        b: "The largest retail body and the chambers (FPCCI, ICCI) call it facilitation that finally avoids the Tajir Dost pitfalls and starts bringing informal retailers into the net.",
        q: "\u201cRetail council: new scheme avoids the pitfalls of Tajir Dost\u201d", a: "Geo News",
        srcs: ["nation", "nukta", "tribune", "geo", "dawn", "profit", "fbr"] },
      { t: "Traders reject it", lean: "neg", n: 1,
        b: "Anjuman-e-Tajiran calls it double taxation and an extra burden, urging the PM to review — the same shopkeeper resistance that sank the last scheme.",
        q: "\u201cAnjuman-e-Tajiran leader rejects proposed \u2018Asan Tax Scheme\u2019\u201d", a: "Business Recorder",
        srcs: ["br"] },
      { t: "Analysts: too soft, won't broaden the base", lean: "mix", n: 3,
        b: "A Dawn op-ed and independent analysts argue it under-taxes a politically-protected trader class and won't fix the structural base problem.",
        q: "\u201cSoft on traders\u201d", a: "Dawn — Opinion",
        srcs: ["dawn", "macro", "po"] },
    ],
    record: [
      { f: 0, items: [
        { s: "nation", d: "7th June", h: "ICCI hopes Fixed Tax Facilitation Scheme will broaden country's tax net" },
        { s: "nation", d: "5th June", h: "Small retailers brought under new fixed tax scheme" },
        { s: "nukta", d: "6th June", h: "Federation of Pakistan Chambers of Commerce welcomes fixed tax scheme for small traders" },
        { s: "tribune", d: "7th June", h: "Tanveer hails fixed tax scheme" },
        { s: "tribune", d: "7th June", h: "Fixed tax scheme (opinion)" },
        { s: "geo", d: "5th June", h: "Retail council chief: new tax scheme avoids the pitfalls of Tajir Dost" },
        { s: "dawn", d: "5th June", h: "Govt launches scheme to bring small shop owners into tax net" },
        { s: "profit", d: "5th June", h: "Govt unveils fixed-tax \u2018Asaan Scheme\u2019 for small traders ahead of budget" },
        { s: "fbr", d: "5th June", h: "Federal Board of Revenue — small trader / fixed-tax scheme (official)" },
      ]},
      { f: 1, items: [
        { s: "br", d: "5th June", h: "Anjuman-e-Tajiran leader rejects proposed \u2018Asan Tax Scheme\u2019" },
      ]},
      { f: 2, items: [
        { s: "dawn", d: "8th June", h: "Soft on traders" },
        { s: "macro", d: "30th May", h: "The tax arithmetic of a state that forgot to make jobs" },
        { s: "po", d: "6th June", h: "Another scheme for traders" },
      ]},
    ],
    history: [
      { d: "30 May", r: [30, 55, 15], l: "Base-problem frame" },
      { d: "5 Jun", r: [15, 25, 60], l: "Scheme launched" },
      { d: "5 Jun", r: [70, 20, 10], l: "Traders push back" },
      { d: "8 Jun", r: [22, 27, 51], l: "Now — chambers endorse" },
    ],
  },
  {
    id: "azad", cat: "Politics", upd: "8th June", tags: "Politics · Azad Kashmir",
    title: "Azad Kashmir — JAAC Action Committee crisis",
    standfirst: "The Joint Awami Action Committee pressed a 35-point charter; the sticking point is 12 reserved \u201crefugee\u201d seats. Talks with the government continue under shutdown pressure.",
    fault: "A rights movement pressing legitimate demands — or a destabilising shutdown the state must contain?",
    facts: [
      "JAAC pressed a 35-point charter of demands",
      "The sticking point is 12 reserved \u201crefugee\u201d seats",
      "Talks with the government are ongoing",
    ],
    blind: "Few outlets report from Muzaffarabad itself — most coverage relays statements from either the committee or the government.",
    seed: "b",
    framings: [
      { t: "The movement presses its charter", lean: "pos", n: 8, b: "Coverage sympathetic to JAAC foregrounds the 35-point charter and the public support behind the shutdown call.", srcs: ["dawn", "nukta", "macro"] },
      { t: "Government: talks underway, order first", lean: "mix", n: 7, b: "Official-leaning coverage stresses negotiations in progress and the cost of prolonged shutdowns.", srcs: ["ary", "geo", "tribune"] },
      { t: "The refugee-seats sticking point", lean: "neg", n: 5, b: "Analysis pieces zero in on the 12 reserved seats as the structural blocker neither side can concede.", srcs: ["dawn", "br"] },
    ],
  },
  {
    id: "waziristan", cat: "Politics", upd: "7th June", tags: "Politics · Security",
    title: "North Waziristan operation — 27 killed",
    standfirst: "Security forces killed 27 militants in intelligence-based operations in the Miran Shah area of North Waziristan over 72 hours.",
    fault: "Decisive counter-terror success — or one more cycle in a conflict the operations alone haven't ended?",
    facts: [
      "27 militants killed in intelligence-based operations",
      "Operations centred on the Miran Shah area over 72 hours",
    ],
    blind: "Civilian impact and displacement get almost no independent verification — access to the area is restricted.",
    seed: "c",
    framings: [
      { t: "Security success — operations praised", lean: "pos", n: 6, b: "Mainstream coverage relays ISPR's account: successful intelligence-based operations, militants neutralised.", srcs: ["ary", "geo", "nation", "bol"] },
      { t: "The longer war in the tribal belt", lean: "mix", n: 3, b: "Analysts place the operation in a years-long cycle of militancy and response in ex-FATA, questioning what ends it.", srcs: ["dawn", "macro"] },
    ],
  },
  {
    id: "nec", cat: "Economy", upd: "8th June", tags: "Economy · Planning",
    title: "NEC & the development plan",
    standfirst: "The National Economic Council — which approves the national development plan (PSDP) before the budget — met under the PM after repeated postponements.",
    fault: "Routine pre-budget process — or coalition friction deciding who controls development spending?",
    facts: [
      "NEC approves the national development plan (PSDP) before the budget",
      "The meeting was postponed repeatedly before convening",
      "A ~Rs4.7tr plan and PSDP allocations were on the table",
    ],
    blind: "Project-level winners and losers inside the PSDP are barely reported — coverage stays at the headline number.",
    seed: "a",
    framings: [
      { t: "Coalition friction — PML-N vs PPP", lean: "neg", n: 1, b: "ARY ties the repeated postponements to unresolved PML-N–PPP issues over control of development spending.", q: "\u201cNEC meeting postponed amid \u2018unresolved PML-N–PPP issues\u2019\u201d", a: "ARY News", srcs: ["ary"] },
      { t: "Process & allocations", lean: "mix", n: 4, b: "The Nation, Nukta and ProPakistani report the meeting, the ~Rs4.7tr plan and PSDP allocations matter-of-factly.", q: "\u201cNEC to consider PKR 4.46 trillion national development plan\u201d", a: "Nukta", srcs: ["nation", "nukta", "br"] },
      { t: "Development gets squeezed", lean: "neg", n: 1, b: "Dawn frames it as fiscal reality reshaping the uplift budget — debt servicing and IMF limits shrink the development plan against a Rs10tr+ project pipeline.", q: "\u201cPolitical, fiscal reality to reshape uplift budget as NEC meets\u201d", a: "Dawn", srcs: ["dawn"] },
    ],
  },
  {
    id: "textiles", cat: "Economy", upd: "8th June", tags: "Economy · Exports",
    title: "Textiles & the export squeeze",
    standfirst: "Pakistan's textile sector — roughly half of all exports — is lobbying hard around the budget: APTMA wants a 9-cent power grid and duty relief.",
    fault: "An industry fighting for survival on energy costs — or a lobby extracting one more subsidy round?",
    facts: [
      "Textiles account for roughly half of Pakistan's exports",
      "APTMA is lobbying for a 9-cent power grid tariff and duty relief",
    ],
    blind: "Almost no coverage tests APTMA's competitiveness numbers against regional benchmarks — the 9-cent figure is repeated, not examined.",
    seed: "b",
    framings: [
      { t: "APTMA: exports at risk without relief", lean: "neg", n: 3, b: "Industry-aligned coverage carries APTMA's case: energy costs are pricing Pakistani textiles out of export markets.", srcs: ["br", "tribune"] },
      { t: "Government weighs the grid ask", lean: "mix", n: 3, b: "Reporting on the budget process treats the 9-cent demand as one of many pre-budget asks being weighed.", srcs: ["profit", "nation"] },
      { t: "Analysts: subsidy déjà vu", lean: "mix", n: 2, b: "Independent analysts note the sector has absorbed repeated support packages without an export breakout.", srcs: ["macro", "dawn"] },
    ],
  },
];

const SOURCE_DIR = {
  outlets: [
    { f: "dawn", k: "Print + Digital · English", o: "Haroon family — Dawn Media Group", t: "Family media group", y: "1941", c: "Pakistan" },
    { f: "geo", k: "TV · Urdu", o: "Mir Shakil-ur-Rahman — Independent Media Corp (Jang Group)", t: "Media conglomerate (largest)", y: "2002", c: "Pakistan" },
    { f: "ary", k: "TV · Urdu", o: "Salman Iqbal — ARY Group", t: "Business conglomerate", y: "2004", c: "Pakistan" },
    { f: "bol", k: "TV · Urdu", o: "Shoaib Ahmed Shaikh — Labbaik (Pvt) Ltd", t: "Private company", y: "2016", c: "Pakistan" },
    { f: "nation", k: "Print + Digital · English", o: "Nizami family — Nawa-i-Waqt Group", t: "Family media group", y: "1986", c: "Pakistan" },
    { f: "nukta", k: "Digital · Eng + Urdu", o: "Founded by Kamran Khan; majority acquired by ARY Digital (2026)", t: "Digital startup", y: "2024", c: "Pakistan / Dubai" },
    { f: "tribune", k: "Print + Digital · English", o: "Lakson Group (Lakhani family) — Express Media Group", t: "Business conglomerate", y: "2010", c: "Pakistan" },
    { f: "br", k: "Print + Digital · English", o: "Zuberi family (founded by M. A. Zuberi)", t: "Family-owned business daily", y: "1965", c: "Pakistan" },
    { f: "profit", k: "Digital + Print · English", o: "Nawa Media (Arif Nizami legacy)", t: "Independent media company", y: "2010", c: "Pakistan" },
  ],
  independent: [
    { f: "macro", k: "Digital · English", o: "Independent analysis newsletter", t: "Independent analyst", y: "—", c: "Pakistan" },
    { f: "po", k: "Print + Digital · English", o: "Observer Media Group", t: "Private publication", y: "1988", c: "Pakistan" },
  ],
  youtube: [
    { f: "irk", k: "YouTube · Urdu", o: "Imran Riaz Khan", t: "Individual / creator", y: "—", c: "Pakistan" },
  ],
  international: [
    { f: "mea", k: "Government · English", o: "Ministry of External Affairs, Government of India", t: "State body", y: "—", c: "India" },
  ],
};

// Live-data hook — if the engine bridge (engine/to_ui.py) loaded window.__LIVE, render real topics.
if (typeof window !== "undefined" && window.__LIVE && Array.isArray(window.__LIVE.stories) && window.__LIVE.stories.length) {
  Object.assign(FAVS, window.__LIVE.favs || {});
  SITE_STORIES.length = 0;
  SITE_STORIES.push(...window.__LIVE.stories);
}

Object.assign(window, { SENT_COLORS, NEUTRAL_PALETTE, FAVS, SITE_STORIES, SOURCE_DIR });
