/* ==========================================================================
   Hero.jsx | 02 Hero
   Oversized headline with a one-off load sequence, an arch-framed interior
   photo against a purple moon, Dusty and a Dusty-approved stamp.
   ========================================================================== */

// The headline slowly swaps one word: "mess" fades into "dust" (Dusty's
// favourite), then back. Screen readers always get "We make the mess
// disappear." ("dust" is hidden).
const MC_HERO_LINES = [
  { key: 'we-make', text: 'We make' },
  {
    key: 'the-mess',
    text: (
      <>
        the{' '}
        <span className="mc-hero__swap">
          <span className="mc-hero__mess mc-anim">mess</span>
          <span className="mc-hero__dust mc-anim" aria-hidden="true">
            dust
          </span>
        </span>
      </>
    ),
  },
  {
    key: 'disappear',
    text: (
      <span className="mc-hero__disappear mc-anim">
        disappear
        <span className="mc-sr">.</span>
        <MCIcon name="sparkle" className="mc-hero__dot mc-anim" />
      </span>
    ),
  },
];

function MCHero({ onIntent, onDetails }) {
  const handleBook = (event) => {
    event.preventDefault();
    onIntent('book');
  };

  return (
    <section className="mc-hero" id="top" aria-labelledby="mc-hero-title">
      <div className="mc-wrap mc-hero__grid">
        <div className="mc-hero__copy">
          <MCEyebrow className="mc-hero__label" icon="pin">
            Cleaning services in Sydney
          </MCEyebrow>

          <h1 className="mc-hero__title" id="mc-hero-title">
            {MC_HERO_LINES.map((line, index) => {
              const isLast = index === MC_HERO_LINES.length - 1;
              return (
                <span className="mc-hero__line" key={line.key}>
                  <span className="mc-hero__lineinner" style={{ '--i': index }}>
                    {line.text}
                    {isLast ? null : ' '}
                  </span>
                </span>
              );
            })}
          </h1>

          <p className="mc-hero__lede">
            From everyday house cleaning to end-of-lease cleans, we help make your spaces feel fresh, comfortable and
            cared for.
          </p>

          <div className="mc-hero__ctas">
            <a href="#quote" className="mc-btn mc-btn--fluid" onClick={handleBook}>
              Book a clean
              <MCIcon name="sparkle" className="mc-btn__spark" />
            </a>
            <a href="#services" className="mc-btn mc-btn--ghost mc-btn--fluid">
              Explore our services
            </a>
          </div>

          <ul className="mc-hero__services" role="list" aria-label="Our cleaning services">
            {MC_SERVICES.map((service) => (
              <li key={service.id}>
                <a href="#details" className={`mc-chip mc-acc-${service.accent}`} onClick={() => onDetails(service.id)}>
                  <span className="mc-chip__icon">
                    <MCIcon name={service.icon} />
                  </span>
                  {service.short}
                </a>
              </li>
            ))}
          </ul>
        </div>

        <div className="mc-hero__visual">
          <span className="mc-hero__moon mc-deco" aria-hidden="true" />
          <MCIcon name="moon" className="mc-hero__crescent mc-deco mc-deco-optional" />
          <div className="mc-hero__arch">
            <MCImageSlot photoKey="hero" align="center" eager sizes="(max-width: 860px) 90vw, 40vw" />
          </div>
          <span className="mc-hero__dusty">
            <span className="mc-dusty-breathe mc-anim">
              <MCDusty />
            </span>
          </span>
          <MCStamp className="mc-hero__stamp" text="Leave it to Dusty ✦ A lot of clean ✦ " />
          <MCSparkle className="mc-hero__spark mc-hero__spark--1" />
          <MCSparkle className="mc-hero__spark mc-hero__spark--2" extra />
          <MCSparkle className="mc-hero__spark mc-hero__spark--3" extra />
        </div>
      </div>
    </section>
  );
}

Object.assign(window, { MCHero });
