/* Wh4 footer + final cta. All copy sourced from https://wh4.co.uk */

function FinalCTA() {
  const videoRef = React.useRef(null);
  React.useEffect(() => {
    if (videoRef.current) {
      videoRef.current.playbackRate = 0.5;
    }
  }, []);
  return (
    <section id="contact" className="final-cta final-cta-video">
      <div className="container final-cta-inner">
        <div className="final-cta-text">
          <Reveal>
            <p className="eyebrow" style={{ color: 'rgba(255,255,255,0.7)' }}>Contact</p>
          </Reveal>
          <Reveal delay={1}>
            <h2 className="hd hd-xxl" style={{ marginTop: 14, color: '#fff' }}>Speak with us confidentially.</h2>
          </Reveal>
          <Reveal delay={2}>
            <p className="lede" style={{ marginTop: 24, color: 'rgba(255,255,255,0.85)', maxWidth: 540 }}>
              Wh<sup>4</sup> exists to support ambitious founders at the moments that matter most — whether they are building a company for the future or preparing to realise its value.
            </p>
          </Reveal>
          <Reveal delay={2}>
            <div className="cta-row" style={{ display: 'flex', flexWrap: 'wrap', gap: 14, marginTop: 36 }}>
              <a href="contact.html" className="btn-primary" style={{ background: '#fff', color: '#191c1f' }}>Get in touch</a>
              <a href="mailto:hello@wh4.co.uk" className="btn-ghost-light">hello@wh4.co.uk</a>
              <a href="tel:+442036339707" className="btn-ghost-light">+44 (0)203 633 9707</a>
            </div>
          </Reveal>
        </div>
        <Reveal delay={2}>
          <div className="final-cta-video-wrap">
            <video
              ref={videoRef}
              src="assets/cta-bg.mp4"
              autoPlay
              muted
              loop
              playsInline
              preload="auto"
              aria-hidden="true"
            />
          </div>
        </Reveal>
      </div>
    </section>
  );
}

function LegalDisclaimers() {
  return null;
}

const footerColumns = [
  { title: 'Wh4 Ltd', links: [
    ['Home', 'index.html'],
    ['Wh4 M&A', 'advisory.html'],
    ['Wh4 Growth Partnerships', 'partners.html'],
    ['Wh4 Land', 'property.html'],
    ['Wh4 Capital', 'capital.html'],
    ['Portfolio', 'portfolio.html'],
    ['Contact', 'contact.html'],
  ]},
  { title: 'Legal', links: [
    ['Privacy Policy', 'privacy.html'],
    ['Terms of Use', 'terms.html'],
    ['Cookies', 'cookies.html'],
    ['Confidentiality', 'confidentiality.html'],
    ['Disclosures', 'disclosures.html'],
  ]},
  { title: 'Contact', links: [
    ['hello@wh4.co.uk', 'mailto:hello@wh4.co.uk'],
    ['+44 (0)203 633 9707', 'tel:+442036339707'],
    ['Lower Thames Street', 'contact.html'],
    ['London, EC3R', 'contact.html'],
    ['Book a consultation', 'contact.html#book'],
  ]},
];

const bottomLegalLinks = [
  ['Privacy Policy', 'privacy.html'],
  ['Terms of Use', 'terms.html'],
  ['Cookies', 'cookies.html'],
  ['Confidentiality', 'confidentiality.html'],
  ['Disclosures', 'disclosures.html'],
  ['Contact', 'contact.html'],
];

/* Render any string containing "Wh4" with the 4 as a superscript */
function fmtWh4F(str) {
  const parts = String(str).split(/Wh4/);
  if (parts.length === 1) return str;
  return parts.flatMap((p, i) => i === 0 ? [p] : [<React.Fragment key={i}>Wh<sup>4</sup></React.Fragment>, p]);
}

/* Cookie notice — essential cookies only; dismiss persists in localStorage */
function CookieNotice() {
  const [show, setShow] = React.useState(() => {
    try { return !localStorage.getItem('wh4-cookies-ok'); } catch (e) { return true; }
  });
  if (!show) return null;
  const accept = () => {
    try { localStorage.setItem('wh4-cookies-ok', '1'); } catch (e) {}
    setShow(false);
  };
  return (
    <div className="cookie-notice" role="dialog" aria-label="Cookie notice">
      <p>We use essential cookies and similar browser storage to make this site work. See our <a href="cookies.html">Cookie Policy</a>.</p>
      <button onClick={accept}>OK</button>
    </div>
  );
}

function SiteFooter() {
  return (
    <footer className="footer">
      <div className="container">
        <div className="link-grid">
          {footerColumns.map((col) => (
            <div key={col.title} className="link-col">
              <h3>{fmtWh4F(col.title)}</h3>
              <ul>
                {col.links.map(([label, href]) => <li key={label}><a href={href}>{fmtWh4F(label)}</a></li>)}
              </ul>
            </div>
          ))}
        </div>

        <div className="footer-mid">
          <a href="index.html" className="logo" style={{ fontWeight: 700, fontSize: 26, letterSpacing: '-0.5px', display: 'inline-flex', alignItems: 'center', gap: 10 }}>
            <span style={{ width: 36, height: 36, borderRadius: 8, display: 'grid', placeItems: 'center', background: '#102e5e' }}>
              <img src={window.__resources && window.__resources.logoWhite || 'assets/wh4-logo.png'} alt="Wh4" style={{ width: '70%', height: '70%', objectFit: 'contain', display: 'block' }} />
            </span>
            <span>Wh<sup>4</sup></span>
          </a>
        </div>

        <div className="footer-bot">
          <a href="mailto:hello@wh4.co.uk" className="email-pill">
            <span>hello@wh4.co.uk</span>
          </a>
          <div className="footer-bot-links">
            {bottomLegalLinks.map(([label, href]) => (
              <a key={label} href={href}>{label}</a>
            ))}
          </div>
        </div>

        <div className="footer-legal">
          <p><strong>Important notice:</strong> nothing on this website constitutes financial, investment, legal, tax, accounting or transaction advice, nor an offer to sell or a solicitation to buy any security. This website is provided for informational purposes only. All engagement decisions are at the sole discretion of Wh<sup>4</sup> Ltd.</p>
          <p>Wh<sup>4</sup> Ltd is a family-owned diversified group operating four divisions: M&A, Growth Partnerships, Land and Capital. Engagements are bespoke and confidential by default.</p>
          <p>Companies featured in the portfolio section have consented to be named. Other engagements remain confidential.</p>
          <p className="footer-statutory">Wh<sup>4</sup> Ltd · Registered in England and Wales · Company No. 16339855 · Registered office: The American Barns, Banbury Road, Lighthorne, Warwick, Warwickshire, England, CV35 0AE · VAT No. 494008877</p>
        </div>

        <div className="footer-regulatory">
          <h4>Regulatory Disclaimer</h4>
          <p>Wh<sup>4</sup> Ltd is not authorised or regulated by the Financial Conduct Authority (FCA) or by any other financial services regulator. Wh<sup>4</sup> Ltd provides strategic and corporate advisory services in connection with the purchase and sale of businesses. We do not provide investment advice, arrange deals in investments, or carry on any other activity regulated under the Financial Services and Markets Act 2000 (FSMA), and nothing on this website constitutes such activity.</p>
          <p>The content of this website is provided for general information purposes only. It does not constitute investment, legal, tax or accounting advice, nor a recommendation, offer, solicitation or inducement to buy, sell or subscribe for any securities or other financial instruments. Visitors should seek their own independent professional advice — including from appropriately authorised financial advisers — before making any decision relating to the sale, purchase or valuation of a business or any investment.</p>
          <p>Our services are directed at business owners and corporate entities and are not intended for retail clients or private individuals seeking regulated financial services. Any transaction discussions we facilitate relate to the sale of businesses as going concerns. Where a proposed transaction is structured in a way that involves regulated activities, we will refer the relevant parties to appropriately authorised firms.</p>
          <p><strong>United Arab Emirates.</strong> Wh<sup>4</sup> Ltd is not licensed or regulated by the UAE Securities and Commodities Authority (SCA), the Central Bank of the UAE, the Dubai Financial Services Authority (DFSA) of the Dubai International Financial Centre (DIFC), or the Financial Services Regulatory Authority (FSRA) of Abu Dhabi Global Market (ADGM). Nothing on this website constitutes the promotion, offering or sale of securities or financial products in or from the UAE, the DIFC or the ADGM, nor the provision of financial services requiring a licence in any of those jurisdictions. This website and its contents are not directed at retail clients in the UAE. Any advisory engagement involving regulated activities in the UAE will be conducted only through, or by referral to, appropriately licensed firms.</p>
          <p>While we take care to ensure the information on this website is accurate, we make no representations or warranties as to its completeness or accuracy, and we accept no liability for any loss arising from reliance upon it.</p>
        </div>

        <div className="footer-strapline">
          <p>Wh<sup>4</sup> Ltd <span className="fs-dot">·</span> M&A <span className="fs-dot">·</span> Growth Partnerships <span className="fs-dot">·</span> Land <span className="fs-dot">·</span> Capital</p>
        </div>

        <div className="footer-copy">
          <p style={{ color: '#191c1f', fontWeight: 500 }}>Copyright © 2026 Wh<sup>4</sup> Ltd — All Rights Reserved.</p>
        </div>
      </div>
    </footer>
  );
}

Object.assign(window, { FinalCTA, LegalDisclaimers, SiteFooter, CookieNotice });
