/* KYDT Partner With Us — Te Whare Aranga build appeal, support impact, recognition, partners, enquiry. */
const { useState: pUseState } = React;

/* Load Cloudflare Turnstile once, whichever page the router lands on first. */
function loadTurnstile(){
  if (window.turnstile) return Promise.resolve(window.turnstile);
  if (!window.__kydtTurnstile) window.__kydtTurnstile = new Promise((resolve, reject)=>{
    const s = document.createElement('script');
    s.src = 'https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit';
    s.async = true; s.onload = ()=> resolve(window.turnstile); s.onerror = reject;
    document.head.appendChild(s);
  });
  return window.__kydtTurnstile;
}

function PartnerPage({ onNav }){
  const DS = window.KYDTDesignSystem_1d4054;
  const { SectionHeading, Card, Button, Input, Textarea, Select, Checkbox, Badge, Whakatauki } = DS;
  const { Reveal, KIcon:I, MotifBackdrop, PageHero } = window;
  window.useScrollFX('partner');
  React.useEffect(()=>{ window.playPageHero && window.playPageHero(); },[]);
  const [sent, setSent] = pUseState(false);
  const [sending, setSending] = pUseState(false);
  const [formError, setFormError] = pUseState('');
  const tsBox = React.useRef(null);
  const tsWidget = React.useRef(null);
  const cfg = window.KYDT_CONFIG || {};
  const contactEmail = cfg.contactEmail || 'support@kydt.org.nz';
  /* Fallbacks for browsers still holding a site-config.js from before the form
     was wired up (the zone lets browsers cache it for 4 hours). */
  const enquiryUrl = cfg.enquiryUrl || (/^(www\.)?kydt\.org\.nz$/.test(location.hostname)
    ? 'https://kydt-receipts-live.coreshifthq.workers.dev/enquiry'
    : 'https://kydt-receipts-test.coreshifthq.workers.dev/enquiry');
  const turnstileSiteKey = cfg.turnstileSiteKey || '0x4AAAAAAFbDGda3GWBEu5qy';

  React.useEffect(()=>{
    if (sent) return;
    let gone = false;
    loadTurnstile().then(ts=>{
      if (gone || !tsBox.current || tsWidget.current != null) return;
      tsWidget.current = ts.render(tsBox.current, { sitekey: turnstileSiteKey, theme: 'light', size: 'flexible' });
    }).catch(()=> setFormError(`The form could not load. Please email us at ${contactEmail}.`));
    return ()=>{ gone = true; if (window.turnstile && tsWidget.current != null) { window.turnstile.remove(tsWidget.current); } tsWidget.current = null; };
  }, [sent]);

  async function submitEnquiry(e){
    e.preventDefault();
    if (sending) return;
    setFormError('');
    const fd = new FormData(e.currentTarget);
    const token = window.turnstile && tsWidget.current != null ? window.turnstile.getResponse(tsWidget.current) : '';
    if (!token) { setFormError('Please wait a moment for the security check to finish, then send again.'); return; }
    setSending(true);
    try {
      const r = await fetch(enquiryUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({
        name: fd.get('name'), organisation: fd.get('organisation'), email: fd.get('email'),
        enquiringAs: fd.get('enquiringAs'), message: fd.get('message'), updates: fd.get('updates') != null,
        page: location.pathname, turnstileToken: token,
      }) });
      const j = await r.json().catch(()=> ({}));
      if (!r.ok) throw new Error(j.error || '');
      setSent(true);
      window.scrollTo({ top: document.getElementById('enquiry').offsetTop - 40, behavior: 'smooth' });
    } catch (err) {
      setFormError((err && err.message) || `Sorry, your enquiry did not send. Please email us at ${contactEmail}.`);
      if (window.turnstile && tsWidget.current != null) window.turnstile.reset(tsWidget.current);
    } finally {
      setSending(false);
    }
  }
  const donateUrl = cfg.donateUrl || '';
  /* Te Whare Aranga appeal. Both figures are edited in PageForm as shown ("50k", "300k");
     site-config.js `appeal` is the fallback. The bar and percentage come from the parsed
     numbers, in dollars ("k" thousands, "m" millions). */
  const appeal = cfg.appeal || { pledged:0, goal:0 };
  const pledgedC = pfCount('partner.appeal.pledged', `${Math.round(appeal.pledged/1000)}k`);
  const goalC = pfCount('partner.appeal.goal', `${Math.round(appeal.goal/1000)}k`);
  const dollars = (c, fallback)=> c.n == null ? fallback : c.n * (/^\s*k/i.test(c.suffix) ? 1000 : /^\s*m/i.test(c.suffix) ? 1000000 : 1);
  const pledged = dollars(pledgedC, appeal.pledged);
  const goal = dollars(goalC, appeal.goal);
  const appealPct = goal ? Math.round((pledged/goal)*1000)/10 : 0;
  const prospectus = pfLink('partner.appeal.prospectus', { href:'assets/KYDT_Sponsor_Prospectus_2026.pdf', label:'Download prospectus', newTab:true });

  const includes = [
    { icon:'chef-hat', t:'A dedicated kitchen', d:'Where baking, preparing kai and sharing kōrero build everyday connection.' },
    { icon:'bath', t:'Additional facilities', d:'Extra bathroom facilities so the space works for everyone who visits.' },
    { icon:'heart-handshake', t:'A place to belong', d:'More than a building — a welcoming home where rangatahi feel safe and valued.' },
  ];
  const makes = [
    { icon:'user-round', t:'One-on-one mentoring for rangatahi' },
    { icon:'briefcase-medical', t:'Qualified social work support for young people and their whānau' },
    { icon:'home', t:'Support for whānau through Family Group Conference processes' },
    { icon:'route', t:'Early intervention that creates positive pathways and prevents harm' },
  ];
  const recognition = [
    { icon:'globe', t:'Website acknowledgement' },
    { icon:'file-text', t:'Inclusion in reports and updates' },
    { icon:'megaphone', t:'Opportunities to share your organisation’s support of this mahi' },
  ];
  /* Proudly Supported By (brief section 7).
     Every logo here is a PLACEHOLDER. Each funder's approved "supported by" logo has
     to be requested from them — see assets/funder-logos/README.md. Do not lift a
     logo off a funder's website.

     To drop a real logo in: save the approved file into site/assets/funder-logos/
     as <slug>.svg (preferred) or <slug>.png, then change that funder's `file` to
     match and delete `placeholder`. One line each, nothing else moves. */
  const funders = [
    { slug:'the-lion-foundation',        name:'The Lion Foundation',                     file:'the-lion-foundation.png' },
    { slug:'nz-lottery-grants-board',    name:'NZ Lottery Grants Board — Te Puna Tahua',  file:'nz-lottery-grants-board.png' },
    { slug:'te-puna-manawa-healthwest',  name:'Te Puna Manawa Trust — HealthWEST',        file:'te-puna-manawa-healthwest-PLACEHOLDER.png',  placeholder:true },
    { slug:'te-puna-hauora',             name:'Te Puna Hauora o Te Raki Paewhenua',       file:'te-puna-hauora.png' },
    { slug:'oranga-tamariki',            name:'Ministry for Children — Oranga Tamariki',  file:'oranga-tamariki-PLACEHOLDER.png',            placeholder:true },
    { slug:'kcft',                       name:'Kaipātiki Community Facilities Trust',     file:'kcft.png' },
  ];
  const anyPlaceholderLogos = funders.some(f=>f.placeholder);

  /* Donor FAQ (brief section 8; round 2 §3 supplied both open answers, verbatim).
     Anything still with the client is a visible TODO rather than filler. */
  const donorFaq = [
    { q:'Where does my donation go?',
      a:'Making a donation via Stripe is supporting the Mahi and the \'Enquire Now\' button is for sponsors who will hopefully be considering larger donations which will contribute to Te Whare Aranga.' },
    { q:'Is my donation tax deductible?',
      a:'Yes, as KYDT is a registered charity, donations of $5 or more are eligible for a tax credit. If you choose to donate through our website, you\'ll receive a tax receipt for each donation. For donations made directly to our bank account, we\'ll provide a receipt for your donations at the end of the financial year, around mid-April. Thank you for helping us support young people to thrive.',
      /* Launch gate, not a staging gate: Stripe's default receipt is a payment
         confirmation, not an NZ donation receipt. Remove once KYDT's accountant confirms. */
      todo:'TODO(KYDT): before launch, confirm the per-donation tax receipt with KYDT\'s accountant — Stripe\'s default receipt is a payment confirmation, not a donation receipt.' },
    { q:'Can I give once, or monthly?',
      a:'Both. Choose one-off or monthly on the donation page and give any amount you like. To change or stop a monthly gift, email support@kydt.org.nz.' },
    { q:'Can I cover the processing fee?',
      a:'Yes. The donation form offers to add the card processing fee to your gift, so the full amount you intended reaches KYDT rather than the payment provider. It is optional and it is your choice.' },
    { q:'Who do I contact about a donation?',
      a:'Email support@kydt.org.nz and someone from the team will come back to you.' },
  ];

  return (
    <div>
      <PageHero eyebrow={<T k="partner.hero.eyebrow">Partner With Us</T>} title={<T k="partner.hero.title">He waka eke noa — we are all in this together.</T>}
        lead={<T k="partner.hero.lead">Partner with KYDT to help rangatahi and whānau thrive. Our mahi is grounded in relationships — together we can create lasting change and build safer, stronger communities.</T>} />

      {/* ---- Te Whare Aranga build appeal (primary focus) ---- */}
      <section className="kydt-section" style={{position:'relative',overflow:'hidden'}}>
        <MotifBackdrop variant="band-jade" opacity={0.05} />
        <div className="kydt-container-wide" style={{position:'relative'}}>
          <div className="kydt-split" style={{display:'grid',gridTemplateColumns:'1fr 1fr',gap:56,alignItems:'center'}}>
            <Reveal>
              <Badge tone="jade"><T k="partner.appeal.badge">Our building appeal</T></Badge>
              <h2 style={{margin:'18px 0 0',fontFamily:'var(--font-display)',fontWeight:600,fontSize:'clamp(2rem,3.6vw,3rem)',lineHeight:1.08,letterSpacing:'-0.02em',color:'var(--text-heading)'}}><T k="partner.appeal.title">Growing our future — Te Whare Aranga</T></h2>
              <p style={{margin:'20px 0 0',fontSize:'var(--text-md)',lineHeight:1.65,color:'var(--text-body)'}}><T k="partner.appeal.intro">{"KYDT is growing to better support the needs of our rangatahi. We're planning an extension to our existing premises, creating a welcoming space where young people can truly feel a sense of belonging."}</T></p>
              <p style={{margin:'14px 0 0',fontSize:15.5,lineHeight:1.65,color:'var(--text-muted)'}}><T k="partner.appeal.nameLead">Our building will be named</T>{' '}<strong style={{color:'var(--text-heading)'}}><T k="partner.appeal.name">Te Whare Aranga</T></strong>{' '}<T k="partner.appeal.nameRest">— a name gifted to KYDT by Matua Beau Panapa. Your support will help bring it to life.</T></p>

              {/* progress (placeholder) */}
              <div style={{marginTop:28,background:'var(--surface-sunken)',border:'1px solid var(--sea-100)',borderRadius:'var(--radius-lg)',padding:'20px 22px'}}>
                <div style={{display:'flex',justifyContent:'space-between',alignItems:'baseline',marginBottom:10}}>
                  <span style={{fontFamily:'var(--font-display)',fontWeight:600,fontSize:'var(--text-lg)',color:'var(--text-heading)'}}><T k="partner.appeal.progressLabel">Appeal progress</T></span>
                  <span style={{fontSize:13,color:'var(--text-muted)'}}>{appealPct}% <T k="partner.appeal.ofGoal">of goal</T></span>
                </div>
                <div style={{height:12,borderRadius:'var(--radius-pill)',background:'var(--sea-100)',overflow:'hidden'}}
                  role="progressbar" aria-valuenow={pledged} aria-valuemin={0} aria-valuemax={goal}
                  aria-label={`Te Whare Aranga appeal: $${pledgedC.shown} pledged of a $${goalC.shown} goal`}>
                  <div className="kydt-progress-fill" data-progress={appealPct} style={{height:'100%',width:appealPct + '%',borderRadius:'var(--radius-pill)',background:'linear-gradient(90deg,var(--jade-500),var(--cyan-500))'}} />
                </div>
                <div style={{display:'flex',justifyContent:'space-between',marginTop:10,fontSize:14}}>
                  <span style={{color:'var(--brand-secondary)',fontWeight:700}}>$<span {...PF.attrs('partner.appeal.pledged')} data-count={pledgedC.n} data-suffix={pledgedC.suffix} data-dec={pledgedC.dec}>{pledgedC.shown}</span> <T k="partner.appeal.pledgedLabel">pledged</T></span>
                  <span style={{color:'var(--text-muted)'}}><T k="partner.appeal.goalLabel">Goal</T> $<span {...PF.attrs('partner.appeal.goal')}>{goalC.shown}</span></span>
                </div>
              </div>

              <div style={{marginTop:26,display:'flex',flexWrap:'wrap',gap:14}}>
                <Button variant="secondary" size="lg" iconRight={I('arrow-right')} onClick={()=>document.getElementById('enquiry').scrollIntoView({behavior:'smooth',block:'start'})}><T k="partner.appeal.enquireButton">Enquire now</T></Button>
                <Button as="a" href={prospectus.href} target={prospectus.newTab ? '_blank' : undefined} rel={prospectus.newTab ? 'noopener noreferrer' : undefined}
                  {...PF.attrs('partner.appeal.prospectus', 'link')} variant="outline" size="lg" iconLeft={I('download')}>{prospectus.label}</Button>
              </div>
            </Reveal>

            <Reveal delay={0.12} data-parallax-scope="">
              <div style={{position:'relative',borderRadius:'var(--radius-xl)',overflow:'hidden',minHeight:440,border:'1px dashed var(--sea-300)',background:'var(--sea-100)',display:'grid',placeItems:'center'}}>
                <div data-parallax="40" style={{position:'absolute',inset:'-6% 0',backgroundImage:'url(assets/photo-ocean-pasifika.png)',backgroundSize:'cover',backgroundPosition:'center',opacity:0.35}} />
                <div style={{position:'relative',textAlign:'center',color:'var(--sea-600)',display:'flex',flexDirection:'column',alignItems:'center',gap:12}}>{I('building-2',44)}<span style={{fontWeight:700,fontSize:15,letterSpacing:'0.04em'}}>Te Whare Aranga render</span><span style={{fontSize:12.5,opacity:0.85}}>Placeholder — architectural render to come</span></div>
              </div>
              <p style={{margin:'14px 4px 0',fontFamily:'var(--font-display)',fontStyle:'italic',fontSize:'var(--text-md)',lineHeight:1.5,color:'var(--text-heading)'}}>
                <T k="partner.appeal.caption">Te Whare Aranga - A whare where young people can feel safe, grow strong and rise up into their full potential.</T>
              </p>
            </Reveal>
          </div>

          {/* what it includes */}
          <div className="kydt-include-grid" style={{display:'grid',gridTemplateColumns:'repeat(3,1fr)',gap:20,marginTop:48}}>
            {includes.map((m,i)=>(
              <Reveal key={m.t} delay={i*0.08}>
                <Card tone="sand" hover style={{height:'100%'}}>
                  <span style={{display:'grid',placeItems:'center',width:48,height:48,borderRadius:'var(--radius-md)',background:'var(--white)',color:'var(--jade-700)',marginBottom:16}}>{I(m.icon,22)}</span>
                  <h3 style={{margin:'0 0 8px',fontFamily:'var(--font-display)',fontWeight:600,fontSize:'var(--text-lg)',color:'var(--text-heading)'}}><T k={`partner.includes.${i}.title`}>{m.t}</T></h3>
                  <p style={{margin:0,fontSize:14.5,lineHeight:1.6,color:'var(--text-body)'}}><T k={`partner.includes.${i}.text`}>{m.d}</T></p>
                </Card>
              </Reveal>
            ))}
          </div>
        </div>
      </section>

      {/* ---- Give directly (donation + donor FAQ) ---- */}
      <section id="donate" className="kydt-section" style={{position:'relative',overflow:'hidden',background:'var(--surface-sand)'}}>
        <div className="kydt-container-wide" style={{position:'relative'}}>
          <div className="kydt-split" style={{display:'grid',gridTemplateColumns:'0.9fr 1.1fr',gap:56,alignItems:'start'}}>
            <Reveal>
              <SectionHeading eyebrow={<T k="partner.give.eyebrow">Give directly</T>} title={<T k="partner.give.title">Support the mahi with a donation</T>}
                lead={<T k="partner.give.lead">{"For individuals who'd like to give now, without waiting on bank details. Every gift goes straight into walking alongside rangatahi and whānau in Kaipātiki."}</T>} />
              <div style={{marginTop:28,display:'flex',flexWrap:'wrap',gap:14,alignItems:'center'}}>
                <Button as="a" href={donateUrl}
                  variant="secondary" size="lg" iconRight={I('heart')}><T k="partner.give.donateButton">Donate Now</T></Button>
                <Badge tone="sea" size="sm"><T k="partner.give.badge">One-off or monthly</T></Badge>
              </div>
              <p style={{margin:'18px 0 0',fontSize:13.5,lineHeight:1.6,color:'var(--text-muted)',maxWidth:420}}>
                {I('lock',14)} <T k="partner.give.secureNote">Donations are handled on a secure hosted payment page. KYDT never sees or stores your card details.</T>
              </p>
            </Reveal>

            <Reveal delay={0.12}>
              <div style={{display:'flex',flexDirection:'column',gap:12}}>
                {donorFaq.map((f,i)=>(
                  <Card key={f.q} padding="var(--space-5)" style={{background:'var(--white)'}}>
                    <h3 style={{margin:'0 0 8px',fontFamily:'var(--font-display)',fontWeight:600,fontSize:'var(--text-lg)',color:'var(--text-heading)'}}><T k={`partner.faq.${i}.question`}>{f.q}</T></h3>
                    {f.a && <p style={{margin:0,fontSize:15,lineHeight:1.6,color:'var(--text-body)'}}><T k={`partner.faq.${i}.answer`}>{f.a}</T></p>}
                    {f.todo && <p style={{margin:f.a?'10px 0 0':0,fontSize:13,lineHeight:1.6,color:'var(--text-muted)',fontStyle:'italic'}}>{f.todo}</p>}
                  </Card>
                ))}
              </div>
            </Reveal>
          </div>
        </div>
      </section>

      {/* ---- What your support makes possible ---- */}
      <section className="kydt-section" style={{position:'relative',overflow:'hidden',background:'var(--surface-sunken)',borderBlock:'1px solid var(--sea-100)'}}>
        {/* faded manaia sitting behind the block (brief section 7) */}
        <img src="assets/kydt-manaia-sea.png" alt="" aria-hidden="true" loading="lazy"
          style={{position:'absolute',right:'-6%',top:'50%',transform:'translateY(-50%)',
            width:'min(560px,52%)',opacity:0.06,pointerEvents:'none',userSelect:'none'}} />
        <div className="kydt-container-wide" style={{position:'relative'}}>
          <Reveal style={{marginBottom:40,maxWidth:600}}>
            <SectionHeading eyebrow={<T k="partner.support.eyebrow">Your support</T>} title={<T k="partner.support.title">What your partnership makes possible</T>}
              lead={<T k="partner.support.lead">Beyond the build, your support sustains the everyday mahi that changes lives.</T>} />
          </Reveal>
          <div className="kydt-makes-grid" style={{display:'grid',gridTemplateColumns:'repeat(2,1fr)',gap:16}}>
            {makes.map((m,i)=>(
              <Reveal key={m.t} delay={i*0.07}>
                <Card hover style={{height:'100%'}}>
                  <div style={{display:'flex',gap:16,alignItems:'flex-start'}}>
                    <span style={{flexShrink:0,width:44,height:44,borderRadius:'var(--radius-md)',background:'var(--jade-100)',color:'var(--jade-700)',display:'grid',placeItems:'center'}}>{I(m.icon)}</span>
                    <p style={{margin:0,fontSize:16,lineHeight:1.55,color:'var(--text-body)',paddingTop:3}}><T k={`partner.support.${i}.text`}>{m.t}</T></p>
                  </div>
                </Card>
              </Reveal>
            ))}
          </div>
        </div>
      </section>

      {/* ---- Recognition ---- */}
      <section className="kydt-section" style={{position:'relative',overflow:'hidden'}}>
        <div className="kydt-container">
          <Reveal style={{marginBottom:40,maxWidth:680}}>
            <SectionHeading eyebrow={<T k="partner.recognition.eyebrow">Recognition</T>} title={<T k="partner.recognition.title">We acknowledge our partners with gratitude and respect</T>}
              lead={<T k="partner.recognition.lead">Partners may be recognised in ways that suit your organisation:</T>} />
          </Reveal>
          <div className="kydt-rec-grid" style={{display:'grid',gridTemplateColumns:'repeat(3,1fr)',gap:20}}>
            {recognition.map((r,i)=>(
              <Reveal key={r.t} delay={i*0.08} style={{display:'flex',gap:14,alignItems:'flex-start'}}>
                <span style={{flexShrink:0,width:40,height:40,borderRadius:'50%',background:'var(--sea-50)',color:'var(--brand-primary)',display:'grid',placeItems:'center'}}>{I(r.icon,20)}</span>
                <p style={{margin:0,paddingTop:8,fontSize:15.5,lineHeight:1.5,color:'var(--text-body)'}}><T k={`partner.recognition.${i}.text`}>{r.t}</T></p>
              </Reveal>
            ))}
          </div>
        </div>
      </section>

      {/* ---- Current partners ---- */}
      <section className="kydt-section" style={{background:'var(--surface-sand)'}}>
        <div className="kydt-container-wide">
          <Reveal style={{marginBottom:36,textAlign:'center'}}>
            <SectionHeading align="center" eyebrow={<T k="partner.funders.eyebrow">Ngā mihi</T>} title={<T k="partner.funders.title">Proudly supported by</T>} maxWidth="560px"
              lead={<T k="partner.funders.lead">With gratitude to the organisations walking alongside us.</T>} />
          </Reveal>
          <div className="kydt-partner-grid" style={{display:'grid',gridTemplateColumns:'repeat(6,1fr)',gap:16}}>
            {funders.map((f,i)=>(
              <Reveal key={f.slug} delay={i*0.06}>
                <div className="kydt-partner-tile" style={{aspectRatio:'3/2',background:'var(--white)',border:'1px solid var(--border-subtle)',borderRadius:'var(--radius-md)',display:'grid',placeItems:'center',padding:'14px',transition:'transform .25s var(--ease-out),box-shadow .25s'}}>
                  <img className="kydt-funder-logo" src={`assets/funder-logos/${f.file}`} alt={f.name} loading="lazy"
                    style={{maxWidth:'100%',maxHeight:56,width:'auto',height:'auto',objectFit:'contain',display:'block'}} />
                </div>
              </Reveal>
            ))}
          </div>
          {anyPlaceholderLogos && (
            <Reveal delay={0.2} style={{marginTop:18,textAlign:'center',fontSize:12.5,color:'var(--text-muted)',fontStyle:'italic'}}>
              TODO(KYDT): Te Puna Manawa Trust — HealthWEST and Oranga Tamariki logos still to come, and Birkenhead Licensing Trust to be added when its logo arrives.
            </Reveal>
          )}
        </div>
      </section>

      {/* ---- Enquiry form ---- */}
      <section id="enquiry" style={{position:'relative',overflow:'hidden',background:'linear-gradient(160deg,var(--sea-800),var(--sea-950))',color:'var(--text-on-dark)'}}>
        <MotifBackdrop variant="wave-bottom" opacity={0.12} />
        <div className="kydt-container kydt-section" style={{position:'relative',maxWidth:760}}>
          <Reveal style={{textAlign:'center',marginBottom:32}}>
            <SectionHeading align="center" onDark eyebrow={<T k="partner.enquiry.eyebrow">Get in touch</T>} title={<T k="partner.enquiry.title">{"If you'd like to walk alongside us, we'd love to kōrero"}</T>} maxWidth="580px" />
          </Reveal>
          <Reveal delay={0.1}>
            <Card tone="default">
              {sent ? (
                <div style={{textAlign:'center',padding:'34px 12px'}}>
                  <div style={{width:60,height:60,borderRadius:'50%',background:'var(--jade-100)',color:'var(--jade-700)',display:'grid',placeItems:'center',margin:'0 auto 18px'}}>{I('check',30)}</div>
                  <h3 style={{margin:'0 0 8px',fontFamily:'var(--font-display)',fontSize:24,color:'var(--text-heading)'}}>Ngā mihi nui!</h3>
                  <p style={{margin:0,color:'var(--text-body)'}}>We've received your enquiry and will be in touch within two working days.</p>
                </div>
              ) : (
                <form onSubmit={submitEnquiry} style={{display:'grid',gridTemplateColumns:'1fr 1fr',gap:16}}>
                  <Input name="name" label="Your name" placeholder="Jane Ngata" required maxLength={120} />
                  <Input name="organisation" label="Organisation" placeholder="Your organisation" maxLength={160} />
                  <Input name="email" label="Email" type="email" placeholder="you@org.nz" required maxLength={200} />
                  <Select name="enquiringAs" label="I'm enquiring as a…" options={['Corporate partner / funder','School','Whānau','Other']} />
                  <div style={{gridColumn:'1 / -1'}}><Textarea name="message" label="How would you like to help?" rows={4} maxLength={5000} placeholder="Tell us about your kaupapa and how you'd like to support Te Whare Aranga…" /></div>
                  <div style={{gridColumn:'1 / -1'}}><Checkbox name="updates" label="I'd like to receive occasional updates about KYDT's mahi" defaultChecked /></div>
                  <div style={{gridColumn:'1 / -1'}} ref={tsBox} />
                  {formError && <div role="alert" style={{gridColumn:'1 / -1',color:'var(--danger)',fontSize:14.5}}>{formError}</div>}
                  <div style={{gridColumn:'1 / -1',display:'flex',flexWrap:'wrap',gap:14,alignItems:'center'}}>
                    <Button type="submit" variant="secondary" size="lg" iconRight={I('send')} disabled={sending}>{sending ? 'Sending…' : 'Send enquiry'}</Button>
                    <Badge tone="jade" size="sm"><T k="partner.enquiry.replyBadge">We reply within 2 working days</T></Badge>
                  </div>
                </form>
              )}
            </Card>
          </Reveal>
          <Reveal delay={0.16} style={{marginTop:28,display:'flex',flexWrap:'wrap',gap:20,justifyContent:'center',fontSize:13.5,color:'var(--text-on-dark-muted)'}}>
            <span style={{display:'inline-flex',alignItems:'center',gap:8}}>{I('shield-check',17)} <T k="partner.enquiry.msd">MSD Level 2 approved</T></span>
            <span style={{display:'inline-flex',alignItems:'center',gap:8}}>{I('file-badge',17)} <T k="partner.enquiry.charity">Registered charity CC48458</T></span>
          </Reveal>
        </div>
      </section>

      <style>{`
        .kydt-partner-tile:hover{transform:translateY(-4px);box-shadow:var(--shadow-md)}
        /* funder logos sit back in greyscale and come up in colour on hover, so the
           strip reads as one row rather than six competing brand palettes */
        .kydt-funder-logo{filter:grayscale(1);opacity:.72;transition:filter .25s,opacity .25s}
        .kydt-partner-tile:hover .kydt-funder-logo{filter:none;opacity:1}
        @media(prefers-reduced-motion:reduce){.kydt-partner-tile{transition:none}}
        @media(max-width:900px){.kydt-makes-grid,.kydt-include-grid,.kydt-rec-grid{grid-template-columns:1fr!important}.kydt-partner-grid{grid-template-columns:repeat(3,1fr)!important}#enquiry form{grid-template-columns:1fr!important}}
        @media(max-width:520px){.kydt-partner-grid{grid-template-columns:1fr 1fr!important}}
      `}</style>
    </div>
  );
}
window.PartnerPage = PartnerPage;
