import type { Metadata } from 'next'
import { Geist } from 'next/font/google'
import localFont from 'next/font/local'
import './globals.css'

const geistSans = Geist({
  variable: '--font-geist-sans',
  subsets: ['latin'],
})

const sourceSerifPro = localFont({
  src: [
    {
      path: '../public/fonts/Source_Serif_4/SourceSerif4-VariableFont_opsz,wght.ttf',
      style: 'normal',
    },
    {
      path: '../public/fonts/Source_Serif_4/SourceSerif4-Italic-VariableFont_opsz,wght.ttf',
      style: 'italic',
    },
  ],
  variable: '--font-source-serif-pro',
  weight: '200 900',
  display: 'swap',
  preload: true,
})

export const metadata: Metadata = {
  metadataBase: new URL('https://greywall.io'),
  title: 'Greywall | Contained Sandboxing for AI Agents',
  description:
    'Default-deny sandboxing with real-time observability for AI agents on Linux and macOS. Filesystem, network, and command boundaries stay under your control.',
  icons: {
    icon: [
      { url: '/greyhaven-mark.svg', type: 'image/svg+xml' },
      { url: '/icon-dark-32x32.png', sizes: '32x32', type: 'image/png', media: '(prefers-color-scheme: dark)' },
      { url: '/icon-light-32x32.png', sizes: '32x32', type: 'image/png', media: '(prefers-color-scheme: light)' },
    ],
    apple: '/apple-icon.png',
  },
  openGraph: {
    title: 'Greywall | Contained Sandboxing for AI Agents',
    description: 'Default-deny sandboxing with real-time observability for AI agents on Linux and macOS.',
    url: 'https://greywall.io',
    siteName: 'Greywall',
    type: 'website',
    images: [{ url: '/og-image.png', width: 1200, height: 630 }],
  },
  twitter: {
    card: 'summary_large_image',
    title: 'Greywall | Contained Sandboxing for AI Agents',
    description: 'Default-deny sandboxing with real-time observability for AI agents on Linux and macOS.',
    images: ['/og-image.png'],
  },
  alternates: {
    canonical: 'https://greywall.io',
  },
}

const jsonLd = {
  '@context': 'https://schema.org',
  '@graph': [
    {
      '@type': 'Organization',
      '@id': 'https://greyhaven.co/#organization',
      name: 'Greyhaven',
      url: 'https://greyhaven.co',
      logo: { '@type': 'ImageObject', url: 'https://greywall.io/greyhaven-mark.svg' },
      sameAs: ['https://github.com/GreyhavenHQ'],
    },
    {
      '@type': 'WebSite',
      '@id': 'https://greywall.io/#website',
      name: 'Greywall',
      url: 'https://greywall.io',
      publisher: { '@id': 'https://greyhaven.co/#organization' },
    },
    {
      '@type': 'SoftwareApplication',
      '@id': 'https://greywall.io/#software',
      name: 'Greywall',
      description:
        'Default-deny sandboxing with real-time observability and dynamic controls for AI agents on Linux and macOS.',
      applicationCategory: 'SecurityApplication',
      operatingSystem: 'Linux, macOS',
      url: 'https://greywall.io',
      downloadUrl: 'https://github.com/GreyhavenHQ/greywall',
      license: 'https://opensource.org/licenses/Apache-2.0',
      offers: { '@type': 'Offer', price: '0', priceCurrency: 'USD' },
      author: { '@id': 'https://greyhaven.co/#organization' },
      featureList: [
        'Filesystem isolation',
        'Network isolation',
        'Command blocking',
        'Real-time violation monitoring',
        'Learning mode',
        'Syscall filtering',
        'Dynamic allow/deny controls',
      ],
      isAccessibleForFree: true,
    },
    {
      '@type': 'SoftwareSourceCode',
      name: 'Greywall',
      codeRepository: 'https://github.com/GreyhavenHQ/greywall',
      programmingLanguage: 'Go',
      license: 'https://opensource.org/licenses/Apache-2.0',
      targetProduct: { '@id': 'https://greywall.io/#software' },
    },
  ],
}

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode
}>) {
  return (
    <html lang="en">
      <head>
        <script
          type="application/ld+json"
          dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
        />
      </head>
      <body className={`${geistSans.variable} ${sourceSerifPro.variable} min-h-dvh flex flex-col`}>
        {children}
      </body>
    </html>
  )
}
