export type LocaleCode = "en" | "fr" | "nb";

export const localeOrder: LocaleCode[] = ["en", "fr", "nb"];

export const localeMeta: Record<LocaleCode, { label: string; switcher: string; note: string }> = {
  en: {
    label: "English",
    switcher: "EN edition",
    note: "The interface changes language first. Long-form features stay in their original edition until translated.",
  },
  fr: {
    label: "Francais",
    switcher: "Cahier FR",
    note: "L'interface change de langue d'abord. Les longs articles restent dans leur edition d'origine pour l'instant.",
  },
  nb: {
    label: "Norsk bokmal",
    switcher: "NB utgave",
    note: "Grensesnittet skifter sprak forst. Langartiklene blir staende i originalutgaven til de er oversatt.",
  },
};

export const localizedSections: Record<
  string,
  Record<LocaleCode, { title: string; tone: string }>
> = {
  business: {
    en: { title: "Business", tone: "Sharp, practical, anti-buzzword." },
    fr: { title: "Affaires", tone: "Net, pratique, allergique au jargon." },
    nb: { title: "Naeringsliv", tone: "Skarpt, praktisk og anti-buzzword." },
  },
  education: {
    en: { title: "Education", tone: "Curious, rigorous, lightly mischievous." },
    fr: { title: "Etudes", tone: "Curieux, rigoureux, legerement malicieux." },
    nb: { title: "Utdanning", tone: "Nysgjerrig, grundig og litt rampete." },
  },
  family: {
    en: { title: "Family", tone: "Private-minded, generous, alive." },
    fr: { title: "Famille", tone: "Prive, genereux, bien vivant." },
    nb: { title: "Familie", tone: "Privat, varm og levende." },
  },
  "fun-postings": {
    en: { title: "Fun Postings", tone: "Playful, deadpan, collectible." },
    fr: { title: "Annonces Delicieuses", tone: "Ludique, pince-sans-rire, a collectionner." },
    nb: { title: "Leken Oppslagstavle", tone: "Leken, torrr og samleverdig." },
  },
  writing: {
    en: { title: "Writing", tone: "Literary, international, smoky." },
    fr: { title: "Ecriture", tone: "Litteraire, international, fumeux dans le bon sens." },
    nb: { title: "Skriving", tone: "Litteraer, internasjonal og litt roykfylt." },
  },
  "jazz-music": {
    en: { title: "Jazz and Music", tone: "Velvet, brassy, precise." },
    fr: { title: "Jazz et Musique", tone: "Velours, cuivre, precision." },
    nb: { title: "Jazz og Musikk", tone: "Fløyel, messing og presisjon." },
  },
  languages: {
    en: { title: "Languages", tone: "Polyglot, sly, welcoming." },
    fr: { title: "Langues", tone: "Polyglotte, malin, accueillant." },
    nb: { title: "Sprak", tone: "Polyglott, lur og inkluderende." },
  },
  "ai-lab": {
    en: { title: "AI Lab", tone: "Forward-looking, grounded, open source friendly." },
    fr: { title: "Laboratoire IA", tone: "Tourne vers l'avenir, solide, ami de l'open source." },
    nb: { title: "AI-lab", tone: "Fremtidsrettet, jordnaer og vennlig mot apen kildekode." },
  },
  norway: {
    en: { title: "Norway", tone: "Observant, civic, place-aware." },
    fr: { title: "Norvege", tone: "Observateur, civique, attentif au lieu." },
    nb: { title: "Norge", tone: "Observant, samfunnsbevisst og stedsnart." },
  },
  projects: {
    en: { title: "Projects", tone: "Builder energy, clean receipts." },
    fr: { title: "Projets", tone: "Energie d'atelier, comptes propres." },
    nb: { title: "Prosjekter", tone: "Byggerenergi og ryddige spor." },
  },
  cv: {
    en: { title: "CV", tone: "Professional, legible, confident." },
    fr: { title: "CV", tone: "Professionnel, lisible, assure." },
    nb: { title: "CV", tone: "Profesjonell, lesbar og trygg." },
  },
  "family-lab": {
    en: { title: "Family Lab", tone: "Private archive, atlas, memory room." },
    fr: { title: "Laboratoire Familial", tone: "Archive privee, atlas, chambre de memoire." },
    nb: { title: "Familielab", tone: "Privat arkiv, atlas og minnerom." },
  },
};

type ChromeContext = {
  activeSlug: string;
  issueDate: Record<LocaleCode, string>;
  articleKey?: "norway" | "jazz" | "projects" | null;
};

const articleLabels: Record<string, Record<LocaleCode, { label: string; note: string }>> = {
  norway: {
    en: { label: "Article / Norway desk", note: "Field report / family life / fathers / immigrants" },
    fr: { label: "Article / Cahier Norvege", note: "Reportage / famille / peres / immigration" },
    nb: { label: "Artikkel / Norge-desk", note: "Feltrapport / familieliv / fedre / innvandring" },
  },
  jazz: {
    en: { label: "Article / Jazz and Music", note: "Field report / Kongsberg x Paris" },
    fr: { label: "Article / Jazz et Musique", note: "Reportage / Kongsberg x Paris" },
    nb: { label: "Artikkel / Jazz og Musikk", note: "Feltrapport / Kongsberg x Paris" },
  },
  projects: {
    en: { label: "Article / Projects desk", note: "Field report / music trivia / Blue Note Rhino / April build" },
    fr: { label: "Article / Cahier Projets", note: "Reportage / quiz musical / Blue Note Rhino / chantier d'avril" },
    nb: { label: "Artikkel / Prosjekt-desk", note: "Feltrapport / musikktrivia / Blue Note Rhino / aprilbygg" },
  },
};

export function getChromeCopy({ activeSlug, issueDate, articleKey }: ChromeContext) {
  const currentSection = localizedSections[activeSlug];
  const article = articleKey ? articleLabels[articleKey] : null;
  const sectionOrder = {
    business: "01",
    education: "02",
    family: "03",
    "fun-postings": "04",
    writing: "05",
    "jazz-music": "06",
    languages: "07",
    "ai-lab": "08",
    norway: "09",
    projects: "10",
    cv: "11",
    "family-lab": "12",
  } as const;
  const sectionNumber = sectionOrder[activeSlug as keyof typeof sectionOrder];

  return {
    ribbonIssue: {
      en: `Founding issue / ${issueDate.en}`,
      fr: `Numero fondateur / ${issueDate.fr}`,
      nb: `Grunnutgave / ${issueDate.nb}`,
    },
    ribbonNote: currentSection
      ? {
          en: currentSection.en.tone,
          fr: currentSection.fr.tone,
          nb: currentSection.nb.tone,
        }
      : article
        ? {
            en: article.en.note,
            fr: article.fr.note,
            nb: article.nb.note,
          }
        : {
            en: "Ringwood / Villanova / Brussels / Paris / Krakow / Oslo / Kongsberg",
            fr: "Ringwood / Villanova / Bruxelles / Paris / Cracovie / Oslo / Kongsberg",
            nb: "Ringwood / Villanova / Brussel / Paris / Krakow / Oslo / Kongsberg",
          },
    issueLabel: currentSection
      ? {
          en: `Section ${sectionNumber} / ${currentSection.en.title}`,
          fr: `Section ${sectionNumber} / ${currentSection.fr.title}`,
          nb: `Seksjon ${sectionNumber} / ${currentSection.nb.title}`,
        }
      : article
        ? {
            en: article.en.label,
            fr: article.fr.label,
            nb: article.nb.label,
          }
        : {
            en: "Founding issue / Personal edition",
            fr: "Numero fondateur / Edition personnelle",
            nb: "Grunnutgave / Personlig utgave",
          },
    mastheadLine: {
      en: "Jazz desk / machine room / family archive / pataphysical bulletin",
      fr: "Cahier jazz / salle des machines / archive familiale / bulletin pataphysique",
      nb: "Jazzdesk / maskinrom / familiearkiv / pataphysisk bulletin",
    },
    domainPrompt: {
      en: "Private AI. Jazz rooms. Civic weather. Pataphysical field notes.",
      fr: "IA privee. Salles de jazz. Meteo civique. Notes de terrain pataphysiques.",
      nb: "Privat AI. Jazzrom. Samfunnsvaer. Pataphysiske feltnotater.",
    },
    domainLede: {
      en: "A bright retro paper for machine rooms, multilingual weather, Norway, family rights, live culture, and the deliberate misuse of the impossible.",
      fr: "Un journal retro-lumineux pour les salles des machines, le temps multilingue, la Norvege, les droits familiaux, la culture vivante et l'usage delibere de l'impossible.",
      nb: "Et lyst retroblad for maskinrom, flerspraklig vaer, Norge, familierett, levende kultur og bevisst misbruk av det umulige.",
    },
    languageNote: {
      en: localeMeta.en.note,
      fr: localeMeta.fr.note,
      nb: localeMeta.nb.note,
    },
    footerHeadline: {
      en: "Jazz desk, machine room, civic archive, and practical impossibility.",
      fr: "Cahier jazz, salle des machines, archive civique et impossibilite pratique.",
      nb: "Jazzdesk, maskinrom, samfunnsarkiv og praktisk umulighet.",
    },
    footerBody: {
      en: "Built in Astro with React islands, backed by PHP and SQL, and edited like a proper newspaper rather than a consultant PDF with lipstick.",
      fr: "Construit avec Astro et des ilots React, soutenu par PHP et SQL, puis edite comme un vrai journal plutot qu'un PDF de conseil maquille.",
      nb: "Bygget i Astro med React-oyer, drevet av PHP og SQL, og redigert som en ordentlig avis i stedet for en konsulent-PDF med leppestift.",
    },
    footerNoteLeft: {
      en: "Astro + React islands + PHP + SQL",
      fr: "Astro + ilots React + PHP + SQL",
      nb: "Astro + React-oyer + PHP + SQL",
    },
    footerNoteRight: {
      en: "Blue Note Logic / Gilligan TECH / Kongsberg / multilingual edition",
      fr: "Blue Note Logic / Gilligan TECH / Kongsberg / edition multilingue",
      nb: "Blue Note Logic / Gilligan TECH / Kongsberg / flerspraklig utgave",
    },
  };
}

export const footerCallouts = {
  blueNoteLogic: {
    href: "https://bluenotelogic.com/",
    label: {
      en: "Blue Note Logic",
      fr: "Blue Note Logic",
      nb: "Blue Note Logic",
    },
    title: {
      en: "Private AI and document intelligence with a real memory.",
      fr: "IA privee et intelligence documentaire avec une vraie memoire.",
      nb: "Privat AI og dokumentintelligens med ekte hukommelse.",
    },
    body: {
      en: "Blue Note Logic frames AI as owned infrastructure: strategy, deployment, document intelligence, and source-aware systems that keep working knowledge inside the firm.",
      fr: "Blue Note Logic traite l'IA comme une infrastructure possedee : strategie, deploiement, intelligence documentaire et systemes cites a la source qui gardent la connaissance dans l'entreprise.",
      nb: "Blue Note Logic behandler AI som eid infrastruktur: strategi, utrulling, dokumentintelligens og kildebevisste systemer som holder kunnskapen i virksomheten.",
    },
  },
  gilliganTech: {
    href: "https://gilligan.tech/",
    label: {
      en: "Gilligan TECH",
      fr: "Gilligan TECH",
      nb: "Gilligan TECH",
    },
    title: {
      en: "Kongsberg-side systems engineering for Nordic SMBs.",
      fr: "Ingenierie de systemes depuis Kongsberg pour les PME nordiques.",
      nb: "Systemingeniorarbeid fra Kongsberg for nordiske SMB-er.",
    },
    body: {
      en: "Gilligan Tech is the Norwegian operating arm: AI audits, system builds, fractional CTO work, and sovereign European delivery for companies that want results before theatre.",
      fr: "Gilligan Tech est le bras norvegien d'operation : audits IA, constructions de systemes, travail de CTO fractionnaire et livraison souveraine europeenne pour les entreprises qui veulent des resultats avant le theatre.",
      nb: "Gilligan Tech er den norske operasjonsarmen: AI-audits, systembygging, fractional CTO-arbeid og suveren europeisk levering for selskaper som vil ha resultater foran teater.",
    },
  },
};

export const policyLinkCopy = {
  privacy: {
    href: "/privacy",
    title: {
      en: "Privacy policy",
      fr: "Politique de confidentialite",
      nb: "Personvern",
    },
    body: {
      en: "How the site handles accounts, family access, forms, and first-party data.",
      fr: "Comment le site gere les comptes, l'acces familial, les formulaires et les donnees de premiere main.",
      nb: "Hvordan nettstedet handterer kontoer, familieadgang, skjemaer og forstepartsdata.",
    },
  },
  cookies: {
    href: "/cookies",
    title: {
      en: "Cookie policy",
      fr: "Politique de cookies",
      nb: "Cookiepolicy",
    },
    body: {
      en: "Essential-first consent, optional analytics later, and external embeds only after permission.",
      fr: "Consentement essential d'abord, analyses optionnelles ensuite, et contenus externes seulement apres permission.",
      nb: "Forst essensielle cookies, valgfri analyse senere, og eksterne innbygginger bare etter samtykke.",
    },
  },
};

export const cookieBannerCopy = {
  eyebrow: {
    en: "Privacy desk / local build",
    fr: "Cahier vie privee / build local",
    nb: "Personverndesk / lokal bygg",
  },
  title: {
    en: "This paper keeps optional tracking turned off until you say yes.",
    fr: "Ce journal laisse le pistage optionnel eteint tant que vous ne dites pas oui.",
    nb: "Denne avisen holder valgfri sporing av til du sier ja.",
  },
  body: {
    en: "Essential cookies keep sign-in, family access, and language choice working. Analytics and future third-party embeds stay off by default.",
    fr: "Les cookies essentiels maintiennent la connexion, l'acces familial et le choix de langue. Les analyses et les futurs contenus tiers restent desactives par defaut.",
    nb: "Nodvendige cookies holder innlogging, familieadgang og sprakvalg i gang. Analyse og fremtidige tredjepartsinnbygginger er av som standard.",
  },
  acceptAll: {
    en: "Accept all",
    fr: "Tout accepter",
    nb: "Godta alt",
  },
  essentialOnly: {
    en: "Essential only",
    fr: "Essentiels seulement",
    nb: "Bare nodvendige",
  },
  customize: {
    en: "Customize",
    fr: "Personnaliser",
    nb: "Tilpass",
  },
  save: {
    en: "Save choices",
    fr: "Enregistrer les choix",
    nb: "Lagre valgene",
  },
  categories: {
    essential: {
      en: "Essential site operations",
      fr: "Fonctions essentielles du site",
      nb: "Essensiell drift",
    },
    analytics: {
      en: "Anonymous analytics later",
      fr: "Analyses anonymes plus tard",
      nb: "Anonym analyse senere",
    },
    embeds: {
      en: "External media embeds",
      fr: "Integrations medias externes",
      nb: "Eksterne medieinnbygginger",
    },
  },
};
