// Marsan Properties — Shared components (real-website edition).

const Icon = ({ name, size = 20, color = 'currentColor', strokeWidth = 1.4, style }) => {
  const props = { width: size, height: size, viewBox: '0 0 24 24', fill: 'none', stroke: color, strokeWidth, strokeLinecap: 'round', strokeLinejoin: 'round', style };
  const paths = {
    plot: <><rect x="3" y="3" width="18" height="18" /><path d="M3 9h18M3 15h18M9 3v18M15 3v18" /></>,
    villa: <><path d="M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-7H10v7H4a1 1 0 0 1-1-1z" /><path d="M9 21v-7h6v7" /></>,
    tower: <><rect x="6" y="3" width="12" height="18" /><path d="M9 7h2M13 7h2M9 11h2M13 11h2M9 15h2M13 15h2M9 21v-3h6v3" /></>,
    farm: <><path d="M2 20h20" /><path d="M4 20V10l8-6 8 6v10" /><path d="M10 20v-5h4v5" /><path d="M2 16c2-2 4-2 6 0s4 2 6 0 4-2 6 0" /></>,
    commercial: <><rect x="3" y="7" width="18" height="14" /><path d="M3 11h18M8 7V3h8v4M9 15h2M13 15h2M9 18h2M13 18h2" /></>,
    upcoming: <><circle cx="12" cy="12" r="9" /><path d="M12 7v5l3 2" /></>,
    road: <><path d="M5 3v18M19 3v18M12 3v3M12 9v3M12 15v3" /></>,
    bolt: <path d="M13 3L4 14h7l-1 7 9-11h-7z" />,
    water: <path d="M12 3s7 8 7 13a7 7 0 1 1-14 0c0-5 7-13 7-13z" />,
    drain: <><circle cx="12" cy="12" r="9" /><path d="M3 12h18M12 3v18M5.6 5.6l12.8 12.8M5.6 18.4L18.4 5.6" /></>,
    light: <><path d="M12 3v2M12 19v2M5 12H3M21 12h-2M6 6l-1.5-1.5M19.5 19.5L18 18M6 18l-1.5 1.5M19.5 4.5L18 6" /><circle cx="12" cy="12" r="4" /></>,
    tree: <><path d="M12 3a5 5 0 0 1 5 5c2 0 3 2 3 4s-1 4-3 4H7c-2 0-3-2-3-4s1-4 3-4a5 5 0 0 1 5-5z" /><path d="M12 16v5" /></>,
    arch: <><path d="M4 21V11a8 8 0 0 1 16 0v10" /><path d="M4 16h16" /></>,
    shield: <><path d="M12 3l8 3v6c0 5-4 8-8 9-4-1-8-4-8-9V6z" /><path d="M9 12l2 2 4-4" /></>,
    club: <><rect x="3" y="9" width="18" height="12" /><path d="M3 9l9-6 9 6" /><path d="M9 21v-6h6v6" /></>,
    park: <><circle cx="12" cy="9" r="5" /><path d="M12 14v7M9 21h6" /></>,
    pool: <><path d="M2 18c2-2 4-2 6 0s4 2 6 0 4-2 6 0" /><path d="M2 14c2-2 4-2 6 0s4 2 6 0 4-2 6 0" /><path d="M6 14V6a2 2 0 0 1 2-2M18 14V6a2 2 0 0 0-2-2" /></>,
    gym: <><path d="M3 9v6M21 9v6M6 5v14M18 5v14M6 12h12" /></>,
    search: <><circle cx="11" cy="11" r="7" /><path d="M21 21l-4.3-4.3" /></>,
    map: <><path d="M9 3L3 5v16l6-2 6 2 6-2V3l-6 2z" /><path d="M9 3v16M15 5v16" /></>,
    pin: <><path d="M12 21s7-7 7-12a7 7 0 1 0-14 0c0 5 7 12 7 12z" /><circle cx="12" cy="9" r="2.5" /></>,
    phone: <path d="M6.6 10.8a14 14 0 0 0 6.6 6.6l2.2-2.2a1 1 0 0 1 1-.25 11.4 11.4 0 0 0 3.6.6 1 1 0 0 1 1 1V20a1 1 0 0 1-1 1A18 18 0 0 1 2 4a1 1 0 0 1 1-1h3.45a1 1 0 0 1 1 1 11.4 11.4 0 0 0 .6 3.6 1 1 0 0 1-.25 1L6.6 10.8z" />,
    whatsapp: <>
      <path d="M3.6 20.5l1.2-4.4A8.5 8.5 0 1 1 12 20.5a8.4 8.4 0 0 1-3.6-.8l-4.8.8z" />
      <path d="M9.1 8c.2-.5.5-.5.7-.5h.5c.2 0 .5 0 .7.5l.7 1.6c.1.2 0 .4-.1.5l-.4.5c-.2.2-.3.4-.1.7a6 6 0 0 0 2.5 2.5c.3.2.5.1.7-.1l.5-.5c.2-.1.4-.2.5-.1l1.7.8c.2.1.3.2.3.4 0 .8-.6 1.6-1.4 1.7a3.4 3.4 0 0 1-1.4-.1c-.7-.2-2.6-.9-4.3-3a5 5 0 0 1-1.2-2.6c0-1 .4-1.5.6-1.7z" />
    </>,
    chevron: <path d="M9 6l6 6-6 6" />,
    arrow: <><path d="M5 12h14M13 5l7 7-7 7" /></>,
    plus: <path d="M12 5v14M5 12h14" />,
    check: <path d="M5 12l5 5L20 7" />,
    star: <path d="M12 2l3 7 7 .5-5.5 4.5L18 22l-6-4-6 4 1.5-8L2 9.5 9 9z" />,
    heart: <path d="M12 21s-8-5-8-12a5 5 0 0 1 9-3 5 5 0 0 1 9 3c0 7-8 12-8 12h-2z" />,
    share: <><circle cx="6" cy="12" r="3" /><circle cx="18" cy="6" r="3" /><circle cx="18" cy="18" r="3" /><path d="M8.5 10.5l7-3M8.5 13.5l7 3" /></>,
    eye: <><path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z" /><circle cx="12" cy="12" r="3" /></>,
    download: <><path d="M12 3v13M6 11l6 6 6-6M4 21h16" /></>,
    play: <path d="M6 4l14 8-14 8z" />,
    filter: <><path d="M3 5h18M6 12h12M10 19h4" /></>,
    grid: <><rect x="3" y="3" width="7" height="7" /><rect x="14" y="3" width="7" height="7" /><rect x="3" y="14" width="7" height="7" /><rect x="14" y="14" width="7" height="7" /></>,
    list: <><path d="M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01" /></>,
    car: <><path d="M5 17H3v-5l2-5h14l2 5v5h-2" /><circle cx="7" cy="17" r="2" /><circle cx="17" cy="17" r="2" /></>,
    school: <><path d="M22 10L12 5 2 10l10 5 10-5z" /><path d="M6 12v5c0 1 3 3 6 3s6-2 6-3v-5" /></>,
    hospital: <><rect x="4" y="4" width="16" height="16" /><path d="M12 8v8M8 12h8" /></>,
    metro: <><rect x="6" y="3" width="12" height="14" rx="2" /><path d="M9 8h6M8 17l-2 4M16 17l2 4" /><circle cx="9" cy="14" r=".5" /><circle cx="15" cy="14" r=".5" /></>,
    edit: <><path d="M12 20h9" /><path d="M16.5 3.5a2 2 0 1 1 3 3L7 19l-4 1 1-4z" /></>,
    upload: <><path d="M12 21V8M6 13l6-6 6 6M4 3h16" /></>,
    layers: <><path d="M12 3l9 5-9 5-9-5z" /><path d="M3 13l9 5 9-5M3 18l9 5 9-5" /></>,
    settings: <><circle cx="12" cy="12" r="3" /><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3h0a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8v0a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z" /></>,
    bed: <><path d="M2 18v-7a3 3 0 0 1 3-3h14a3 3 0 0 1 3 3v7" /><path d="M2 14h20M2 18v3M22 18v3" /><circle cx="7" cy="11" r="1.5" /></>,
    bath: <><path d="M3 12h18v3a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4z" /><path d="M5 12V6a2 2 0 0 1 4 0M3 19l-1 2M21 19l1 2" /></>,
    area: <><path d="M3 9V3h6M21 9V3h-6M3 15v6h6M21 15v6h-6" /></>,
    calendar: <><rect x="3" y="5" width="18" height="16" rx="1" /><path d="M3 9h18M8 3v4M16 3v4" /></>,
    user: <><circle cx="12" cy="8" r="4" /><path d="M4 21c0-4 4-7 8-7s8 3 8 7" /></>,
    mail: <><rect x="3" y="5" width="18" height="14" /><path d="M3 7l9 6 9-6" /></>,
    diamond: <><path d="M6 3h12l3 6-9 12L3 9z" /><path d="M3 9h18M9 3l3 6 3-6M12 9l-2 12M12 9l2 12" /></>,
    award: <><circle cx="12" cy="9" r="6" /><path d="M9 14l-2 8 5-3 5 3-2-8" /></>,
    instagram: <><rect x="3" y="3" width="18" height="18" rx="4" /><circle cx="12" cy="12" r="4" /><circle cx="17.5" cy="6.5" r=".7" /></>,
    facebook: <path d="M14 21v-7h3l1-4h-4V8a2 2 0 0 1 2-2h2V2h-3a5 5 0 0 0-5 5v3H7v4h3v7z" />,
    youtube: <><rect x="2" y="6" width="20" height="12" rx="3" /><path d="M10 9l5 3-5 3z" /></>,
    linkedin: <><rect x="3" y="3" width="18" height="18" /><path d="M7 10v7M7 7v.01M11 17v-4a2 2 0 0 1 4 0v4M11 17v-7" /></>,
    close: <><path d="M6 6l12 12M18 6L6 18" /></>,
    menu: <><path d="M3 6h18M3 12h18M3 18h18" /></>,
    sparkle: <path d="M12 3v6M12 15v6M3 12h6M15 12h6M5.6 5.6l4 4M14.4 14.4l4 4M5.6 18.4l4-4M14.4 9.6l4-4" />,
    drone: <><circle cx="12" cy="12" r="3" /><circle cx="5" cy="5" r="2" /><circle cx="19" cy="5" r="2" /><circle cx="5" cy="19" r="2" /><circle cx="19" cy="19" r="2" /><path d="M9 12L7 7M15 12l2-5M9 12l-2 5M15 12l2 5" /></>,
    brochure: <><path d="M4 4h10l4 4v12H4z" /><path d="M14 4v4h4M8 13h6M8 17h6M8 9h2" /></>,
    ruler: <><rect x="3" y="9" width="18" height="6" rx="1" /><path d="M7 9v3M11 9v4M15 9v3M19 9v4" /></>,
  };
  return <svg {...props}>{paths[name] || null}</svg>;
};

const MarsanLogo = ({ light = false, compact = false, href = '/' }) => (
  <a className="ms-logo" href={href} aria-label="Marsan Properties — Home">
    <img src="/assets/marsan-logo.png" alt="Marsan" />
    {!compact && (
      <div className="ms-stack">
        <span className="ms-logo-text" style={{ color: light ? '#e8dcc1' : '#0a1f17' }}>MARSAN</span>
        <span className="ms-logo-text-sub" style={{ color: light ? '#c9a55c' : '#a88841' }}>Properties</span>
      </div>
    )}
  </a>
);

const NAV = [
  { label: 'Properties', href: '/properties.html' },
  { label: 'Insights',   href: '/insights.html' },
  { label: 'About',      href: '/about.html' },
  { label: 'Contact',    href: '/contact.html' },
];

const Header = ({ active = 'Home', light = true }) => (
  <header className="ms-header-shell" style={{
    display: 'flex', alignItems: 'center', justifyContent: 'space-between',
    padding: '20px 56px',
    borderBottom: light ? '1px solid rgba(232,220,193,0.12)' : '1px solid rgba(20,58,42,0.08)',
    background: light ? 'rgba(10, 31, 23, 0.55)' : 'rgba(246, 241, 230, 0.92)',
    backdropFilter: 'blur(20px)', WebkitBackdropFilter: 'blur(20px)',
    position: 'relative', zIndex: 50,
  }}>
    <MarsanLogo light={light} />
    <nav className="ms-header-nav" style={{ display: 'flex', gap: 44 }}>
      {NAV.map(n => (
        <a key={n.label} href={n.href} style={{
          fontSize: 11, letterSpacing: '0.22em', textTransform: 'uppercase',
          color: light ? (active === n.label ? '#e2bd6b' : 'rgba(232,220,193,0.85)') : (active === n.label ? '#0a1f17' : '#4a4540'),
          fontWeight: active === n.label ? 600 : 400,
          textDecoration: 'none', cursor: 'pointer',
          paddingBottom: 4,
          borderBottom: active === n.label ? '1px solid #c9a55c' : '1px solid transparent',
          display: 'inline-flex', alignItems: 'center', gap: 6,
        }}>
          {n.label}
          {n.label === 'Properties' && <span style={{ fontSize: 8, opacity: 0.6 }}>▾</span>}
        </a>
      ))}
    </nav>
    <div className="ms-header-cta" style={{ display: 'flex', gap: 12, alignItems: 'center' }}>
      <a href="tel:+919849999708" className="ms-btn ms-btn-sm" style={{
        background: 'transparent', color: light ? '#e8dcc1' : '#0a1f17',
        border: `1px solid ${light ? 'rgba(232,220,193,0.3)' : 'rgba(20,58,42,0.2)'}`,
      }}>
        <Icon name="phone" size={14} /> +91 98499 99708
      </a>
      <a href="/enquire.html?type=visit" className="ms-btn ms-btn-primary ms-btn-sm">Book Site Visit</a>
    </div>
    <a href="/properties.html" className="ms-mobile-only" style={{
      width: 40, height: 40, border: '1px solid', borderColor: light ? 'rgba(232,220,193,0.3)' : 'rgba(20,58,42,0.2)',
      alignItems: 'center', justifyContent: 'center', color: light ? '#e2bd6b' : '#0a1f17',
    }}>
      <Icon name="menu" size={18} />
    </a>
  </header>
);

const Footer = () => {
  const [email, setEmail] = React.useState('');
  const [msg, setMsg] = React.useState('');
  const subscribe = async (e) => {
    e.preventDefault();
    if (!email) return;
    try {
      await window.MarsanAPI.subscribers.add(email);
      setMsg('Thanks — you’re on the list.');
      setEmail('');
    } catch (err) {
      setMsg(err.message || 'Subscription failed.');
    }
  };
  return (
    <footer style={{ background: '#0a1f17', color: '#e8dcc1', padding: '80px 56px 32px', position: 'relative' }} className="ms-grain">
      <div style={{ display: 'grid', gridTemplateColumns: '1.4fr 1fr 1fr 1fr 1.2fr', gap: 48, position: 'relative', zIndex: 1 }} className="ms-collapse-mobile">
        <div>
          <MarsanLogo light />
          <p style={{ marginTop: 24, fontSize: 14, lineHeight: 1.7, color: 'rgba(232,220,193,0.7)', maxWidth: 280 }}>
            A premium real estate atelier curating land, villas, residences and commercial spaces across Hyderabad's most resilient corridors.
          </p>
          <form onSubmit={subscribe} style={{ marginTop: 24, display: 'flex', gap: 8 }}>
            <input value={email} onChange={(e) => setEmail(e.target.value)} type="email" required placeholder="Quarterly dispatch — your email"
              style={{ flex: 1, padding: '10px 14px', background: 'rgba(255,255,255,0.05)', border: '1px solid rgba(232,220,193,0.2)', color: '#e8dcc1', fontFamily: 'Inter', fontSize: 12 }} />
            <button className="ms-btn ms-btn-primary ms-btn-sm" type="submit">Subscribe</button>
          </form>
          {msg && <div style={{ fontSize: 11, color: '#e2bd6b', marginTop: 8 }}>{msg}</div>}
          <div style={{ display: 'flex', gap: 12, marginTop: 24 }}>
            {['instagram', 'facebook', 'youtube', 'linkedin'].map(s => (
              <a key={s} href="#" aria-label={s} style={{
                width: 36, height: 36, border: '1px solid rgba(201,165,92,0.4)',
                display: 'flex', alignItems: 'center', justifyContent: 'center',
                color: '#c9a55c', cursor: 'pointer', textDecoration: 'none',
              }}><Icon name={s} size={16} /></a>
            ))}
          </div>
        </div>
        {[
          { title: 'Discover', items: [
            ['All Properties', '/properties.html'],
            ['Open Plots', '/properties.html?cat=Open+Plots'],
            ['Villas', '/properties.html?cat=Villas'],
            ['Apartments', '/properties.html?cat=Apartments'],
            ['Commercial', '/properties.html?cat=Commercial'],
            ['Farm Lands', '/properties.html?cat=Farm+Lands'],
          ] },
          { title: 'Company', items: [
            ['About Marsan', '/about.html'],
            ['Our Process', '/about.html#process'],
            ['Insights', '/insights.html'],
            ['Gallery', '/gallery.html'],
            ['Contact', '/contact.html'],
            ['Careers', '/contact.html'],
          ] },
          { title: 'Resources', items: [
            ['Tools & EMI', '/tools.html'],
            ['FAQ', '/faq.html'],
            ['Privacy Policy', '/privacy.html'],
            ['Terms of Service', '/privacy.html?tab=terms'],
            ['RERA Disclosure', '/privacy.html?tab=rera'],
            ['Cookies', '/privacy.html?tab=cookies'],
          ] },
        ].map(col => (
          <div key={col.title}>
            <div className="ms-eyebrow on-dark" style={{ marginBottom: 20 }}>{col.title}</div>
            <ul style={{ listStyle: 'none', padding: 0, margin: 0, display: 'flex', flexDirection: 'column', gap: 10 }}>
              {col.items.map(([label, href]) => (
                <li key={label}>
                  <a href={href} style={{ fontSize: 13, color: 'rgba(232,220,193,0.7)', textDecoration: 'none' }}>{label}</a>
                </li>
              ))}
            </ul>
          </div>
        ))}
        <div>
          <div className="ms-eyebrow on-dark" style={{ marginBottom: 20 }}>Sales Atelier</div>
          <p style={{ fontSize: 13, lineHeight: 1.7, color: 'rgba(232,220,193,0.85)' }}>
            Marsan House, 4th Floor<br/>
            Plot 27, Road 12, Banjara Hills<br/>
            Hyderabad 500034
          </p>
          <p style={{ fontSize: 13, marginTop: 16, color: '#c9a55c' }}>
            <a href="tel:+919849999708" style={{ color: 'inherit', textDecoration: 'none' }}>+91 98499 99708</a><br/>
            <a href="mailto:concierge@marsanproperties.com" style={{ color: 'inherit', textDecoration: 'none' }}>concierge@marsanproperties.com</a>
          </p>
          <a href="https://wa.me/919849999708" target="_blank" rel="noopener" style={{ marginTop: 20, padding: '10px 14px', border: '1px solid rgba(201,165,92,0.4)', display: 'inline-flex', alignItems: 'center', gap: 8, fontSize: 11, letterSpacing: '0.16em', textTransform: 'uppercase', color: '#c9a55c', textDecoration: 'none' }}>
            <Icon name="whatsapp" size={14} /> WhatsApp Concierge
          </a>
        </div>
      </div>
      <div style={{ marginTop: 64, paddingTop: 24, borderTop: '1px solid rgba(232,220,193,0.1)', display: 'flex', justifyContent: 'space-between', alignItems: 'center', fontSize: 11, color: 'rgba(232,220,193,0.5)', letterSpacing: '0.08em', gap: 16 }} className="ms-mobile-stack">
        <span>© 2026 Marsan Properties. All rights reserved.</span>
        <span>RERA: TG-RERA-A-2025-0042 · CIN: U70109TG2020PTC000000</span>
        <a href="/admin-login.html" style={{ color: 'rgba(232,220,193,0.4)', textDecoration: 'none', fontSize: 10, letterSpacing: '0.18em' }}>Studio Sign-in</a>
      </div>
    </footer>
  );
};

const PropertyCard = ({ p, variant = 'default' }) => {
  const href = '/property.html?slug=' + encodeURIComponent(p.slug);
  return (
    <a href={href} className="ms-card" style={{
      background: '#fff', border: '1px solid #d9cfb8',
      transition: 'all 0.3s', cursor: 'pointer',
      position: 'relative', overflow: 'hidden',
      textDecoration: 'none', color: 'inherit', display: 'block',
    }}>
      <div style={{ position: 'relative', height: variant === 'tall' ? 320 : 240 }}>
        {p.heroUrl ? (
          <img src={p.heroUrl} alt={p.name} style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover' }} />
        ) : (
          <div className="ms-img-ph" style={{ position: 'absolute', inset: 0 }}>
            <span>Property · {p.image}</span>
          </div>
        )}
        <div style={{ position: 'absolute', top: 16, left: 16, display: 'flex', gap: 8 }}>
          <span className="ms-chip gold">{p.launch}</span>
          {p.featured && <span className="ms-chip" style={{ background: 'rgba(10,31,23,0.85)', color: '#e2bd6b', border: 'none' }}>Featured</span>}
        </div>
        <div style={{ position: 'absolute', bottom: 16, left: 16 }}>
          <span className={`ms-status ${p.status === 'Available' ? 'available' : p.status === 'Sold Out' ? 'sold' : p.status === 'Few Left' ? 'few' : 'upcoming'}`} style={{
            background: 'rgba(255,255,255,0.95)', padding: '6px 10px', color: '#0a1f17',
          }}>{p.status}</span>
        </div>
      </div>
      <div style={{ padding: 24 }}>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: 6 }}>
          <span className="ms-eyebrow">{p.category}</span>
          <span className="ms-meta">{(p.id || '').toUpperCase()}</span>
        </div>
        <h3 className="ms-h4" style={{ margin: '8px 0 6px', color: '#0a1f17' }}>{p.name}</h3>
        <div style={{ display: 'flex', alignItems: 'center', gap: 6, color: '#8c857b', fontSize: 13 }}>
          <Icon name="pin" size={14} /> {p.location}
        </div>
        <div style={{ height: 1, background: '#d9cfb8', margin: '20px 0' }} />
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 16, marginBottom: 20 }}>
          <div>
            <div className="ms-meta" style={{ marginBottom: 4 }}>PRICE</div>
            <div style={{ fontFamily: 'Cormorant Garamond, serif', fontSize: 24, color: '#0a1f17', letterSpacing: '-0.005em' }}>
              ₹{p.priceMin}<span style={{ color: '#a88841', margin: '0 4px' }}>–</span>{p.priceMax}
              <span style={{ fontFamily: 'Cormorant Garamond, serif', fontStyle: 'italic', fontSize: 18, color: '#a88841', marginLeft: 6 }}>{p.priceUnit}</span>
            </div>
          </div>
          <div>
            <div className="ms-meta" style={{ marginBottom: 4 }}>{p.areaUnit === 'sq.yd' || p.areaUnit === 'acres' ? 'PLOT' : 'AREA'}</div>
            <div style={{ fontFamily: 'Cormorant Garamond, serif', fontSize: 24, color: '#0a1f17', letterSpacing: '-0.005em' }}>
              {p.areaMin}<span style={{ color: '#a88841', margin: '0 4px' }}>–</span>{p.areaMax}
              <span style={{ fontFamily: 'Cormorant Garamond, serif', fontStyle: 'italic', fontSize: 18, color: '#a88841', marginLeft: 6 }}>{p.areaUnit}</span>
            </div>
          </div>
        </div>
        <p style={{ fontSize: 13, color: '#a88841', fontWeight: 500, margin: '0 0 20px' }}>{p.highlight}</p>
        <div style={{ display: 'flex', gap: 8 }}>
          <span className="ms-btn ms-btn-primary ms-btn-sm" style={{ flex: 1 }}>View Details</span>
          <a href={`https://wa.me/919849999708?text=${encodeURIComponent('Interested in ' + p.name)}`} target="_blank" rel="noopener" onClick={(e) => e.stopPropagation()}
             style={{ width: 42, height: 42, border: '1px solid #143a2a', background: '#fff', color: '#143a2a', display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer' }}>
            <Icon name="whatsapp" size={16} />
          </a>
          <a href="tel:+919849999708" onClick={(e) => e.stopPropagation()}
             style={{ width: 42, height: 42, border: '1px solid #143a2a', background: '#fff', color: '#143a2a', display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer' }}>
            <Icon name="phone" size={16} />
          </a>
        </div>
      </div>
    </a>
  );
};

const SectionHeader = ({ eyebrow, title, body, align = 'left', light = false, action = null }) => (
  <div className="ms-mobile-stack" style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end', textAlign: align, marginBottom: 56, gap: 48 }}>
    <div style={{ maxWidth: 720 }}>
      <div className={`ms-eyebrow ${light ? 'on-dark' : ''}`} style={{ marginBottom: 16 }}>{eyebrow}</div>
      <h2 className="ms-h2" style={{ color: light ? '#f6f1e6' : '#0a1f17', margin: '0 0 16px' }}>{title}</h2>
      {body && <p style={{ fontSize: 16, lineHeight: 1.7, color: light ? 'rgba(232,220,193,0.7)' : '#4a4540', margin: 0, maxWidth: 600 }}>{body}</p>}
    </div>
    {action}
  </div>
);

// Number ticker — counts from 0 → final value once it scrolls into view.
const CountUp = ({ value, prefix = '', suffix = '', duration = 1200, decimals = 0, format = null, style }) => {
  const ref = React.useRef(null);
  const [n, setN] = React.useState(0);
  const [started, setStarted] = React.useState(false);
  React.useEffect(() => {
    if (!ref.current || started) return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach(e => {
        if (e.isIntersecting) {
          setStarted(true);
          const start = performance.now();
          const tick = (t) => {
            const p = Math.min(1, (t - start) / duration);
            const eased = 1 - Math.pow(1 - p, 3);
            setN(value * eased);
            if (p < 1) requestAnimationFrame(tick);
          };
          requestAnimationFrame(tick);
          io.disconnect();
        }
      });
    }, { threshold: 0.3 });
    io.observe(ref.current);
    return () => io.disconnect();
  }, [value, duration, started]);
  const display = format ? format(n) : n.toFixed(decimals);
  return <span ref={ref} className={`ms-count ${started ? 'ms-count--in' : ''}`} style={style}>{prefix}{display}{suffix}</span>;
};

// Reveal-on-scroll observer (utility — apply class="ms-reveal").
if (typeof IntersectionObserver !== 'undefined' && !window.__msRevealBound) {
  window.__msRevealBound = true;
  const io = new IntersectionObserver((entries) => {
    entries.forEach(e => { if (e.isIntersecting) { e.target.classList.add('is-in'); io.unobserve(e.target); } });
  }, { threshold: 0.12 });
  const bind = () => document.querySelectorAll('.ms-reveal:not(.is-in)').forEach(el => io.observe(el));
  document.addEventListener('DOMContentLoaded', bind);
  setTimeout(bind, 1500);
}

window.MarsanComponents = { Icon, MarsanLogo, Header, Footer, PropertyCard, SectionHeader, CountUp, NAV };
