import re

def build_about_us():
    with open('index.html', 'r', encoding='utf-8') as f:
        content = f.read()

    header_match = re.search(r'(.*?)(<section\s+(?:id="hero-section"|class="hero-section"))', content, re.DOTALL | re.IGNORECASE)
    header = header_match.group(1) if header_match else ""

    about_match = re.search(r'(<section id="about-section".*?</section>\s*)<!--', content, re.DOTALL | re.IGNORECASE)
    about_section = about_match.group(1) if about_match else ""

    mission_match = re.search(r'(<!-- Our Mission Section -->.*?)(?=<!-- 4\. News)', content, re.DOTALL | re.IGNORECASE)
    mission_section = mission_match.group(1) if mission_match else ""

    footer_match = re.search(r'(<footer.*)', content, re.DOTALL | re.IGNORECASE)
    footer = footer_match.group(1) if footer_match else ""

    header = header.replace('href="index.html" class="active"', 'href="index.html"')
    header = header.replace('href="about-us.html"', 'href="about-us.html" class="active"')
    
    header = re.sub(r'<!-- Unclippable Flying Bible.*?</div>', '', header, flags=re.DOTALL)
    header = re.sub(r'<script>\s*document\.addEventListener\("DOMContentLoaded", function\(\) \{\s*const heroBibleRef.*?updateBibleFlight\(\);\s*\}\s*\};\s*\}\);\s*</script>', '', header, flags=re.DOTALL)

    page_hero = """
    <!-- Page Hero -->
    <section style="padding: 12rem 2rem 8rem 2rem; background-image: url('assets/images/church-bg.jpg'); background-size: cover; background-position: center; position: relative; overflow: hidden;">
        <div style="position: absolute; inset: 0; background-color: rgba(12, 11, 10, 0.7);"></div>
        <div style="max-width: 800px; margin: 0 auto; position: relative; z-index: 2; text-align: center;">
            <div style="display: inline-flex; align-items: center; gap: 0.6rem; background: rgba(255,255,255,0.1); backdrop-filter: blur(10px); padding: 0.5rem 1rem; border-radius: 50px; margin-bottom: 1.5rem; border: 1px solid rgba(255,255,255,0.2);">
                <span style="width: 8px; height: 8px; background-color: #c8102e; border-radius: 50%; display: inline-block;"></span>
                <span style="color: #ffffff; font-size: 0.85rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; font-family: 'Instrument Sans', sans-serif;">WHO WE ARE</span>
            </div>
            <h1 style="font-family: 'Phudu', sans-serif; font-size: clamp(3rem, 5vw, 4.5rem); font-weight: 700; color: #ffffff; text-transform: uppercase; margin: 0;">ABOUT US</h1>
        </div>
    </section>
    """

    history_section = """
    <section id="history-section" style="padding: 6rem 0; background-color: #FFFFFF; color: #57534e; font-family: 'Instrument Sans', sans-serif; font-size: 1.15rem; line-height: 1.8;">
        <div style="max-width: 1000px; margin: 0 auto; padding: 0 2rem;">
            <h3 style="font-family: 'Phudu', sans-serif; font-size: 2.5rem; font-weight: 700; color: #1c1917; text-transform: uppercase; margin-bottom: 2.5rem; text-align: center;">Our History</h3>
            
            <p style="margin-bottom: 1.5rem;">The Third Order Regular (TOR) of St. Francis traces its origins to the ancient Order of Penance, which dates back to the fourth century AD. Men and women voluntarily embraced lives of penance for the sake of the Kingdom of God and their own spiritual growth. Some penitents were married and lived with their families, while others chose the life of hermits or formed communities dedicated to the service of the Church.</p>
            
            <p style="margin-bottom: 1.5rem;">During his early conversion experience, St. Francis of Assisi (1181–1226) became associated with the Order of Penance, an itinerant movement known as the Penitents of Assisi. He addressed them through an Exhortation, encouraging them to lead holy lives of penance. It is within this movement that the Third Order Regular of St. Francis finds its roots. The penitents received a way of life from St. Francis around 1209–1210, and their Rule was formally approved by the Church through Supra Montem, promulgated by Pope Nicholas IV in 1289.</p>
            
            <p style="margin-bottom: 1.5rem;">Among the early Franciscan penitents were both Seculars (Third Order Seculars), who continued to live with their families, and Regulars, who lived according to a regula (rule of life). The Regulars embraced religious life characterized by the profession of vows, observance of the Third Order Rule, and communal living in hermitages or communities devoted to works of mercy. The practice of professing the vows of poverty, chastity, and obedience received papal approval in 1321 through Pope John XXII’s letter Altissimo in Divinis.</p>
            
            <div style="background-color: #FAF7F0; padding: 2.5rem; border-left: 4px solid #c8102e; margin: 3rem 0; border-radius: 0 16px 16px 0;">
                <p style="font-style: italic; font-weight: 600; color: #1c1917; margin: 0; font-size: 1.25rem;">Conversion, contemplation, poverty, and humility lie at the heart of Franciscan identity. The fundamental charism of the Third Order Regular, however, is penance, understood as ongoing conversion. This involves turning to God in love, reconciliation with Him, harmony with oneself, and charity toward one’s neighbour.</p>
            </div>

            <p style="margin-bottom: 1.5rem;">In 1447, Pope Nicholas V, through the bull Pastoralis Officii, united approximately sixty communities of male Franciscan tertiaries in Italy under a single Minister General. This marked the formal beginning of the Third Order Regular of St. Francis. In 1512, the Order established its headquarters at the Basilica of Saints Cosmas and Damian in Rome, where its Generalate remains to this day.</p>
            
            <p style="margin-bottom: 1.5rem;">The Third Order Regular received a revised Rule from Pope Pius XI in 1927 through the document Rerum Conditio. This Rule was renewed on 8 December 1982 by Pope John Paul II through the apostolic letter Franciscanum Vitae Propositum, becoming the Rule and Life of nearly four hundred Franciscan Third Order congregations of men and women throughout the world.</p>
            
            <p style="margin-bottom: 1.5rem;">Today, the Order comprises three provinces in India; two provinces each in Italy and the United States; one province each in Sri Lanka, Spain and Croatia; vice provinces in South Africa, Brazil, Paraguay, and Mexico; delegations in the Philippines, France, Sweden, and Bangladesh; and a commissariat of the Spanish Province in Peru.</p>
            
            <h4 style="font-family: 'Phudu', sans-serif; font-size: 1.8rem; font-weight: 700; color: #1c1917; margin: 3rem 0 1.5rem 0;">The TOR in India</h4>
            
            <p style="margin-bottom: 1.5rem;">The history of the TOR in India began in 1938 when missionaries from the Province of the Sacred Heart of Jesus, USA, arrived in Bhagalpur, Bihar. The mission steadily grew and was established as a Commissariat in 1945. In 1971, it was elevated to the status of a Province under the title Province of St. Thomas the Apostle.</p>
            
            <p style="margin-bottom: 1.5rem;">In 1996, the Commissariat of St. Francis was established at Ranchi. On 4 October 1999, the Most Rev. Bonaventure Midili, TOR, Minister General, elevated it to the status of a Vice Province. The Vice Province of St. Francis was formally inaugurated by him in Ranchi on 8 December 1999.</p>
            
            <p style="margin-bottom: 1.5rem;">Recognizing the remarkable growth and expansion of the Vice Province between 1999 and 2005, as well as the strategic importance of India for the future of the Order, the Most Rev. Ilija Živković, TOR, Minister General, elevated it to a full-fledged Province on 20 March 2006. The ceremony took place in Ranchi during a Eucharistic celebration presided over by the Most Rev. Dr. Vincent Barwa, Auxiliary Bishop of Ranchi.</p>
            
            <p style="margin-bottom: 1.5rem;">The Province presently has 104 professed friars, including 84 solemnly professed and 19 temporarily professed members. Among them are 71 priests and 3 brothers. The Province has 28 major seminarians, 4 novices, 9 pre-novices, and 36 candidates.</p>
            
            <p style="margin-bottom: 1.5rem;">The Province maintains four houses in the Archdiocese of Ranchi, four in Khunti, three in Simdega, two in Rourkela, two in Jalpaiguri, and one each in the dioceses of Bagdogra, Gumla, Purnea, and Bongaigaon. The friars serve the People of God through ministry in 14 parishes and 22 schools. Two friars are currently engaged in ministry abroad.</p>
            
            <p style="margin-bottom: 1.5rem;">The Province has three formation houses: one in Ranchi, one in Dorma, and one in Bichna.</p>
        </div>
    </section>
    """

    councils_section = """
    <section id="councils-section" style="padding: 6rem 0; background-color: #FAF7F0; color: #1c1917;">
        <div style="max-width: 1320px; margin: 0 auto; padding: 0 2rem;">
            <div style="text-align: center; margin-bottom: 4rem;">
                <h3 style="font-family: 'Phudu', sans-serif; font-size: 2.5rem; font-weight: 700; text-transform: uppercase;">Leadership & Councils</h3>
                <div style="width: 60px; height: 3px; background-color: #c8102e; margin: 1rem auto 0 auto;"></div>
            </div>
            <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 4rem;">
                <!-- General Council -->
                <div style="background: #ffffff; padding: 3rem; border-radius: 24px; box-shadow: 0 15px 40px rgba(0,0,0,0.03);">
                    <h4 style="font-family: 'Phudu', sans-serif; font-size: 1.5rem; font-weight: 600; text-transform: uppercase; margin-bottom: 2rem; color: #4A2A18; border-bottom: 1px solid #e7e5e4; padding-bottom: 0.8rem;">General Council</h4>
                    <ul style="list-style: none; padding: 0; margin: 0; font-family: 'Instrument Sans', sans-serif; font-size: 1.05rem; line-height: 1.8;">
                        <li style="display: flex; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #f5f5f4;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">1.</span> <strong>Minister General</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Most Rev. Fr. Armando Trujillo, TOR</span></li>
                        <li style="display: flex; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #f5f5f4;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">2.</span> <strong>Vicar General</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Very Rev. Fr. Sean Sheridan, TOR</span></li>
                        <li style="display: flex; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #f5f5f4;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">3.</span> <strong>First Councilor</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Very Rev. Fr. Zvonimir Brusac, TOR</span></li>
                        <li style="display: flex; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #f5f5f4;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">4.</span> <strong>Second Councilor</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Very Rev. Fr. Shibin Kurian Vallattuthundathil, TOR</span></li>
                        <li style="display: flex; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #f5f5f4;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">5.</span> <strong>Third Councilor</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Very Rev. Fr. Massimo Cucinotta, TOR</span></li>
                        <li style="display: flex; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #f5f5f4;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">6.</span> <strong>Fourth Councilor</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Very Rev. Fr. Bijay Prakash Tirkey, TOR</span></li>
                        <li style="display: flex; gap: 1rem;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">7.</span> <strong>Secretary General</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Very Rev. Fr. Shibin Vallattuthundathil, TOR</span></li>
                    </ul>
                </div>
                <!-- Provincial Council -->
                <div style="background: #ffffff; padding: 3rem; border-radius: 24px; box-shadow: 0 15px 40px rgba(0,0,0,0.03);">
                    <h4 style="font-family: 'Phudu', sans-serif; font-size: 1.5rem; font-weight: 600; text-transform: uppercase; margin-bottom: 2rem; color: #4A2A18; border-bottom: 1px solid #e7e5e4; padding-bottom: 0.8rem;">Provincial Council</h4>
                    <ul style="list-style: none; padding: 0; margin: 0; font-family: 'Instrument Sans', sans-serif; font-size: 1.05rem; line-height: 1.8;">
                        <li style="display: flex; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #f5f5f4;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">1.</span> <strong>Minister Provincial</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Very Rev. Fr. Manoj Vengathanam, TOR</span></li>
                        <li style="display: flex; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #f5f5f4;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">2.</span> <strong>Vicar Provincial</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Very Rev. Fr. Manoj Kullu, TOR</span></li>
                        <li style="display: flex; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #f5f5f4;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">3.</span> <strong>First Councilor</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Rev. Fr. Paulinus Kiro TOR</span></li>
                        <li style="display: flex; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #f5f5f4;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">4.</span> <strong>Second Councilor</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Rev. Fr. Benedict Tirkey, TOR</span></li>
                        <li style="display: flex; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #f5f5f4;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">5.</span> <strong>Third Councilor</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Rev. Fr. Benjamin Tiru, TOR</span></li>
                        <li style="display: flex; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #f5f5f4;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">6.</span> <strong>Fourth Councilor</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Rev. Fr. Xavier Kindo, TOR</span></li>
                        <li style="display: flex; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #f5f5f4;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">7.</span> <strong>Provincial Secretary</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Rev. Fr. Paulinus Kiro, TOR</span></li>
                        <li style="display: flex; gap: 1rem;"><span style="color: #c8102e; font-weight: 700; min-width: 20px;">8.</span> <strong>Province Econome</strong> <span style="margin-left: auto; text-align: right; color: #57534e;">Rev. Fr. Paulinus Kiro, TOR</span></li>
                    </ul>
                </div>
            </div>
        </div>
    </section>
    """

    with open('about-us.html', 'w', encoding='utf-8') as f:
        f.write(header)
        f.write(page_hero)
        f.write(about_section)
        f.write(mission_section)
        f.write(history_section)
        f.write(councils_section)
        f.write(footer)

build_about_us()
