/* ============================================================
   Rainbow Group — sections.jsx
   Home body sections: Manifesto, Numbers, Work, Services,
   Clients, Testimonials, Leadership, Contact (+inline footer).
   Per DESIGN-SYSTEM.md §5.6–5.13.
   ============================================================ */

const { useState: useStateSx, useEffect: useEffectSx, useRef: useRefSx } = React;

/* ---------- PROJECTS data (home Work) ---------- */
const PROJECTS = [
  { id: '001', name: 'Haute Dolci', nameAr: 'هوت دولچي',  year: '2025', loc: 'Kuwait',   scope: 'Facade · GRG dome · Joinery', type: 'Hospitality', href: 'Haute Dolci - Case Study.html',
    imgs: ['assets/projects/hot-dolce-3.jpeg','assets/projects/hot-dolce-1.jpeg','assets/projects/hot-dolce-2.jpeg','assets/projects/hot-dolce-4.jpeg','assets/projects/hot-dolce-5.jpeg'] },
  { id: '002', name: 'Tamdeen Square',              nameAr: 'تمدين سكوير',  year: '2022', loc: 'Salmiya',  scope: 'Fit-out · Joinery',           type: 'Residential', href: 'Tamdeen Square - Case Study.html',
    imgs: ['assets/projects/tamdeen-square.jpg','assets/projects/tamdeen-square-2.jpg','assets/projects/tamdeen-3.jpg','assets/projects/tamdeen-4.jpg'] },
  { id: '003', name: 'Lexus Kuwait Showroom',       nameAr: 'صالة لكزس',    year: '2021', loc: 'Shuwaikh', scope: 'Showroom fit-out',            type: 'Retail',      href: 'Lexus - Case Study.html',
    imgs: ['assets/projects/lexus.jpg','assets/projects/lexus-2.png','assets/projects/lexus-3.png'] },
  { id: '004', name: '360 Mall — Skylight Wing',     nameAr: '٣٦٠ مول',      year: '2023', loc: 'Zahra',    scope: 'Ceilings · Finishes',         type: 'Retail',      href: '360 Mall - Case Study.html',
    imgs: ['assets/projects/360-skylight.png','assets/projects/360-mall.jpg','assets/projects/360-3.png'] },
  { id: '005', name: 'Siddiqa Fatima Zahra Mosque', nameAr: 'مسجد السيدة فاطمة الزهراء', year: '2020', loc: 'Mahboula', scope: 'GRG dome · Specialty paint', type: 'Religious',   href: 'Mosque - Case Study.html',
    imgs: ['assets/projects/fatima-zahra-mosque.png','assets/projects/mosque-2.jpg','assets/projects/mosque-3.webp'] },
  { id: '007', name: 'Four Points by Sheraton',      nameAr: 'فور بوينتس شيراتون', year: '2020', loc: 'Kuwait', scope: 'Hospitality fit-out',         type: 'Hospitality', href: '#007',
    imgs: ['assets/projects/four-points.jpg','assets/projects/four-points-2.jpg','assets/projects/four-points-3.jpg'] },
  { id: '008', name: 'Liwan Mall',                   nameAr: 'ليوان مول',    year: '2021', loc: 'Kuwait',   scope: 'Retail fit-out',              type: 'Retail',      href: '#008',
    imgs: ['assets/projects/liwan-mall.jpg'] },
  { id: '009', name: 'Gate Mall',                    nameAr: 'قيت مول',      year: '2022', loc: 'Egaila',   scope: 'Ceilings · Joinery',          type: 'Retail',      href: '#009',
    imgs: ['assets/projects/gate-mall.jpg','assets/projects/gate-mall-2.jpg','assets/projects/gate-mall-3.jpg'] },
];

/* ============================================================
   Manifesto (§01 sidecar under Heritage)
   ============================================================ */
function Manifesto() {
  const ref = useReveal();
  return (
    <section id="practice" ref={ref} className="reveal" style={{ background: 'var(--paper)', padding: '140px 0 120px' }}>
      <div className="wrap">
        <SectionHead idx="01" kicker="Manifesto · بيان" en="What we believe" ar="ما نؤمن به" />
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 2fr', gap: 64, alignItems: 'start' }} data-mobile-stack>
          <figure style={{ margin: 0, borderLeft: '3px solid var(--gold)', paddingLeft: 24 }}>
            <blockquote style={{ fontFamily: "'Fraunces', serif", fontStyle: 'italic', fontSize: 20, lineHeight: 1.45, color: 'var(--ink-2)', margin: 0 }}>
              "True luxury lies in the details. Our ethos is built on the intersection of Quality, Detail, and Efficiency — from logistical planning to the final brushstroke."
            </blockquote>
            <figcaption className="mono" style={{ marginTop: 20, color: 'var(--muted)' }}>— Asif Bhati, CEO</figcaption>
          </figure>
          <p className="display" style={{ fontSize: 'clamp(28px, 3.2vw, 52px)', lineHeight: 1.25 }}>
            A building is finished by a thousand <em style={{ color: 'var(--gold)', fontStyle: 'italic' }}>quiet decisions</em> — the radius of a plaster return, the joint between stone and wood, the temperature of a gold leaf. We keep those decisions with us so the architect&rsquo;s drawing survives the journey.
          </p>
        </div>
      </div>
    </section>
  );
}

/* ============================================================
   Numbers — dark with timelapse video bg
   ============================================================ */
function Numbers() {
  const ref = useReveal();
  return (
    <section ref={ref} className="reveal" style={{ background: 'var(--ink)', color: '#f3ede2', padding: '140px 0', position: 'relative', overflow: 'hidden' }}>
      <video
        src="assets/timelapse/timelapse.mp4"
        muted loop playsInline autoPlay preload="auto"
        aria-hidden="true"
        style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', opacity: 0.28, filter: 'saturate(0.5) contrast(1.1) brightness(0.75)', zIndex: 0 }}
      />
      <div style={{ position: 'absolute', inset: 0, background: 'linear-gradient(180deg, rgba(21,20,18,0.5) 0%, rgba(21,20,18,0.35) 50%, rgba(21,20,18,0.6) 100%)', zIndex: 1 }} aria-hidden="true" />
      <div className="wrap" style={{ position: 'relative', zIndex: 2 }}>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', marginBottom: 72, flexWrap: 'wrap', gap: 16 }}>
          <div className="eyebrow" style={{ color: 'rgba(243,237,226,0.6)' }}>By the numbers · بالأرقام</div>
          <div className="mono" style={{ color: 'rgba(243,237,226,0.5)', fontSize: 10 }}>RGCC ARCHIVE · TIMELAPSE LOOP</div>
        </div>
        <div className="numbers-grid" style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 40, alignItems: 'end' }} data-mobile-stack>
          <Stat num="500" suffix="+" label="Projects executed" ar="مشروع" dark />
          <Stat num="100" suffix="+" label="Multi-disciplined personnel" ar="موظف" dark />
          <Stat num="30"  suffix="+" label="Repeat institutional clients" ar="عميل" dark />
          <Stat num="25"  suffix="+" label="Years of compounded heritage" ar="عاماً" dark />
        </div>
      </div>
    </section>
  );
}

/* ============================================================
   Work — editorial index rows w/ floating image preview
   ============================================================ */
function Work() {
  const ref = useReveal();
  const [hover, setHover] = useStateSx(null);
  const [pos, setPos] = useStateSx({ x: 0, y: 0 });
  const [frame, setFrame] = useStateSx(0);
  const [isMobile, setIsMobile] = useStateSx(false);
  const timerRef = useRefSx(null);
  const rowRefs = useRefSx([]);

  /* Detect mobile viewport */
  useEffectSx(() => {
    const mq = window.matchMedia('(max-width: 900px)');
    const check = () => setIsMobile(mq.matches);
    check();
    if (mq.addEventListener) mq.addEventListener('change', check);
    else mq.addListener(check);
    return () => {
      if (mq.removeEventListener) mq.removeEventListener('change', check);
      else mq.removeListener(check);
    };
  }, []);

  /* Image frame cycling */
  useEffectSx(() => {
    if (hover === null) {
      if (timerRef.current) { clearInterval(timerRef.current); timerRef.current = null; }
      setFrame(0);
      return;
    }
    const imgs = PROJECTS[hover].imgs;
    timerRef.current = setInterval(() => {
      setFrame(f => (f + 1) % imgs.length);
    }, 900);
    return () => { if (timerRef.current) clearInterval(timerRef.current); };
  }, [hover]);

  /* Mobile: scroll-based activation.
     Find the project row whose vertical centre is closest to the upper-third
     focal zone of the viewport; activate its preview when within range.
     Clear once the section leaves view. */
  useEffectSx(() => {
    if (!isMobile) return;
    let raf = null;
    const compute = () => {
      raf = null;
      const vh = window.innerHeight;
      const focalY = vh * 0.42;
      let bestIdx = null;
      let bestDist = Infinity;
      for (let i = 0; i < PROJECTS.length; i++) {
        const el = rowRefs.current[i];
        if (!el) continue;
        const rect = el.getBoundingClientRect();
        if (rect.bottom < 0 || rect.top > vh) continue;
        const rowCentre = rect.top + rect.height / 2;
        const dist = Math.abs(rowCentre - focalY);
        if (dist < bestDist) { bestDist = dist; bestIdx = i; }
      }
      // Focal band ≈ 30 % of viewport height around focalY
      if (bestIdx !== null && bestDist < vh * 0.30) setHover(bestIdx);
      else setHover(null);
    };
    const onScroll = () => { if (raf == null) raf = requestAnimationFrame(compute); };
    window.addEventListener('scroll', onScroll, { passive: true });
    window.addEventListener('resize', onScroll);
    compute();
    return () => {
      window.removeEventListener('scroll', onScroll);
      window.removeEventListener('resize', onScroll);
      if (raf != null) cancelAnimationFrame(raf);
    };
  }, [isMobile]);

  return (
    <section id="work" ref={ref} className="reveal" style={{ background: 'var(--paper-2)', padding: '140px 0 120px', position: 'relative' }}>
      <div className="wrap"
           onMouseLeave={isMobile ? undefined : () => setHover(null)}
           onMouseMove={isMobile ? undefined : (e) => setPos({ x: e.clientX, y: e.clientY })}>
        <SectionHead idx="02" kicker="Selected work · أعمال مختارة" en="Eight of five hundred" ar="ثمانيةٌ من خمسمائة" />
        <div className="work-hint" style={{ display: 'flex', alignItems: 'baseline', gap: 8, marginBottom: 20, paddingBottom: 16, borderBottom: '1px solid var(--rule)' }}>
          <span className="mono" style={{ color: 'var(--gold)', letterSpacing: '0.28em', fontSize: 10, fontStyle: 'italic' }}>{isMobile ? 'Scroll' : 'Hover'}</span>
          <span className="hover-hint-arrow" style={{ color: 'var(--gold)', fontSize: 13, lineHeight: 1, display: 'inline-block' }}>{isMobile ? '↓' : '↘'}</span>
        </div>
        <div>
          {PROJECTS.map((p, i) => {
            const clickable = !p.href.startsWith('#');
            return (
              <a
                key={p.id}
                ref={(el) => { rowRefs.current[i] = el; }}
                href={p.href}
                data-cursor-label={clickable ? 'VIEW' : 'SOON'}
                className="work-row"
                style={{
                  display: 'grid',
                  gridTemplateColumns: '70px 1.4fr 1fr auto 1.2fr auto',
                  gap: 24, padding: '28px 0',
                  borderTop: i === 0 ? 'none' : '1px solid var(--rule)',
                  borderBottom: i === PROJECTS.length - 1 ? '1px solid var(--rule)' : 'none',
                  opacity: hover !== null && hover !== i ? 0.35 : 1,
                  transition: 'opacity 0.35s ease',
                  alignItems: 'baseline',
                  color: 'inherit',
                }}
              >
                <span className="mono" style={{ color: 'var(--muted)' }}>{p.id}</span>
                <div
                  onMouseEnter={isMobile ? undefined : () => setHover(i)}
                  onMouseLeave={isMobile ? undefined : () => setHover(null)}
                  data-cursor-label={clickable ? 'PREVIEW' : 'SOON'}
                  style={{
                    position: 'relative',
                    display: 'inline-block',
                    paddingBottom: 2,
                    borderBottom: hover === i ? '1px solid var(--gold)' : '1px solid transparent',
                    transition: 'border-color 0.3s ease',
                  }}
                >
                  <span className="display" style={{ fontSize: 'clamp(22px, 2.2vw, 32px)' }}>
                    {p.name}
                    {clickable ? <span style={{ color: 'var(--gold)', fontSize: '0.7em', marginLeft: 8 }}>↗</span> : null}
                  </span>
                  <div className="ar" style={{ fontSize: 16, color: 'var(--muted)', marginTop: 4 }}>{p.nameAr}</div>
                </div>
                <span style={{ fontSize: 13, color: 'var(--ink-2)' }}>{p.loc}</span>
                <span className="mono" style={{ color: 'var(--muted)', textAlign: 'right' }}>{p.type}</span>
                <span style={{ fontSize: 13, fontStyle: 'italic', fontFamily: "'Fraunces', serif", color: 'var(--ink-2)', textAlign: 'right' }}>{p.scope}</span>
                <span className="mono work-row__cta" style={{ fontSize: 10, textAlign: 'right', color: clickable ? 'var(--gold)' : 'rgba(0,0,0,0.2)' }}>
                  {clickable ? 'View case study →' : 'On request'}
                </span>
              </a>
            );
          })}
        </div>

        <div style={{ marginTop: 48, display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: 16 }}>
          <span className="mono" style={{ color: 'var(--muted)' }}>Showing 8 of 500+ — full portfolio on request</span>
          <a href="#contact" className="btn" data-cursor-label="Write">Request full portfolio <span className="arrow">→</span></a>
        </div>
      </div>

      {/* Floating preview — portaled to body so the transformed .reveal ancestor
          doesn't act as a containing block and position: fixed actually obeys the viewport.
          Desktop: follows the cursor with a tilt.
          Mobile: pinned to the upper-right, smaller, untilted. */}
      {hover !== null && typeof document !== 'undefined'
        ? ReactDOM.createPortal(
            <div
              key={`preview-${hover}`}
              style={{
                position: 'fixed',
                pointerEvents: 'none',
                zIndex: 50,
                border: '1px solid rgba(0,0,0,0.05)',
                background: 'var(--ink-2)',
                overflow: 'hidden',
                ...(isMobile
                  ? {
                      top: 80,
                      right: 16,
                      width: 140,
                      height: 188,
                      boxShadow: '0 18px 36px rgba(21,20,18,0.35)',
                      animation: 'work-preview-pop 0.35s cubic-bezier(.2,.7,.2,1) both',
                    }
                  : {
                      left: pos.x + 24,
                      top: pos.y - 220,
                      width: 340,
                      height: 440,
                      transform: 'rotate(-2deg)',
                      boxShadow: '0 30px 60px rgba(0,0,0,0.35)',
                    }),
              }}
            >
              <img
                src={PROJECTS[hover].imgs[frame % PROJECTS[hover].imgs.length]}
                alt=""
                style={{ width: '100%', height: '100%', objectFit: 'cover' }}
              />
              <div className="mono" style={{ position: 'absolute', bottom: 10, left: 10, right: 10, color: '#f3ede2', fontSize: isMobile ? 8 : 9, letterSpacing: '0.2em', textShadow: '0 1px 2px rgba(0,0,0,0.45)' }}>
                {PROJECTS[hover].id} · {PROJECTS[hover].loc}
              </div>
            </div>,
            document.body
          )
        : null}
    </section>
  );
}

/* ============================================================
   Services — 5 columns
   ============================================================ */
const SERVICES_DATA = [
  { n: '01', en: 'Acoustic & Ceilings',   ar: 'الأسقف والصوتيات', items: ['Acoustical ceilings', 'Perforated wood ceilings', 'Gypsum, GRG & GRC works'] },
  { n: '02', en: 'Wall Solutions',         ar: 'حلول الجدران',     items: ['EFS', 'Exterior facades', 'Stone cladding & ceramic', 'Wall panels', 'Gypsum, GRG & GRC works'] },
  { n: '03', en: 'Flooring',                ar: 'الأرضيات',         items: ['Luxury vinyl tiles (LVT)', 'Carpet tiles', 'Raised access floors', 'Natural & composite stone', 'Epoxy'] },
  { n: '04', en: 'Architectural Interiors', ar: 'التصميم الداخلي',  items: ['Demountable partitions', 'Wood works & joinery', 'Interior moss walls', 'Furniture', 'Toilet fixtures'] },
  { n: '05', en: 'Specialised Finishes',    ar: 'تشطيبات خاصة',     items: ['Ventilated facade (fibre cement)', 'Interior painting', 'Antique gold / silver painting'] },
];

function Services() {
  const ref = useReveal();
  return (
    <section id="services" ref={ref} className="reveal" style={{ background: 'var(--paper)', padding: '140px 0 120px' }}>
      <div className="wrap">
        <SectionHead idx="03" kicker="Capabilities · القدرات" en="The finishing trades" ar="مِهَنُ التشطيب" />
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(5, 1fr)', gap: 0, borderTop: '1px solid var(--rule)' }} data-mobile-stack>
          {SERVICES_DATA.map((s, i) => (
            <div key={s.n} style={{
              padding: '32px 24px 40px',
              borderRight: i < SERVICES_DATA.length - 1 ? '1px solid var(--rule)' : 'none',
              borderBottom: '1px solid var(--rule)',
              minHeight: 320,
              display: 'flex', flexDirection: 'column',
            }}>
              <div className="mono" style={{ color: 'var(--muted)', marginBottom: 24 }}>{s.n}</div>
              <div className="display" style={{ fontSize: 24, marginBottom: 8 }}>{s.en}</div>
              <div className="ar" style={{ fontSize: 14, color: 'var(--muted)', marginBottom: 24 }}>{s.ar}</div>
              <ul style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
                {s.items.map((it) => (
                  <li key={it} style={{ fontSize: 13, color: 'var(--ink-2)', display: 'flex', gap: 10, alignItems: 'baseline' }}>
                    <span style={{ color: 'var(--gold)', fontSize: 8 }}>◆</span> <span>{it}</span>
                  </li>
                ))}
              </ul>
            </div>
          ))}
        </div>
        <div style={{ display: 'grid', gridTemplateColumns: '1fr auto', gap: 40, alignItems: 'center', marginTop: 40 }} data-mobile-stack>
          <p style={{ color: 'var(--ink-2)', fontSize: 15, lineHeight: 1.65, maxWidth: '66ch', margin: 0 }}>
            Every trade above is delivered in-house or through long-term partnerships with <strong style={{ fontWeight: 500 }}>Knauf, Mannington, Recer Cerâmica, Sitab</strong> and <strong style={{ fontWeight: 500 }}>Strähle</strong> — product partners we have worked with for a decade.
          </p>
          <a href="#contact" className="btn" data-cursor-label="Write">Discuss scope <span className="arrow">→</span></a>
        </div>

        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', marginTop: 56, gap: 16, flexWrap: 'wrap' }}>
          <span className="eyebrow">Product partners · شركاء المنتج</span>
          <span className="mono" style={{ color: 'var(--muted)', fontSize: 10 }}>In trade since 2008 · hover to pause</span>
        </div>
        <div className="partner-ribbon" aria-label="Product partners">
          <div className="partner-ribbon__track">
            {/* One pass */}
            <div className="partner-ribbon__item"><img src="assets/partners/knauf.png" alt="Knauf AMF" /></div>
            <div className="partner-ribbon__item"><img src="assets/partners/mannington.webp" alt="Mannington" /></div>
            <div className="partner-ribbon__item"><img src="assets/partners/recer-ceramica.png" alt="Recer Cerâmica" /></div>
            <div className="partner-ribbon__item"><img src="assets/partners/sitab.png" alt="Sitab" /></div>
            <div className="partner-ribbon__item"><img src="assets/partners/straehle.png" alt="Strähle" /></div>
            {/* Duplicate pass for seamless loop */}
            <div className="partner-ribbon__item" aria-hidden="true"><img src="assets/partners/knauf.png" alt="" /></div>
            <div className="partner-ribbon__item" aria-hidden="true"><img src="assets/partners/mannington.webp" alt="" /></div>
            <div className="partner-ribbon__item" aria-hidden="true"><img src="assets/partners/recer-ceramica.png" alt="" /></div>
            <div className="partner-ribbon__item" aria-hidden="true"><img src="assets/partners/sitab.png" alt="" /></div>
            <div className="partner-ribbon__item" aria-hidden="true"><img src="assets/partners/straehle.png" alt="" /></div>
          </div>
        </div>
      </div>
    </section>
  );
}

/* ============================================================
   Clients — dark grid
   ============================================================ */
const CLIENT_LOGOS = [
  { name: 'Al Shaya',             file: 'alshaya.png' },
  { name: 'Tamdeen',              file: 'tamdeen.png' },
  { name: 'JW Marriott',          file: 'jw-marriott.png' },
  { name: 'Lexus',                file: 'lexus.png' },
  { name: 'AGI Architects',       file: 'agi.png' },
  { name: 'M.A. Kharafi & Sons',  file: 'kharafi.png' },
  { name: 'Ahmadiah Contracting', file: 'ahmadiah.png' },
  { name: 'Lulu Group',           file: 'lulu.png' },
  { name: 'Holiday Inn',          file: 'holiday-inn.png' },
  { name: 'CGC Kuwait',           file: 'cgc.png' },
];

function Clients() {
  const ref = useReveal();
  return (
    <section id="clients" ref={ref} className="reveal" style={{ background: 'var(--ink)', color: '#f3ede2', padding: '140px 0 120px' }}>
      <div className="wrap">
        <div style={{ marginBottom: 56 }}>
          <div className="eyebrow" style={{ color: 'rgba(243,237,226,0.5)', marginBottom: 8 }}>Clients · عملاء</div>
          <h2 className="display" style={{ fontSize: 'clamp(40px, 5.5vw, 84px)', color: '#f3ede2' }}>
            Trusted by thirty houses <em style={{ color: 'var(--gold-hi)', fontStyle: 'italic' }}>in the Gulf</em>.
          </h2>
        </div>

        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(5, 1fr)', gap: 0, border: '1px solid rgba(243,237,226,0.15)' }} data-mobile-stack>
          {CLIENT_LOGOS.map((c, i) => (
            <div key={c.file} style={{
              aspectRatio: '3 / 2',
              display: 'flex', alignItems: 'center', justifyContent: 'center',
              padding: 20,
              position: 'relative',
              borderRight: (i + 1) % 5 !== 0 ? '1px solid rgba(243,237,226,0.15)' : 'none',
              borderBottom: i < 5 ? '1px solid rgba(243,237,226,0.15)' : 'none',
            }}>
              <span className="mono" style={{ position: 'absolute', top: 10, left: 12, fontSize: 9, color: 'rgba(243,237,226,0.35)' }}>{`0${(i % 9) + 1}`}</span>
              <img src={`assets/clients/${c.file}`} alt={c.name}
                   style={{ maxWidth: '75%', maxHeight: 60, width: 'auto', height: 'auto', filter: 'invert(1) grayscale(1) brightness(1.2)', opacity: 0.8 }} />
            </div>
          ))}
        </div>

        <p style={{ marginTop: 40, color: 'rgba(243,237,226,0.6)', fontSize: 13, lineHeight: 1.7, columnCount: 2, columnGap: 40, maxWidth: 1100 }}>
          Also engaged by: Ministry of Finance · AGI Architects · Sayed Hamid Behbihani &amp; Sons · The Sultan Center · The Interior Collaboratives · First United · Al Yousifi · UPS Kuwait · Symphony Hotel · Grand Hyatt · Al Rasheed Group · Sheikh Mubarak Al Sabah Estate · Gassan Al Khalid Residential · and more.
        </p>
      </div>
    </section>
  );
}

/* ============================================================
   Testimonials
   ============================================================ */
function Testimonials() {
  const ref = useReveal();
  const QUOTES = [
    { quote: 'Attention to detail and quality is exemplary for all others in the business.', name: 'Sameh Elashry', role: 'Project Manager', project: 'First United · Ministry Complex' },
    { quote: 'Takes their work very seriously, executing with precision and meeting quality standards.', name: 'Tarek Najia',  role: 'Project Manager', project: 'The Sultan Center · SC Ahmadi' },
    { quote: 'Completed the project to our full satisfaction. We wish them all the best for the future.', name: 'Krishnakumar', role: 'Ahmadiah Contracting & Trading', project: 'Tower Fit-out' },
  ];
  return (
    <section ref={ref} className="reveal" style={{ background: 'var(--paper)', padding: '140px 0 120px' }}>
      <div className="wrap">
        <SectionHead idx="05" kicker="Words · كلمات" en="What they said" ar="ما قالوه" />
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 48 }} data-mobile-stack>
          {QUOTES.map((q) => (
            <figure key={q.name} style={{ borderTop: '1px solid var(--ink)', padding: '32px 0', margin: 0 }}>
              <div className="mono" style={{ color: 'var(--gold)', marginBottom: 20 }}>— {q.project}</div>
              <blockquote className="display italic" style={{ fontSize: 'clamp(22px, 2vw, 30px)', lineHeight: 1.3, margin: 0 }}>{q.quote}</blockquote>
              <figcaption style={{ marginTop: 28 }}>
                <div style={{ fontWeight: 500, fontSize: 15 }}>{q.name}</div>
                <div className="mono" style={{ color: 'var(--muted)', marginTop: 4 }}>{q.role}</div>
              </figcaption>
            </figure>
          ))}
        </div>
      </div>
    </section>
  );
}

/* ============================================================
   Leadership — 4 cards
   ============================================================ */
const TEAM = [
  { name: 'Asif Bhati',      ar: 'آصف بھاٹی',   role: 'Chief Executive Officer',     years: '25', init: 'AB' },
  { name: 'Rizwan Bhati',    ar: 'رضوان بھاٹی', role: 'General Manager',              years: '18', init: 'RB' },
  { name: 'George Paul',     ar: 'جورج بول',   role: 'Director',                     years: '20', init: 'GP' },
];

function Leadership() {
  const ref = useReveal();
  return (
    <section ref={ref} className="reveal" style={{ background: 'var(--paper-2)', padding: '140px 0 120px' }}>
      <div className="wrap">
        <SectionHead idx="06" kicker="Strategic leadership · القيادة" en="Three who carry the firm" ar="ثلاثةٌ يحملون الشركة" />
        <div style={{ display: 'grid', gridTemplateColumns: `repeat(${TEAM.length}, 1fr)`, gap: 24 }} data-mobile-stack>
          {TEAM.map((t, i) => (
            <div key={t.name} style={{ background: 'var(--paper)', padding: 28, minHeight: 380, border: '1px solid var(--rule)', display: 'flex', flexDirection: 'column', justifyContent: 'space-between' }}>
              <div>
                <div className="mono" style={{ color: 'var(--muted)', marginBottom: 20 }}>{`0${i + 1} / 0${TEAM.length}`}</div>
                <div className="leadership-portrait" style={{ width: 120, height: 160, background: 'linear-gradient(135deg, var(--ink-2), var(--ink))', display: 'flex', alignItems: 'center', justifyContent: 'center', position: 'relative' }}>
                  <span className="mono" style={{ position: 'absolute', top: 10, left: 10, color: 'rgba(243,237,226,0.4)', fontSize: 8 }}>PORTRAIT</span>
                  <span style={{ fontFamily: "'Fraunces', serif", fontStyle: 'italic', fontSize: 48, color: 'var(--gold-hi)' }}>{t.init}</span>
                </div>
              </div>
              <div>
                <div style={{ fontFamily: "'Fraunces', serif", fontSize: 22, lineHeight: 1.1 }}>{t.name}</div>
                <div className="ar" style={{ fontSize: 14, color: 'var(--muted)', marginTop: 4 }}>{t.ar}</div>
                <div style={{ fontSize: 13, color: 'var(--ink-2)', marginTop: 8 }}>{t.role}</div>
                <div className="mono" style={{ color: 'var(--gold)', marginTop: 14, fontSize: 11 }}>{t.years} years in the trade</div>
              </div>
            </div>
          ))}
        </div>
        <p className="mono" style={{ color: 'var(--muted)', marginTop: 32, maxWidth: '80ch' }}>
          Supported by site engineers, safety supervisors, and skilled tradesmen — 100+ personnel across all active sites.
        </p>
      </div>
    </section>
  );
}

/* ============================================================
   Local FooterCol helper (home-only; shared-chrome has its own)
   ============================================================ */
function FooterColH({ title, items }) {
  return (
    <div>
      <div className="mono" style={{ color: 'rgba(243,237,226,0.5)', marginBottom: 18 }}>{title}</div>
      <ul style={{ display: 'flex', flexDirection: 'column', gap: 8, fontSize: 13 }}>
        {items.map((it) => (
          <li key={it.label}>
            {it.href
              ? <a href={it.href} style={{ color: 'rgba(243,237,226,0.8)', transition: 'color 0.3s ease' }}>{it.label}</a>
              : <span style={{ color: 'rgba(243,237,226,0.8)' }}>{it.label}</span>}
          </li>
        ))}
      </ul>
    </div>
  );
}

/* ============================================================
   Contact + inline footer (home §07)
   ============================================================ */
function Field({ label, ar, value, onChange, type = 'text', textarea = false }) {
  const [focus, setFocus] = useStateSx(false);
  return (
    <label style={{ display: 'block', padding: '22px 0', borderBottom: '1px solid rgba(243,237,226,0.2)', cursor: 'text' }}>
      <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', marginBottom: 10 }}>
        <span className="mono" style={{ color: focus ? 'var(--gold-hi)' : 'rgba(243,237,226,0.55)', transition: 'color 0.3s ease' }}>{label}</span>
        <span className="ar" style={{ fontSize: 12, color: 'rgba(243,237,226,0.45)' }}>{ar}</span>
      </div>
      {textarea
        ? <textarea rows={3} value={value} onChange={(e) => onChange(e.target.value)} onFocus={() => setFocus(true)} onBlur={() => setFocus(false)} style={{ width: '100%', background: 'transparent', border: 0, color: '#f3ede2', fontSize: 18, fontFamily: 'inherit', lineHeight: 1.5, outline: 'none', resize: 'none' }} />
        : <input type={type} value={value} onChange={(e) => onChange(e.target.value)} onFocus={() => setFocus(true)} onBlur={() => setFocus(false)} style={{ width: '100%', background: 'transparent', border: 0, color: '#f3ede2', fontSize: 18, fontFamily: 'inherit', outline: 'none' }} />
      }
    </label>
  );
}

function Contact() {
  const ref = useReveal();
  const [name, setName] = useStateSx('');
  const [email, setEmail] = useStateSx('');
  const [brief, setBrief] = useStateSx('');
  const [sent, setSent] = useStateSx(false);

  const onSubmit = (e) => { e.preventDefault(); setSent(true); };

  return (
    <section id="contact" ref={ref} className="reveal" style={{ background: 'var(--ink)', color: '#f3ede2', padding: '140px 0 48px', position: 'relative', overflow: 'hidden' }}>
      <div className="giant-outline" aria-hidden="true">Rainbow</div>
      <div className="wrap" style={{ position: 'relative', zIndex: 2 }}>
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 80 }} data-mobile-stack>
          <div>
            <div className="eyebrow" style={{ color: 'rgba(243,237,226,0.55)', marginBottom: 8 }}>Commence a project</div>
            <h2 className="display" style={{ fontSize: 'clamp(44px, 5.5vw, 88px)', color: '#f3ede2' }}>
              Write to us.<br/>
              <em style={{ color: 'var(--gold-hi)', fontStyle: 'italic' }}>We read</em><br/>
              each one.
            </h2>
            <div className="ar" style={{ fontSize: 28, color: 'rgba(243,237,226,0.6)', marginTop: 20 }}>اكتبوا لنا. نقرأُ كلَّ رسالة.</div>

            <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 48, marginTop: 56, paddingTop: 32, borderTop: '1px solid rgba(243,237,226,0.2)' }}>
              <div>
                <div className="mono" style={{ color: 'rgba(243,237,226,0.55)', marginBottom: 10 }}>Office</div>
                <div style={{ fontFamily: "'Fraunces', serif", fontSize: 16, lineHeight: 1.5 }}>
                  B1 Suad Complex,<br/>
                  Fahad Al Salam Street,<br/>
                  Kuwait City, Kuwait
                </div>
              </div>
              <div>
                <div className="mono" style={{ color: 'rgba(243,237,226,0.55)', marginBottom: 10 }}>Direct</div>
                <div style={{ lineHeight: 1.6 }}>
                  <a href="mailto:info@rainbowgroup-kwt.com" style={{ borderBottom: '1px solid rgba(243,237,226,0.6)', color: '#f3ede2' }}>info@rainbowgroup-kwt.com</a><br/>
                  <span style={{ color: 'rgba(243,237,226,0.9)' }}>+965 · 2241 0045</span>
                </div>
              </div>
            </div>
          </div>

          <form onSubmit={onSubmit} style={{ borderTop: '1px solid rgba(243,237,226,0.25)', paddingTop: 18 }}>
            <div className="mono" style={{ color: 'rgba(243,237,226,0.5)', marginBottom: 6 }}>Enquiry form</div>
            <Field label="Name" ar="الاسم"  value={name}  onChange={setName}  />
            <Field label="Email" ar="البريد" value={email} onChange={setEmail} type="email" />
            <Field label="Project brief" ar="الموجز" value={brief} onChange={setBrief} textarea />
            <button type="submit" style={{
              marginTop: 32, padding: '22px 28px',
              background: sent ? 'var(--ink-2)' : 'var(--gold)',
              color: '#f3ede2', border: 0, fontFamily: "'Inter Tight', sans-serif",
              fontSize: 13, letterSpacing: '0.12em', textTransform: 'uppercase',
              cursor: sent ? 'default' : 'pointer',
              display: 'flex', alignItems: 'center', justifyContent: 'space-between', width: '100%',
              transition: 'background 0.4s ease',
            }}>
              <span>{sent ? 'Thank you — we will reply within 48 hours' : 'Send enquiry'}</span>
              <span>{sent ? '✓' : '→'}</span>
            </button>
          </form>
        </div>

        {/* Footer within section */}
        <div style={{ marginTop: 120, paddingTop: 40, borderTop: '1px solid rgba(243,237,226,0.2)' }}>
          <div style={{ display: 'grid', gridTemplateColumns: '2fr 1fr 1fr 1fr', gap: 40 }} data-mobile-stack>
            <div>
              <div style={{ display: 'flex', alignItems: 'center', gap: 14, marginBottom: 16 }}>
                <img src="assets/logo-icon.png" alt="RGCC" style={{ height: 44, width: 'auto' }} />
                <div>
                  <div className="display" style={{ fontSize: 20 }}>Rainbow Group Contracting Company W.L.L</div>
                  <div className="mono" style={{ color: 'rgba(243,237,226,0.5)', fontSize: 9, marginTop: 4 }}>RGCC · A Heritage of Excellence · Est. 2017</div>
                </div>
              </div>
              <div style={{ marginTop: 14, color: 'rgba(243,237,226,0.85)' }}>
                <SocialIcons variant="dark" />
              </div>
            </div>
            <FooterColH title="Navigate" items={[
              { label: 'Work',     href: 'Projects.html' },
              { label: 'Practice', href: 'About.html' },
              { label: 'Services', href: '#services' },
              { label: 'Clients',  href: '#clients' },
              { label: 'Contact',  href: '#contact' },
            ]} />
            <FooterColH title="Practice" items={[
              { label: 'Leadership', href: 'About.html#leadership' },
              { label: 'Ethos',      href: 'About.html#ethos' },
              { label: 'Press',      href: 'mailto:press@rainbowgroup-kwt.com' },
            ]} />
            <FooterColH title="Legal" items={[
              { label: 'Privacy',          href: '#' },
              { label: 'Terms',            href: '#' },
              { label: 'CR No. — Kuwait' },
              { label: '© 2026 RGCC' },
            ]} />
          </div>
          <div className="footer-legal" style={{ display: 'flex', justifyContent: 'space-between', flexWrap: 'wrap', gap: 16, marginTop: 40 }}>
            <span className="mono" style={{ color: 'rgba(243,237,226,0.45)' }}>N 29.3759° · E 47.9774°</span>
            <span className="mono" style={{ color: 'rgba(243,237,226,0.45)' }}>Drawn in Kuwait City</span>
          </div>
        </div>
      </div>
      <div className="rainbow-hair" style={{ position: 'absolute', inset: 'auto 0 0 0', zIndex: 3 }} />
    </section>
  );
}

Object.assign(window, { Manifesto, Numbers, Work, Services, Clients, Testimonials, Leadership, Contact, PROJECTS, SERVICES_DATA, CLIENT_LOGOS, TEAM });
