import React from 'react';

export default function MapEmbed({ address, title = 'Project location' }) {
  if (!address) return null;
  const src = `https://www.google.com/maps?q=${encodeURIComponent(address)}&output=embed`;

  return (
    <section className="mt-6" aria-labelledby="map-heading">
      <h3 id="map-heading" className="h3 mb-3">Location</h3>
      <div className="overflow-hidden rounded-xl border border-slate-200 bg-slate-50">
        <iframe
          title={title}
          src={src}
          loading="lazy"
          referrerPolicy="no-referrer-when-downgrade"
          className="h-64 w-full md:h-72"
        />
      </div>
      <p className="mt-2 text-xs text-slate-500">Based on project location: {address}</p>
    </section>
  );
}


