/**
 * Content model. Every page reads typed content through src/lib/content.ts,
 * so these shapes can be mapped one-to-one onto a headless CMS schema later.
 *
 * Inline text fields support two marks only: **bold** and [label](/internal-or-https-link).
 */

export type BusinessModel = "saas" | "ecommerce";

export type ServiceSlug =
  | "paid-media"
  | "paid-social"
  | "seo-ai-search"
  | "cro"
  | "landing-pages"
  | "analytics-attribution"
  | "lifecycle-retention";

export type IndustrySlug = "saas-marketing" | "ecommerce-marketing";

export type ResourceSlug =
  | "saas-cac-benchmarking-guide"
  | "mer-vs-roas-guide"
  | "landing-page-experiment-checklist"
  | "paid-search-account-audit-checklist"
  | "attribution-readiness-guide"
  | "ai-search-visibility-guide";

export type CircuitStageId = "discover" | "acquire" | "convert" | "measure" | "expand";

export interface SeoMeta {
  /** Page title without the brand suffix (the root template appends it). Aim for ≤ 60 chars including suffix. */
  title: string;
  /** 120–160 characters. */
  description: string;
}

export interface LinkItem {
  label: string;
  href: string;
}

export interface FaqItem {
  question: string;
  answer: string;
}

export interface TitledText {
  title: string;
  description: string;
}

/* ---------------------------------- Services ---------------------------------- */

export interface MeasurementTier {
  tier: "Business outcome" | "Efficiency" | "Diagnostic";
  summary: string;
  metrics: TitledText[];
}

export interface ServiceContent {
  slug: ServiceSlug;
  /** Full name, e.g. "Paid Media". */
  name: string;
  /** One line for menus and cards (≤ 70 chars). */
  shortDescription: string;
  /** Which Revenue Circuit stage the service mainly serves. */
  stage: CircuitStageId;
  seo: SeoMeta;
  hero: {
    eyebrow: string;
    /** The page H1. */
    title: string;
    intro: string;
    /** 3–5 short outcome phrases shown as chips. */
    outcomes: string[];
  };
  problem: {
    heading: string;
    intro: string;
    /** 3–4 items. */
    items: TitledText[];
  };
  approach: {
    heading: string;
    intro: string;
    /** 4–5 principles or steps. */
    steps: TitledText[];
  };
  deliverables: {
    heading: string;
    intro: string;
    /** 6–8 items. */
    items: TitledText[];
  };
  applications: {
    heading: string;
    intro: string;
    saas: { summary: string; points: string[] };
    ecommerce: { summary: string; points: string[] };
  };
  process: {
    heading: string;
    intro: string;
    /** 4–5 steps. */
    steps: TitledText[];
  };
  measurement: {
    heading: string;
    intro: string;
    tiers: [MeasurementTier, MeasurementTier, MeasurementTier];
  };
  /** 5–6 questions. */
  faqs: FaqItem[];
  related: {
    services: ServiceSlug[];
    resources: ResourceSlug[];
  };
}

/* --------------------------------- Industries --------------------------------- */

export interface IndustryCapability {
  id: string;
  label: string;
  heading: string;
  intro: string;
  points: TitledText[];
  links: LinkItem[];
}

export interface IndustryContent {
  slug: IndustrySlug;
  model: BusinessModel;
  name: string;
  seo: SeoMeta;
  hero: {
    eyebrow: string;
    title: string;
    intro: string;
    focus: string[];
    imageAlt: string;
  };
  challenges: {
    heading: string;
    intro: string;
    items: { title: string; symptom: string; response: string }[];
  };
  system: {
    heading: string;
    intro: string;
    steps: TitledText[];
    note: string;
  };
  capabilities: IndustryCapability[];
  metrics: {
    heading: string;
    intro: string;
    items: { code: string; name: string; definition: string }[];
  };
  process: {
    heading: string;
    intro: string;
    steps: TitledText[];
  };
  faqs: FaqItem[];
  cta: { heading: string; body: string };
}

/* --------------------------------- Resources ---------------------------------- */

export type ResourceCategory =
  | "SaaS"
  | "E-commerce"
  | "CRO"
  | "Paid media"
  | "Measurement"
  | "SEO + AI search";

export type ArticleBlock =
  | { type: "h2"; text: string }
  | { type: "h3"; text: string }
  | { type: "p"; text: string }
  | { type: "ul"; items: string[] }
  | { type: "ol"; items: string[] }
  | { type: "checklist"; title?: string; items: { label: string; detail?: string }[] }
  | { type: "callout"; tone: "note" | "warning"; title?: string; text: string }
  | { type: "formula"; label: string; expression: string; note?: string }
  | { type: "table"; caption?: string; columns: string[]; rows: string[][] }
  /** A worked example with clearly hypothetical numbers. Always rendered with a "Hypothetical" tag. */
  | { type: "example"; title: string; lines: string[]; note?: string };

export interface ResourceSummary {
  slug: ResourceSlug;
  title: string;
  dek: string;
  category: ResourceCategory;
  format: "Guide" | "Checklist";
  models: BusinessModel[];
  /** ISO date (YYYY-MM-DD). */
  publishedAt: string;
  updatedAt?: string;
}

export interface ResourceArticle extends ResourceSummary {
  seo: SeoMeta;
  /** 3–4 key takeaways. */
  takeaways: string[];
  body: ArticleBlock[];
  cta: { heading: string; body: string };
  related: {
    services: ServiceSlug[];
    resources: ResourceSlug[];
  };
}

/* ------------------------------------ Home ------------------------------------ */

export interface CircuitStage {
  id: CircuitStageId;
  index: string;
  name: string;
  promise: string;
  description: string;
  items: string[];
  output: string;
}

export interface MetricDefinition {
  code: string;
  name: string;
  definition: string;
  decision: string;
}

export interface ProcessStep {
  index: string;
  name: string;
  whatHappens: string;
  youReceive: string;
  decisionNext: string;
}

/** Official marks served from public/logos/<slug>.svg (see docs/03-visual-design-system.md). */
export type PlatformLogo =
  | "google-ads"
  | "meta"
  | "linkedin"
  | "microsoft"
  | "ga4"
  | "google-tag-manager"
  | "search-console"
  | "shopify"
  | "klaviyo"
  | "hubspot"
  | "salesforce"
  | "stripe";

export interface PlatformItem {
  name: string;
  logo: PlatformLogo;
}
