import type { AppConfig } from "@wrnexus/styles";

const config: AppConfig = {
  mobile: {
    enabled: true,
    appId: "com.example.wrnexusjs",
    appName: "WRNexusJS",
    userAgent: "WRNexusJSMobile",
    backgroundColor: "#0f172a",
    // layout: "mobile", // app/layouts/mobile.wrn
    // icon: "resources/icon.png",
  },

  // PWA support is enabled automatically. Override any install metadata here.
  pwa: {
    name: "WRNexusJS Documentation",
    shortName: "WRNexusJS Docs",
    display: "standalone",
    themeColor: "#6366f1",
    backgroundColor: "#0f172a",
  },

  seo: {
    title: "WRNexusJS Documentation",
    titleTemplate: "%s | WRNexusJS",
    description: "Complete documentation for every WRNexusJS package, API, function, and workflow.",
    robots: "index,follow",
    themeColor: "#6366f1",
  },

  security: {
    headers: {
      hsts: true,
      noSniff: true,
      referrerPolicy: "strict-origin-when-cross-origin",
      permissionsPolicy: "camera=(), microphone=(), geolocation=()",
    },
    csp: {
      enabled: true,
      directives: {
        "default-src": ["'self'"],
        "img-src": ["'self'", "data:", "https:"],
        "font-src": ["'self'", "https://fonts.gstatic.com"],
        "style-src": ["'self'", "https://fonts.googleapis.com"],
        "connect-src": ["'self'"],
      },
    },
  },

  styles: {
    entry: "app/styles/global.css",

    // Tailwind v4 build. Runs once at dev-serve time (cached; re-run on restart)
    // and at `wrnexus build`. `@tailwindcss/cli` writes to stdout, so we capture
    // and return the final CSS. Delete this hook to drop Tailwind — global.css is
    // still bundled and served as-is.
    process: async ({ entryPath, mode }) => {
      const args = ["@tailwindcss/cli", "-i", entryPath!];
      if (mode === "production") args.push("--minify");
      return await Bun.$`bunx ${args}`.text();
    },
  },

  fonts: {
    sans: '"Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif',
    google: [{ family: "Plus Jakarta Sans", weights: [400, 500, 600, 700, 800] }],
  },

  // Fonts — the framework emits optimized <head> markup (preconnect, subsetted
  // Google Fonts with font-display, self-hosted @font-face with preload) and
  // auto-extends the CSP for Google Fonts. Uncomment to use a custom font:
  //
  // fonts: {
  //   sans: '"Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif',
  //   google: [{ family: "Plus Jakarta Sans", weights: [400, 500, 600, 700] }],
  //   // Or self-host (fastest, no third party) — drop files in public/fonts/:
  //   // local: [{ family: "Plus Jakarta Sans", src: "/fonts/jakarta.woff2", weight: "100 900", preload: true }],
  // },

  // security: {
  //   cors: {
  //     enabled: true,
  //     origin: ["http://localhost:5173"],
  //   },
  // },
};

export default config;
