import { describe, it, expect } from 'vitest';
import fs from 'node:fs';
import path from 'node:path';

const cssPath = path.resolve(__dirname, '../../resources/css/typography.css');
const css = fs.existsSync(cssPath) ? fs.readFileSync(cssPath, 'utf-8') : '';

describe('typography.css', () => {
    it('imports Inter variable font', () => {
        expect(css).toMatch(/@import\s+url\([^)]*fonts\.googleapis\.com[^)]*Inter[^)]*\)/i);
    });

    it('imports JetBrains Mono', () => {
        expect(css).toMatch(/@import\s+url\([^)]*fonts\.googleapis\.com[^)]*JetBrains[+\s]?Mono/i);
    });

    it('sets Inter as default body font with tnum', () => {
        expect(css).toMatch(/font-family:[^;]*['"]?Inter['"]?[^;]*system-ui/);
        expect(css).toMatch(/font-feature-settings:[^;]*['"]?tnum['"]?\s*1/);
    });

    it('defines .ld-mono utility for JetBrains Mono with tnum', () => {
        expect(css).toMatch(/\.ld-mono\s*{[^}]*font-family:[^;]*['"]?JetBrains Mono['"]?/);
        expect(css).toMatch(/\.ld-mono\s*{[^}]*font-feature-settings:[^;]*['"]?tnum['"]?/);
    });

    it.each(['ld-label', 'ld-body', 'ld-body-strong', 'ld-h3', 'ld-h2', 'ld-h1'])('defines %s class', (cls) => {
        expect(css).toMatch(new RegExp(`\\.${cls}\\s*{`));
    });
});
