// site-sections.jsx — Liam & Rich homepage sections.
// Uses the Industrial Monogram (Lockup) brand: deep navy + rust + concrete + sand.

const LR = {
  navy: '#0d1f2a',
  navyDeep: '#081620',
  rust: '#d4773a',
  rustDeep: '#b85f25',
  sand: '#f0e8d8',
  sandLight: '#f7f1e3',
  concrete: '#c9b89c',
  concreteLight: '#e2d7c0',
  iron: '#4a5a6a',
  ironLight: '#7a8694',
};

function useResponsive() {
  const getViewport = () => ({
    isMobile: window.innerWidth < 760,
    isTablet: window.innerWidth >= 760 && window.innerWidth < 1024,
  });

  const [viewport, setViewport] = React.useState(getViewport);

  React.useEffect(() => {
    const onResize = () => setViewport(getViewport());
    window.addEventListener('resize', onResize);
    return () => window.removeEventListener('resize', onResize);
  }, []);

  return viewport;
}

// ─── Reusable: logomark for nav (smaller version) ──────────
function NavLogomark({ size = 36 }) {
  return (
    <svg width={size} height={size} viewBox="0 0 80 80" xmlns="http://www.w3.org/2000/svg">
      <rect x="0" y="0" width="80" height="80" fill="#0d1f2a"/>
      <path d="M10 10 H28 V58 H46 V70 H10 Z" fill="#d4773a"/>
      <path d="M40 10 H58 C66 10 72 17 72 26 C72 33 68 38 62 40 L72 70 H58 L50 44 H46 V70 H40 Z M46 22 V32 H54 C57 32 59 30 59 27 C59 24 57 22 54 22 Z" fill="#f0e8d8"/>
    </svg>
  );
}

function Wordmark({ display, weight = 700, size = 22, color = '#0d1f2a', spacing = -0.03 }) {
  return (
    <span style={{
      fontFamily: display, fontWeight: weight, fontSize: size,
      letterSpacing: `${spacing}em`, color, textTransform: 'uppercase',
      lineHeight: 1,
    }}>LIAM &amp; RICH</span>
  );
}

// ─── Section label ─────────────────────────────────────────
function SectionLabel({ children, mono, color = LR.rust }) {
  return (
    <div style={{
      fontFamily: mono, fontSize: 12, letterSpacing: 2.4, textTransform: 'uppercase',
      color, fontWeight: 600, marginBottom: 20,
      display: 'inline-flex', alignItems: 'center', gap: 10,
    }}>
      <span style={{ width: 24, height: 1, background: color }}></span>
      {children}
    </div>
  );
}

// ─── Sticky Nav ────────────────────────────────────────────
function Nav({ display, body, mono }) {
  const { isMobile, isTablet } = useResponsive();
  const links = ['How it works', 'What we claim', 'Pricing', 'Stories', 'FAQ'];
  return (
    <nav style={{
      position: 'sticky', top: 0, zIndex: 50,
      background: 'rgba(247,241,227,0.92)', backdropFilter: 'blur(8px)',
      borderBottom: `1px solid ${LR.concrete}66`,
      padding: isMobile ? '12px 20px' : '14px 48px',
      display: 'flex', alignItems: 'center', justifyContent: 'space-between',
      gap: isMobile ? 16 : 24,
      fontFamily: body,
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
        <NavLogomark size={isMobile ? 32 : 36} />
        <Wordmark display={display} size={isMobile ? 16 : 18} weight={700} />
      </div>
      <div style={{ display: isMobile || isTablet ? 'none' : 'flex', alignItems: 'center', gap: 36 }}>
        {links.map((l) => (
          <a key={l} href={`#${l.toLowerCase().replace(/ /g, '-')}`} style={{
            fontFamily: body, fontSize: 14, color: LR.navy, textDecoration: 'none',
            fontWeight: 500, letterSpacing: 0.1,
          }}>{l}</a>
        ))}
      </div>
      <div style={{ display: 'flex', alignItems: 'center', gap: isMobile ? 0 : 12 }}>
        <a href="#login" style={{
          fontFamily: body, fontSize: 14, color: LR.navy, textDecoration: 'none', fontWeight: 500,
          display: isMobile ? 'none' : 'inline',
        }}>Talk to us</a>
        <a href="#claim-review" style={{
          fontFamily: body, fontSize: isMobile ? 12 : 13, color: LR.sand, background: LR.navy,
          padding: isMobile ? '10px 12px' : '11px 20px', borderRadius: 2, textDecoration: 'none', fontWeight: 600,
          letterSpacing: 0.4,
          whiteSpace: 'nowrap',
        }}>{isMobile ? 'Start →' : 'Start a claim pack →'}</a>
      </div>
    </nav>
  );
}

// ─── Hero ──────────────────────────────────────────────────
function Hero({ display, body, mono }) {
  const { isMobile, isTablet } = useResponsive();
  return (
    <section style={{
      background: LR.sand,
      padding: isMobile ? '64px 20px 72px' : isTablet ? '80px 32px 96px' : '100px 48px 120px',
      position: 'relative', overflow: 'hidden',
    }}>
      {/* concrete grid bg */}
      <div style={{
        position: 'absolute', inset: 0,
        backgroundImage: `linear-gradient(${LR.concrete}26 1px, transparent 1px), linear-gradient(90deg, ${LR.concrete}26 1px, transparent 1px)`,
        backgroundSize: '64px 64px',
        maskImage: 'radial-gradient(circle at 50% 50%, black 30%, transparent 90%)',
        pointerEvents: 'none',
      }}></div>
      <div style={{
        maxWidth: 1280, margin: '0 auto', display: 'grid',
        gridTemplateColumns: isMobile || isTablet ? '1fr' : '1.4fr 1fr',
        gap: isMobile ? 40 : isTablet ? 56 : 80,
        alignItems: 'center', position: 'relative',
      }}>
        <div>
          <div style={{
            fontFamily: mono, fontSize: 12, letterSpacing: 2.4, textTransform: 'uppercase',
            color: LR.rust, fontWeight: 600, marginBottom: 28,
            display: 'inline-flex', alignItems: 'center', gap: 10,
            padding: '8px 14px', border: `1px solid ${LR.rust}55`, borderRadius: 2,
          }}>
            <span style={{ width: 6, height: 6, background: LR.rust, borderRadius: '50%' }}></span>
            For commercial subcontractors · Victoria first
          </div>
          <h1 style={{
            fontFamily: display, fontWeight: 700, fontSize: isMobile ? 52 : isTablet ? 72 : 96, lineHeight: 0.95,
            letterSpacing: '-0.04em', color: LR.navy, margin: 0, textTransform: 'uppercase',
            textWrap: 'balance',
          }}>
            Turn messy <span style={{ color: LR.rust }}>variation</span><br/>records into claim-ready<br/>evidence.
          </h1>
          <p style={{
            fontFamily: body, fontSize: isMobile ? 17 : 20, lineHeight: 1.5, color: LR.iron,
            marginTop: 32, maxWidth: 560,
          }}>
            Upload the emails, photos, drawings, diaries and messages behind a disputed variation.
            We organise chronology, deadlines and source evidence into a pack your team can review before sending.
          </p>
          <div style={{ display: 'flex', gap: 14, marginTop: 40, alignItems: 'center', flexWrap: 'wrap' }}>
            <a href="#claim-review" style={{
              fontFamily: body, fontSize: 15, color: LR.sand, background: LR.navy,
              padding: isMobile ? '16px 22px' : '18px 28px', borderRadius: 2, textDecoration: 'none', fontWeight: 600,
              letterSpacing: 0.4, textTransform: 'uppercase',
            }}>Start a claim pack →</a>
            <a href="#how-it-works" style={{
              fontFamily: body, fontSize: 15, color: LR.navy, background: 'transparent',
              padding: isMobile ? '16px 22px' : '18px 28px', borderRadius: 2, textDecoration: 'none', fontWeight: 600,
              letterSpacing: 0.4, textTransform: 'uppercase', border: `1.5px solid ${LR.navy}`,
            }}>How it works</a>
          </div>
          <div style={{
            marginTop: 36, fontFamily: mono, fontSize: 12, color: LR.iron, letterSpacing: 0.6,
            display: 'flex', gap: 28, flexWrap: 'wrap',
          }}>
            <span>✓ Source-linked evidence packs</span>
            <span>✓ Variations of any size</span>
            <span>✓ Not legal advice or entitlement decisions</span>
          </div>
        </div>

        {/* HERO SIDE: output preview card */}
        <div style={{
          background: LR.navy, color: LR.sand, padding: isMobile ? '26px 24px 24px' : '32px 32px 28px', borderRadius: 4,
          boxShadow: `0 30px 80px ${LR.navyDeep}55, 0 0 0 1px ${LR.navy}`,
          transform: isMobile ? 'none' : 'rotate(-1deg)',
        }}>
          <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 18 }}>
            <div style={{ fontFamily: mono, fontSize: 11, letterSpacing: 1.8, textTransform: 'uppercase', opacity: 0.7 }}>
              Example output preview
            </div>
            <div style={{
              fontFamily: mono, fontSize: 10, padding: '4px 9px', borderRadius: 2,
              background: LR.rust, color: LR.navy, letterSpacing: 1, textTransform: 'uppercase', fontWeight: 700,
            }}>Draft pack</div>
          </div>
          <div style={{
            fontFamily: display, fontWeight: 700, fontSize: 32, lineHeight: 1.05, letterSpacing: '-0.02em',
            textTransform: 'uppercase', marginBottom: 16,
          }}>Variation file<br/>structured for review</div>
          <div style={{ fontFamily: body, fontSize: 13, lineHeight: 1.5, opacity: 0.8, marginBottom: 20 }}>
            Chronology, contract clauses, notice dates, evidence links and missing-info flags in one auditable pack.
          </div>
          <div style={{ height: 1, background: `${LR.sand}22`, margin: '4px 0 18px' }}></div>
          <div style={{ display: 'grid', gridTemplateColumns: isMobile ? '1fr' : '1fr 1fr', gap: 16 }}>
            <div>
              <div style={{ fontFamily: mono, fontSize: 9, letterSpacing: 1.4, textTransform: 'uppercase', opacity: 0.6, marginBottom: 4 }}>
                Included
              </div>
              <div style={{ fontFamily: body, fontSize: 13, lineHeight: 1.4 }}>
                Timeline by date<br/>Evidence map by source<br/>Draft claim structure
              </div>
            </div>
            <div>
              <div style={{ fontFamily: mono, fontSize: 9, letterSpacing: 1.4, textTransform: 'uppercase', opacity: 0.6, marginBottom: 4 }}>
                Needs input
              </div>
              <div style={{ fontFamily: body, fontSize: 13, lineHeight: 1.4, color: `${LR.sand}cc` }}>
                Missing dayworks<br/>Instruction confirmations<br/>Final subcontract annexures
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─── Stats strip ───────────────────────────────────────────
function Stats({ display, body, mono }) {
  const { isMobile, isTablet } = useResponsive();
  return (
    <section style={{ background: LR.navy, color: LR.sand, padding: isMobile ? '56px 20px' : isTablet ? '64px 32px' : '64px 48px' }}>
      <div style={{
        maxWidth: 1280, margin: '0 auto', display: 'grid',
        gridTemplateColumns: isMobile || isTablet ? '1fr' : '0.9fr 1.6fr',
        gap: isMobile ? 28 : 64,
        alignItems: 'center',
      }}>
        <div>
          <div style={{ fontFamily: mono, fontSize: 11, letterSpacing: 1.8, textTransform: 'uppercase', color: LR.rust, fontWeight: 700, marginBottom: 14 }}>
            Victoria security of payment changes
          </div>
          <div style={{ fontFamily: display, fontWeight: 700, fontSize: isMobile ? 38 : 48, lineHeight: 0.95, letterSpacing: '-0.03em', textTransform: 'uppercase' }}>
            Are your variation records ready?
          </div>
        </div>
        <div>
          <p style={{ fontFamily: body, fontSize: isMobile ? 16 : 18, lineHeight: 1.55, color: `${LR.sand}dd`, margin: 0, marginBottom: 18 }}>
            Victoria's Security of Payment rules changed on 15 April 2026. The old excluded-amounts limits were removed, which means disputed variations and time-related costs can now form part of payment claims in a way they often could not before.
          </p>
          <p style={{ fontFamily: body, fontSize: 15, lineHeight: 1.55, color: `${LR.sand}aa`, margin: 0 }}>
            That makes the paperwork matter more: dates, instructions, drawings, photos, emails and site notes need to line up before a claim goes out.
          </p>
        </div>
      </div>
    </section>
  );
}

// ─── Problem section ───────────────────────────────────────
function Problem({ display, body, mono }) {
  const { isMobile, isTablet } = useResponsive();
  return (
    <section style={{ background: LR.sandLight, padding: isMobile ? '72px 20px' : isTablet ? '88px 32px' : '120px 48px' }}>
      <div style={{
        maxWidth: 1280, margin: '0 auto', display: 'grid',
        gridTemplateColumns: isMobile || isTablet ? '1fr' : '1fr 1.2fr',
        gap: isMobile ? 36 : 80,
        alignItems: 'start',
      }}>
        <div>
          <SectionLabel mono={mono}>The problem</SectionLabel>
          <h2 style={{
            fontFamily: display, fontWeight: 700, fontSize: isMobile ? 40 : 64, lineHeight: 0.95,
            letterSpacing: '-0.03em', color: LR.navy, margin: 0, textTransform: 'uppercase',
            textWrap: 'balance',
          }}>
            Variations are how subbies <span style={{ color: LR.rust }}>get burned</span>.
          </h2>
        </div>
        <div style={{ paddingTop: 12 }}>
          <p style={{
            fontFamily: body, fontSize: isMobile ? 17 : 19, lineHeight: 1.55, color: LR.navy, margin: 0, marginBottom: 28,
          }}>
            The job changed. The drawings changed. The scope crept. You did the extra work
            because the build couldn't wait. And now the head contractor is asking
            for "more detail" on your claim — for the third time.
          </p>
          <div style={{
            background: LR.sand, padding: '28px 32px', borderLeft: `4px solid ${LR.rust}`,
          }}>
            <div style={{ fontFamily: mono, fontSize: 11, letterSpacing: 1.8, textTransform: 'uppercase', color: LR.iron, marginBottom: 12, fontWeight: 600 }}>
              Reality on site
            </div>
            <div style={{ fontFamily: display, fontWeight: 700, fontSize: 44, color: LR.navy, lineHeight: 1, letterSpacing: '-0.02em', marginBottom: 8 }}>
              Messy records
            </div>
            <p style={{ fontFamily: body, fontSize: 15, color: LR.iron, lineHeight: 1.5, margin: 0 }}>
              Most teams have enough proof to support a claim, but it is split across inboxes, chats,
              photos and site notes. The problem is assembly, traceability and timing.
            </p>
          </div>
        </div>
      </div>
    </section>
  );
}

Object.assign(window, { LR, useResponsive, NavLogomark, Wordmark, SectionLabel, Nav, Hero, Stats, Problem });
