// ============================================
// CoderFire — i18n translations (en-US / pt-BR)
// ============================================

const LangContext = React.createContext('pt');
const useLang = () => React.useContext(LangContext);
const useT = () => { const lang = useLang(); return translations[lang]; };

function detectLang() {
  const langs = (navigator.languages && navigator.languages.length)
    ? Array.from(navigator.languages)
    : [navigator.language || 'en'];
  return langs.some(l => l.toLowerCase().startsWith('pt')) ? 'pt' : 'en';
}

const translations = {
  en: {
    lang: 'en',
    meta: {
      title: 'CoderFire — Senior engineering, forged in Brazil.',
      description: 'Outsourced product teams and AI/IoT consulting from Brazil. Shipped globaly: Pinterest, Accenture, BairesDev.',
    },
    nav: {
      services: 'Services',
      capabilities: 'Capabilities',
      work: 'Work',
      industries: 'Industries',
      team: 'Team',
      bookCall: 'Book a call',
    },
    hero: {
      eyebrow: 'SOFTWARE ENGINEERING FIRM · SINCE 2006 · BRAZIL',
      title1: 'Production software,',
      title2: 'forged with fire.',
      sub: 'A Brazilian software firm building, shipping, and consulting on web platforms, computer vision, and LLM-powered products. Remote-first. Senior craftsmanship.',
      cta: 'Book a call',
      ctaSecondary: 'See case studies',
      metaPrefix: 'Currently accepting new engagements · reply within',
      metaStrong: '1 business day',
      stats: [
        { n: '18+',  l: 'years shipping production code' },
        { n: '8',    l: 'industries served' },
        { n: '3',    l: 'languages PT · EN · ES' },
        { n: '100%', l: 'remote · async-friendly' },
      ],
      terminal: {
        title: 'coderfire — zsh — 80×24',
        lines: [
          { p: '~/coderfire', c: 'whoami',                        d: 'software engineering firm · Brazil' },
          { p: '~/coderfire', c: 'cat services.toml',             d: null },
          { p: null,          c: null, d: '[delivery]    fixed_scope = true   demo = "biweekly"' },
          { p: null,          c: null, d: '[consulting]  architecture = true   review = true' },
          { p: null,          c: null, d: '[ai_iot]      cv = true   llm_integration = true' },
          { p: '~/coderfire', c: 'history --since 2006 | wc -l', d: '180+ projects shipped' },
          { p: '~/coderfire', c: 'status',                        d: 'remote · async · BRT ±5h' },
        ],
      },
    },
    logoStrip: { label: 'WHERE CODERFIRE HAS SHIPPED' },
    services: {
      eyebrow: 'SERVICES · 03',
      title: 'Two ways CoderFire ships.',
      sub: "Pick the engagement that matches the bottleneck. We'll tell you on the scoping call if we're not the right fit — every engagement priced after a brief scope.",
      notSure: 'Not sure which fits?',
      ctaLink: 'Book a 30-min scoping call',
      cards: [
        {
          tag: '01 · PRODUCT DELIVERY',
          title: 'Build & ship, end-to-end',
          desc: 'Fixed-scope delivery: we architect, build, and ship — then hand it off with docs, tests, and a warranty period. Greenfield products or features inside an existing platform.',
          features: ['Scoped in 1 week', 'Bi-weekly demos', 'Full handoff package', 'Post-launch warranty', 'Source on your VCS'],
          popular: true,
          flag: 'CORE PRACTICE',
        },
        {
          tag: '02 · CONSULTING',
          title: 'Architecture & technical leadership',
          desc: 'Drop us into your roadmap before the code lands. Architecture reviews, technical due diligence, code audits, and fractional-CTO engagements — grounded in 18 years of shipping.',
          features: ['Architecture deep-dive', 'Code & security review', 'Hiring rubrics', 'Fractional CTO', 'Async-friendly cadence'],
          popular: false,
          flag: null,
        },
      ],
    },
    capabilities: {
      eyebrow: 'CAPABILITIES · 08 AREAS',
      title: 'What CoderFire does, in plain text.',
      sub: 'Eight areas of practice, all under one roof. No layers, no account managers — you talk to the engineer doing the work.',
      groups: [
        { title: 'Full-stack product',  stack: 'Python · JavaScript · TypeScript · React · Django · Flask', blurb: "Web and SaaS, front to back. Greenfield builds, rescue missions, and the boring legacy work other shops won't touch." },
        { title: 'LLM integration',     stack: 'OpenAI · Anthropic · self-hosted · RAG · evals',           blurb: "Integrate the model of your choice into your product. We bring the retrieval, the structured output, the guardrails, and the evals — you keep your data." },
        { title: 'Computer vision',     stack: 'OpenCV · Edge inference',                                   blurb: 'Quality inspection on production lines. Real-time defect detection. Shipped to automotive and consumer-goods plants.' },
        { title: 'IoT & Industry 4.0',  stack: 'ZeroMQ · RabbitMQ · MQTT · Edge gateways',                 blurb: 'Telemetry, line-side dashboards. Took vision models out of notebooks and onto the shop floor.' },
        { title: 'Data engineering',    stack: 'SQL · SparkSQL · AirFlow',                                  blurb: 'Pipelines, scorecards, and quality-health dashboards. Built the analytics platform to power your product decisions.' },
        { title: 'Mobile · embedded',   stack: 'C/C++ · ReactNative',                                      blurb: 'Mobile apps and embedded gaming systems.' },
        { title: 'DevOps · cloud',      stack: 'Linux · AWS · Docker · CI/CD',                             blurb: 'From bare-metal Linux configuration up. Certified at 4linux. We own deploys end-to-end.' },
        { title: 'Legacy & rescue',     stack: 'C/C++ · Qt · 18 yrs of CVS history',                      blurb: "We don't flinch at old stacks. Inheriting a 2008 codebase is most weeks for us." },
      ],
    },
    caseStudies: {
      eyebrow: 'CASE STUDIES · SHIPPED',
      title: 'Real fires CoderFire has put out.',
      sub: 'Four engagements across as many industries. Every metric is from production, not pitch decks.',
      cases: [
        {
          tag: 'AD-TECH · PINTEREST · 4+ YRS',
          title: 'Quality Health Scorecard & Business Entity Service',
          metric: '20+', metricLabel: 'products and service scored, daily',
          stack: 'Python · React · SparkSQL · AirFlow · Jenkins',
          desc: "Lead engineering on Pinterest's internal analytics for code and product quality enabling teams to set quarterly goals based on metrics. Also lead on Business Preferences APIs (Business Entity Services).",
        },
        {
          tag: 'AUTOMOTIVE · POLLUX / ACCENTURE · 3 YRS',
          title: 'Computer-vision defect inspection on a Tier-1 line.',
          metric: '+99%', metricLabel: 'defect-detection recall',
          stack: 'Python · TensorFlow · OpenCV · ZeroMQ · GenICam',
          desc: 'Visual inspection with a real-time CV pipeline running on edge GPUs at the cell. Three years technical lead across automotive, aerospatial, and consumer-goods deployments.',
        },
        {
          tag: 'CIVIL SUPPLY · COLLABO · 2.5 YRS',
          title: 'Geolocation-driven marketplace for civil engineering supply.',
          metric: '1k+', metricLabel: 'Demands connected',
          stack: 'C/C++ · Python · Django · Qt · SQLAlchemy · RabbitMQ',
          desc: 'Built and operated a SaaS platform connecting product demand with regional suppliers across Brazil. Led architecture, engineering, and some of the sales conversations.',
        },
        {
          tag: 'EDTECH · REFATORE · 1 YEAR',
          title: 'Programming literacy for 100+ kids in Brazilian public schools.',
          metric: '100+', metricLabel: 'kids reached',
          stack: 'Python · JavaScript · Code.org · AWS',
          desc: 'Co-founded an early-stage EdTech to bring programming to underserved schools. Designed the curriculum, the platform, and ran the classes. Now operates as a board-level engagement.',
        },
      ],
    },
    industries: {
      eyebrow: 'INDUSTRIES · 08',
      title: 'On the line, in the cloud, on your phone.',
      sub: 'A multi-industry background means CoderFire reads your domain faster. The gotchas tend to look familiar.',
      list: [
        { tag: 'AD-TECH',              note: 'Business platforms, scorecards, preferences APIs' },
        { tag: 'AUTOMOTIVE',           note: 'Tier-1 inspection, line telemetry, Manufacturing Execution System (MES)' },
        { tag: 'AEROSPATIAL',          note: 'Industrial control & vision, Manufacturing Execution System (MES)' },
        { tag: 'CONSUMER GOODS',       note: 'Quality control, demand forecasting' },
        { tag: 'EDTECH',               note: 'K-12 curriculum, gamified learning' },
        { tag: 'CIVIL SUPPLY CHAIN',   note: 'Marketplace SaaS, geolocation' },
        { tag: 'GAMING',               note: 'Embedded slot, bingo, poker (worldwide)' },
        { tag: 'DEVTOOLS',             note: 'Internal platforms, CI/CD scorecards' },
      ],
    },
    leadership: {
      eyebrow: 'CODERFIRE · PRINCIPAL',
      title: "Who's on the call.",
      sub: "No account managers. No marketplace middlemen. You talk to the engineer who'll architect the work.",
      name: 'Rafael Fernandes',
      role: 'Founder & Software Engineer',
      bio: '18+ years building production software across automotive, ad-tech, edtech, and gaming. Currently Software Engineer @ <strong>Pinterest</strong>, formerly Tech Lead at <strong>Pollux/Accenture</strong> (industrial automation and computer vision), co-founder of <strong>Refatore</strong> (EdTech), and <strong>Collabo</strong> (SaaS supply chain).',
      cvLabel: 'CV · HIGHLIGHTS',
    },
    ctaBanner: {
      eyebrow: 'READY WHEN YOU ARE',
      title: "Let's scope it out.",
      sub: "30-minute call. No pitch deck. We'll tell you on the call whether CoderFire is a fit — and if we're not, we'll point you to who is.",
      button: 'BOOK A CALL',
    },
    footer: {
      tagline: 'A Brazilian software firm.\nForged with fire · shipped worldwide.\nSenior craftsmanship since 2006.',
      hire: 'Hire',
      work: 'Work',
      company: 'Company',
      productDelivery: 'Product delivery',
      archConsulting: 'Architecture & consulting',
      cvLlm: 'CV / LLM integration',
      caseStudies: 'Case studies',
      industries: 'Industries',
      capabilities: 'Capabilities',
      team: 'Team',
      contact: 'Contact',
      location: 'Brazil · Remote-first · UTC-3 (BRT)',
    },
    modal: {
      eyebrow: 'BOOK A CALL · 30 MIN · NO PITCH DECK',
      title: "Tell us what's on fire.",
      sub: "We'll reply within one business day. If CoderFire isn't the right fit, we'll say so on the call.",
      labels: { email: 'Email', need: 'What you need', message: 'What hurts?' },
      placeholders: {
        email: 'you@company.com',
        message: 'e.g. We need a computer-vision pipeline for defect inspection on our packaging line.',
      },
      options: [
        'Product delivery (fixed scope)',
        'Architecture / consulting',
        'Computer vision / LLM integration',
        'Fractional CTO / advisory',
      ],
      submitting: 'Sending…',
      send: 'Send',
      close: 'Close',
      successTitle: "Thank you. We'll be in touch.",
      successSub: 'Expect a calendar link within one business day (BRT).',
      genericError: 'Could not send your message. Please try again.',
    },
  },

  pt: {
    lang: 'pt',
    meta: {
      title: 'CoderFire — Engenharia de Software, forjada no Brasil.',
      description: 'Times de produto terceirizados e consultoria em Desenvolvimento de Software. Entregamos globalmente: Pinterest, Accenture, BairesDev.',
    },
    nav: {
      services: 'Serviços',
      capabilities: 'Atuação',
      work: 'Trabalho',
      industries: 'Indústrias',
      team: 'Time',
      bookCall: 'Agendar call',
    },
    hero: {
      eyebrow: 'DESENVOLVIMENTO DE SOFTWARE · DESDE 2006 · BRASIL',
      title1: 'Software de produção,',
      title2: 'forjado no fogo.',
      sub: 'Uma empresa de desenvilvimento de software que constrói, entrega e oferece consultoria em plataformas web, visão computacional e produtos com LLM. Remoto',
      cta: 'Agendar uma conversa',
      ctaSecondary: 'Ver cases',
      metaPrefix: 'Aceitando novos projetos · resposta em',
      metaStrong: '1 dia útil',
      stats: [
        { n: '18+',  l: 'anos entregando código em produção' },
        { n: '8',    l: 'setores atendidos' },
        { n: '3',    l: 'idiomas PT · EN · ES' },
        { n: '100%', l: 'remoto · assíncrono' },
      ],
      terminal: {
        title: 'coderfire — zsh — 80×24',
        lines: [
          { p: '~/coderfire', c: 'whoami',                        d: 'empresa de software · Brasil' },
          { p: '~/coderfire', c: 'cat services.toml',             d: null },
          { p: null,          c: null, d: '[entrega]     escopo_fixo = true   demo = "quinzenal"' },
          { p: null,          c: null, d: '[consultoria] arquitetura = true   revisao = true' },
          { p: null,          c: null, d: '[ia_iot]      cv = true   integracao_llm = true' },
          { p: '~/coderfire', c: 'history --since 2006 | wc -l', d: '180+ projetos entregues' },
          { p: '~/coderfire', c: 'status',                        d: 'remoto · assíncrono · BRT ±5h' },
        ],
      },
    },
    logoStrip: { label: 'ONDE A CODERFIRE JÁ ENTREGOU' },
    services: {
      eyebrow: 'SERVIÇOS · 02',
      title: 'Duas formas de entregar com a CoderFire.',
      sub: 'Escolha o modelo que se encaixa no seu contexto. Diremos na call de escopo se não formos a melhor opção — cada projeto é precificado após um breve escopo.',
      notSure: 'Não sabe qual se encaixa?',
      ctaLink: 'Agende uma call de escopo de 30 min',
      cards: [
        {
          tag: '01 · ENTREGA DE PRODUTO',
          title: 'Construir & entregar, do começo ao fim',
          desc: 'Entrega de escopo fixo: arquitetamos, construímos e entregamos — com documentação, testes e um período de garantia. Produtos do zero ou funcionalidades em plataformas existentes.',
          features: ['Escopo em 1 semana', 'Demos quinzenais', 'Pacote completo de handoff', 'Garantia pós-lançamento', 'Código no seu VCS'],
          popular: true,
          flag: 'PRÁTICA PRINCIPAL',
        },
        {
          tag: '02 · CONSULTORIA',
          title: 'Arquitetura & liderança técnica',
          desc: 'Nos integre ao seu roadmap antes do código chegar. Revisões de arquitetura, due diligence técnica, auditorias de código e engajamentos fracionados de CTO — com 18 anos de entrega.',
          features: ['Deep-dive de arquitetura', 'Revisão de código & segurança', 'CTO fracionado', 'Cadência assíncrona'],
          popular: false,
          flag: null,
        },
      ],
    },
    capabilities: {
      eyebrow: 'ATUAÇÂO · 08 ÁREAS',
      title: 'O que a CoderFire faz',
      sub: 'Oito áreas de prática, tudo sob o mesmo teto. Sem camadas, sem gerentes de conta — você fala com o engenheiro fazendo o trabalho.',
      groups: [
        { title: 'Produto full-stack',  stack: 'Python · JavaScript · TypeScript · React · Django · Flask', 
            blurb: 'Web e SaaS, do front ao back. Produtos do zero, missões de resgate e o trabalho legado chato que outras empresas não topam.' },
        { title: 'Integração com LLM', stack: 'OpenAI · Anthropic · self-hosted · RAG · evals',           
            blurb: 'Integre o modelo da sua escolha ao seu produto. Trazemos o retrieval, a saída estruturada, os guardrails e os evals — você mantém seus dados.' },
        { title: 'Visão computacional', stack: 'OpenCV · Edge inference',                                  
            blurb: 'Inspeção de qualidade em linhas de produção. Detecção de defeitos em tempo real. Entregue em plantas automotivas e de bens de consumo.' },
        { title: 'IoT & Indústria 4.0', stack: 'ZeroMQ · RabbitMQ · MQTT · Edge gateways',                
            blurb: 'Telemetria, dashboards de linha de produção. Levamos modelos de visão dos notebooks para o chão de fábrica.' },
        { title: 'Engenharia de dados', stack: 'SQL · SparkSQL · AirFlow',                                 
            blurb: 'Pipelines, scorecards e dashboards de qualidade. Construímos a plataforma de analytics para potencializar as decisões do seu produto.' },
        { title: 'Mobile · embarcado',  stack: 'C/C++ · ReactNative',                                     
            blurb: 'Apps mobile e sistemas embarcados.' },
        { title: 'DevOps · cloud',      stack: 'Linux · AWS · Docker · CI/CD',                            
            blurb: 'De configuração Linux bare-metal para cima. Somos donos dos deploys do início ao fim.' },
        { title: 'Legado & resgate',    stack: 'C/C++ · Qt · 18 anos de histórico CVS',                   
            blurb: 'Não travamos diante de stacks antigas. Herdar uma codebase de 2008 é rotina para nós.' },
      ],
    },
    caseStudies: {
      eyebrow: 'CASES · ENTREGUES',
      title: 'Incêndios reais que a CoderFire apagou.',
      sub: 'Quatro projetos em quatro setores. Cada métrica vem de produção, não de pitch decks.',
      cases: [
        {
          tag: 'AD-TECH · PINTEREST · 4+ ANOS',
          title: 'Quality Health Scorecard & Business Entity Service',
          metric: '20+', metricLabel: 'produtos e serviços avaliados, diariamente',
          stack: 'Python · React · SparkSQL · AirFlow · Jenkins',
          desc: 'Liderança de engenharia na plataforma interna de analytics da Pinterest para qualidade de código e produto, permitindo que equipes definam metas trimestrais com base em métricas. Mantenedor da Business Preferences APIs (Business Entity Services).',
        },
        {
          tag: 'AUTOMOTIVO · POLLUX / ACCENTURE · 3 ANOS',
          title: 'Inspeção de defeitos por visão computacional em linha Tier-1.',
          metric: '+99%', metricLabel: 'recall de detecção de defeitos',
          stack: 'Python · TensorFlow · OpenCV · ZeroMQ · GenICam',
          desc: 'Inspeção visual com pipeline de CV em tempo real rodando em GPUs de Edge na célula. Três anos de liderança técnica em implantações automotivas, aeroespaciais e de bens de consumo.',
        },
        {
          tag: 'CONSTRUÇÃO CIVIL · COLLABO · 2,5 ANOS',
          title: 'Marketplace com geolocalização para suprimentos de engenharia civil.',
          metric: '1k+', metricLabel: 'Demandas conectadas',
          stack: 'C/C++ · Python · Django · Qt · SQLAlchemy · RabbitMQ',
          desc: 'Construímos e operamos uma plataforma SaaS conectando demanda de produtos a fornecedores regionais em todo o Brasil. Liderei a arquitetura, a engenharia e algumas conversas de vendas.',
        },
        {
          tag: 'EDTECH · REFATORE · 1 ANO',
          title: 'Letramento em ciência da computação para 100+ crianças em escolas públicas brasileiras.',
          metric: '100+', metricLabel: 'crianças impactadas',
          stack: 'Python · JavaScript · Code.org · AWS',
          desc: 'Co-fundei uma EdTech em estágio inicial para levar programação a escolas públicas carentes. Desenhei o currículo, a plataforma e conduzi as aulas. Hoje opera como engajamento de conselho.',
        },
      ],
    },
    industries: {
      eyebrow: 'SETORES · 08',
      title: 'Na linha, na nuvem, no seu celular.',
      sub: 'Um histórico multissetorial significa que a CoderFire lê seu domínio mais rápido. Os problemas tendem a parecer familiares.',
      list: [
        { tag: 'AD-TECH',                    note: 'Plataformas de negócios, scorecards, APIs de preferências' },
        { tag: 'AUTOMOTIVO',                 note: 'Inspeção Tier-1, telemetria de linha, MES' },
        { tag: 'AEROESPACIAL',               note: 'Controle industrial & visão, MES' },
        { tag: 'BENS DE CONSUMO',            note: 'Controle de qualidade, previsão de demanda' },
        { tag: 'EDTECH',                     note: 'Currículo K-12, aprendizado gamificado' },
        { tag: 'SUPPLY CHAIN',               note: 'SaaS marketplace, geolocalização' },
        { tag: 'GAMES',                      note: 'Slot embarcado, bingo, poker (mundial)' },
        { tag: 'DEVTOOLS',                   note: 'Plataformas internas, scorecards de CI/CD' },
      ],
    },
    leadership: {
      eyebrow: 'CODERFIRE · PRINCIPAL',
      title: 'Quem está na call.',
      sub: 'Sem gerentes de conta. Sem intermediários. Você fala com o engenheiro que vai arquitetar o trabalho.',
      name: 'Rafael Fernandes',
      role: 'Fundador & Engenheiro de Software',
      bio: '18+ anos construindo software de produção em automotivo, ad-tech, edtech e games. Atualmente Software Engineer @ <strong>Pinterest</strong>, ex-Tech Lead na <strong>Pollux/Accenture</strong> (automação industrial e visão computacional), co-fundador da <strong>Refatore</strong> (EdTech) e <strong>Collabo</strong> (SaaS supply chain).',
      cvLabel: 'DESTAQUES DO CV',
    },
    ctaBanner: {
      eyebrow: 'PRONTO QUANDO VOCÊ ESTIVER',
      title: 'Vamos definir o escopo.',
      sub: '30 minutos. Sem pitch deck. Diremos na call se a CoderFire é a escolha certa — e se não for, indicaremos quem é.',
      button: 'AGENDAR UMA CALL',
    },
    footer: {
      tagline: 'Uma empresa brasileira de software.\nForjado com fogo · entregue mundialmente.\nDesenvilvimento de software desde 2006.',
      hire: 'Contratar',
      work: 'Trabalho',
      company: 'Empresa',
      productDelivery: 'Entrega de produto',
      archConsulting: 'Arquitetura & consultoria',
      cvLlm: 'CV / integração LLM',
      caseStudies: 'Cases',
      industries: 'Setores',
      capabilities: 'Atuação',
      team: 'Time',
      contact: 'Contato',
      location: 'Brasil · Remoto · UTC-3 (BRT)',
    },
    modal: {
      eyebrow: 'AGENDAR UMA CALL · 30 MIN · SEM PITCH DECK',
      title: 'Nos conte o que está pegando fogo.',
      sub: 'Responderemos em até um dia útil. Se a CoderFire não for a opção certa, diremos na call.',
      labels: { email: 'E-mail', need: 'O que você precisa', message: 'O que está travando?' },
      placeholders: {
        email: 'voce@empresa.com.br',
        message: 'ex.: Precisamos de um pipeline de visão computacional para inspeção de defeitos na nossa linha de embalagens.',
      },
      options: [
        'Entrega de produto (escopo fixo)',
        'Arquitetura / consultoria',
        'Visão computacional / integração LLM',
        'CTO fracionado / advisory',
      ],
      submitting: 'Enviando…',
      send: 'Enviar',
      close: 'Fechar',
      successTitle: 'Obrigado. Entraremos em contato.',
      successSub: 'Enviaremos um link de calendário em até um dia útil (BRT).',
      genericError: 'Não foi possível enviar sua mensagem. Tente novamente.',
    },
  },
};

Object.assign(window, { LangContext, useLang, useT, detectLang, translations });
