#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Static site builder for NRI Property Guard marketing pages.
Produces fully self-contained, SEO-complete HTML files (no server-side includes needed —
safe to deploy as-is on shared/cPanel hosting). Run: python3 build.py
"""
import os

SITE_NAME = "NRI Property Guard"
SITE_URL = "https://www.nripropertyguard.in"
PHONE_DISPLAY = "+91 99480 39325"
WHATSAPP_NUMBER = "919948039325"
EMAIL = "support@nripropertyguard.in"

NAV_ITEMS = [
    ("index.html", "Home"),
    ("services.html", "Services"),
    ("how-it-works.html", "How It Works"),
    ("pricing.html", "Pricing"),
    ("about.html", "About Us"),
    ("faq.html", "FAQ"),
    ("contact.html", "Contact"),
]

LOGO_SVG = """<svg width="34" height="34" viewBox="0 0 48 48" fill="none" aria-hidden="true">
<path d="M24 3 6 11v11c0 12.2 7.7 21.9 18 24 10.3-2.1 18-11.8 18-24V11L24 3z" fill="#0E8F6B"/>
<path d="M24 3 6 11v11c0 12.2 7.7 21.9 18 24 10.3-2.1 18-11.8 18-24V11L24 3z" stroke="#0B3357" stroke-width="1.4"/>
<path d="M16.5 24.5 21 29l10.5-11" stroke="#fff" stroke-width="3.1" stroke-linecap="round" stroke-linejoin="round"/>
</svg>"""

def nav_html(active):
    items = ""
    for href, label in NAV_ITEMS:
        cls = ' class="active"' if href == active else ''
        items += f'<li><a href="{href}"{cls}>{label}</a></li>\n'
    return items

def head(title, description, canonical_path, og_type="website"):
    canonical = f"{SITE_URL}/{canonical_path}" if canonical_path != "index.html" else SITE_URL + "/"
    return f"""<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{title}</title>
<meta name="description" content="{description}">
<link rel="canonical" href="{canonical}">
<meta name="robots" content="index, follow, max-image-preview:large">
<meta name="author" content="{SITE_NAME}">
<meta name="theme-color" content="#0b3357">

<!-- Open Graph -->
<meta property="og:type" content="{og_type}">
<meta property="og:site_name" content="{SITE_NAME}">
<meta property="og:title" content="{title}">
<meta property="og:description" content="{description}">
<meta property="og:url" content="{canonical}">
<meta property="og:image" content="{SITE_URL}/assets/img/og-cover.jpg">
<meta property="og:locale" content="en_IN">

<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="{title}">
<meta name="twitter:description" content="{description}">
<meta name="twitter:image" content="{SITE_URL}/assets/img/og-cover.jpg">

<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M24 3 6 11v11c0 12.2 7.7 21.9 18 24 10.3-2.1 18-11.8 18-24V11L24 3z' fill='%230E8F6B'/%3E%3Cpath d='M16.5 24.5 21 29l10.5-11' stroke='%23fff' stroke-width='3.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E">

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/style.css">

<!-- Organization structured data -->
<script type="application/ld+json">
{{
  "@context": "https://schema.org",
  "@type": "Organization",
  "name": "{SITE_NAME}",
  "url": "{SITE_URL}/",
  "logo": "{SITE_URL}/assets/img/og-cover.jpg",
  "description": "Independent property verification, inspection and remote property management for Non-Resident Indians (NRIs) investing in or owning property in India.",
  "areaServed": "IN",
  "telephone": "{PHONE_DISPLAY}",
  "email": "{EMAIL}",
  "sameAs": [
    "https://wa.me/{WHATSAPP_NUMBER}"
  ],
  "contactPoint": [{{
    "@type": "ContactPoint",
    "telephone": "{PHONE_DISPLAY}",
    "contactType": "customer service",
    "areaServed": "IN",
    "availableLanguage": ["English", "Hindi", "Telugu"]
  }}]
}}
</script>

<!-- ============================================================
     ANALYTICS / DIGITAL MARKETING — plug in your IDs and uncomment
     ============================================================
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){{dataLayer.push(arguments);}}
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXXXXX');
</script>
<script>
  !function(f,b,e,v,n,t,s){{if(f.fbq)return;n=f.fbq=function(){{n.callMethod?
  n.callMethod.apply(n,arguments):n.queue.push(arguments)}};if(!f._fbq)f._fbq=n;
  n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
  t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}}(window,
  document,'script','https://connect.facebook.net/en_US/fbevents.js');
  fbq('init', 'YOUR_META_PIXEL_ID');
  fbq('track', 'PageView');
</script>
============================================================= -->
"""

def header(active):
    return f"""<a class="skip-link" href="#main">Skip to content</a>
<div class="topbar">
  <div class="container">
    <span class="topbar-item">🛡️ Independent property verification &amp; management for NRIs across India</span>
    <span class="topbar-item">📞 <a href="tel:+{WHATSAPP_NUMBER}">{PHONE_DISPLAY}</a> &nbsp;|&nbsp; <a href="https://wa.me/{WHATSAPP_NUMBER}" target="_blank" rel="noopener">WhatsApp Us</a></span>
  </div>
</div>
<header class="navbar">
  <div class="nav-inner">
    <a href="index.html" class="brand">{LOGO_SVG}<span>{SITE_NAME}<small>Verify. Visit. Protect.</small></span></a>
    <nav>
      <ul class="nav-links">
        {nav_html(active)}
        <li class="only-mobile"><a href="portal/index.html" class="btn btn-primary btn-sm">Owner Login</a></li>
      </ul>
    </nav>
    <div class="nav-cta">
      <a href="portal/index.html" class="btn btn-outline-navy btn-sm">Owner Login</a>
      <a href="contact.html" class="btn btn-primary btn-sm">Get a Free Consultation</a>
    </div>
    <button class="nav-toggle" aria-label="Menu" aria-expanded="false">
      <svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="#0b3357" stroke-width="2"><path d="M3 6h18M3 12h18M3 18h18" stroke-linecap="round"/></svg>
    </button>
  </div>
</header>
"""

def footer():
    return f"""<footer>
  <div class="container">
    <div class="footer-grid">
      <div>
        <div class="footer-brand">{LOGO_SVG}<span>{SITE_NAME}</span></div>
        <p style="color:#a9c3da;font-size:.92rem;max-width:320px;">
          Independent, on-ground property verification and remote management for NRIs —
          GPS-tagged evidence, tamper-evident reports, and a real-time dashboard so you never
          have to fly down just to check on your property.
        </p>
        <div class="social-row" aria-label="Social media">
          <a href="#" aria-label="Facebook"><svg width="16" height="16" viewBox="0 0 24 24" fill="#fff"><path d="M13.5 21v-8h2.7l.4-3.1h-3.1V8c0-.9.3-1.5 1.6-1.5H17V3.7C16.7 3.6 15.7 3.5 14.6 3.5c-2.4 0-4.1 1.5-4.1 4.2v2.2H7.8V13h2.7v8h3z"/></svg></a>
          <a href="#" aria-label="Instagram"><svg width="16" height="16" viewBox="0 0 24 24" fill="#fff"><path d="M12 2.2c2.7 0 3 0 4 .1 1 .1 1.7.2 2.3.5.6.2 1.1.6 1.6 1.1.5.5.8 1 1.1 1.6.3.6.4 1.3.5 2.3.1 1 .1 1.3.1 4s0 3-.1 4c-.1 1-.2 1.7-.5 2.3-.2.6-.6 1.1-1.1 1.6-.5.5-1 .8-1.6 1.1-.6.3-1.3.4-2.3.5-1 .1-1.3.1-4 .1s-3 0-4-.1c-1-.1-1.7-.2-2.3-.5-.6-.2-1.1-.6-1.6-1.1-.5-.5-.8-1-1.1-1.6-.3-.6-.4-1.3-.5-2.3-.1-1-.1-1.3-.1-4s0-3 .1-4c.1-1 .2-1.7.5-2.3.2-.6.6-1.1 1.1-1.6.5-.5 1-.8 1.6-1.1.6-.3 1.3-.4 2.3-.5 1-.1 1.3-.1 4-.1zM12 7a5 5 0 100 10 5 5 0 000-10zm0 8.2A3.2 3.2 0 1112 8.7a3.2 3.2 0 010 6.5zm5.2-8.4a1.2 1.2 0 11-2.3 0 1.2 1.2 0 012.3 0z"/></svg></a>
          <a href="#" aria-label="LinkedIn"><svg width="16" height="16" viewBox="0 0 24 24" fill="#fff"><path d="M6.9 8.4H3.6V20h3.3V8.4zM5.3 3.5a1.9 1.9 0 100 3.8 1.9 1.9 0 000-3.8zM20.4 20h-3.3v-6c0-1.4 0-3.2-2-3.2s-2.3 1.5-2.3 3.1V20H9.5V8.4h3.1v1.6h.1c.4-.8 1.5-1.7 3.1-1.7 3.3 0 3.9 2.2 3.9 5V20z"/></svg></a>
          <a href="https://wa.me/{WHATSAPP_NUMBER}" aria-label="WhatsApp"><svg width="16" height="16" viewBox="0 0 24 24" fill="#fff"><path d="M17.6 14.1c-.3-.2-1.7-.8-2-.9-.3-.1-.5-.1-.6.1-.2.3-.7.9-.9 1-.2.2-.3.2-.6.1-.3-.2-1.2-.4-2.2-1.4-.8-.7-1.4-1.6-1.6-1.9-.2-.3 0-.5.1-.6l.4-.5c.1-.1.2-.3.2-.4.1-.1 0-.3 0-.4-.1-.1-.6-1.4-.8-1.9-.2-.5-.4-.4-.6-.4h-.5c-.2 0-.5.1-.7.3-.2.3-.9.9-.9 2.1 0 1.2.9 2.4 1 2.6.1.2 1.8 2.8 4.4 3.9.6.3 1.1.4 1.5.5.6.2 1.2.2 1.6.1.5-.1 1.7-.7 1.9-1.3.2-.6.2-1.1.2-1.2-.1-.1-.3-.2-.6-.3zM12 2C6.5 2 2 6.5 2 12c0 1.8.5 3.5 1.4 5L2 22l5.2-1.4c1.4.8 3.1 1.2 4.8 1.2 5.5 0 10-4.5 10-10S17.5 2 12 2z"/></svg></a>
        </div>
      </div>
      <div>
        <h3>Company</h3>
        <ul>
          <li><a href="about.html">About Us</a></li>
          <li><a href="how-it-works.html">How It Works</a></li>
          <li><a href="pricing.html">Pricing</a></li>
          <li><a href="faq.html">FAQ</a></li>
          <li><a href="contact.html">Contact</a></li>
        </ul>
      </div>
      <div>
        <h3>Services</h3>
        <ul>
          <li><a href="services.html#verification">Property Verification</a></li>
          <li><a href="services.html#inspection">On-site Inspection</a></li>
          <li><a href="services.html#reports">Inspection Reports</a></li>
          <li><a href="services.html#management">Remote Property Management</a></li>
          <li><a href="services.html#sos">Emergency SOS (Prime)</a></li>
        </ul>
      </div>
      <div>
        <h3>Get in Touch</h3>
        <ul>
          <li><a href="tel:+{WHATSAPP_NUMBER}">{PHONE_DISPLAY}</a></li>
          <li><a href="https://wa.me/{WHATSAPP_NUMBER}" target="_blank" rel="noopener">WhatsApp Chat</a></li>
          <li><a href="mailto:{EMAIL}">{EMAIL}</a></li>
          <li><a href="portal/index.html">Owner Portal Login</a></li>
        </ul>
      </div>
    </div>
    <div class="footer-bottom">
      <span>&copy; <span id="yr"></span> {SITE_NAME}. All rights reserved.</span>
      <span><a href="privacy-policy.html">Privacy Policy</a> &nbsp;·&nbsp; <a href="terms.html">Terms of Service</a></span>
    </div>
  </div>
</footer>
<script>document.getElementById('yr').textContent = new Date().getFullYear();</script>
<script src="assets/js/main.js"></script>
"""

def page(filename, title, description, active, body, og_type="website"):
    html = f"""<!doctype html>
<html lang="en-IN">
<head>
{head(title, description, filename, og_type)}
</head>
<body>
{header(active)}
<main id="main">
{body}
</main>
{footer()}
</body>
</html>"""
    with open(filename, "w", encoding="utf-8") as f:
        f.write(html)
    print("wrote", filename)
