/* global React */
const HEADLINES = {
  faith_filled: { text: 'A faith-filled hair stylist, in a peaceful private suite.', emphasis: 'peaceful' },
  rooted_in_grace: { text: 'A salon rooted in grace.', emphasis: 'grace' },
  peaceful_chair: { text: 'A peaceful chair, with faith at its heart.', emphasis: 'peaceful' },
  quiet_hour: { text: 'Your quiet hour, in a faith-filled suite.', emphasis: 'quiet' },
  small_on_purpose: { text: 'Small on purpose. Faith-filled by nature.', emphasis: 'Faith-filled' },
  come_as_you_are: { text: 'Come as you are. Leave a little lighter.', emphasis: 'lighter' },
};

const SUBHEADS = {
  quiet_pace: 'A quiet, private suite. By appointment only, with a calmer pace.',
  one_guest: 'A private suite where it\u2019s just you and Kallie. No crowded floor, no rushing.',
  faith_kindness: 'A small, faith-rooted salon for women who want quiet hospitality and skilled hands.',
  unhurried: 'An unhurried hair appointment. Real conversation, gentle care, no pressure.',
  invitation: 'Pull up a chair. Stay a while. Leave feeling tended to.',
  no_pressure: 'A peaceful place to sit, talk, or simply rest. No preaching, no pressure.',
  warm_welcome: 'Warm welcomes, gentle hands, and time to actually breathe.',
  sanctuary: 'A small sanctuary in Sarasota for honest conversation and beautiful hair.',
  by_design: 'Small by design, kind by default. One guest at a time.',
  morning_light: 'Soft morning light, hot tea, and your hair in good hands.',
  hospitality: 'Hospitality first. Skilled hands, an open chair, and all the time you need.',
  intentional: 'Intentional, unhurried hair care for women who value quiet over quick.',
  good_company: 'Good hair, good company, and a quiet hour to yourself.',
  bring_yourself: 'Bring yourself, bring your hair, bring whatever\u2019s on your mind.',
  slow_morning: 'A slow morning, a single chair, and someone glad you came.',
  rest_chair: 'A chair to rest in, hands you can trust, and grace through the whole appointment.',
  faith_at_work: 'Faith at work in small, kind ways. A private suite for women in Sarasota.',
  not_just_hair: 'It\u2019s not just hair. It\u2019s an hour where someone tends to you.',
};

function renderHeadline(text, emphasis) {
  if (!emphasis) return text;
  const idx = text.toLowerCase().indexOf(emphasis.toLowerCase());
  if (idx < 0) return text;
  const before = text.slice(0, idx);
  const match = text.slice(idx, idx + emphasis.length);
  const after = text.slice(idx + emphasis.length);
  return <React.Fragment>{before}<em style={{ fontStyle: 'italic' }}>{match}</em>{after}</React.Fragment>;
}

function Hero({ onBook, headlineKey = 'faith_filled', subheadKey = 'quiet_pace' }) {
  const Btn = window.GFH_Button;
  const Eyebrow = window.GFH_Eyebrow;
  const h = HEADLINES[headlineKey] || HEADLINES.faith_filled;
  const sub = SUBHEADS[subheadKey] || SUBHEADS.quiet_pace;
  return (
    <section style={{ maxWidth: 1180, margin: '0 auto', padding: '72px 24px 56px' }}>
      <div className="gfh-hero" style={{
        display: 'grid', gridTemplateColumns: '1fr 1.15fr', gap: 56, alignItems: 'center',
      }}>
        <div>
          <Eyebrow>Sarasota &amp; Lakewood Ranch · Florida</Eyebrow>
          <h1 style={{
            fontFamily: "'Cormorant Garamond', serif",
            fontSize: 60, lineHeight: 1.08,
            color: '#3D2F22', fontWeight: 500,
            letterSpacing: '-0.01em', margin: '20px 0 22px', textWrap: 'balance',
          }}>
            {renderHeadline(h.text, h.emphasis)}
          </h1>
          <p style={{
            fontFamily: "'Cormorant Garamond',serif", fontSize: 23, lineHeight: 1.45,
            color: '#2E2A26', fontStyle: 'italic', fontWeight: 400,
            margin: '0 0 24px', maxWidth: 520, textWrap: 'pretty',
          }}>
            {sub}
          </p>
          <div style={{ display: 'flex', gap: 12, flexWrap: 'wrap', marginBottom: 24 }}>
            <Btn as="a" href="book.html" size="lg">Book your visit</Btn>
            <Btn as="a" href="services.html" variant="outlined" size="lg">See the services</Btn>
          </div>
        </div>
        <div style={{ position: 'relative' }}>
          <div style={{ width: '100%', aspectRatio: '4 / 5', borderRadius: 8, overflow: 'hidden', display: 'block' }}
               dangerouslySetInnerHTML={{ __html: `<image-slot id="home-hero-photo" shape="rounded" radius="8" placeholder="Drop a hero photo here" style="display:block;width:100%;height:100%;"></image-slot>` }}/>
          <img src="assets/sprig-corner.svg" alt=""
               style={{ position: 'absolute', top: -28, right: -16, width: 96, opacity: 0.85, transform: 'scaleX(-1)', pointerEvents: 'none' }}/>
        </div>
      </div>
    </section>
  );
}

window.GFH_Hero = Hero;
window.GFH_HEADLINES = HEADLINES;
window.GFH_SUBHEADS = SUBHEADS;
