import re, sys

# Mapping: current px -> replacement px (for sizes < 32px)
# Target: minimum 28px for labels, 34px for body text, 38px for list items
REMAP = {
    12: 26, 13: 26, 14: 28, 15: 28, 16: 30, 17: 32,
    18: 34, 19: 34, 20: 36, 22: 38, 24: 40, 26: 44, 28: 46
}

def fix_font_sizes(html):
    def replace_size(m):
        val = int(m.group(1))
        new_val = REMAP.get(val, val)
        return f'font-size: {new_val}px'
    return re.sub(r'font-size:\s*(\d+)px', replace_size, html)

for path in sys.argv[1:]:
    with open(path) as f:
        original = f.read()
    fixed = fix_font_sizes(original)
    with open(path, 'w') as f:
        f.write(fixed)
    # Report changes
    orig_sizes = set(re.findall(r'font-size:\s*(\d+)px', original))
    new_sizes = set(re.findall(r'font-size:\s*(\d+)px', fixed))
    changed = [(s, REMAP[int(s)]) for s in orig_sizes if int(s) in REMAP]
    print(f"{path}: changed {changed}")
