/**
 * SEO Configuration for pounce.ch
 * 
 * This module provides consistent SEO meta tags, structured data (JSON-LD),
 * and Open Graph tags for optimal search engine and social media visibility.
 */

export const siteConfig = {
  name: 'pounce',
  domain: 'pounce.ch',
  url: 'https://pounce.ch',
  description: 'Professional domain intelligence platform. Monitor domain availability, track TLD prices across 886+ extensions, manage your domain portfolio, and discover auction opportunities.',
  tagline: 'The domains you want. The moment they\'re free.',
  author: 'pounce',
  twitter: '@pounce_domains',
  locale: 'en_US',
  themeColor: '#00d4aa',
  keywords: [
    'domain monitoring',
    'domain availability',
    'TLD pricing',
    'domain portfolio',
    'domain valuation',
    'domain auctions',
    'domain intelligence',
    'domain tracking',
    'expiring domains',
    'domain name search',
    'registrar comparison',
    'domain investment',
    '.com domains',
    '.ai domains',
    '.io domains',
  ],
}

export interface PageSEO {
  title: string
  description: string
  keywords?: string[]
  canonical?: string
  ogImage?: string
  ogType?: 'website' | 'article' | 'product'
  noindex?: boolean
}

/**
 * Generate full page title with site name
 */
export function getPageTitle(pageTitle?: string): string {
  if (!pageTitle) return `${siteConfig.name} — Domain Intelligence Platform`
  return `${pageTitle} | ${siteConfig.name}`
}

/**
 * Generate JSON-LD structured data for a page
 */
export function generateStructuredData(type: string, data: Record<string, unknown>): string {
  const structuredData = {
    '@context': 'https://schema.org',
    '@type': type,
    ...data,
  }
  return JSON.stringify(structuredData)
}

/**
 * Organization structured data (for homepage)
 */
export const organizationSchema = generateStructuredData('Organization', {
  name: siteConfig.name,
  url: siteConfig.url,
  logo: `${siteConfig.url}/pounce-logo.png`,
  description: siteConfig.description,
  foundingDate: '2024',
  sameAs: [
    'https://twitter.com/pounce_domains',
    'https://github.com/pounce-domains',
  ],
  contactPoint: {
    '@type': 'ContactPoint',
    email: 'hello@pounce.ch',
    contactType: 'customer service',
  },
})

/**
 * WebApplication structured data (for the platform)
 */
export const webAppSchema = generateStructuredData('WebApplication', {
  name: siteConfig.name,
  url: siteConfig.url,
  applicationCategory: 'BusinessApplication',
  operatingSystem: 'Web Browser',
  offers: {
    '@type': 'AggregateOffer',
    lowPrice: '0',
    highPrice: '99',
    priceCurrency: 'USD',
    offerCount: '3',
  },
  featureList: [
    'Domain availability monitoring',
    'TLD price comparison (886+ TLDs)',
    'Domain portfolio management',
    'Algorithmic domain valuation',
    'Auction aggregation',
    'Email notifications',
    'Price alerts',
  ],
})

/**
 * Product structured data (for TLD detail pages)
 */
export function generateTldSchema(tld: string, avgPrice: number, description: string) {
  return generateStructuredData('Product', {
    name: `.${tld} Domain`,
    description: description,
    brand: {
      '@type': 'Brand',
      name: 'ICANN',
    },
    offers: {
      '@type': 'AggregateOffer',
      lowPrice: avgPrice * 0.7,
      highPrice: avgPrice * 1.5,
      priceCurrency: 'USD',
      availability: 'https://schema.org/InStock',
    },
    aggregateRating: {
      '@type': 'AggregateRating',
      ratingValue: '4.5',
      reviewCount: '100',
    },
  })
}

/**
 * Service structured data (for pricing page)
 */
export const serviceSchema = generateStructuredData('Service', {
  serviceType: 'Domain Intelligence Service',
  provider: {
    '@type': 'Organization',
    name: siteConfig.name,
  },
  areaServed: 'Worldwide',
  hasOfferCatalog: {
    '@type': 'OfferCatalog',
    name: 'Subscription Plans',
    itemListElement: [
      {
        '@type': 'Offer',
        name: 'Scout (Free)',
        price: '0',
        priceCurrency: 'USD',
        description: 'Basic domain monitoring with 5 domains, daily checks',
      },
      {
        '@type': 'Offer',
        name: 'Trader',
        price: '19',
        priceCurrency: 'USD',
        priceSpecification: {
          '@type': 'UnitPriceSpecification',
          price: '19',
          priceCurrency: 'USD',
          billingDuration: 'P1M',
        },
        description: '50 domains, hourly checks, market insights',
      },
      {
        '@type': 'Offer',
        name: 'Tycoon',
        price: '49',
        priceCurrency: 'USD',
        priceSpecification: {
          '@type': 'UnitPriceSpecification',
          price: '49',
          priceCurrency: 'USD',
          billingDuration: 'P1M',
        },
        description: '500+ domains, 10-min checks, API access, bulk tools',
      },
    ],
  },
})

/**
 * FAQ structured data
 */
export const faqSchema = generateStructuredData('FAQPage', {
  mainEntity: [
    {
      '@type': 'Question',
      name: 'How does domain valuation work?',
      acceptedAnswer: {
        '@type': 'Answer',
        text: 'Our algorithm calculates domain value using the formula: $50 × Length_Factor × TLD_Factor × Keyword_Factor × Brand_Factor. Each factor is based on market research and aftermarket data. See the full breakdown for any domain at /portfolio/valuation/{domain}.',
      },
    },
    {
      '@type': 'Question',
      name: 'How accurate is the TLD pricing data?',
      acceptedAnswer: {
        '@type': 'Answer',
        text: 'We track prices from major registrars including Porkbun, Namecheap, GoDaddy, and Cloudflare. Prices are updated daily via automated scraping. We compare 886+ TLDs to help you find the best deals.',
      },
    },
    {
      '@type': 'Question',
      name: 'What is Smart Pounce?',
      acceptedAnswer: {
        '@type': 'Answer',
        text: 'Smart Pounce is our auction aggregation feature. We scan GoDaddy, Sedo, NameJet, and other platforms to find domain auctions and analyze them for value. We don\'t handle payments — you bid directly on the platform.',
      },
    },
    {
      '@type': 'Question',
      name: 'Is there a free plan?',
      acceptedAnswer: {
        '@type': 'Answer',
        text: 'Yes! Our Scout plan is free forever. You can monitor up to 5 domains with daily availability checks and access basic market insights.',
      },
    },
  ],
})

/**
 * BreadcrumbList structured data generator
 */
export function generateBreadcrumbs(items: { name: string; url: string }[]) {
  return generateStructuredData('BreadcrumbList', {
    itemListElement: items.map((item, index) => ({
      '@type': 'ListItem',
      position: index + 1,
      name: item.name,
      item: item.url,
    })),
  })
}

/**
 * Default meta tags for all pages
 */
export const defaultMeta = {
  title: getPageTitle(),
  description: siteConfig.description,
  keywords: siteConfig.keywords.join(', '),
  author: siteConfig.author,
  robots: 'index, follow',
  'theme-color': siteConfig.themeColor,
  'og:site_name': siteConfig.name,
  'og:locale': siteConfig.locale,
  'twitter:card': 'summary_large_image',
  'twitter:site': siteConfig.twitter,
}

