import re

def fix_html_fonts(file_path):
    with open(file_path, 'r', encoding='utf-8') as f:
        content = f.read()

    # Find the Mass Intention block up to <footer
    pattern = re.compile(r'(<!-- Mass Intention in USA Section -->.*?)(<footer)', re.DOTALL)
    match = pattern.search(content)
    if not match:
        print(f"Section not found in {file_path}")
        return

    mass_intention_html = match.group(1)
    
    # 1. Update H2
    mass_intention_html = re.sub(
        r'<h2[^>]*>([\s\S]*?)</h2>',
        r'<h2 class="gsap-reveal-h2" style="font-family: \'Phudu\', sans-serif !important; font-size: clamp(2.4rem, 4vw, 3.6rem) !important; font-weight: 600 !important; color: #1c1917 !important; text-transform: uppercase; line-height: 1.15; letter-spacing: -0.01em; margin-bottom: 0.5rem;">\1</h2>',
        mass_intention_html
    )

    # 2. Update P (subtitle)
    mass_intention_html = re.sub(
        r'<p style="font-family: \'Instrument Sans\'([^>]+)>([\s\S]*?)</p>',
        r'<p class="gsap-reveal-p" style="font-family: \'Instrument Sans\'\1>\2</p>',
        mass_intention_html
    )

    # 3. Add gsap-fade-up to the box container
    # <div style="background-color: #FAF7F0; padding: 3.5rem; border-radius: 4px; text-align: left;">
    mass_intention_html = mass_intention_html.replace(
        '<div style="background-color: #FAF7F0; padding: 3.5rem; border-radius: 4px; text-align: left;">',
        '<div class="gsap-fade-up" style="background-color: #FAF7F0; padding: 3.5rem; border-radius: 4px; text-align: left;">'
    )

    new_content = content[:match.start()] + mass_intention_html + content[match.end(2):]
    
    with open(file_path, 'w', encoding='utf-8') as f:
        f.write(new_content)
    print(f"Fixed {file_path}")

fix_html_fonts('d:\\iss\\Franciscan Society\\index.html')
try:
    fix_html_fonts('d:\\iss\\Franciscan Society\\about.html')
except:
    pass
