import type { Config } from "tailwindcss";
import { heroui } from "@heroui/theme";
import { realpathSync } from "fs";
import { join } from "path";

// pnpm uses symlinks for node_modules; fast-glob (used by Tailwind) doesn't
// follow symlinks by default, causing HeroUI theme classes to be purged.
// Resolve the real physical path so Tailwind can scan it correctly.
function resolveHeroUIPath() {
  try {
    return realpathSync(join(process.cwd(), "node_modules/@heroui/theme/dist"));
  } catch {
    return join(process.cwd(), "node_modules/@heroui/theme/dist");
  }
}

export default {
  darkMode: "class",
  content: [
    "./pages/**/*.{js,ts,jsx,tsx,mdx}",
    "./components/**/*.{js,ts,jsx,tsx,mdx}",
    "./app/**/*.{js,ts,jsx,tsx,mdx}",
    `${resolveHeroUIPath()}/**/*.{js,ts,jsx,tsx}`,
  ],
  theme: {
    screens: {
      'sm': '640px',
      'md': '1024px',
      'lg': '1024px',
      'xl': '1280px',
      '2xl': '1536px',
    },
    extend: {
      colors: {
        background: "var(--background)",
        foreground: "var(--foreground)",
        'bg-subtle': '#f9fafb',
        'bg-surface': '#ffffff',
        'border-normal': '#e5e7eb',
        'border-gray': '#f3f4f6',
        'text-primary': '#111827',
        'text-tertiary': '#9ca1af',
        'fill-secondary-click': '#f3f4f6',
      },
      fontFamily: {
        inter: ['var(--font-inter)', 'Inter', 'sans-serif'],
        jetbrains: ['var(--font-inter)', 'JetBrains Mono', 'monospace'],
      },
      fontSize: {
        'caption-tiny': ['12px', { lineHeight: '150%', letterSpacing: '0.01em' }],
        'body-small': ['14px', { lineHeight: '150%' }],
        'body-default': ['16px', { lineHeight: '150%' }],
        'body-large': ['18px', { lineHeight: '150%' }],
        'heading-h4': ['20px', { lineHeight: '140%', letterSpacing: '-0.005em' }],
        'heading-h3': ['24px', { lineHeight: '130%', letterSpacing: '-0.005em' }],
        'heading-h2': ['32px', { lineHeight: '120%', letterSpacing: '-0.01em' }],
      },
      fontWeight: {
        regular: '400',
        medium: '500',
        bold: '700',
        extrabold: '800',
      },
      animation: {
        'fade-in': 'fadeInCard 0.4s ease-out',
      },
      keyframes: {
        fadeInCard: {
          '0%': {
            opacity: '0',
            transform: 'scale(0.95) translateY(20px)',
          },
          '100%': {
            opacity: '1',
            transform: 'scale(1) translateY(0)',
          },
        },
      },
    },
  },
  plugins: [heroui()],
} satisfies Config;
