/* ==========================================================================
   Shared.jsx
   Configuration, official asset slots, brand data and small building blocks
   used by every section. Load this file before the other components.
   All top-level names are prefixed (MC / mc) so the in-browser Babel scripts
   never collide with each other.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Configuration
   -------------------------------------------------------------------------- */
const MC_CONFIG = {
  /* URL of a form handler that accepts JSON (POST). While this is null the
     form validates in the browser but never claims to have sent anything. */
  formEndpoint: null,

  /* Developer-only Tweaks panel. Set to false before the site goes live. */
  showTweaks: true,

  /* Before & after: keep this true while the slider uses generated stand-in
     images. It labels them on the page as illustrative. Set it to false only
     once they are replaced with real photos from Dusty Cleaning jobs. */
  beforeAfterIllustrative: true,

  /* Business details: anything left as null shows a labelled placeholder. */
  contact: {
    phone: '0481 545 522',
    email: 'dustycleaning@gmail.com',
    areas: 'North Sydney',
  },
  social: {
    instagram: null, // full URL
    facebook: null,  // full URL
  },
  privacyUrl: null,
};

/* The standalone build embeds every asset as a data URI in
   window.MC_INLINE_ASSETS; everywhere else the file path is used, prefixed
   with window.MC_ASSET_BASE on pages that live in a sub-folder
   (e.g. '../' on /thecleanersbible/). */
function mcAsset(path) {
  const inlined = window.MC_INLINE_ASSETS;
  return (inlined && inlined[path]) || (window.MC_ASSET_BASE || '') + path;
}

/* --------------------------------------------------------------------------
   Official asset slots
   Add the official files to /assets and set their paths here. Anything left
   as null renders a clearly labelled placeholder instead.
   -------------------------------------------------------------------------- */
const MC_ASSETS = {
  logo: mcAsset('assets/logo.svg'),              // official logo, light backgrounds
  logoOnDark: mcAsset('assets/logo-on-dark.svg'), // official logo, dark backgrounds (off-white wordmark)
  dusty: mcAsset('assets/dusty.svg'),            // official Dusty artwork (also embedded in MC_DUSTY_ART so the eyes can move); null shows a placeholder
  photos: {
    hero: mcAsset('assets/photos/hero-cleaner.jpg'),
    svcHouse: mcAsset('assets/photos/service-house-cleaning.jpg'),
    svcHousekeeping: mcAsset('assets/photos/service-housekeeping.jpg'),
    svcLease: mcAsset('assets/photos/service-end-of-lease.jpg'),
    svcOffice: mcAsset('assets/photos/service-office.jpg'),
    storyDetails: mcAsset('assets/photos/story-details.jpg'),
    storyFresh: mcAsset('assets/photos/story-fresh-start.jpg'),
    storyLiving: mcAsset('assets/photos/story-more-living.jpg'),
    baKitchenBefore: mcAsset('assets/photos/ba-kitchen-before.jpg'),
    baKitchenAfter: mcAsset('assets/photos/ba-kitchen-after.jpg'),
    baBathroomBefore: mcAsset('assets/photos/ba-bathroom-before.jpg'),
    baBathroomAfter: mcAsset('assets/photos/ba-bathroom-after.jpg'),
    baLivingBefore: mcAsset('assets/photos/ba-living-before.jpg'),
    baLivingAfter: mcAsset('assets/photos/ba-living-after.jpg'),
  },
};

/* What each photo slot should show. Used for placeholders and for alt text
   once a real photo is added. */
const MC_PHOTO_BRIEFS = {
  hero: {
    subject: 'Cleaner in a Dusty Cleaning T-shirt in a bright kitchen',
    note: 'Portrait crop: smiling cleaner pulling on purple gloves, clean kitchen behind.',
    alt: 'A smiling cleaner in a Dusty Cleaning T-shirt pulling on purple gloves in a bright, clean kitchen',
  },
  svcHouse: {
    subject: 'Clean kitchen with clear benchtops',
    note: 'Landscape, natural light. Wiped splashback and sink, nothing cluttering the bench.',
    alt: 'A bright, clean kitchen with white benchtops, a stainless steel sink and timber cabinets',
    position: '62% 55%',
  },
  svcHousekeeping: {
    subject: 'Freshly made bed and folded laundry',
    note: 'Three-quarter angle. Crisp linen with a neat stack of folded towels at the foot of the bed.',
    alt: 'A freshly made bed with folded white towels and a welcome card',
    position: '45% 68%',
  },
  svcLease: {
    subject: 'Empty home ready for handover',
    note: 'Wide shot of an empty living area or kitchen after an end of lease clean. Daylight, clear floors.',
    alt: 'An empty, clean apartment with timber floors and a balcony, ready for handover',
    position: '45% 55%',
  },
  svcOffice: {
    subject: 'Tidy modern office',
    note: 'Daylight, clear desks and a clean shared table. A real workplace, not staged stock.',
    alt: 'A bright Sydney office with tidy desks and a view of the Opera House and Harbour Bridge',
    position: '68% 50%',
  },
  storyDetails: {
    subject: 'Close-up cleaning detail',
    note: 'Macro detail: a polished tap, a wiped switch plate or a clean skirting board corner.',
    alt: 'A gloved hand wiping a timber skirting board with a microfibre cloth',
    position: '78% 50%',
  },
  storyFresh: {
    subject: 'Morning light in a fresh bedroom',
    note: 'Soft light across a made bed, open curtains and an uncluttered bedside table.',
    alt: 'Folded white towels on a freshly made bed in soft morning light',
    position: '74% 55%',
  },
  storyLiving: {
    subject: 'Relaxing in a clean living room',
    note: 'A candid moment: someone reading or having a coffee on the sofa. Natural, not posed.',
    alt: 'A woman relaxing on the sofa with a book and a cup of coffee in a bright, tidy living room',
    position: '86% 50%',
  },
  baKitchenBefore: {
    subject: 'Before: kitchen',
    note: 'Real job photo taken before cleaning, with the same angle and framing as the after shot.',
    alt: 'Kitchen before cleaning',
  },
  baKitchenAfter: {
    subject: 'After: kitchen',
    note: 'Real job photo taken after cleaning, from the same spot as the before shot.',
    alt: 'Kitchen after cleaning',
  },
  baBathroomBefore: {
    subject: 'Before: bathroom',
    note: 'Real job photo taken before cleaning, with the same angle and framing as the after shot.',
    alt: 'Bathroom before cleaning',
  },
  baBathroomAfter: {
    subject: 'After: bathroom',
    note: 'Real job photo taken after cleaning, from the same spot as the before shot.',
    alt: 'Bathroom after cleaning',
  },
  baLivingBefore: {
    subject: 'Before: living area',
    note: 'Real job photo taken before cleaning, with the same angle and framing as the after shot.',
    alt: 'Living area before cleaning',
  },
  baLivingAfter: {
    subject: 'After: living area',
    note: 'Real job photo taken after cleaning, from the same spot as the before shot.',
    alt: 'Living area after cleaning',
  },
};

/* --------------------------------------------------------------------------
   Brand data
   -------------------------------------------------------------------------- */
const MC_SERVICES = [
  {
    id: 'house',
    name: 'House Cleaning',
    short: 'House cleaning',
    accent: 'purple',
    icon: 'house',
    photo: 'svcHouse',
    desc: 'Regular or one-off cleaning to keep your home fresh, comfortable and welcoming.',
    benefits: [
      'Weekly, fortnightly or one-off cleans',
      'Kitchens, bathrooms and living areas',
      'Shaped around your home and routine',
    ],
    tasks: ['Kitchen surfaces', 'Bathroom cleaning', 'Dusting', 'Vacuuming', 'Mopping', 'General tidying'],
    goodFor: 'busy households, couples and families who want a home that feels looked after.',
  },
  {
    id: 'housekeeping',
    name: 'Housekeeping',
    short: 'Housekeeping',
    accent: 'green',
    icon: 'basket',
    photo: 'svcHousekeeping',
    desc: 'Extra help with everyday household tasks, keeping your home organised and running smoothly.',
    benefits: [
      'Help with the everyday jobs',
      'Laundry, beds and tidying',
      'A household that runs more smoothly',
    ],
    tasks: ['General household organisation', 'Laundry assistance', 'Bed making', 'Kitchen maintenance', 'Everyday household support'],
    goodFor: 'homeowners and families who could use an extra pair of hands around the house.',
  },
  {
    id: 'lease',
    name: 'End of Lease Cleaning',
    short: 'End of lease',
    accent: 'orange',
    icon: 'key',
    photo: 'svcLease',
    desc: 'Detailed cleaning to help prepare your property for its final inspection and handover.',
    benefits: [
      'A detailed, room-by-room clean',
      'Kitchens, bathrooms, surfaces and floors',
      'Scope agreed with you before we start',
    ],
    tasks: ['Detailed kitchen cleaning', 'Bathroom and toilet cleaning', 'Internal surfaces', 'Floors and skirting boards', 'Additional agreed cleaning requirements'],
    goodFor: 'tenants and occupants getting ready to hand back the keys.',
    note: 'We clean to the scope we agree with you. Bond decisions are made by your landlord or property manager, so we can’t guarantee a bond outcome.',
    extras: 'Extras such as oven cleaning, fridge cleaning and interior window cleaning may be available on request.',
  },
  {
    id: 'office',
    name: 'Office Cleaning',
    short: 'Office cleaning',
    accent: 'black',
    icon: 'briefcase',
    photo: 'svcOffice',
    desc: 'Clean, organised workspaces that help create a pleasant environment for employees and visitors.',
    benefits: [
      'Desks, kitchens and shared spaces',
      'Bathrooms, floors and rubbish removal',
      'Timing discussed to suit your workplace',
    ],
    tasks: ['Desks and common areas', 'Kitchen and break rooms', 'Bathrooms', 'Floors', 'Rubbish removal', 'General workspace maintenance'],
    goodFor: 'small businesses and offices that want a clean, welcoming place to work.',
  },
];

const MC_NAV_LINKS = [
  { label: 'Services', href: '#services' },
  { label: 'About', href: '#about' },
  { label: 'How It Works', href: '#how-it-works' },
  { label: 'FAQ', href: '#faq' },
  { label: 'Contact', href: '#contact' },
];

/* --------------------------------------------------------------------------
   Icon system: flat, solid shapes on a 24px grid with one visual weight.
   The sparkle is the official Dusty Cleaning star (from the brand artboard,
   scaled to 24px). The other icons are interim stand-ins: replace them with
   the official icon set when supplied (same names).
   -------------------------------------------------------------------------- */
const MC_SPARKLE_PATH = 'M 11.3,13.6 c -1.72,1.42 -3.39,2.8 -5.07,4.19 c -0.02,-0.02 -0.03,-0.03 -0.04,-0.04 c 1.38,-1.67 2.76,-3.34 4.17,-5.05 c -3.49,-0.22 -6.92,-0.45 -10.36,-0.67 c 0,-0.02 -0,-0.04 -0,-0.05 c 3.32,-0.21 6.65,-0.43 10.04,-0.65 c -1.31,-1.59 -2.58,-3.13 -3.86,-4.67 c 0.01,-0.02 0.03,-0.03 0.04,-0.05 c 1.67,1.38 3.33,2.75 5.04,4.16 c 0.23,-2.84 0.45,-5.63 0.68,-8.43 c 0.02,-0 0.04,-0 0.06,-0 c 0.21,2.67 0.43,5.34 0.65,8.08 c 1.58,-1.29 3.13,-2.55 4.67,-3.81 c 0.02,0.01 0.03,0.03 0.05,0.04 c -1.25,1.54 -2.51,3.07 -3.8,4.64 c 3.51,0.23 6.97,0.45 10.43,0.67 c 0,0.02 0,0.04 0,0.05 c -3.56,0.23 -7.11,0.46 -10.74,0.69 c 1.39,1.7 2.75,3.36 4.1,5.02 c -0.02,0.02 -0.03,0.03 -0.04,0.05 c -1.55,-1.27 -3.1,-2.54 -4.7,-3.84 c -0.21,2.6 -0.41,5.15 -0.62,7.71 c -0.02,0 -0.04,0 -0.06,0 C 11.73,18.99 11.52,16.32 11.3,13.6 z';

const MC_ICON_SHAPES = {
  sparkle: <path d={MC_SPARKLE_PATH} />,
  moon: <path d="M21 13.6A9.2 9.2 0 1 1 10.4 3a7.2 7.2 0 0 0 10.6 10.6z" />,
  magnifier: (
    <>
      <path fillRule="evenodd" d="M10 2.5a7.5 7.5 0 1 1 0 15 7.5 7.5 0 0 1 0-15zm0 3.5a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" />
      <path d="M15.2 17.6l2.4-2.4 4.6 4.6a1.7 1.7 0 0 1-2.4 2.4z" />
    </>
  ),
  broom: (
    <g transform="rotate(38 12 12)">
      <rect x="10.6" y="0.4" width="2.8" height="10.4" rx="1.4" />
      <rect x="7.6" y="10.2" width="8.8" height="3" rx="1.2" />
      <path d="M7.8 14h2.9l-.6 7.6H5.4z" />
      <path d="M11.3 14h1.4l.5 7.6h-2.4z" />
      <path d="M13.3 14h2.9l2.4 7.6h-3.9z" />
    </g>
  ),
  spray: (
    <>
      <path d="M5 3.4A1.4 1.4 0 0 1 6.4 2H15l3 1.6v1.8L15 7H6.4A1.4 1.4 0 0 1 5 5.6z" />
      <rect x="8" y="7" width="4.4" height="2.6" />
      <path d="M6.4 7h2.1l-1.7 4.4H4.9z" />
      <path fillRule="evenodd" d="M8 9.4h4.4c2 0 3.6 1.6 3.6 3.6v7a2 2 0 0 1-2 2H6.4a2 2 0 0 1-2-2v-7c0-2 1.6-3.6 3.6-3.6zm-1 5.1v4h6.4v-4z" />
      <circle cx="20.6" cy="2.4" r="1.1" />
      <circle cx="21.8" cy="5.2" r="1.1" />
      <circle cx="20.6" cy="8" r="1.1" />
    </>
  ),
  squeegee: (
    <>
      <rect x="10.6" y="1.5" width="2.8" height="12" rx="1.4" />
      <rect x="2.5" y="13" width="19" height="3.8" rx="1.4" />
      <rect x="3.5" y="17.8" width="17" height="2" rx="1" />
      <path d={'M19.5 20.6c.2 1.2.7 1.7 1.9 1.9-1.2.2-1.7.7-1.9 1.9-.2-1.2-.7-1.7-1.9-1.9 1.2-.2 1.7-.7 1.9-1.9z'} />
    </>
  ),
  heart: <path d="M12 20.6C6.5 16.7 2.5 13.3 2.5 9 2.5 6.1 4.7 3.9 7.4 3.9c1.9 0 3.6 1 4.6 2.6 1-1.6 2.7-2.6 4.6-2.6 2.7 0 4.9 2.2 4.9 5.1 0 4.3-4 7.7-9.5 11.6z" />,
  calendar: (
    <>
      <path fillRule="evenodd" d="M5.5 4h13A2.5 2.5 0 0 1 21 6.5v13a2.5 2.5 0 0 1-2.5 2.5h-13A2.5 2.5 0 0 1 3 19.5v-13A2.5 2.5 0 0 1 5.5 4zm0 5.5v10h13v-10z" />
      <rect x="7" y="1.8" width="2.4" height="4.4" rx="1.2" />
      <rect x="14.6" y="1.8" width="2.4" height="4.4" rx="1.2" />
      <rect x="7.4" y="11.6" width="3.4" height="3.2" rx=".8" />
      <rect x="13.2" y="11.6" width="3.4" height="3.2" rx=".8" />
      <rect x="7.4" y="16" width="3.4" height="2.4" rx=".8" />
    </>
  ),
  house: <path d="M12 2.6l9.4 7.6c.4.3.6.7.6 1.2V20a2 2 0 0 1-2 2h-5v-6.5H9V22H4a2 2 0 0 1-2-2v-8.6c0-.5.2-.9.6-1.2z" />,
  basket: (
    <>
      <path d="M6.5 8.6C6.5 5.6 9 3.6 12 3.6s5.5 2 5.5 5z" />
      <path fillRule="evenodd" d="M2.5 9.8h19l-1.9 10.4A2.2 2.2 0 0 1 17.4 22H6.6a2.2 2.2 0 0 1-2.2-1.8zM7.4 13v5.6h2V13zm3.6 0v5.6h2V13zm3.6 0v5.6h2V13z" />
    </>
  ),
  key: (
    <g transform="rotate(-45 12 12)">
      <path fillRule="evenodd" d="M6.5 7a5 5 0 1 1 0 10 5 5 0 0 1 0-10zm0 3a2 2 0 1 0 0 4 2 2 0 0 0 0-4z" />
      <path d="M11 10.5h11.2v3h-1.4v2.8h-2.6v-2.8h-1.4v2.2h-2.6v-2.2H11z" />
    </g>
  ),
  briefcase: (
    <>
      <path fillRule="evenodd" d="M9 2.8h6a2 2 0 0 1 2 2V6h3a2 2 0 0 1 2 2v4H2V8a2 2 0 0 1 2-2h3V4.8a2 2 0 0 1 2-2zM9.2 5v1h5.6V5z" />
      <path d="M2 13.4h8.6v1.4c0 .6.4 1 1 1h.8c.6 0 1-.4 1-1v-1.4H22V19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2z" />
    </>
  ),
  frame: (
    <>
      <path fillRule="evenodd" d="M4.5 3.5h15a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2h-15a2 2 0 0 1-2-2v-13a2 2 0 0 1 2-2zM5 6v9.6l4.2-4.6 3.3 3.5 2.5-2.6 4 4V6z" />
      <circle cx="15.5" cy="9" r="1.8" />
    </>
  ),
  plus: <path d="M10.6 3h2.8v7.6H21v2.8h-7.6V21h-2.8v-7.6H3v-2.8h7.6z" />,
  menu: (
    <>
      <rect x="3" y="5.5" width="18" height="2.6" rx="1.3" />
      <rect x="3" y="10.7" width="18" height="2.6" rx="1.3" />
      <rect x="3" y="15.9" width="12" height="2.6" rx="1.3" />
    </>
  ),
  close: <path d="M5.6 3.8L12 10.2l6.4-6.4 1.8 1.8-6.4 6.4 6.4 6.4-1.8 1.8-6.4-6.4-6.4 6.4-1.8-1.8 6.4-6.4-6.4-6.4z" />,
  chevron: <path d="M5.6 8.2L12 14.6l6.4-6.4 1.9 1.9-8.3 8.3-8.3-8.3z" />,
  arrows: <path d="M8.6 6.4L3 12l5.6 5.6 1.8-1.8L6.6 12l3.8-3.8zm6.8 0l-1.8 1.8 3.8 3.8-3.8 3.8 1.8 1.8L21 12z" />,
  phone: <path d="M7.2 2.5c.6 0 1.1.4 1.3 1l1.1 3.6c.2.6 0 1.2-.5 1.6L7.4 10.2a12.6 12.6 0 0 0 6.4 6.4l1.5-1.7c.4-.5 1-.7 1.6-.5l3.6 1.1c.6.2 1 .7 1 1.3V20a2 2 0 0 1-2.2 2C10.1 21.4 2.6 13.9 2 4.7A2 2 0 0 1 4 2.5z" />,
  mail: <path fillRule="evenodd" d="M4 4.5h16a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-11a2 2 0 0 1 2-2zm0 2.7v2l8 5.6 8-5.6v-2l-8 5.6z" />,
  pin: <path fillRule="evenodd" d="M12 1.8a7.6 7.6 0 0 1 7.6 7.6c0 5.4-7.6 12.8-7.6 12.8S4.4 14.8 4.4 9.4A7.6 7.6 0 0 1 12 1.8zm0 4.6a3 3 0 1 0 0 6 3 3 0 0 0 0-6z" />,
  alert: <path fillRule="evenodd" d="M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20zm-1.3 4.8v7.4h2.6V6.8zm0 9v2.6h2.6v-2.6z" />,
  check: <path d="M9.6 17.6L4 12l1.9-1.9 3.7 3.7 8.5-8.5L20 7.2z" />,
  info: <path fillRule="evenodd" d="M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20zm-1.3 8.2v8h2.6v-8zm0-4.4v2.6h2.6V5.8z" />,
};

/* --------------------------------------------------------------------------
   Building blocks
   -------------------------------------------------------------------------- */
function MCIcon({ name, className = '', title }) {
  const shape = MC_ICON_SHAPES[name];
  if (!shape) return null;
  return (
    <svg
      className={`mc-icon ${className}`}
      viewBox="0 0 24 24"
      fill="currentColor"
      focusable="false"
      aria-hidden={title ? undefined : 'true'}
      role={title ? 'img' : undefined}
    >
      {title ? <title>{title}</title> : null}
      {shape}
    </svg>
  );
}

function MCSparkle({ className = '', extra = false, optional = false }) {
  const classes = ['mc-sparkle', 'mc-deco', extra ? 'mc-deco-extra' : '', optional ? 'mc-deco-optional' : '', className]
    .filter(Boolean)
    .join(' ');
  return (
    <svg className={classes} viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">
      <path d={MC_SPARKLE_PATH} />
    </svg>
  );
}

/* Circular stamp with slowly rotating text. Decorative only. */
function MCStamp({ text = 'Dusty approved ✦ A lot of clean ✦ ', className = '', center = 'sparkle' }) {
  const rawId = React.useId();
  const pathId = 'mc-stamp-' + rawId.replace(/[^a-zA-Z0-9]/g, '');
  const circumference = 2 * Math.PI * 74;
  return (
    <span className={`mc-stamp mc-deco ${className}`} aria-hidden="true">
      <svg viewBox="0 0 200 200" focusable="false">
        <defs>
          <path id={pathId} d="M100,100 m-74,0 a74,74 0 1,1 148,0 a74,74 0 1,1 -148,0" />
        </defs>
        <circle className="mc-stamp__bg" cx="100" cy="100" r="98" />
        <circle className="mc-stamp__ring" cx="100" cy="100" r="56" />
        <g className="mc-stamp__spin">
          <text className="mc-stamp__text">
            <textPath href={`#${pathId}`} textLength={Math.round(circumference - 6)} lengthAdjust="spacing">
              {text.toUpperCase()}
            </textPath>
          </text>
        </g>
        <g className="mc-stamp__center" transform="translate(72 72) scale(2.333)">
          {MC_ICON_SHAPES[center]}
        </g>
      </svg>
    </span>
  );
}

/* Photo slot: renders the real photo when MC_ASSETS has one, otherwise a
   clearly labelled placeholder describing the intended shot. */
function MCImageSlot({ photoKey, className = '', align = 'bottom', variant = '', eager = false, sizes = '(max-width: 760px) 100vw, 50vw', altPrefix = '' }) {
  const src = MC_ASSETS.photos[photoKey];
  const brief = MC_PHOTO_BRIEFS[photoKey] || { subject: 'Photo', note: '', alt: '' };
  if (src) {
    return (
      <img
        className={`mc-photo ${className}`}
        src={src}
        alt={altPrefix + brief.alt}
        style={brief.position ? { objectPosition: brief.position } : undefined}
        sizes={sizes}
        loading={eager ? 'eager' : 'lazy'}
        decoding="async"
        fetchpriority={eager ? 'high' : 'auto'}
      />
    );
  }
  const classes = ['mc-ph-img', `mc-ph-img--${align}`, variant ? `mc-ph-img--${variant}` : '', className].filter(Boolean).join(' ');
  return (
    <div className={classes} role="img" aria-label={`Photo placeholder: ${brief.subject}`} data-placeholder="photo">
      <div className="mc-ph-img__label">
        <span className="mc-ph-img__tag">
          <MCIcon name="frame" />
          Photo placeholder
        </span>
        <span className="mc-ph-img__subject">{brief.subject}</span>
        {brief.note ? <span className="mc-ph-img__note">{brief.note}</span> : null}
      </div>
    </div>
  );
}

/* Dusty's official artwork (from assets/dusty.svg), embedded so the eyes can
   animate. Eye centres are in the artwork's own coordinates. */
const MC_DUSTY_ART = {
  viewBox: [49.93, 18.11, 210.93, 157.11],
  body: 'M172.43,119.77c-15.77,0-31.54,0-47.3,0c-6.31,0-12.62-0.01-18.94-0.01c-8.29-0.01-16.58,0.07-24.87-0.08   c-3.95-0.07-7.95-0.26-11.81-0.98c-2.15-0.4-4.16-1.87-6.08-3.11c-5.81-3.75-8.79-9.44-10.44-15.9   c-1.49-5.82-1.03-11.77-0.87-17.69c0.23-8.54,1.41-16.97,3-25.35c1.57-8.22,3.19-16.43,4.96-24.61c0.32-1.46,1.34-2.86,2.32-4.07   c0.8-0.99,2.05-0.93,3.02-0.01c0.61,0.58,1.17,1.23,1.6,1.95c2.03,3.39,3.99,6.83,6,10.23c1.71,2.88,2.38,3.07,5.64,2.58   c3.16-0.48,6.36-0.98,9.55-1.04c8.01-0.14,16.03-0.14,24.04,0.05c2.57,0.06,4.42-0.71,5.79-2.73c2.07-3.04,4.06-6.13,6.11-9.18   c0.87-1.29,1.72-2.57,3.4-3.02c1.52-0.41,2.75-0.02,3.62,1.2c0.77,1.06,1.45,2.21,2,3.39c0.95,2.04,1.73,4.17,2.69,6.21   c0.19,0.4,0.88,0.85,1.3,0.81c1.29-0.1,2.69-0.15,3.82-0.7c4.11-2.01,8.03-4.39,12.19-6.28c4.15-1.88,8.48-3.36,12.74-4.99   c5.41-2.07,10.89-3.9,16.57-5.14c7.06-1.54,14.11-1.46,21.22-0.45c9.78,1.39,18.8,4.76,27.09,10.06   c5.99,3.83,11.46,8.31,15.64,14.16c3.17,4.44,5.35,9.4,7.1,14.54c2.35,6.89,3.81,13.98,4.32,21.23c0.34,4.88,0.25,9.79,0.67,14.67   c0.67,7.64,0.24,15.25-0.33,22.85c-0.78,10.4-6.16,17.74-15.72,22.02c-4.97,2.23-10.22,3.19-15.62,3.65   c-11.45,0.97-22.92,0.71-34.38,0.51c-5.99-0.11-11.97-0.5-17.96-0.71c-4.91-0.17-9.83-0.15-14.64,1.06   c-1.81,0.45-3.59,1.18-5.24,2.05c-2.08,1.09-3.02,4.44-1.82,6.45c0.46,0.76,1.47,1.29,2.34,1.68c2.51,1.14,5.22,1.2,7.91,1.22   c6.37,0.04,12.75-0.04,19.12,0.03c1.73,0.02,3.52,0.15,5.16,0.65c5.92,1.78,7.81,8.08,5.48,13.29c-1.01,2.25-2.48,2.98-4.93,2.96   c-11.85-0.12-23.7-0.08-35.55-0.02c-1.97,0.01-3.67-0.47-5.35-1.46c-6.38-3.77-10.43-9.24-11.75-16.5   c-1.75-9.65,2.59-19.35,12.04-24.12c4.52-2.28,9.35-3.44,14.36-3.91c2.95-0.28,5.91-0.55,8.87-0.56c16.9-0.05,33.8,0.01,50.7-0.07   c2.57-0.01,5.15-0.51,7.71-0.88c1.31-0.19,2.03-1.09,2.23-2.4c0.2-1.33-0.41-2.36-1.62-2.61c-2.24-0.46-4.53-0.9-6.8-0.91   c-16.76-0.07-33.52-0.04-50.27-0.04C172.43,119.75,172.43,119.76,172.43,119.77z M117.76,86.18c1.72-0.38,3.44-0.77,5.17-1.13   c2.51-0.52,4.69-1.67,6.5-3.45c0.37-0.36,0.35-1.12,0.51-1.69c-0.6,0-1.47-0.26-1.75,0.03c-1.54,1.63-3.55,2.3-5.57,2.9   c-3.06,0.92-6.22,1.31-9.28,0.19c-2.02-0.73-3.86-1.92-5.83-2.8c-0.45-0.2-1.09,0.02-1.64,0.05c0.15,0.47,0.16,1.11,0.48,1.38   C109.65,84.34,113.3,86.11,117.76,86.18z M63.82,79.67c-0.1,0.15-0.2,0.29-0.3,0.44c0.2,1.29,1.16,2.04,2.15,2.74   c3.94,2.79,8.37,3.69,13.02,2.81c3.12-0.59,6.25-1.56,8.53-4.04c0.35-0.38,0.33-1.09,0.48-1.65c-0.6,0.04-1.26-0.05-1.79,0.17   c-0.58,0.25-0.98,0.9-1.56,1.17c-6.27,2.91-12.45,3.5-18.44-0.77C65.3,80.13,64.52,79.96,63.82,79.67z',
  closedEyes: ['M64.65,79.67c0.7,0.29,1.48,0.46,2.08,0.88c5.99,4.27,12.17,3.68,18.44,0.77c0.58-0.27,0.98-0.93,1.56-1.17   c0.53-0.22,1.19-0.13,1.79-0.17c-0.15,0.56-0.13,1.27-0.48,1.65c-2.28,2.48-5.41,3.44-8.53,4.04c-4.65,0.88-9.08-0.02-13.02-2.81   c-0.99-0.7-1.95-1.45-2.15-2.74C64.45,79.96,64.55,79.82,64.65,79.67z', 'M118.59,86.18c-4.46-0.07-8.11-1.84-11.4-4.53c-0.32-0.26-0.33-0.91-0.48-1.38c0.55-0.03,1.19-0.25,1.64-0.05   c1.97,0.88,3.81,2.07,5.83,2.8c3.07,1.12,6.23,0.73,9.28-0.19c2.01-0.61,4.03-1.27,5.57-2.9c0.28-0.3,1.15-0.04,1.75-0.03   c-0.16,0.57-0.14,1.33-0.51,1.69c-1.81,1.78-4,2.93-6.5,3.45C122.04,85.41,120.32,85.8,118.59,86.18z'],
  eyes: [
    { cx: 76.4, cy: 81.8 },
    { cx: 118.7, cy: 81.9 },
  ],
};

/* Dusty slot. With the official artwork (MC_ASSETS.dusty) Dusty naps; a gentle
   pat (pointer moving over Dusty, or a tap) makes Dusty happy: content ^ ^ eyes,
   a little blush, a soft lean into the hand and a few floating hearts. When the
   petting stops Dusty keeps the eyes open and follows the pointer for a moment,
   then dozes off again. Without the artwork a labelled placeholder is shown. */
function MCDusty({ className = '', decorative = false, interactive = true, forceAwake = false, petSignal = 0 }) {
  const art = MC_DUSTY_ART;
  const pupilRefs = React.useRef([]);
  const svgRef = React.useRef(null);
  const timersRef = React.useRef({ sleep: 0, happy: 0 });
  const hoverRef = React.useRef(false);
  const lookRef = React.useRef(null);
  const strokeRef = React.useRef({ x: null, y: null, travelled: 0, lastHeart: 0 });
  const heartIdRef = React.useRef(0);
  const [dustyAwake, setDustyAwake] = React.useState(false);
  const [dustyHappy, setDustyHappy] = React.useState(false);
  const [dustyHearts, setDustyHearts] = React.useState([]);
  const awake = dustyAwake || forceAwake;

  const scheduleSleep = (ms) => {
    window.clearTimeout(timersRef.current.sleep);
    timersRef.current.sleep = window.setTimeout(() => {
      if (!hoverRef.current) setDustyAwake(false);
    }, ms);
  };

  const addHeart = () => {
    const now = Date.now();
    if (now - strokeRef.current.lastHeart < 380) return;
    strokeRef.current.lastHeart = now;
    heartIdRef.current += 1;
    const id = heartIdRef.current;
    const heart = { id, x: 16 + Math.random() * 42, size: 15 + Math.random() * 9, drift: Math.round((Math.random() * 2 - 1) * 16) };
    setDustyHearts((list) => list.slice(-4).concat(heart));
    window.setTimeout(() => setDustyHearts((list) => list.filter((item) => item.id !== id)), 1700);
  };

  const pet = () => {
    setDustyAwake(true);
    setDustyHappy(true);
    addHeart();
    window.clearTimeout(timersRef.current.happy);
    timersRef.current.happy = window.setTimeout(() => setDustyHappy(false), 1200);
    if (!hoverRef.current) scheduleSleep(3600);
  };

  // A keyboard "pat" from a parent button (e.g. the Meet Dusty section).
  React.useEffect(() => {
    if (petSignal) pet();
  }, [petSignal]);

  React.useEffect(() => () => {
    window.clearTimeout(timersRef.current.sleep);
    window.clearTimeout(timersRef.current.happy);
  }, []);

  // While awake (and not mid-cuddle), the pupils follow the pointer.
  React.useEffect(() => {
    const pupils = pupilRefs.current;
    const centre = () => pupils.forEach((el) => { if (el) el.style.transform = ''; });
    if (!awake || dustyHappy) {
      if (!awake) centre();
      return undefined;
    }
    let frame = 0;
    const update = () => {
      frame = 0;
      const svg = svgRef.current;
      const target = lookRef.current;
      if (!svg || !target) return;
      const rect = svg.getBoundingClientRect();
      const [vx, vy, vw, vh] = art.viewBox;
      const sx = rect.width / vw;
      const sy = rect.height / vh;
      art.eyes.forEach((eye, index) => {
        const el = pupils[index];
        if (!el) return;
        const ex = rect.left + (eye.cx - vx) * sx;
        const ey = rect.top + (eye.cy - vy) * sy;
        const dx = target.x - ex;
        const dy = target.y - ey;
        const dist = Math.hypot(dx, dy) || 1;
        const reach = Math.min(1, dist / 90);
        el.style.transform = `translate(${((dx / dist) * 6.4 * reach).toFixed(2)}px, ${((dy / dist) * 3 * reach).toFixed(2)}px)`;
      });
    };
    const track = (event) => {
      lookRef.current = { x: event.clientX, y: event.clientY };
      if (!frame) frame = window.requestAnimationFrame(update);
    };
    window.addEventListener('pointermove', track, { passive: true });
    window.addEventListener('pointerdown', track, { passive: true });
    update();
    return () => {
      window.removeEventListener('pointermove', track);
      window.removeEventListener('pointerdown', track);
      if (frame) window.cancelAnimationFrame(frame);
    };
  }, [awake, dustyHappy]);

  const handlers = interactive
    ? {
        onPointerEnter: (event) => {
          hoverRef.current = true;
          lookRef.current = { x: event.clientX, y: event.clientY };
          strokeRef.current = { ...strokeRef.current, x: event.clientX, y: event.clientY, travelled: 0 };
          window.clearTimeout(timersRef.current.sleep);
          setDustyAwake(true);
        },
        onPointerMove: (event) => {
          lookRef.current = { x: event.clientX, y: event.clientY };
          const stroke = strokeRef.current;
          if (stroke.x !== null) stroke.travelled += Math.hypot(event.clientX - stroke.x, event.clientY - stroke.y);
          stroke.x = event.clientX;
          stroke.y = event.clientY;
          if (stroke.travelled > 36) {
            stroke.travelled = 0;
            pet();
          }
        },
        onPointerLeave: () => {
          hoverRef.current = false;
          strokeRef.current = { ...strokeRef.current, x: null, y: null, travelled: 0 };
          scheduleSleep(2600);
        },
        onPointerDown: (event) => {
          lookRef.current = { x: event.clientX, y: event.clientY };
          pet();
        },
      }
    : {};

  if (!MC_ASSETS.dusty) {
    return (
      <span
        className={`mc-dusty mc-dusty--ph ${className}`}
        role={decorative ? undefined : 'img'}
        aria-label={decorative ? undefined : 'Placeholder for the official Dusty mascot artwork'}
        aria-hidden={decorative ? 'true' : undefined}
        data-placeholder="dusty"
      >
        <span className="mc-dusty__ph">
          <MCIcon name="moon" className="mc-dusty__icon" />
          <span className="mc-dusty__name">Dusty</span>
          <span className="mc-dusty__note">Official artwork here</span>
        </span>
      </span>
    );
  }

  const classes = ['mc-dusty', awake ? 'is-awake' : '', dustyHappy ? 'is-happy' : '', interactive ? 'is-pettable' : '', className]
    .filter(Boolean)
    .join(' ');

  return (
    <span className={classes} {...handlers}>
      <span className="mc-dusty__lean">
        <svg
          ref={svgRef}
          className="mc-dusty-art"
          viewBox={art.viewBox.join(' ')}
          focusable="false"
          role={decorative ? undefined : 'img'}
          aria-label={decorative ? undefined : 'Dusty, the Dusty Cleaning mascot'}
          aria-hidden={decorative ? 'true' : undefined}
        >
          <path d={art.body} fill="#000000" />
          {/* The artwork's body has eye-shaped cut-outs: fill them so the
              background never shows through when the sleepy eyes fade out. */}
          <g fill="#000000" stroke="#000000" strokeWidth="2" strokeLinejoin="round">
            {art.closedEyes.map((d) => (
              <path key={d.slice(0, 12)} d={d} />
            ))}
          </g>
          <g className="mc-dusty__closed" fill="#FFFFFF">
            {art.closedEyes.map((d) => (
              <path key={d.slice(0, 12)} d={d} />
            ))}
          </g>
          <g className="mc-dusty__blush">
            {art.eyes.map((eye) => (
              <ellipse key={eye.cx} cx={eye.cx} cy={eye.cy + 10.5} rx="6.5" ry="3.2" />
            ))}
          </g>
          <g className="mc-dusty__happyeyes" fill="none" stroke="#FFFFFF" strokeWidth="3.6" strokeLinecap="round">
            {art.eyes.map((eye) => (
              <path key={eye.cx} d={`M${eye.cx - 9} ${eye.cy + 3.4}Q${eye.cx} ${eye.cy - 7.6} ${eye.cx + 9} ${eye.cy + 3.4}`} />
            ))}
          </g>
          <g className="mc-dusty__open">
            <g className="mc-dusty__blink">
              {art.eyes.map((eye, index) => (
                <g key={eye.cx}>
                  <ellipse cx={eye.cx} cy={eye.cy} rx="12.2" ry="8.6" fill="#FFFFFF" />
                  <g
                    className="mc-dusty__pupil"
                    ref={(el) => {
                      pupilRefs.current[index] = el;
                    }}
                  >
                    <circle cx={eye.cx} cy={eye.cy} r="4.9" fill="#1e1e1e" />
                  </g>
                </g>
              ))}
            </g>
          </g>
        </svg>
      </span>
      {dustyHearts.map((heart) => (
        <span
          key={heart.id}
          className="mc-dusty__heart"
          style={{ left: `${heart.x}%`, width: `${heart.size}px`, '--drift': `${heart.drift}px` }}
          aria-hidden="true"
        >
          <MCIcon name="heart" />
        </span>
      ))}
    </span>
  );
}

/* Logo slot: the official logo file, or a plain text wordmark placeholder. */
function MCLogo({ onDark = false, className = '' }) {
  const light = MC_ASSETS.logo;
  const dark = MC_ASSETS.logoOnDark || MC_ASSETS.logo;
  if (onDark && dark) {
    return <img className={`mc-logo-img ${className}`} src={dark} alt="Dusty Cleaning" width="406" height="145" />;
  }
  if (light) {
    return (
      <span className={`mc-logo-pair ${className}`}>
        <img className="mc-logo-img mc-logo-img--light" src={light} alt="Dusty Cleaning" width="406" height="145" />
        {dark && dark !== light ? (
          <img className="mc-logo-img mc-logo-img--dark" src={dark} alt="" aria-hidden="true" width="406" height="145" />
        ) : null}
      </span>
    );
  }
  return (
    <span className={`mc-logo ${className}`} data-placeholder="logo">
      Dusty Cleaning
    </span>
  );
}

/* Inline text placeholder for business details that are not confirmed yet. */
function MCPh({ children }) {
  return (
    <span className="mc-ph" data-placeholder="content">
      [{children}]
    </span>
  );
}

function MCEyebrow({ children, className = '', icon = 'sparkle' }) {
  return (
    <p className={`mc-eyebrow ${className}`}>
      <MCIcon name={icon} className="mc-eyebrow__mark" />
      {children}
    </p>
  );
}

/* --------------------------------------------------------------------------
   Helpers
   -------------------------------------------------------------------------- */
function mcPrefersReducedMotion() {
  return !!(window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches);
}

/* Smooth-scroll to a section and optionally move focus to a field in it. */
function mcScrollToId(id, focusId) {
  const target = document.getElementById(id);
  if (!target) return;
  const reduce = mcPrefersReducedMotion();
  target.scrollIntoView({ behavior: reduce ? 'auto' : 'smooth', block: 'start' });
  if (focusId) {
    window.setTimeout(() => {
      const field = document.getElementById(focusId);
      if (field) field.focus({ preventScroll: true });
    }, reduce ? 0 : 500);
  }
}

/* Section reveals. Uses a data attribute (not a class) so React re-renders
   never undo a reveal. Without IntersectionObserver everything stays visible. */
function mcInitReveal() {
  const root = document.documentElement;
  const items = Array.prototype.slice.call(document.querySelectorAll('[data-reveal]'));
  if (!('IntersectionObserver' in window)) {
    root.classList.remove('mc-reveal-ready');
    return () => {};
  }
  root.classList.add('mc-reveal-ready');
  const observer = new IntersectionObserver(
    (entries) => {
      entries.forEach((entry) => {
        if (entry.isIntersecting) {
          entry.target.setAttribute('data-revealed', '');
          observer.unobserve(entry.target);
        }
      });
    },
    { rootMargin: '0px 0px -8% 0px', threshold: 0.08 }
  );
  items.forEach((el) => observer.observe(el));
  return () => observer.disconnect();
}

Object.assign(window, {
  MC_CONFIG,
  mcAsset,
  MC_ASSETS,
  MC_PHOTO_BRIEFS,
  MC_SERVICES,
  MC_NAV_LINKS,
  MC_ICON_SHAPES,
  MCIcon,
  MCSparkle,
  MCStamp,
  MCImageSlot,
  MC_DUSTY_ART,
  MCDusty,
  MCLogo,
  MCPh,
  MCEyebrow,
  mcPrefersReducedMotion,
  mcScrollToId,
  mcInitReveal,
});
