/* Shared site content + small presentational helpers. Exposed on window. */

const DS = window.DawsonsDesignSystem_489d7d;
const { Icon, Badge } = DS;

const SITE = {
  phone: '0114 360 1180',
  email: 'hello@dawsonsltd.co.uk',
  areas: 'Sheffield · Barnsley · Manchester',
  nav: ['Home', 'Services', 'About', 'Contact'],
  services: [
    { icon: 'zap', title: 'Electrical', blurb: 'EICRs, rewires, fuse-board upgrades, fault-finding and EV charge points — domestic to industrial.', tag: 'NICEIC' },
    { icon: 'flame', title: 'Heating & Gas', blurb: 'Boiler installations, servicing and Gas Safe repairs, plus full central-heating systems.', tag: 'Gas Safe' },
    { icon: 'droplet', title: 'Plumbing', blurb: 'Bathrooms, leaks, pipework and drainage — reliable plumbing for homes and businesses.', tag: 'WaterSafe' },
    { icon: 'hammer', title: 'Building', blurb: 'Extensions, renovations and commercial fit-outs, managed end to end by one team.', tag: 'Project-managed' },
    { icon: 'shield-check', title: 'Testing & Compliance', blurb: 'EICR, PAT, fire alarm and emergency-lighting testing with full certification.', tag: 'Certified' },
    { icon: 'wrench', title: 'Maintenance', blurb: 'Planned and reactive maintenance contracts for landlords, offices and facilities.', tag: 'Contracts' },
  ],
  steps: [
    { icon: 'phone-call', title: 'Get in touch', text: 'Call or send the form — we respond within one working day.' },
    { icon: 'clipboard-list', title: 'Free survey & quote', text: 'We assess the job on site and give you a clear, fixed quote.' },
    { icon: 'hard-hat', title: 'We do the work', text: 'Tidy, certified work by our own qualified, insured tradespeople.' },
    { icon: 'badge-check', title: 'Tested & signed off', text: 'Everything is tested and handed over with full documentation.' },
  ],
  stats: [
    { value: '25', suffix: '+', label: 'Years trading' },
    { value: '4.9', suffix: '★', label: 'Google rating' },
    { value: '3,000', suffix: '+', label: 'Jobs completed' },
    { value: '24/7', suffix: '', label: 'Emergency cover' },
  ],
  reviews: [
    { name: 'Sarah M.', place: 'Sheffield', text: 'Rewired our whole house and fitted a new consumer unit. Tidy, on time and properly certified. Wouldn\u2019t use anyone else.' },
    { name: 'James T.', place: 'Barnsley', text: 'Boiler packed in over a weekend — Dawsons had an engineer out same day. Fair price and no fuss. Brilliant service.' },
    { name: 'Priya K.', place: 'Manchester', text: 'Managed a full office fit-out for us: electrics, heating and building work under one roof. Made the whole thing painless.' },
  ],
  accreditations: ['NICEIC', 'Gas Safe', 'CHAS', 'TrustMark', 'NAPIT'],
};

/* Photo placeholder — honest stand-in for real on-site photography. */
function Photo({ label = 'Photo', icon = 'image', style = {}, className = '' }) {
  return (
    <div className={`photo ${className}`} style={style}>
      <span className="ph-ico"><Icon name={icon} size={56} strokeWidth={1.25} /></span>
      <span className="ph-label"><Icon name="camera" size={13} /> {label}</span>
    </div>
  );
}

function Stars({ n = 5, size = 16 }) {
  return (
    <span className="stars">
      {Array.from({ length: n }).map((_, i) => <Icon key={i} name="star" size={size} style={{ fill: 'currentColor' }} />)}
    </span>
  );
}

function ReviewCard({ review }) {
  const initials = review.name.split(' ').map((w) => w[0]).join('').slice(0, 2);
  return (
    <div style={{ background: 'var(--color-surface)', border: '1px solid var(--color-border)', borderRadius: 'var(--radius-lg)', padding: 'var(--space-6)', boxShadow: 'var(--shadow-sm)', height: '100%', boxSizing: 'border-box' }}>
      <div className="review">
        <Stars />
        <p style={{ fontSize: 'var(--fs-body)', color: 'var(--text-secondary)', lineHeight: 1.6, margin: 0 }}>{review.text}</p>
        <div className="reviewer">
          <span className="avatar">{initials}</span>
          <span>
            <span style={{ display: 'block', fontFamily: 'var(--font-display)', fontWeight: 'var(--fw-bold)', color: 'var(--text-primary)', fontSize: 'var(--fs-body-sm)' }}>{review.name}</span>
            <span style={{ display: 'block', fontSize: 'var(--fs-caption)', color: 'var(--text-muted)' }}>{review.place}</span>
          </span>
        </div>
      </div>
    </div>
  );
}

Object.assign(window, { SITE, Photo, Stars, ReviewCard });
