import fs from 'fs';
import path from 'path';

const dir = 'src/components';
const files = fs.readdirSync(dir).filter(f => f.endsWith('.tsx'));

for (const file of files) {
  const filePath = path.join(dir, file);
  let content = fs.readFileSync(filePath, 'utf8');
  let original = content;

  // Hero Section
  if (file === 'HeroSection.tsx') {
    content = content.replaceAll('text-5xl md:text-7xl lg:text-8xl', 'text-4xl md:text-6xl lg:text-8xl break-words');
    content = content.replaceAll('text-2xl md:text-4xl font-hero', 'text-xl md:text-3xl lg:text-4xl font-hero');
  } else {
    // Normal Sections Big Titles
    // Replace text-6xl md:text-7xl font-bold pt-4 pb-10 leading-[1.8] text-gradient
    content = content.replace(/text-6xl md:text-7xl/g, 'text-4xl md:text-5xl lg:text-7xl break-words');
    content = content.replace(/text-5xl md:text-6xl/g, 'text-3xl md:text-4xl lg:text-6xl break-words');
    
    // Smaller sizes
    content = content.replace(/text-5xl pt-3 pb-6/g, 'text-3xl md:text-4xl lg:text-5xl pt-3 pb-6 break-words');
    content = content.replace(/text-4xl pt-3 pb-5/g, 'text-2xl md:text-3xl lg:text-4xl pt-3 pb-5');
    content = content.replace(/text-3xl pt-3 pb-5/g, 'text-xl md:text-2xl lg:text-3xl pt-3 pb-5');
    
    // Footer / Nav
    content = content.replace(/text-4xl py-4/g, 'text-2xl md:text-3xl lg:text-4xl py-4');
    content = content.replace(/text-4xl py-2/g, 'text-2xl md:text-3xl lg:text-4xl py-2');
    content = content.replace(/text-2xl py-2/g, 'text-lg md:text-xl lg:text-2xl py-2');
  }

  // General overflow catch-all: Ensure .container has overflow-hidden just in case? 
  // No, adding break-words is better.

  if (original !== content) {
    fs.writeFileSync(filePath, content);
    console.log(`Fixed responsive sizes in ${file}`);
  }
}
