from bs4 import BeautifulSoup, NavigableString
from pathlib import Path
import re

src = Path('/Users/iggy/.hermes/profiles/ignite_team/outbound/zeekr-original.html')
out = Path('/Users/iggy/.hermes/profiles/ignite_team/outbound/st-catherines-zeekr-template-text-only.html')
html = src.read_text(errors='ignore')
soup = BeautifulSoup(html, 'html.parser')

# Ensure relative assets keep resolving when previewed from localhost.
head = soup.find('head')
if head and not head.find('base'):
    base = soup.new_tag('base', href='https://www.zeekrlife.com/')
    head.insert(0, base)

replacements = {
    # nav / global calls-to-action
    'The New Zeekr X now starting from $48,900 Driveaway. Plus an exclusive EOFY offer, available for a limited time only.': 'Discover a Toorak girls’ school where courage, curiosity and confidence shape every stage of learning.',
    'Models': 'Learning',
    'About Zeekr': 'About St Catherine’s',
    'Zeekr Services': 'School Life',
    'Offers': 'Admissions',
    'Find a Dealer': 'Visit Campus',
    'Book a Test Drive': 'Book a Tour',
    'Build & Price': 'Enquire Now',
    'Download Brochure': 'Download Prospectus',
    'Book your test drive': 'Book your tour',
    'Learn about Zeekr’s story, values and vision.': 'Explore St Catherine’s story, values and vision.',
    'Explore the latest Zeekr news, stories, and brand updates.': 'Explore the latest St Catherine’s news, stories and updates.',
    'Dive into the world of Zeekr with our tech-inspired blogs.': 'Read ideas from our classrooms, community and alumnae.',
    'Service and Warranty': 'Student Wellbeing',
    'Explore Zeekr service, warranty details, and owner support.': 'Explore wellbeing, pastoral care and student support.',
    'Change of Ownership': 'Enrolment Journey',
    'Easily transfer your Zeekr vehicle ownership and connected digital services.': 'Follow each step from first enquiry to a confident start.',
    'Zeekr Accessories': 'Co-curricular',
    'Explore Zeekr accessories to enhance your drive.': 'Explore sport, music, performing arts and clubs.',
    'Novated Leasing': 'Boarding',
    'Novated leasing with DRIVA tailored for Zeekr drivers.': 'Boarding options tailored for regional and international families.',

    # hero
    'The New Zeekr X': 'St Catherine’s School',
    'Settle No More.': 'She Who Dares.',
    'WLTP Cruising Range (AWD)*': 'Founded in Toorak',
    '0-100 km/h Accelerate Time (AWD)^': 'ELC to Year 12 Girls’ Journey',
    'Battery Capacity (AWD)': 'Values Guiding Every Student',
    'Zeekr X': 'St Catherine’s',
    'Exterior': 'Learning',
    'Interior': 'Wellbeing',
    'Technology': 'Programs',
    'Space': 'Boarding',
    'Safety': 'Community',
    'Specs': 'Outcomes',

    # intro / feature tabs
    'Introducing the New Zeekr X': 'Introducing St Catherine’s School',
    'The Zeekr X was built for a generation that refuses to settle. Compact yet commanding, it brings together progressive design, intelligent technology and refined performance in a form that feels effortless and unmistakably contemporary. Settle no more.': 'St Catherine’s was built for girls ready to think boldly. Established in Toorak, it brings together academic excellence, wellbeing, creativity and leadership in a setting that feels personal, ambitious and deeply connected. She who dares.',
    'Modern Appearance': 'Academic Confidence',
    'Quality Refinements': 'Personal Wellbeing',
    'Power Control': 'Student Agency',
    'Intelligent Technology': 'Future Focus',
    'Advanced Safety': 'Trusted Care',
    'Urban-inspired Colors': 'A Toorak Learning Journey',

    # brief cards / section headers
    'Luxury or technology.': 'Tradition or ambition.',
    'It used to be a choice.': 'Here, girls are given both.',
    'Exterior Presence': 'Academic Presence',
    'Modern Appearance with LED Lighting': 'Learning That Inspires Courage',
    'Sharp double-edged LED lines and a 3D prism effect create an instantly recognisable face, while 349 precision taillights illuminate the full rear for bold, confident presence day or night.': 'From early learning through the senior years, students are encouraged to ask better questions, think independently and speak with clarity, building confidence that is visible in every classroom.',
    'Open Skies for Unrivaled Comfort.': 'Open Pathways for Every Girl.',
    'A sweeping 1.12m² panoramic sunroof with advanced heat insulation, 99% UV protection and soundproofing, flooding the cabin with light while keeping you cool, quiet and comfortable.': 'A broad curriculum, specialist teachers and rich subject choice create space for each girl to discover strengths, pursue interests and prepare thoughtfully for future study and life.',
    'Smart Doors with Seamless Entry': 'A Confident Start at Every Stage',
    'Frameless automatic front doors open and close at the touch of a button, with intelligent sensors that detect obstacles and prevent collisions automatically. Available as an option on the AWD model.': 'Families are welcomed through a clear enrolment journey, with tours, conversations and transition support designed to help every student feel known before her first day.',
    'Luxury or performance.': 'Excellence or belonging.',
    'Interior Comfort': 'Wellbeing Culture',
    'Crafted for Comfort': 'Known and Supported',
    'High-quality PVC leather with precise cross-stitch detailing delivers understated luxury and contemporary style, crafted for those who expect refinement in every detail.': 'Pastoral care, wellbeing programs and close teacher relationships help students feel understood, supported and ready to take on challenge with resilience and perspective.',
    'Your Perfect Position': 'Her Place to Grow',
    'Front seats feature 6-way power adjustment, heating, cooling and a memory system as standard. An integrated massage function is available on the AWD model.': 'Across Junior and Senior School, each girl is guided to understand herself as a learner, set goals and build habits that support long-term confidence.',
    'Sound Without Compromise': 'Voice Without Compromise',
    'The standard Yamaha surround sound system delivers powerful, immersive audio through premium speakers, setting a new benchmark for in-cabin sound quality.': 'Debating, music, performance and classroom discussion give students regular opportunities to express ideas clearly and contribute with courage.',
    'Control at Your Fingertips': 'Leadership at Every Level',
    'The heated Super Fiber PU steering wheel features 4-way telescopic adjustment and an inductive touch-button panel controlling defrost, central locking, park assist and more.': 'Leadership is built through responsibility, service, mentoring and everyday choices, helping girls practise initiative rather than waiting for permission.',
    'Built for the Whole Family': 'A Community for Families',
    'The second row offers a versatile 40/60 split with integrated cup holders and ISOFIX child restraint points on outboard seats, blending practicality with premium comfort.': 'Parents, staff, students and alumnae form a connected school community, supporting each girl through friendships, shared values and a strong sense of belonging.',

    # intelligence/programs
    'Intelligence': 'Purpose',
    'Built to think ahead': 'Prepared to think beyond',
    'Always Up To Date': 'Future-ready Learning',
    'Over-the-air (OTA) updates keep your Zeekr X improving, refreshing the operating system, driver assistance and connectivity without the need to visit a dealership. Allowing you to spend more time on the road.': 'Contemporary learning keeps students curious and adaptable, connecting classroom knowledge with digital skills, global awareness and the confidence to keep growing beyond school.',
    'Brilliance at the Touch of a Screen': 'Excellence Across Every Classroom',
    'The 14.6" HD infortainment display, powered by the advanced 8155 7nm processor, delivers seamless, lightning-fast interaction and efortless control - keeping you connected to every moment of the journey.': 'Strong academic programs, expert teachers and high expectations help girls engage deeply with ideas, challenge assumptions and develop the discipline to achieve their best.',
    'Zeekr APP': 'St Catherine’s Community',
    'The Zeekr app provides seamless remote control of your vehicle, accessing real-time status, managing essential functions like locks, windows, lights, and climate. Send navigation, locate your car, and enhance security with PIN protection.': 'Families stay connected through school life, events, communications and relationships that make progress visible and ensure support is never far from reach.',
    'Next Generation Technology': 'Next Generation Learning',
    'Advanced SEA Architecture': 'A Strong Educational Foundation',
    'Zeekr X built on the Sustainable Experience Architecture (SEA), integrating nearly 30 years of vehicle manufacturing expertise. This global pure electric platform is developed by a 2000+ strong international engineering team.': 'St Catherine’s combines more than a century of educational heritage with contemporary teaching practice, giving students a grounded foundation for bold, future-facing learning.',
    'Your Drive, Your Battery': 'Her Pace, Her Pathway',
    'The RWD model supports 11kW AC and 230kW DC fast charging, while the AWD steps up to 22kW AC and 150kW DC, getting you back on the road faster whatever your lifestyle demands.': 'Flexible pathways, extension opportunities and tailored guidance help students move confidently through each stage, from first discoveries to senior subject choices.',
    'High-Performance Braking System': 'Confidence Under Pressure',
    'Equipped with a braking system that enables the vehicle to achieve a 100km/h-0 stopping distance of only 34.5m.': 'Students learn to pause, reflect and respond with judgement, even when expectations rise.',
    'High-Performance Motors': 'Momentum for Ambition',
    '365 Kw (496 hp) with 573 Nm is brought by a dual-motor system, which allows 0-100 km/h acceleration in only 3.7 second (AWD)': 'Academic care and co-curricular challenge work together to build motivation, purpose and momentum.',

    # space/boarding/community
    'Comfortable Luxe': 'Boarding Life',
    'Crafted for Comfort': 'A Home in Toorak',
    'Smarter Storage, Every Journey': 'Room to Belong',
    "The Zeekr X delivers 404L of rear boot space ready for everyday life — whether that's the weekly shop, weekend luggage, or travel essentials. When you need more, the rear seats extend to open up flexible cargo space. A 12L frunk adds extra room for smaller items, keeping your cabin clear and organised.": 'Boarding gives regional, rural and international students a warm base in Melbourne, balancing structured routines, friendships, study support and access to the full life of the school.',
    'Make It Yours': 'Make It Yours',
    'The AWD Performance offers an exclusive Black PU interior with red seat belts and stitching creating a bold signature that sets it apart.': 'Each girl is encouraged to bring her personality, strengths and ambitions into school life, shaping an experience that feels genuinely her own.',
    'Your Perfect Temperature, Every Time': 'Balance for Every Day',
    'Dual-zone EATC climate control means driver and passenger can each set their own comfort level without compromise. Combined with heated and ventilated front seats and a heated steering wheel, the Zeekr X ensures the right temperature from the moment you get in.': 'Wellbeing, study, friendship and activity are carefully balanced so students can feel settled, stretched and supported throughout busy school days.',
    'Power Without the Clutter': 'Focus Without the Noise',
    'Keep your devices charged and your cabin tidy with built-in wireless charging. Simply place your phone down and stay connected — no cables, no fuss.': 'Clear expectations and calm routines help students focus on learning, relationships and growth without unnecessary distraction.',
    'Cool or Warm, Always Perfect': 'Challenge and Support, Together',
    'The factory-fitted dual-mode fridge comes standard on the AWD model, keeping drinks cold and snacks warm with a temperature range from -15 to 50 degrees. Luxury built in.': 'Students are challenged to extend themselves while knowing support is close, creating the conditions for genuine confidence, not pressure for its own sake.',
    'Power for Every Device': 'Opportunities for Every Interest',
    '50W wireless charging panels. Centre console fast charges devices, with a non-slip design and advanced heat management for stable, efficient performance.': 'Sport, music, drama, clubs, service and leadership provide practical ways for each girl to explore interests and discover new capabilities.',
    'Charger Smarter, Last Longer': 'Learn Well, Grow Longer',
    'Intelligent battery management limits charge stress and improves thermal control, extending long-term battery life and ensuring your Zeekr X delivers consistent performance every drive.': 'Strong study habits, feedback and reflection help students sustain progress across the years, not simply perform in a single moment.',
    'Your Car is Now a Power Source': 'Her School is a Launchpad',
    'With a 3.3 kWh V2L capability, the Zeekr X can power camping gear or household essentials during an outtage, turning your SUV into a portable power source.': 'St Catherine’s gives girls the knowledge, networks and courage to contribute beyond the gates, wherever their next chapter leads.',
    'Everything You Need at a Glance': 'Everything in One Connected Place',
    "Key information displayed on the B-pillar before you even enter, showing charge status, door lock and special features like pet mode. Standard on the AWD model, simplifying every part of your day.": 'From learning updates to events and wellbeing support, families can see how the school works together around each student’s journey.',
    'Protected from Every Angle': 'Care from Every Angle',
    'Seven advanced airbags, including a unique front centre airbag and side curtains that stay inflated for six seconds, surround every occupant with a shield of cutting-edge protection.': 'Teachers, mentors, wellbeing staff and peers surround students with attentive care, helping them feel safe enough to ask questions, take risks and grow.',
    'Your Co-Pilot on Every Drive': 'Guidance at Every Step',
    '5 HD cameras, 5 millimetre-wave radars and 12 ultrasonic sensors powered by a Mobileye EyeQ4 chip give the Zeekr X 220-metre vision, continuously monitoring lanes, traffic and pedestrians for a safer drive.': 'From classroom feedback to careers conversations, students are guided by people who understand their strengths and help them look ahead with confidence.',
    'Park With Confidence': 'Step Forward with Confidence',
    "The 360° camera delivers a complete bird's-eye view, making every park effortless and precise, whether navigating tight city spaces or squeezing into that last spot on a busy street.": 'Girls practise decision-making in supportive settings, learning to step forward thoughtfully whether in class, on stage, on the field or in leadership.',
    'Security You Can Count On': 'Values You Can Count On',
    'Sentry Mode uses exterior cameras to detect suspicious activity, triggering alerts and recording footage automatically. DVR runs continuously while driving, giving you complete peace of mind.': 'Integrity, curiosity, perseverance, gratitude and empathy give students a clear foundation for choices, friendships and meaningful contribution.',
    'Reinforced Anti-Collision Beams': 'Resilience for Life Beyond School',
    'Internal anti-collision beams utilise an 8-tube multi-layer structure, enabling the vehicle to withstand a lateral impact force of 65 tons, enhancing both battery and passenger protection.': 'Students build the resilience to navigate challenge, adapt to change and remain grounded in who they are becoming.',

    # specs / footer
    'Choose the Zeekr X that fits your style': 'Choose the St Catherine’s pathway that fits your family',
    'Zeekr X RWD': 'Junior School',
    'Zeekr X AWD': 'Senior School',
    'Performance': 'Learning',
    'Range': 'Years',
    'Battery': 'Support',
    'Exterior Colours': 'Co-curricular',
    'Wheels': 'Campus',
    'Interior Colours': 'Community',
    '5.6 sec': 'ELC–6',
    '0-100 km/h Acceleration^': 'Early and Junior Years',
    '250 kW': 'Inquiry',
    'Peak Power': 'Learning approach',
    'Single': 'One',
    'Electric Motor': 'Connected campus',
    'Rear Wheel Drive': 'Toorak',
    'Drive Train': 'School location',
    '405 km': 'ELC–6',
    'WLTP Cruising Range*': 'Junior learning journey',
    '61 kWh': 'Pastoral',
    'Battery Capacity': 'Care program',
    'LFP': 'Specialist',
    'Battery Type': 'Teaching support',
    '11 kW': 'Sport',
    'AC Charge': 'Weekly opportunities',
    '230 kW': 'Music',
    'DC Charge': 'Creative opportunities',
    'Crystal White': 'Curiosity',
    'With Coloured Roof': 'Core value',
    'Palace Beige': 'Gratitude',
    'Grid Grey': 'Empathy',
    '19" Alloy Wheels': 'Heyington Place',
    'Silver': 'Toorak VIC',
    'Black & Grey': 'Students',
    'PU Leather': 'Learning together',
    'Black & White': 'Families',
    '3.7 sec': '7–12',
    '365 kW': 'Agency',
    'Dual': 'Two',
    'All Wheel Drive': 'Senior pathways',
    '415 km': 'Years 7–12',
    '66 kWh': 'Wellbeing',
    'NCM': 'Careers',
    '22 kW': 'Leadership',
    '150 kW': 'Service',
    'With Black Roof': 'Core value',
    'Onyx Black': 'Integrity',
    'Khaki Green': 'Perseverance',
    '20" Alloy Wheels': 'Heyington Gates',
    'Black': 'Alumnae',
    'PU Leather with Red Highlights': 'Lifelong network',
    'Dimensions': 'At a Glance',
    'A Width': 'A Founded',
    '1,836 mm': '1896',
    'B Length': 'B Campus',
    '4,432 mm': 'Toorak',
    'C Max Height': 'C Years',
    '1,566 mm': 'ELC–12',
    'D Wheelbase': 'D Values',
    '2,750 mm': '5',
    'Warranty': 'Enrolment',
    'Basic Vehicle': 'Visit the School',
    '5 Years or Unlimited kms, whichever comes first [A1]': 'Book a tour to experience classrooms, grounds and community.',
    'Battery': 'Speak with Admissions',
    '8 Years or 160,000 kms, whichever comes first [A1]': 'Ask questions about entry years, boarding and next steps.',
    'About Us': 'About Us',
    'News': 'News',
    'Accessories': 'Co-curricular',
    'Register Your Interest': 'Register Your Interest',
    'Services': 'Student Services',
    'RMI': 'Contact',
    '© 2026 Zeekr and/or its affiliates. All rights reserved.': '© 2026 St Catherine’s School example copy. All rights reserved.',
    'Disclaimer: Depending on where you are, information on this page may not be accurate for the models available in your local market. The availability of vehicle models, options, specifications and colours may vary from market to market and Zeekr reserves the right to make changes without notice. Vehicles may be shown with optional equipment that is not available in all markets. Images and videos are for illustrative purposes only. This website is governed by Zeekr’s Terms of use.': 'Disclaimer: This is concept copy prepared for layout review only. Details should be checked against St Catherine’s School admissions, curriculum and policy information before publication. Existing imagery remains unchanged in this mock-up and is used only to preserve the supplied page structure for discussion.',
}

# Replace exact visible text nodes only, avoiding script/style/pre/code.
changed = []
for node in soup.find_all(string=True):
    if not isinstance(node, NavigableString):
        continue
    parent = node.parent.name if node.parent else ''
    if parent in {'script','style','noscript','code','pre'}:
        continue
    text = str(node)
    stripped = text.strip()
    if stripped in replacements:
        new = text.replace(stripped, replacements[stripped])
        node.replace_with(new)
        changed.append((stripped, replacements[stripped]))

# Fix title/meta text where sensible without touching imagery/assets.
if soup.title and soup.title.string:
    soup.title.string = 'St Catherine’s School | Concept Page'
for meta in soup.find_all('meta'):
    if meta.get('name') in {'description','twitter:title','twitter:description'} or meta.get('property') in {'og:title','og:description'}:
        val = meta.get('content')
        if val:
            meta['content'] = val.replace('The New Zeekr X', 'St Catherine’s School').replace('Zeekr X', 'St Catherine’s')

out.write_text(str(soup), encoding='utf-8')

# Report counts for page-content-ish replacements (not including nav/footer duplicates exactly).
orig_words = sum(len(re.findall(r"\b[\w’'-]+\b", k)) for k in replacements)
new_words = sum(len(re.findall(r"\b[\w’'-]+\b", v)) for v in replacements.values())
print(f'wrote {out}')
print(f'exact text nodes changed: {len(changed)} / replacement keys: {len(replacements)}')
print(f'mapped words original={orig_words} new={new_words} delta={new_words-orig_words}')
missing = [k for k in replacements if k not in [c[0] for c in changed]]
print('missing sample:', missing[:30])
