// pages/Interior.jsx — About, Team, Resources, Intercessors, Calendar

const useLangInt = () => {
  const [, setLang] = React.useState(() => (window.__getLang && window.__getLang()) || 'en');
  React.useEffect(() => {
    if (!window.__onLangChange) return;
    return window.__onLangChange(setLang);
  }, []);
};
const Ti = (k) => (window.t ? window.t(k) : k);

const PageHeader = ({ eyebrow, title, subtitle, bgImg, bgOpacity = 0.18, bgFilter = 'sepia(0.3)', bgPosition = 'center' }) => (
  <section style={{
    position: 'relative',
    background: 'var(--grad-blue)',
    color: 'var(--cream)',
    padding: 'clamp(60px, 8vw, 100px) 0 clamp(50px, 6vw, 80px)',
    overflow: 'hidden',
    borderBottom: '4px solid var(--gold)',
  }} className="grain">
    {bgImg && (
      <div style={{ position: 'absolute', inset: 0, opacity: bgOpacity }}>
        <img src={bgImg} alt="" style={{ width: '100%', height: '100%', objectFit: 'cover', objectPosition: bgPosition, filter: bgFilter }} />
      </div>
    )}
    <div className="u-container" style={{ position: 'relative', zIndex: 2, textAlign: 'center' }}>
      <div className="u-eyebrow" style={{ justifyContent: 'center', color: 'var(--gold-soft)', marginBottom: 20 }}>{eyebrow}</div>
      <h1 className="h-display h-hero" style={{
        fontSize: 'clamp(32px, 7vw, 80px)', color: 'var(--gold)', margin: 0,
        textTransform: 'uppercase', lineHeight: 1.08,
      }}>{title}</h1>
      {subtitle && (
        <p className="h-elegant" style={{ fontSize: 'clamp(16px, 2.2vw, 22px)', color: 'var(--gold-soft)', margin: '28px auto 0', maxWidth: 700, lineHeight: 1.5 }}>
          {subtitle}
        </p>
      )}
    </div>
  </section>
);

// ---------------- ABOUT ----------------
const AboutPage = () => {
  useLangInt();
  return (
  <>
    <PageHeader
      eyebrow={Ti('about.header.eyebrow')}
      title={Ti('about.header.title')}
      subtitle={Ti('about.header.sub')}
      bgImg="uploads/sacramento-kstreet.png"
      bgOpacity={0.42}
      bgFilter="saturate(0.95) contrast(1.02)"
      bgPosition="center 40%"
    />
    <section className="section" style={{ background: 'var(--beige)' }}>
      <div className="u-container" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 80 }}>
        <div>
          <div className="u-eyebrow" style={{ marginBottom: 16 }}>{Ti('about.vision.eyebrow')}</div>
          <h2 className="h-display h-section" style={{ fontSize: 40, color: 'var(--blue)', margin: '0 0 20px', textTransform: 'uppercase' }}>
            {Ti('about.vision.title')}
          </h2>
          <p style={{ fontSize: 16, lineHeight: 1.8, color: 'var(--ink-soft)' }}>
            {Ti('about.vision.body')}
          </p>
        </div>
        <div>
          <div className="u-eyebrow" style={{ marginBottom: 16 }}>{Ti('about.mission.eyebrow')}</div>
          <h2 className="h-display h-section" style={{ fontSize: 40, color: 'var(--blue)', margin: '0 0 20px', textTransform: 'uppercase' }}>
            {Ti('about.mission.title')}
          </h2>
          <p style={{ fontSize: 16, lineHeight: 1.8, color: 'var(--ink-soft)' }}>
            {Ti('about.mission.body')}
          </p>
        </div>
      </div>
    </section>
    {/* Values section — commented out for now
    <section className="section" style={{ background: 'var(--cream)', paddingTop: 0 }}>
      <div className="u-container">
        <div style={{ textAlign: 'center', marginBottom: 50 }}>
          <div className="u-eyebrow" style={{ justifyContent: 'center', marginBottom: 16 }}>{Ti('about.values.eyebrow')}</div>
          <h2 className="h-display h-section" style={{ fontSize: 48, color: 'var(--blue)', margin: 0, textTransform: 'uppercase' }}>
            {Ti('about.values.title')}
          </h2>
        </div>
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 20 }}>
          {[
            { t: Ti('about.values.unity.t'), d: Ti('about.values.unity.d') },
            { t: Ti('about.values.continuous.t'), d: Ti('about.values.continuous.d') },
            { t: Ti('about.values.scripture.t'), d: Ti('about.values.scripture.d') },
            { t: Ti('about.values.humility.t'), d: Ti('about.values.humility.d') },
          ].map(v => (
            <div key={v.t} className="retro-card" style={{ padding: 28 }}>
              <div style={{ color: 'var(--gold-deep)', fontSize: 28, marginBottom: 10 }}>✦</div>
              <h3 className="h-display" style={{ fontSize: 24, color: 'var(--blue)', margin: '0 0 8px', textTransform: 'uppercase' }}>{v.t}</h3>
              <p style={{ fontSize: 14, color: 'var(--ink-soft)', lineHeight: 1.6, margin: 0 }}>{v.d}</p>
            </div>
          ))}
        </div>
      </div>
    </section>
    */}
    <section className="section section-dark grain" style={{ padding: '100px 0' }}>
      <div className="u-container">
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1.3fr', gap: 60, alignItems: 'center' }}>
          <div>
            <div className="u-eyebrow" style={{ color: 'var(--gold-soft)', marginBottom: 16 }}>{Ti('about.faith.eyebrow')}</div>
            <h2 className="h-display h-section" style={{ fontSize: 44, color: 'var(--gold)', margin: 0, textTransform: 'uppercase', lineHeight: 1.05 }}>
              {Ti('about.faith.title')}
            </h2>
          </div>
          <div style={{ fontSize: 15, lineHeight: 1.8, color: 'rgba(251,247,240,0.85)', columns: 1 }}>
            {[1,2,3,4,5,6,7].map(n => (
              <p key={n} style={n === 1 ? { marginTop: 0 } : undefined}>
                {Ti(`about.faith.s${n}`)}
              </p>
            ))}
          </div>
        </div>
      </div>
    </section>
  </>
  );
};

// ---------------- TEAM ----------------
const TeamPage = () => {
  useLangInt();
  // Executive team — names + churches sourced from citypastors.net
  const team = [
    { name: 'Lance Hahn',              church: 'Bridgeway Christian Church',         photo: 'uploads/team-lance-hahn.png' },
    { name: 'Tamara Bennett',          church: 'This Is Pentecost Fellowship Ministries', photo: 'uploads/team-tamara-bennett.png' },
    { name: 'Juan de Dios Villanueva', church: 'MPAP Restauración Vino Nueva',       photo: 'uploads/team-juan-villanueva.png' },
    { name: 'Francis Anfuso',          church: Ti('team.church.francis'),            photo: 'uploads/team-francis-anfuso.png' },
    { name: 'Rick Cole',               church: 'Capital Compassion',                 photo: 'uploads/team-rick-cole.png' },
    { name: 'Vladimir Yarmolyuk',      church: 'Destiny Church',                    photo: 'uploads/team-vladimir-yarmolyuk.png' },
    { name: 'Parnell Lovelace',        church: 'Center of Praise',                   photo: 'uploads/team-parnell-lovelace.png' },
    { name: 'Phil Goudeaux, Jr.',      church: 'Calvary Christian Center',           photo: 'uploads/team-phil-goudeaux.png' },
    { name: 'Don and Christa Proctor', church: 'City Pastors',                       photo: 'uploads/team-don-christa-proctor.png', role: Ti('team.role.directors') },
  ];
  return (
    <>
      <PageHeader
        eyebrow={Ti('team.header.eyebrow')}
        title={Ti('team.header.title')}
        subtitle={Ti('team.header.sub')}
        bgImg={IMG.congregation}
      />
      <section className="section" style={{ background: 'var(--beige)' }}>
        <div className="u-container">
          <div className="team-grid" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 30 }}>
            {team.map(p => (
              <div key={p.name} className="retro-card" style={{ overflow: 'hidden', padding: 0 }}>
                <div style={{ aspectRatio: '4 / 3', overflow: 'hidden', borderBottom: '2px solid var(--ink)', background: 'var(--beige-2)' }}>
                  <img src={p.photo} alt={p.name} style={{ width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center top', display: 'block' }} />
                </div>
                <div style={{ padding: 24 }}>
                  {p.role && (
                    <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em', color: 'var(--gold-deep)', textTransform: 'uppercase', marginBottom: 6 }}>
                      {p.role}
                    </div>
                  )}
                  <h3 className="h-display" style={{ fontSize: 22, color: 'var(--blue)', margin: '0 0 10px', textTransform: 'uppercase', lineHeight: 1.15 }}>
                    {p.name}
                  </h3>
                  <p style={{ fontSize: 14, color: 'var(--ink-soft)', lineHeight: 1.5, margin: 0 }}>
                    {p.church}
                  </p>
                </div>
              </div>
            ))}
          </div>
        </div>
      </section>
    </>
  );
};

// ---------------- RESOURCES ----------------
const ResourceCard = ({ format, title, desc, ctaLabel, ctaUrl, accent = 'var(--blue)' }) => (
  <div className="retro-card" style={{ padding: 32, display: 'flex', flexDirection: 'column' }}>
    <div style={{
      fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
      color: accent, textTransform: 'uppercase', marginBottom: 12,
    }}>{format}</div>
    <h3 className="h-display" style={{
      fontSize: 26, color: 'var(--blue)', margin: '0 0 12px',
      textTransform: 'uppercase', lineHeight: 1.1,
    }}>{title}</h3>
    <p style={{ fontSize: 14.5, color: 'var(--ink-soft)', lineHeight: 1.65, margin: '0 0 22px', flex: 1 }}>
      {desc}
    </p>
    <a
      href={ctaUrl}
      target="_blank"
      rel="noopener noreferrer"
      className="btn btn-ghost"
      style={{ padding: '11px 18px', fontSize: 12, alignSelf: 'flex-start', textDecoration: 'none' }}
    >
      {ctaLabel} →
    </a>
  </div>
);

const ResourcesPage = ({ onNavigate }) => {
  useLangInt();

  // Featured course (hero)
  const featured = {
    format: Ti('res.featured.format'),
    title: Ti('res.featured.title'),
    desc: Ti('res.featured.desc'),
    ctaLabel: Ti('res.featured.cta'),
    ctaUrl: 'https://prayercourse.org/home/',
  };

  // Mid-grid: 4 supporting resources
  const resources = [
    {
      format: Ti('res.r1.format'),
      title: Ti('res.r1.title'),
      desc: Ti('res.r1.desc'),
      ctaLabel: Ti('res.r1.cta'),
      ctaUrl: 'https://lectio365.com/pray-the-bible/',
      accent: 'var(--gold-deep)',
    },
    {
      format: Ti('res.r2.format'),
      title: Ti('res.r2.title'),
      desc: Ti('res.r2.desc'),
      ctaLabel: Ti('res.r2.cta'),
      ctaUrl: 'https://www.24-7prayer.com/resource/lectio-course/',
    },
    {
      format: Ti('res.r3.format'),
      title: Ti('res.r3.title'),
      desc: Ti('res.r3.desc'),
      ctaLabel: Ti('res.r3.cta'),
      ctaUrl: 'https://www.24-7prayer.com/prayer_guide/courses-on-prayer/',
      accent: 'var(--gold-deep)',
    },
    {
      format: Ti('res.r4.format'),
      title: Ti('res.r4.title'),
      desc: Ti('res.r4.desc'),
      ctaLabel: Ti('res.r4.cta'),
      ctaUrl: 'https://onecry.com/podcast/',
    },
  ];

  const partners = [
    { label: 'Pray The Bay',              sub: Ti('res.partners.p1.sub'), url: 'http://PrayTheBay.org' },
    { label: 'Austin Prays',              sub: Ti('res.partners.p2.sub'), url: 'http://Austinprays.org' },
    { label: 'America Prays',             sub: Ti('res.partners.p3.sub'), url: 'http://Americaprays.org' },
    { label: 'Global Day of Prayer',      sub: Ti('res.partners.p4.sub'), url: 'http://Globaldayofprayer.com' },
    { label: 'Harvest Prayer Ministries', sub: Ti('res.partners.p5.sub'), url: 'http://Harvestprayer.com' },
    { label: 'One Hope Network',          sub: Ti('res.partners.p6.sub'), url: 'https://onehopenetwork.org/community-prayer-guide' },
  ];

  const prayerPoints = [
    Ti('res.points.p1'),
    Ti('res.points.p2'),
    Ti('res.points.p3'),
    Ti('res.points.p4'),
  ];

  return (
    <>
      <PageHeader
        eyebrow={Ti('res.header.eyebrow')}
        title={Ti('res.header.title')}
        subtitle={Ti('res.header.sub')}
        bgImg={IMG.bible}
      />

      {/* Coming Soon overlay */}
      <section className="section" style={{ background: 'var(--beige)', paddingBottom: 60 }}>
        <div className="u-container" style={{ textAlign: 'center', padding: '80px 20px' }}>
          <div style={{
            fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.2em',
            color: 'var(--gold-deep)', textTransform: 'uppercase', marginBottom: 16,
          }}>{Ti('res.coming.eyebrow')}</div>
          <h2 className="h-display" style={{
            fontSize: 48, color: 'var(--blue)', margin: '0 0 20px',
            textTransform: 'uppercase', lineHeight: 1.05,
          }}>{Ti('res.coming.title')}</h2>
          <p style={{ fontSize: 17, color: 'var(--ink-soft)', lineHeight: 1.7, maxWidth: 560, margin: '0 auto 40px' }}>
            {Ti('res.coming.body')}
          </p>
          <button className="btn btn-primary" onClick={() => onNavigate('home')}>
            {Ti('res.coming.cta')} →
          </button>
        </div>
      </section>

      {/* Resource content preserved but hidden until vetted */}
      {false && <>
      {/* Featured hero card */}
      <section className="section" style={{ background: 'var(--beige)', paddingBottom: 40 }}>
        <div className="u-container">
          <div className="retro-card resource-hero" style={{
            padding: 0, overflow: 'hidden',
            display: 'grid', gridTemplateColumns: '1.1fr 1fr',
          }}>
            <div style={{ padding: '48px 48px 44px' }}>
              <div style={{
                fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
                color: 'var(--gold-deep)', textTransform: 'uppercase', marginBottom: 14,
              }}>{featured.format}</div>
              <h2 className="h-display" style={{
                fontSize: 48, color: 'var(--blue)', margin: '0 0 16px',
                textTransform: 'uppercase', lineHeight: 1.05,
              }}>{featured.title}</h2>
              <p style={{ fontSize: 16, color: 'var(--ink-soft)', lineHeight: 1.65, margin: '0 0 28px' }}>
                {featured.desc}
              </p>
              <a
                href={featured.ctaUrl}
                target="_blank"
                rel="noopener noreferrer"
                className="btn btn-primary"
                style={{ textDecoration: 'none' }}
              >
                {featured.ctaLabel} →
              </a>
            </div>
            <div style={{
              background: 'var(--blue)', color: 'var(--cream)',
              padding: '48px 44px', position: 'relative', overflow: 'hidden',
            }}>
              <div style={{
                fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
                color: 'var(--gold)', textTransform: 'uppercase', marginBottom: 24,
              }}>{Ti('res.featured.coverEyebrow')}</div>
              <ol style={{
                listStyle: 'none', padding: 0, margin: 0,
                display: 'grid', gap: 8, counterReset: 'session',
              }}>
                {[
                  Ti('res.featured.s1'),
                  Ti('res.featured.s2'),
                  Ti('res.featured.s3'),
                  Ti('res.featured.s4'),
                  Ti('res.featured.s5'),
                  Ti('res.featured.s6'),
                  Ti('res.featured.s7'),
                  Ti('res.featured.s8'),
                ].map((s, i) => (
                  <li key={s} style={{
                    display: 'flex', alignItems: 'baseline', gap: 14,
                    padding: '10px 0', borderBottom: i < 7 ? '1px dashed rgba(245,225,160,0.25)' : 'none',
                    fontSize: 15,
                  }}>
                    <span style={{
                      fontFamily: 'var(--ff-mono)', fontSize: 11, color: 'var(--gold)',
                      minWidth: 28,
                    }}>0{i + 1}</span>
                    <span>{s}</span>
                  </li>
                ))}
              </ol>
            </div>
          </div>
        </div>
      </section>

      {/* Supporting resources */}
      <section className="section" style={{ background: 'var(--beige)', paddingTop: 24, paddingBottom: 60 }}>
        <div className="u-container">
          <div style={{
            display: 'flex', alignItems: 'baseline', justifyContent: 'space-between',
            marginBottom: 24, gap: 16, flexWrap: 'wrap',
          }}>
            <h2 className="h-display" style={{
              fontSize: 28, color: 'var(--blue)', margin: 0, textTransform: 'uppercase',
            }}>{Ti('res.more.title')}</h2>
            <div style={{
              fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.15em',
              color: 'var(--ink-soft)', textTransform: 'uppercase',
            }}>{Ti('res.more.kicker')}</div>
          </div>
          <div className="resource-grid" style={{
            display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 24,
          }}>
            {resources.map(r => <ResourceCard key={r.title} {...r} />)}
          </div>
        </div>
      </section>

      {/* Bottom row: partners + weekly points */}
      <section className="section" style={{ background: 'var(--cream)', paddingTop: 60 }}>
        <div className="u-container">
          <div className="resource-bottom" style={{
            display: 'grid', gridTemplateColumns: '1.2fr 1fr', gap: 28,
          }}>
            {/* Partner movements */}
            <div className="retro-card" style={{ padding: 36 }}>
              <div style={{
                fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
                color: 'var(--blue)', textTransform: 'uppercase', marginBottom: 10,
              }}>{Ti('res.partners.eyebrow')}</div>
              <h3 className="h-display" style={{
                fontSize: 28, color: 'var(--blue)', margin: '0 0 8px',
                textTransform: 'uppercase',
              }}>{Ti('res.partners.title')}</h3>
              <p style={{ fontSize: 14, color: 'var(--ink-soft)', lineHeight: 1.6, margin: '0 0 20px' }}>
                {Ti('res.partners.body')}
              </p>
              <ul style={{ listStyle: 'none', padding: 0, margin: 0, borderTop: '1px dashed rgba(11,45,92,0.25)' }}>
                {partners.map(p => (
                  <li key={p.label} style={{ borderBottom: '1px dashed rgba(11,45,92,0.15)' }}>
                    <a
                      href={p.url}
                      target="_blank"
                      rel="noopener noreferrer"
                      style={{
                        display: 'flex', justifyContent: 'space-between', alignItems: 'center',
                        padding: '14px 0', textDecoration: 'none', gap: 16,
                      }}
                    >
                      <div>
                        <div style={{ fontSize: 15, color: 'var(--ink)', fontWeight: 600 }}>{p.label}</div>
                        <div style={{ fontSize: 12, color: 'var(--ink-soft)', marginTop: 2 }}>{p.sub}</div>
                      </div>
                      <span style={{ color: 'var(--gold-deep)', fontFamily: 'var(--ff-mono)', fontSize: 11 }}>→</span>
                    </a>
                  </li>
                ))}
              </ul>
            </div>

            {/* Weekly prayer points — NOT links */}
            <div className="retro-card" style={{
              padding: 36, background: 'var(--blue)', color: 'var(--cream)',
            }}>
              <div style={{
                fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
                color: 'var(--gold)', textTransform: 'uppercase', marginBottom: 10,
              }}>{Ti('res.points.eyebrow')}</div>
              <h3 className="h-display" style={{
                fontSize: 28, color: 'var(--cream)', margin: '0 0 8px',
                textTransform: 'uppercase',
              }}>{Ti('res.points.title')}</h3>
              <p style={{ fontSize: 14, color: 'rgba(245,225,160,0.85)', lineHeight: 1.6, margin: '0 0 24px' }}>
                {Ti('res.points.body')}
              </p>
              <ul style={{ listStyle: 'none', padding: 0, margin: 0 }}>
                {prayerPoints.map((pt, i) => (
                  <li key={i} style={{
                    display: 'flex', gap: 14, padding: '14px 0',
                    borderBottom: i < prayerPoints.length - 1 ? '1px dashed rgba(245,225,160,0.25)' : 'none',
                    fontSize: 15, lineHeight: 1.5,
                  }}>
                    <span style={{
                      fontFamily: 'var(--ff-mono)', fontSize: 11, color: 'var(--gold)',
                      minWidth: 28, paddingTop: 3,
                    }}>0{i + 1}</span>
                    <span>{pt}</span>
                  </li>
                ))}
              </ul>
            </div>
          </div>
        </div>
      </section>
      </>}
    </>
  );
};

// ---------------- INTERCESSORS ----------------
// Coverage week — 7×24 grid of which hours are claimed
const COVERAGE_WEEK = (() => {
  // deterministic-ish: ~70% claimed, with overnight gaps
  const rows = [];
  for (let d = 0; d < 7; d++) {
    const row = [];
    for (let h = 0; h < 24; h++) {
      // overnight (1–4am) tends to be open; rest mostly covered
      const open = (h >= 1 && h <= 4) ? Math.random() < 0.55 : Math.random() < 0.18;
      row.push(open ? 'open' : 'covered');
    }
    rows.push(row);
  }
  return rows;
})();

const IntercessorsPage = () => {
  useLangInt();
  const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];

  const testimonies = [
    { date: Ti('int.test.t1.date'), meta: Ti('int.test.t1.meta'), title: Ti('int.test.t1.h'), body: Ti('int.test.t1.b') },
    { date: Ti('int.test.t2.date'), meta: Ti('int.test.t2.meta'), title: Ti('int.test.t2.h'), body: Ti('int.test.t2.b') },
    { date: Ti('int.test.t3.date'), meta: Ti('int.test.t3.meta'), title: Ti('int.test.t3.h'), body: Ti('int.test.t3.b') },
  ];

  const checkins = [
    { n: Ti('int.checkin.c1.n'), church: Ti('int.checkin.c1.church'), t: Ti('int.checkin.c1.t'), tag: Ti('int.checkin.c1.tag'), m: Ti('int.checkin.c1.m') },
    { n: Ti('int.checkin.c2.n'), church: Ti('int.checkin.c2.church'), t: Ti('int.checkin.c2.t'), tag: Ti('int.checkin.c2.tag'), m: Ti('int.checkin.c2.m') },
    { n: Ti('int.checkin.c3.n'), church: Ti('int.checkin.c3.church'), t: Ti('int.checkin.c3.t'), tag: Ti('int.checkin.c3.tag'), m: Ti('int.checkin.c3.m') },
    { n: Ti('int.checkin.c4.n'), church: Ti('int.checkin.c4.church'), t: Ti('int.checkin.c4.t'), tag: Ti('int.checkin.c4.tag'), m: Ti('int.checkin.c4.m') },
  ];

  // Map each tag value back to its color (compare against EN canonical tags via key prefix)
  const tagColorMap = {
    Praying: 'var(--blue)', Orando: 'var(--blue)',
    Need: '#b45309', Necesidad: '#b45309',
    Word: 'var(--gold-deep)', Palabra: 'var(--gold-deep)',
    Praise: '#15803d', Alabanza: '#15803d',
  };

  return (
  <>
    <PageHeader
      eyebrow={Ti('int.header.eyebrow')}
      title={Ti('int.header.title')}
      subtitle={Ti('int.header.sub')}
      bgImg="uploads/stained-glass-intercession.png"
      bgOpacity={0.25}
      bgFilter="none"
    />

    {/* CLAIM-AN-HOUR STRIP */}
    <section className="section" style={{ background: 'var(--beige)', paddingTop: 50, paddingBottom: 30 }}>
      <div className="u-container">
        <div className="retro-card" style={{ padding: 0, overflow: 'hidden' }}>
          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1.1fr', gap: 0 }} className="claim-strip">
            {/* Left: pitch */}
            <div style={{ padding: '40px 40px 36px' }}>
              <div style={{
                fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
                color: 'var(--gold-deep)', textTransform: 'uppercase', marginBottom: 12,
              }}>{Ti('int.claim.eyebrow')}</div>
              <h2 className="h-display" style={{
                fontSize: 36, color: 'var(--blue)', margin: '0 0 14px',
                textTransform: 'uppercase', lineHeight: 1.05,
              }}>{Ti('int.claim.title')}</h2>
              <p style={{ fontSize: 15.5, color: 'var(--ink-soft)', lineHeight: 1.65, margin: '0 0 22px' }}>
                {Ti('int.claim.body')}
              </p>
              <div style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
                <button className="btn btn-primary">{Ti('int.claim.cta1')} →</button>
                <button className="btn btn-ghost">{Ti('int.claim.cta2')}</button>
              </div>
            </div>
            {/* Right: coverage week heatmap */}
            <div style={{ background: 'var(--blue)', padding: '32px 32px 28px', color: 'var(--cream)' }}>
              <div style={{
                display: 'flex', justifyContent: 'space-between', alignItems: 'baseline',
                marginBottom: 18,
              }}>
                <div style={{
                  fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
                  color: 'var(--gold)', textTransform: 'uppercase',
                }}>{Ti('int.claim.coverageLabel')}</div>
                <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'rgba(245,225,160,0.7)' }}>
                  Apr 20 – 26
                </div>
              </div>
              {/* Heatmap */}
              <div style={{ display: 'grid', gridTemplateColumns: '32px 1fr', gap: 4, marginBottom: 14 }}>
                <div />
                <div style={{ display: 'grid', gridTemplateColumns: 'repeat(24, 1fr)', gap: 2, fontFamily: 'var(--ff-mono)', fontSize: 8, color: 'rgba(245,225,160,0.5)' }}>
                  {[0, 6, 12, 18].map(h => (
                    <div key={h} style={{ gridColumn: `${h + 1} / span 6`, textAlign: 'left' }}>
                      {h === 0 ? '12a' : h === 12 ? '12p' : h > 12 ? `${h - 12}p` : `${h}a`}
                    </div>
                  ))}
                </div>
                {COVERAGE_WEEK.map((row, di) => (
                  <React.Fragment key={di}>
                    <div style={{
                      fontFamily: 'var(--ff-mono)', fontSize: 10,
                      color: 'var(--gold)', alignSelf: 'center',
                    }}>{days[di]}</div>
                    <div style={{ display: 'grid', gridTemplateColumns: 'repeat(24, 1fr)', gap: 2 }}>
                      {row.map((cell, hi) => (
                        <div
                          key={hi}
                          title={`${days[di]} ${hi}:00 — ${cell}`}
                          style={{
                            aspectRatio: '1',
                            background: cell === 'covered' ? 'var(--gold)' : 'rgba(245,225,160,0.12)',
                            border: cell === 'open' ? '1px dashed rgba(245,225,160,0.35)' : 'none',
                            borderRadius: 2,
                          }}
                        />
                      ))}
                    </div>
                  </React.Fragment>
                ))}
              </div>
              <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.1em', color: 'rgba(245,225,160,0.6)', textTransform: 'uppercase' }}>
                {Ti('int.claim.coverageNote')}
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>

    {/* WEEKLY FOCUS */}
    <section className="section" style={{ background: 'var(--beige)', paddingTop: 30, paddingBottom: 50 }}>
      <div className="u-container">
        <div className="int-focus" style={{ display: 'grid', gridTemplateColumns: '1.3fr 1fr', gap: 28 }}>
          <div className="retro-card" style={{ padding: 40 }}>
            <div style={{
              fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
              color: 'var(--gold-deep)', textTransform: 'uppercase', marginBottom: 12,
              display: 'flex', alignItems: 'center', gap: 10,
            }}>
              <span style={{ display: 'inline-block', width: 8, height: 8, borderRadius: '50%', background: 'var(--gold-deep)' }} />
              {Ti('int.focus.eyebrow')}
            </div>
            <h2 className="h-display" style={{
              fontSize: 38, color: 'var(--blue)', margin: '0 0 18px',
              textTransform: 'uppercase', lineHeight: 1.05,
            }}>{Ti('int.focus.title')}</h2>
            <p style={{ fontSize: 16, color: 'var(--ink-soft)', lineHeight: 1.75, margin: '0 0 28px' }}>
              {Ti('int.focus.body')}
            </p>
          </div>
          <div className="retro-card" style={{
            padding: 36,
            background: 'var(--cream)',
            display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
          }}>
            <div>
              <div style={{
                fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
                color: 'var(--gold-deep)', textTransform: 'uppercase', marginBottom: 14,
              }}>{Ti('int.focus.scriptureLabel')}</div>
              <p className="h-elegant" style={{
                fontSize: 22, color: 'var(--blue)', margin: '0 0 16px',
                lineHeight: 1.45, fontStyle: 'italic',
              }}>
                {Ti('int.focus.scripture')}
              </p>
            </div>
            <div style={{
              borderTop: '1px dashed rgba(11,45,92,0.25)', paddingTop: 16,
              fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.15em',
              color: 'var(--gold-deep)', textTransform: 'uppercase',
            }}>
              {Ti('int.focus.scriptureRef')}
            </div>
          </div>
        </div>
      </div>
    </section>

    {/* TESTIMONIES + CHECK-IN BOARD */}
    <section className="section" style={{ background: 'var(--cream)', paddingTop: 70 }}>
      <div className="u-container">
        <div className="int-bottom" style={{ display: 'grid', gridTemplateColumns: '1.3fr 1fr', gap: 40 }}>
          {/* Testimonies as letter-stack */}
          <div>
            <div style={{ marginBottom: 26 }}>
              <div style={{
                fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
                color: 'var(--gold-deep)', textTransform: 'uppercase', marginBottom: 8,
              }}>{Ti('int.test.eyebrow')}</div>
              <h2 className="h-display" style={{
                fontSize: 32, color: 'var(--blue)', margin: 0, textTransform: 'uppercase',
              }}>{Ti('int.test.title')}</h2>
            </div>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 20 }}>
              {testimonies.map((t, i) => (
                <div key={i} className="retro-card" style={{ padding: 32, position: 'relative' }}>
                  <div style={{
                    display: 'flex', justifyContent: 'space-between', alignItems: 'baseline',
                    marginBottom: 10, flexWrap: 'wrap', gap: 8,
                  }}>
                    <div style={{
                      fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.15em',
                      color: 'var(--gold-deep)', textTransform: 'uppercase',
                    }}>{t.date}</div>
                    <div style={{
                      fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.12em',
                      color: 'var(--ink-soft)', textTransform: 'uppercase',
                    }}>{t.meta}</div>
                  </div>
                  <h3 className="h-display" style={{
                    fontSize: 24, color: 'var(--blue)', margin: '0 0 10px',
                    textTransform: 'uppercase', lineHeight: 1.15,
                  }}>{t.title}</h3>
                  <p style={{ margin: 0, fontSize: 15, color: 'var(--ink-soft)', lineHeight: 1.7 }}>{t.body}</p>
                </div>
              ))}
            </div>
          </div>

          {/* Check-in feed */}
          <div>
            <div style={{ marginBottom: 26 }}>
              <div style={{
                display: 'flex', alignItems: 'center', gap: 10, marginBottom: 8,
              }}>
                <span style={{
                  display: 'inline-block', width: 8, height: 8,
                  borderRadius: '50%', background: '#22c55e',
                  boxShadow: '0 0 0 4px rgba(34,197,94,0.18)',
                }} />
                <div style={{
                  fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
                  color: 'var(--gold-deep)', textTransform: 'uppercase',
                }}>{Ti('int.checkin.eyebrow')}</div>
              </div>
              <h2 className="h-display" style={{
                fontSize: 28, color: 'var(--blue)', margin: 0, textTransform: 'uppercase',
              }}>{Ti('int.checkin.title')}</h2>
            </div>
            <div className="retro-card" style={{ padding: 8 }}>
              {checkins.map((c, i) => {
                const tagColor = tagColorMap[c.tag] || 'var(--blue)';
                return (
                  <div key={i} style={{
                    padding: '20px 24px',
                    borderBottom: i < checkins.length - 1 ? '1px dashed rgba(11,45,92,0.18)' : 'none',
                  }}>
                    <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 6, gap: 10 }}>
                      <div style={{ display: 'flex', alignItems: 'center', gap: 10, minWidth: 0 }}>
                        <div style={{
                          width: 30, height: 30, borderRadius: '50%',
                          background: 'var(--beige-2)', border: '1.5px solid var(--ink)',
                          display: 'flex', alignItems: 'center', justifyContent: 'center',
                          fontFamily: 'var(--ff-display)', fontSize: 11, color: 'var(--blue)',
                          fontWeight: 700, flexShrink: 0,
                        }}>{c.n.charAt(0)}</div>
                        <div style={{ minWidth: 0 }}>
                          <div style={{
                            fontFamily: 'var(--ff-display)', fontSize: 14, color: 'var(--blue)', fontWeight: 600,
                            whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis',
                          }}>{c.n}</div>
                          <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--ink-soft)' }}>
                            {c.church}
                          </div>
                        </div>
                      </div>
                      <span style={{
                        fontFamily: 'var(--ff-mono)', fontSize: 9, letterSpacing: '0.12em',
                        color: tagColor, textTransform: 'uppercase',
                        padding: '3px 8px', border: `1px solid ${tagColor}`, borderRadius: 999,
                        flexShrink: 0,
                      }}>{c.tag}</span>
                    </div>
                    <p style={{
                      margin: '6px 0 6px 40px', fontSize: 13.5, color: 'var(--ink-soft)', lineHeight: 1.55,
                    }}>{c.m}</p>
                    <div style={{
                      fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--ink-soft)',
                      marginLeft: 40, opacity: 0.7,
                    }}>{c.t}</div>
                  </div>
                );
              })}
            </div>
          </div>
        </div>
      </div>
    </section>
  </>
  );
};

// ---------------- CALENDAR ----------------
const CalendarPage = () => {
  useLangInt();
  // Months data — April 2026 has the real content; neighbors are empty
  const MONTHS = [
    { labelKey: 'cal.month.mar', offset: 0, days: 31 },
    { labelKey: 'cal.month.apr', offset: 3, days: 30, today: 22 },
    { labelKey: 'cal.month.may', offset: 5, days: 31 },
    { labelKey: 'cal.month.jun', offset: 1, days: 30 },
  ];
  const [monthIdx, setMonthIdx] = React.useState(1);
  const month = MONTHS[monthIdx];
  const FIRST_DAY_OFFSET = month.offset;
  const DAYS_IN_MONTH = month.days;
  const TODAY = month.today || 0;

  const [selectedDay, setSelectedDay] = React.useState(24);

  // Real, plausible Sacramento prayer events (April only)
  const eventsApril = {
    22: [
      { time: Ti('cal.e22.1.time'), dur: Ti('cal.e22.1.dur'),
        title: Ti('cal.e22.1.title'), host: Ti('cal.e22.1.host'),
        loc: Ti('cal.e22.1.loc'), tag: 'walk' },
    ],
    24: [
      { time: Ti('cal.e24.1.time'), dur: Ti('cal.e24.1.dur'),
        title: Ti('cal.e24.1.title'), host: Ti('cal.e24.1.host'),
        loc: Ti('cal.e24.1.loc'), tag: 'pastors' },
      { time: Ti('cal.e24.2.time'), dur: Ti('cal.e24.2.dur'),
        title: Ti('cal.e24.2.title'), host: Ti('cal.e24.2.host'),
        loc: Ti('cal.e24.2.loc'), tag: 'walk' },
      { time: Ti('cal.e24.3.time'), dur: Ti('cal.e24.3.dur'),
        title: Ti('cal.e24.3.title'), host: Ti('cal.e24.3.host'),
        loc: Ti('cal.e24.3.loc'), tag: 'worship' },
    ],
    26: [
      { time: Ti('cal.e26.1.time'), dur: Ti('cal.e26.1.dur'),
        title: Ti('cal.e26.1.title'), host: Ti('cal.e26.1.host'),
        loc: Ti('cal.e26.1.loc'), tag: 'gathering' },
    ],
    28: [
      { time: Ti('cal.e28.1.time'), dur: Ti('cal.e28.1.dur'),
        title: Ti('cal.e28.1.title'), host: Ti('cal.e28.1.host'),
        loc: Ti('cal.e28.1.loc'), tag: 'walk' },
    ],
    30: [
      { time: Ti('cal.e30.1.time'), dur: Ti('cal.e30.1.dur'),
        title: Ti('cal.e30.1.title'), host: Ti('cal.e30.1.host'),
        loc: Ti('cal.e30.1.loc'), tag: 'worship' },
    ],
  };

  // Recurring rhythms (every week)
  const rhythms = [
    { day: Ti('cal.r1.day'), time: Ti('cal.r1.time'), title: Ti('cal.r1.title'), loc: Ti('cal.r1.loc') },
    { day: Ti('cal.r2.day'), time: Ti('cal.r2.time'), title: Ti('cal.r2.title'), loc: Ti('cal.r2.loc') },
    { day: Ti('cal.r3.day'), time: Ti('cal.r3.time'), title: Ti('cal.r3.title'), loc: Ti('cal.r3.loc') },
    { day: Ti('cal.r4.day'), time: Ti('cal.r4.time'), title: Ti('cal.r4.title'), loc: Ti('cal.r4.loc') },
    { day: Ti('cal.r5.day'), time: Ti('cal.r5.time'), title: Ti('cal.r5.title'), loc: Ti('cal.r5.loc') },
  ];

  // tag keys are stable; map to color + display label via Ti
  const tagColor = (t) => ({
    walk: 'var(--blue)',
    worship: 'var(--gold-deep)',
    pastors: '#15803d',
    gathering: '#b45309',
  })[t] || 'var(--blue)';
  const tagLabel = (t) => ({
    walk: Ti('cal.legend.walk'),
    worship: Ti('cal.legend.worship'),
    pastors: Ti('cal.legend.pastors'),
    gathering: Ti('cal.legend.gathering'),
  })[t] || t;

  // Only April has events; other months show empty state
  const events = monthIdx === 1 ? eventsApril : {};

  const goPrev = () => {
    setMonthIdx(i => Math.max(0, i - 1));
    setSelectedDay(1);
  };
  const goNext = () => {
    setMonthIdx(i => Math.min(MONTHS.length - 1, i + 1));
    setSelectedDay(1);
  };

  const dayEvents = events[selectedDay] || [];
  const totalEventDays = Object.keys(events).length;
  const totalEvents = Object.values(events).reduce((a, b) => a + b.length, 0);

  return (
    <>
      <PageHeader
        eyebrow={Ti('cal.header.eyebrow')}
        title={Ti('cal.header.title')}
        subtitle={Ti('cal.header.sub')}
        bgImg="uploads/sacramento-gathering.png"
        bgOpacity={0.4}
        bgFilter="saturate(1.05)"
        bgPosition="center 35%"
      />

      {/* Month grid + selected day events */}
      <section className="section" style={{ background: 'var(--beige)', paddingTop: 50, paddingBottom: 50 }}>
        <div className="u-container">
          <div className="cal-grid" style={{ display: 'grid', gridTemplateColumns: '1.25fr 1fr', gap: 32 }}>

            {/* MONTH GRID */}
            <div className="retro-card" style={{ padding: 36 }}>
              <div style={{
                display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start',
                marginBottom: 28, gap: 16,
              }}>
                <div>
                  <div style={{
                    fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
                    color: 'var(--gold-deep)', textTransform: 'uppercase', marginBottom: 6,
                  }}>{totalEvents} {Ti('cal.eventCount.events')} · {totalEventDays} {totalEventDays === 1 ? Ti('cal.eventCount.day') : Ti('cal.eventCount.days')}</div>
                  <h2 className="h-display" style={{
                    fontSize: 36, color: 'var(--blue)', margin: 0,
                    textTransform: 'uppercase', lineHeight: 1,
                  }}>{Ti(month.labelKey)}</h2>
                </div>
                <div style={{ display: 'flex', gap: 8 }}>
                  <button onClick={goPrev} aria-label="Previous month" disabled={monthIdx === 0} style={{
                    width: 42, height: 42, borderRadius: '50%',
                    border: '1.5px solid var(--blue)', background: 'transparent',
                    color: 'var(--blue)', fontSize: 18,
                    cursor: monthIdx === 0 ? 'not-allowed' : 'pointer',
                    opacity: monthIdx === 0 ? 0.35 : 1,
                  }}>‹</button>
                  <button onClick={goNext} aria-label="Next month" disabled={monthIdx === MONTHS.length - 1} style={{
                    width: 42, height: 42, borderRadius: '50%',
                    border: '1.5px solid var(--blue)',
                    background: monthIdx === MONTHS.length - 1 ? 'transparent' : 'var(--blue)',
                    color: monthIdx === MONTHS.length - 1 ? 'var(--blue)' : 'var(--gold)',
                    fontSize: 18,
                    cursor: monthIdx === MONTHS.length - 1 ? 'not-allowed' : 'pointer',
                    opacity: monthIdx === MONTHS.length - 1 ? 0.35 : 1,
                  }}>›</button>
                </div>
              </div>

              {/* Day headers */}
              <div style={{
                display: 'grid', gridTemplateColumns: 'repeat(7, 1fr)', gap: 6,
                marginBottom: 8, paddingBottom: 12,
                borderBottom: '1px dashed rgba(11,45,92,0.2)',
              }}>
                {['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'].map((d, i) => (
                  <div key={i} style={{
                    textAlign: 'center', fontFamily: 'var(--ff-mono)', fontSize: 10,
                    letterSpacing: '0.2em', color: 'var(--gold-deep)', padding: 4,
                  }}>{d}</div>
                ))}
              </div>

              {/* Day cells */}
              <div style={{ display: 'grid', gridTemplateColumns: 'repeat(7, 1fr)', gap: 6, marginTop: 12 }}>
                {Array.from({ length: FIRST_DAY_OFFSET }).map((_, i) => <div key={`p${i}`} />)}
                {Array.from({ length: DAYS_IN_MONTH }, (_, i) => i + 1).map(d => {
                  const dayEvts = events[d] || [];
                  const has = dayEvts.length > 0;
                  const selected = d === selectedDay;
                  const isToday = d === TODAY;
                  return (
                    <button
                      key={d}
                      onClick={() => setSelectedDay(d)}
                      style={{
                        aspectRatio: '1',
                        background: selected ? 'var(--blue)' : 'transparent',
                        color: selected ? 'var(--gold)' : 'var(--ink)',
                        border: selected ? 'none'
                          : isToday ? '1.5px solid var(--gold-deep)'
                          : has ? '1.5px solid rgba(11,45,92,0.35)'
                          : '1px solid rgba(11,45,92,0.12)',
                        borderRadius: 8,
                        fontFamily: 'var(--ff-display)',
                        fontSize: 17,
                        fontWeight: selected || isToday ? 700 : 500,
                        position: 'relative',
                        cursor: 'pointer',
                        padding: 0,
                      }}
                    >
                      {d}
                      {/* event dots */}
                      {has && !selected && (
                        <span style={{
                          position: 'absolute', bottom: 6, left: '50%',
                          transform: 'translateX(-50%)', display: 'flex', gap: 3,
                        }}>
                          {dayEvts.slice(0, 3).map((e, j) => (
                            <span key={j} style={{
                              width: 4, height: 4, borderRadius: '50%',
                              background: tagColor(e.tag),
                            }} />
                          ))}
                        </span>
                      )}
                      {/* today label */}
                      {isToday && !selected && (
                        <span style={{
                          position: 'absolute', top: 4, right: 6,
                          fontFamily: 'var(--ff-mono)', fontSize: 7,
                          letterSpacing: '0.1em', color: 'var(--gold-deep)',
                        }}>TODAY</span>
                      )}
                    </button>
                  );
                })}
              </div>

              {/* Legend */}
              <div style={{
                marginTop: 24, paddingTop: 18,
                borderTop: '1px dashed rgba(11,45,92,0.2)',
                display: 'flex', flexWrap: 'wrap', gap: '10px 18px',
                fontFamily: 'var(--ff-mono)', fontSize: 9, letterSpacing: '0.12em',
                color: 'var(--ink-soft)', textTransform: 'uppercase',
              }}>
                {['walk', 'worship', 'pastors', 'gathering'].map(t => (
                  <span key={t} style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
                    <span style={{ width: 7, height: 7, borderRadius: '50%', background: tagColor(t) }} />
                    {tagLabel(t)}
                  </span>
                ))}
              </div>
            </div>

            {/* SELECTED DAY EVENTS */}
            <div>
              <div style={{ marginBottom: 18 }}>
                <div style={{
                  fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
                  color: 'var(--gold-deep)', textTransform: 'uppercase', marginBottom: 6,
                }}>{Ti(month.labelKey).split(' ')[0]} {selectedDay}{selectedDay === TODAY ? ' · ' + Ti('cal.today') : ''}</div>
                <h3 className="h-display" style={{
                  fontSize: 28, color: 'var(--blue)', margin: 0, textTransform: 'uppercase',
                }}>
                  {dayEvents.length === 0
                    ? Ti('cal.dayHeader.zero')
                    : dayEvents.length === 1 ? Ti('cal.dayHeader.one')
                    : Ti('cal.dayHeader.many').replace('{n}', dayEvents.length)}
                </h3>
              </div>

              {dayEvents.length > 0 ? (
                <div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
                  {dayEvents.map((e, i) => {
                    const c = tagColor(e.tag);
                    return (
                      <div key={i} className="retro-card" style={{ padding: '24px 24px 24px 32px', position: 'relative', overflow: 'hidden' }}>
                        <div style={{
                          position: 'absolute', top: 0, left: 0, bottom: 0,
                          width: 8, background: c,
                        }} />
                        <div style={{
                          display: 'flex', justifyContent: 'space-between', alignItems: 'baseline',
                          marginBottom: 10, gap: 12, flexWrap: 'wrap',
                        }}>
                          <div style={{
                            fontFamily: 'var(--ff-mono)', fontSize: 13, letterSpacing: '0.1em',
                            color: 'var(--blue)', fontWeight: 600,
                          }}>
                            {e.time} <span style={{ color: 'var(--ink-soft)', fontWeight: 400 }}>· {e.dur}</span>
                          </div>
                          <span style={{
                            fontFamily: 'var(--ff-mono)', fontSize: 9, letterSpacing: '0.12em',
                            color: c, textTransform: 'uppercase',
                            padding: '3px 8px', border: `1px solid ${c}`, borderRadius: 999,
                          }}>{tagLabel(e.tag)}</span>
                        </div>
                        <h4 className="h-display" style={{
                          fontSize: 20, color: 'var(--blue)', margin: '0 0 10px',
                          textTransform: 'uppercase', lineHeight: 1.15,
                        }}>{e.title}</h4>
                        <div style={{ fontSize: 13, color: 'var(--ink-soft)', marginBottom: 4 }}>
                          {e.host}
                        </div>
                        <div style={{
                          fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.08em',
                          color: 'var(--ink-soft)', marginBottom: 16,
                          display: 'flex', alignItems: 'center', gap: 7,
                        }}>
                          <svg width="11" height="14" viewBox="0 0 11 14" fill="none" style={{ flexShrink: 0 }}>
                            <path d="M5.5 0.5C2.74 0.5 0.5 2.74 0.5 5.5C0.5 9.25 5.5 13.5 5.5 13.5C5.5 13.5 10.5 9.25 10.5 5.5C10.5 2.74 8.26 0.5 5.5 0.5Z" stroke="currentColor" strokeWidth="1.2" fill="none"/>
                            <circle cx="5.5" cy="5.5" r="1.6" fill="currentColor"/>
                          </svg>
                          {e.loc}
                        </div>
                        <div style={{ display: 'flex', gap: 10 }}>
                          <button className="btn btn-ghost" style={{ padding: '8px 14px', fontSize: 11 }}>
                            {Ti('cal.btn.add')}
                          </button>
                          <button className="btn btn-ghost" style={{ padding: '8px 14px', fontSize: 11 }}>
                            {Ti('cal.btn.directions')}
                          </button>
                        </div>
                      </div>
                    );
                  })}
                </div>
              ) : (
                <div style={{
                  padding: '48px 32px', textAlign: 'center',
                  background: 'var(--beige-2)', borderRadius: 14,
                  border: '1.5px dashed rgba(11,45,92,0.25)',
                }}>
                  <div className="h-elegant" style={{
                    fontSize: 20, color: 'var(--blue)', margin: '0 0 8px', fontStyle: 'italic',
                  }}>{Ti('cal.empty.quote')}</div>
                  <p style={{ fontSize: 13, color: 'var(--ink-soft)', margin: 0, lineHeight: 1.6 }}>
                    {Ti('cal.empty.body')}
                  </p>
                </div>
              )}
            </div>
          </div>
        </div>
      </section>

      {/* WEEKLY RHYTHMS */}
      <section className="section" style={{ background: 'var(--cream)', paddingTop: 70, paddingBottom: 80 }}>
        <div className="u-container">
          <div style={{
            display: 'flex', alignItems: 'baseline', justifyContent: 'space-between',
            marginBottom: 28, gap: 16, flexWrap: 'wrap',
          }}>
            <div>
              <div style={{
                fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
                color: 'var(--gold-deep)', textTransform: 'uppercase', marginBottom: 8,
              }}>{Ti('cal.rhythms.eyebrow')}</div>
              <h2 className="h-display" style={{
                fontSize: 36, color: 'var(--blue)', margin: 0, textTransform: 'uppercase',
              }}>{Ti('cal.rhythms.title')}</h2>
            </div>
            <div style={{ fontSize: 14, color: 'var(--ink-soft)', maxWidth: 360, textAlign: 'right' }}>
              {Ti('cal.rhythms.note')}
            </div>
          </div>
          <div className="rhythms-grid" style={{
            display: 'grid', gridTemplateColumns: 'repeat(5, 1fr)', gap: 16,
          }}>
            {rhythms.map((r, i) => (
              <div key={i} style={{
                padding: 24,
                background: 'var(--beige)',
                border: '1.5px solid var(--ink)',
                borderRadius: 12,
                boxShadow: '4px 4px 0 var(--gold-deep)',
                display: 'flex', flexDirection: 'column', gap: 10,
              }}>
                <div style={{
                  fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em',
                  color: 'var(--gold-deep)', textTransform: 'uppercase',
                }}>{r.day}</div>
                <div style={{
                  fontFamily: 'var(--ff-display)', fontSize: 22, color: 'var(--blue)',
                  fontWeight: 700,
                }}>{r.time}</div>
                <h4 className="h-display" style={{
                  fontSize: 16, color: 'var(--blue)', margin: '4px 0 0',
                  textTransform: 'uppercase', lineHeight: 1.2,
                }}>{r.title}</h4>
                <div style={{ fontSize: 12, color: 'var(--ink-soft)', lineHeight: 1.5, marginTop: 'auto' }}>
                  {r.loc}
                </div>
              </div>
            ))}
          </div>
        </div>
      </section>
    </>
  );
};

/* ─── PRAYER PAGE: wall + form combined ─── */
const PrayerPage = ({ onNavigate }) => {
  useLangInt();
  return (
    <>
      <PageHeader
        eyebrow={Ti('wall.page.eyebrow')}
        title={Ti('wall.page.title')}
        subtitle={Ti('wall.page.sub')}
        bgImg="uploads/sacramento-gathering.png"
        bgOpacity={0.15}
      />
      <window.PrayerWallV2 />
      <window.PrayerFormV2 />
    </>
  );
};

/* ─── REGISTER: multi-step church signup ─── */
const NEIGHBORHOODS = [
  'Antelope', 'Arden-Arcade', 'Auburn', 'Cameron Park', 'Carmichael',
  'Citrus Heights', 'Clarksburg', 'Colfax', 'Cool', 'Courtland',
  'Davis', 'Dixon', 'Downtown Sacramento', 'East Sacramento', 'El Dorado Hills',
  'Elk Grove', 'Elverta', 'Esparto', 'Fair Oaks', 'Florin',
  'Folsom', 'Foothill Farms', 'Foresthill', 'Franklin', 'Fruitridge',
  'Galt', 'Georgetown', 'Gold River', 'Granite Bay', 'Grass Valley',
  'Greenback', 'Herald', 'Highlands', 'Hood', 'Isleton',
  'La Riviera', 'Laguna', 'Land Park', 'Lincoln', 'Live Oak',
  'Loomis', 'Marysville', 'McClellan Park', 'Meadowview', 'Midtown Sacramento',
  'Natomas', 'Nevada City', 'Newcastle', 'North Highlands', 'North Sacramento',
  'Oak Park', 'Olivehurst', 'Orangevale', 'Penryn', 'Pilot Hill',
  'Placerville', 'Pocket', 'Rancho Cordova', 'Rancho Murieta', 'Rio Linda',
  'Rio Vista', 'Robla', 'Rocklin', 'Rosemont', 'Roseville',
  'Sacramento (Central)', 'Shingle Springs', 'South Lake Tahoe', 'South Sacramento',
  'Suisun City', 'Sutter Creek', 'Tahoe City', 'Truckee', 'Vacaville',
  'Vineyard', 'Walnut Grove', 'West Sacramento', 'Wheatland', 'Wilton',
  'Winters', 'Woodland', 'Yuba City / Plumas Lake', 'Other',
];
const SIZES = ['Under 50', '50–200', '200+'];

const RegisterPage = ({ onNavigate }) => {
  useLangInt();
  const [step, setStep] = React.useState(1);
  const [form, setForm] = React.useState({
    contactName: '', phone: '', email: '',
    churchName: '', neighborhood: '', churchSize: '',
    preferredDay: 0, cycleTrack: '',
    hasIntercessor: null,
    intercessorName: '', intercessorPhone: '', intercessorEmail: '',
    website: '',
  });
  const [loading, setLoading] = React.useState(false);
  const [err, setErr] = React.useState('');
  const [claimedDays, setClaimedDays] = React.useState({ A: {}, B: {} });
  const [cycleIndex, setCycleIndex] = React.useState(() => Math.random() < 0.5 ? 0 : 1);
  const set = (k, v) => setForm(f => ({ ...f, [k]: v }));

  React.useEffect(() => {
    fetch('/api/claimed-days')
      .then(r => r.json())
      .then(({ A, B }) => { setClaimedDays({ A: A || {}, B: B || {} }); })
      .catch(() => {});
  }, []);

  const canAdvance = step === 1
    ? form.contactName.trim() && form.phone.trim()
    : step === 2
    ? form.churchName.trim() && form.neighborhood && form.churchSize
    : true;

  const submit = async () => {
    setLoading(true);
    setErr('');
    try {
      const payload = {
        contactName: form.contactName, phone: form.phone, email: form.email,
        churchName: form.churchName, neighborhood: form.neighborhood, churchSize: form.churchSize,
        preferredDay: form.preferredDay,
        cycleTrack: form.cycleTrack || 'A',
        hasIntercessor: form.hasIntercessor === true,
        intercessorName: form.intercessorName, intercessorPhone: form.intercessorPhone, intercessorEmail: form.intercessorEmail,
        website: form.website,
      };
      const res = await fetch('/api/register-church', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(payload),
      });
      if (!res.ok) {
        const data = await res.json().catch(() => ({}));
        setErr(data.error || 'Something went wrong. Please try again.');
        setLoading(false);
        return;
      }
    } catch (_) { setErr('Something went wrong. Please try again.'); setLoading(false); return; }
    setLoading(false);
    setStep(4);
  };

  const inputStyle = {
    width: '100%', padding: 14, fontFamily: 'var(--ff-body)', fontSize: 15,
    color: 'var(--ink)', background: 'white',
    border: '1.5px solid rgba(11,45,92,0.25)', borderRadius: 10,
  };
  const labelStyle = {
    display: 'block', fontFamily: 'var(--ff-mono)', fontSize: 10,
    letterSpacing: '0.2em', textTransform: 'uppercase',
    color: 'var(--gold-deep)', marginBottom: 8,
  };
  const pillRow = { display: 'flex', gap: 8, flexWrap: 'wrap' };
  const pill = (active) => ({
    padding: '10px 16px', fontFamily: 'var(--ff-mono)', fontSize: 11,
    letterSpacing: '0.12em', textTransform: 'uppercase', fontWeight: 500,
    borderRadius: 999,
    background: active ? 'var(--blue)' : 'transparent',
    color: active ? 'var(--gold)' : 'var(--blue)',
    border: `1.5px solid ${active ? 'var(--blue)' : 'rgba(11,45,92,0.3)'}`,
    cursor: 'pointer',
  });

  return (
    <>
      <PageHeader
        eyebrow={Ti('reg.eyebrow')}
        title={Ti('reg.title')}
        subtitle={Ti('reg.sub')}
        bgImg="uploads/stained-glass-intercession.png"
        bgOpacity={0.25}
        bgFilter="none"
      />
      <section style={{ background: 'var(--beige)', padding: '60px 0 80px' }}>
        <div className="u-container" style={{ maxWidth: 560 }}>
          {/* Progress bar */}
          <div style={{ display: 'flex', gap: 8, marginBottom: 36 }}>
            {[1, 2, 3].map(s => (
              <div key={s} style={{
                flex: 1, height: 4, borderRadius: 2,
                background: step >= s ? 'var(--gold)' : 'rgba(11,45,92,0.15)',
                transition: 'background 0.3s',
              }} />
            ))}
          </div>

          <div className="retro-card" style={{ padding: 36 }}>
            {step === 1 && (
              <>
                <div style={{ marginBottom: 24 }}>
                  <div className="u-eyebrow" style={{ marginBottom: 8 }}>
                    <span style={{ color: 'var(--gold-deep)' }}>{Ti('reg.step1')}</span>
                  </div>
                  <h3 className="h-display" style={{ fontSize: 26, color: 'var(--blue)', margin: 0, textTransform: 'uppercase' }}>
                    {Ti('reg.step1')}
                  </h3>
                </div>
                <div style={{ marginBottom: 18 }}>
                  <label style={labelStyle}>{Ti('reg.name')} *</label>
                  <input type="text" name="contactName" autoComplete="name" value={form.contactName} onChange={e => set('contactName', e.target.value)}
                    placeholder={Ti('reg.namePh')} style={inputStyle} required />
                </div>
                <div style={{ marginBottom: 18 }}>
                  <label style={labelStyle}>{Ti('reg.phone')} *</label>
                  <input type="tel" name="phone" autoComplete="tel" value={form.phone} onChange={e => set('phone', e.target.value)}
                    placeholder={Ti('reg.phonePh')} style={inputStyle} required />
                </div>
                <div style={{ marginBottom: 24 }}>
                  <label style={labelStyle}>{Ti('reg.email')}</label>
                  <input type="email" name="email" autoComplete="email" value={form.email} onChange={e => set('email', e.target.value)}
                    placeholder={Ti('reg.emailPh')} style={inputStyle} />
                </div>
                <input type="text" name="website" value={form.website} onChange={e => set('website', e.target.value)} style={{ display: 'none' }} tabIndex={-1} autoComplete="off" />
                <button className="btn btn-primary" style={{ width: '100%', justifyContent: 'center' }}
                  disabled={!canAdvance} onClick={() => setStep(2)}>
                  Next →
                </button>
              </>
            )}

            {step === 2 && (
              <>
                <div style={{ marginBottom: 24 }}>
                  <div className="u-eyebrow" style={{ marginBottom: 8 }}>
                    <span style={{ color: 'var(--gold-deep)' }}>{Ti('reg.step2')}</span>
                  </div>
                  <h3 className="h-display" style={{ fontSize: 26, color: 'var(--blue)', margin: 0, textTransform: 'uppercase' }}>
                    {Ti('reg.step2')}
                  </h3>
                </div>
                <div style={{ marginBottom: 18 }}>
                  <label style={labelStyle}>{Ti('reg.churchName')} *</label>
                  <input type="text" name="churchName" autoComplete="organization" value={form.churchName} onChange={e => set('churchName', e.target.value)}
                    placeholder={Ti('reg.churchPh')} style={inputStyle} required />
                </div>
                <div style={{ marginBottom: 18 }}>
                  <label style={labelStyle}>{Ti('reg.neighborhood')} *</label>
                  <CustomSelect
                    value={form.neighborhood}
                    onChange={v => set('neighborhood', v)}
                    placeholder={Ti('reg.neighborhoodPh')}
                    options={NEIGHBORHOODS}
                  />
                </div>
                <div style={{ marginBottom: 24 }}>
                  <label style={labelStyle}>{Ti('reg.size')} *</label>
                  <div style={pillRow}>
                    {SIZES.map(s => (
                      <button key={s} type="button" onClick={() => set('churchSize', s)}
                        style={pill(form.churchSize === s)}>{s}</button>
                    ))}
                  </div>
                </div>
                <div style={{ display: 'flex', gap: 12 }}>
                  <button className="btn btn-ghost" onClick={() => setStep(1)}>← Back</button>
                  <button className="btn btn-primary" style={{ flex: 1, justifyContent: 'center' }}
                    disabled={!canAdvance} onClick={() => setStep(3)}>
                    Next →
                  </button>
                </div>
              </>
            )}

            {step === 3 && (() => {
              const mIdx = cycleIndex % 12;
              const yr = 2027 + Math.floor(cycleIndex / 12);
              const track = mIdx % 2 === 0 ? 'A' : 'B';
              const trackData = claimedDays[track] || {};
              const getDayStatus = (d) => {
                const info = trackData[d];
                return info ? 'taken' : 'available';
              };
              const totalClaimed = Object.keys(claimedDays.A || {}).length + Object.keys(claimedDays.B || {}).length;
              const totalSpots = 61;
              const spotsLeft = totalSpots - totalClaimed;
              const firstDow = new Date(yr, mIdx, 1).getDay();
              const dim = new Date(yr, mIdx + 1, 0).getDate();
              const lang = (window.__getLang && window.__getLang()) || 'en';
              const mLabel = new Date(yr, mIdx, 1).toLocaleDateString(lang === 'es' ? 'es-US' : 'en-US', { month: 'long', year: 'numeric' });
              const dh = lang === 'es' ? ['D','L','M','X','J','V','S'] : ['S','M','T','W','T','F','S'];
              const cells = [];
              for (let i = 0; i < firstDow; i++) cells.push(null);
              for (let d = 1; d <= dim; d++) cells.push(d);
              return (
              <>
                <div style={{ marginBottom: 24 }}>
                  <div className="u-eyebrow" style={{ marginBottom: 8 }}>
                    <span style={{ color: 'var(--gold-deep)' }}>{Ti('reg.step3')}</span>
                  </div>
                  <h3 className="h-display" style={{ fontSize: 26, color: 'var(--blue)', margin: 0, textTransform: 'uppercase' }}>
                    {Ti('reg.step3')}
                  </h3>
                </div>
                <div style={{ marginBottom: 18 }}>
                  <label style={labelStyle}>{Ti('reg.preferredDay')}</label>
                  <p style={{ fontSize: 13, color: 'var(--ink-soft)', lineHeight: 1.5, margin: '0 0 12px' }}>
                    {Ti('reg.preferredDayNote')}
                  </p>
                  <div style={{
                    display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,
                    background: spotsLeft > 20 ? 'rgba(6,28,58,0.06)' : 'rgba(242,183,5,0.12)',
                    borderRadius: 8, padding: '8px 14px', marginBottom: 14,
                  }}>
                    <span style={{ fontFamily: 'var(--ff-display)', fontSize: 20, fontWeight: 700, color: 'var(--blue)', lineHeight: 1 }}>
                      {spotsLeft}
                    </span>
                    <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.12em', color: 'var(--ink-soft)', textTransform: 'uppercase' }}>
                      {lang === 'es' ? `de ${totalSpots} lugares disponibles` : `of ${totalSpots} spots available`}
                    </span>
                  </div>
                  <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 10 }}>
                    <button type="button" onClick={() => setCycleIndex(i => Math.max(0, i - 1))}
                      disabled={cycleIndex === 0}
                      style={{ background: 'none', border: 'none', fontSize: 22, cursor: cycleIndex === 0 ? 'default' : 'pointer', color: 'var(--blue)', opacity: cycleIndex === 0 ? 0.25 : 1, padding: '2px 10px', fontWeight: 700, lineHeight: 1 }}>
                      ‹
                    </button>
                    <span style={{ fontFamily: 'var(--ff-display)', fontSize: 15, fontWeight: 600, color: 'var(--blue)', textTransform: 'capitalize' }}>
                      {mLabel}
                    </span>
                    <button type="button" onClick={() => setCycleIndex(i => i + 1)}
                      style={{ background: 'none', border: 'none', fontSize: 22, cursor: 'pointer', color: 'var(--blue)', padding: '2px 10px', fontWeight: 700, lineHeight: 1 }}>
                      ›
                    </button>
                  </div>
                  <div style={{ display: 'grid', gridTemplateColumns: 'repeat(7, 1fr)', gap: 6, marginBottom: 4 }}>
                    {dh.map((h, i) => (
                      <div key={i} style={{ textAlign: 'center', fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--ink-soft)', textTransform: 'uppercase', letterSpacing: '0.1em', padding: '4px 0' }}>
                        {h}
                      </div>
                    ))}
                  </div>
                  <div style={{ display: 'grid', gridTemplateColumns: 'repeat(7, 1fr)', gap: 6 }}>
                    {cells.map((d, i) => {
                      if (d === null) return <div key={'e' + i} />;
                      const selected = form.preferredDay === d && form.cycleTrack === track;
                      const isTaken = getDayStatus(d) === 'taken';
                      const bg = selected ? 'var(--blue)' : isTaken ? 'rgba(11,45,92,0.08)' : 'transparent';
                      const color = selected ? 'var(--gold)' : isTaken ? 'rgba(11,45,92,0.35)' : 'var(--ink)';
                      return (
                        <button key={d} type="button" disabled={isTaken}
                          onClick={() => { if (!isTaken) { set('preferredDay', d); set('cycleTrack', track); } }}
                          style={{
                            aspectRatio: '1', borderRadius: 8,
                            background: bg, color: color,
                            border: selected ? 'none' : '1px solid rgba(11,45,92,0.15)',
                            fontFamily: 'var(--ff-display)', fontSize: 15,
                            fontWeight: selected ? 700 : 500,
                            cursor: isTaken ? 'not-allowed' : 'pointer', padding: 0,
                            opacity: isTaken ? 0.5 : 1,
                          }}>
                          {d}
                        </button>
                      );
                    })}
                  </div>
                  <div style={{
                    display: 'flex', gap: 16, marginTop: 12, flexWrap: 'wrap',
                    fontFamily: 'var(--ff-mono)', fontSize: 9, letterSpacing: '0.12em',
                    color: 'var(--ink-soft)', textTransform: 'uppercase',
                  }}>
                    <span style={{ display: 'flex', alignItems: 'center', gap: 5 }}>
                      <span style={{ width: 8, height: 8, borderRadius: 2, border: '1px solid rgba(11,45,92,0.15)', background: 'transparent' }} />
                      {Ti('reg.dayAvailable')}
                    </span>
                    <span style={{ display: 'flex', alignItems: 'center', gap: 5 }}>
                      <span style={{ width: 8, height: 8, borderRadius: 2, background: 'rgba(11,45,92,0.08)', opacity: 0.5 }} />
                      {Ti('reg.dayTaken')}
                    </span>
                  </div>
                  {form.preferredDay > 0 && form.preferredDay < 4 && form.cycleTrack === 'A' && (
                    <p style={{ fontSize: 12, color: 'var(--gold-deep)', fontFamily: 'var(--ff-mono)', letterSpacing: '0.05em', lineHeight: 1.5, marginTop: 8 }}>
                      {Ti('reg.earlyDayNote')}
                    </p>
                  )}
                  {form.preferredDay === 31 && form.cycleTrack === 'A' && (
                    <p style={{ fontSize: 12, color: 'var(--gold-deep)', fontFamily: 'var(--ff-mono)', letterSpacing: '0.05em', lineHeight: 1.5, marginTop: 8 }}>
                      {Ti('reg.edgeA31')}
                    </p>
                  )}
                  {form.preferredDay === 31 && form.cycleTrack === 'B' && (
                    <p style={{ fontSize: 12, color: 'var(--gold-deep)', fontFamily: 'var(--ff-mono)', letterSpacing: '0.05em', lineHeight: 1.5, marginTop: 8 }}>
                      {Ti('reg.edgeB31')}
                    </p>
                  )}
                  {form.preferredDay >= 29 && form.preferredDay <= 30 && form.cycleTrack === 'B' && (
                    <p style={{ fontSize: 12, color: 'var(--gold-deep)', fontFamily: 'var(--ff-mono)', letterSpacing: '0.05em', lineHeight: 1.5, marginTop: 8 }}>
                      {Ti('reg.edgeBFeb')}
                    </p>
                  )}
                  {form.preferredDay === 0 && (
                    <p style={{ fontSize: 12, color: 'var(--ink-soft)', fontStyle: 'italic', lineHeight: 1.5, marginTop: 10 }}>
                      {Ti('reg.skipDay')}
                    </p>
                  )}
                </div>
                <div style={{ marginBottom: 18, borderTop: '1px dashed rgba(11,45,92,0.15)', paddingTop: 18 }}>
                  <label style={labelStyle}>{Ti('reg.intercessorTitle')}</label>
                  <p style={{ fontSize: 13, color: 'var(--ink-soft)', lineHeight: 1.5, margin: '0 0 12px' }}>
                    {Ti('reg.intercessorQuestion')}
                  </p>
                  <div style={pillRow}>
                    <button type="button" onClick={() => set('hasIntercessor', true)}
                      style={pill(form.hasIntercessor === true)}>{Ti('reg.intercessorYes')}</button>
                    <button type="button" onClick={() => {
                      set('hasIntercessor', false);
                      set('intercessorName', '');
                      set('intercessorPhone', '');
                      set('intercessorEmail', '');
                    }} style={pill(form.hasIntercessor === false)}>{Ti('reg.intercessorNo')}</button>
                  </div>
                  {form.hasIntercessor === false && (
                    <p style={{ fontSize: 12, color: 'var(--ink-soft)', fontStyle: 'italic', marginTop: 8 }}>
                      {Ti('reg.intercessorNote')}
                    </p>
                  )}
                </div>
                {form.hasIntercessor === true && (
                  <>
                    <div style={{ marginBottom: 18 }}>
                      <label style={labelStyle}>{Ti('reg.intercessorName')}</label>
                      <input type="text" name="intercessorName" autoComplete="off" value={form.intercessorName} onChange={e => set('intercessorName', e.target.value)}
                        placeholder={Ti('reg.intercessorNamePh')} style={inputStyle} />
                    </div>
                    <div style={{ marginBottom: 18 }}>
                      <label style={labelStyle}>{Ti('reg.intercessorPhone')}</label>
                      <input type="tel" name="intercessorPhone" autoComplete="off" value={form.intercessorPhone} onChange={e => set('intercessorPhone', e.target.value)}
                        placeholder={Ti('reg.intercessorPhonePh')} style={inputStyle} />
                    </div>
                    <div style={{ marginBottom: 24 }}>
                      <label style={labelStyle}>{Ti('reg.intercessorEmail')}</label>
                      <input type="email" name="intercessorEmail" autoComplete="off" value={form.intercessorEmail} onChange={e => set('intercessorEmail', e.target.value)}
                        placeholder={Ti('reg.intercessorEmailPh')} style={inputStyle} />
                    </div>
                  </>
                )}
                {err && <p style={{ color: '#c0392b', fontSize: 13, marginBottom: 12 }}>{err}</p>}
                <div style={{ display: 'flex', gap: 12 }}>
                  <button className="btn btn-ghost" onClick={() => setStep(2)}>← Back</button>
                  <button className="btn btn-primary" style={{ flex: 1, justifyContent: 'center' }}
                    disabled={!canAdvance || loading} onClick={submit}>
                    {loading ? 'Sending…' : Ti('reg.submit')}
                  </button>
                </div>
              </>
              );
            })()}

            {step === 4 && (() => {
              const hasDates = form.preferredDay > 0;
              const trackMonths = form.cycleTrack === 'B' ? [1, 3, 5, 7, 9, 11] : [0, 2, 4, 6, 8, 10];
              const lang = (window.__getLang && window.__getLang()) || 'en';
              const locale = lang === 'es' ? 'es-US' : 'en-US';
              const dates = hasDates ? trackMonths.map(m => {
                const dim = new Date(2027, m + 1, 0).getDate();
                const day = Math.min(form.preferredDay, dim);
                return new Date(2027, m, day).toLocaleDateString(locale, { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' });
              }) : [];
              return (
              <div style={{ textAlign: 'center', padding: '24px 0' }}>
                <div style={{ fontSize: 48, marginBottom: 16 }}>✦</div>
                <h3 className="h-display" style={{ fontSize: 28, color: 'var(--blue)', margin: '0 0 12px', textTransform: 'uppercase' }}>
                  {Ti('reg.done.title')}
                </h3>
                <p style={{ fontSize: 15, color: 'var(--ink-soft)', lineHeight: 1.7, margin: '0 0 24px', maxWidth: 400, marginLeft: 'auto', marginRight: 'auto' }}>
                  {Ti('reg.done.body')}
                </p>
                {hasDates ? (
                  <>
                    <div style={{
                      background: 'var(--beige)', border: '2px solid var(--blue)', borderRadius: 14,
                      padding: '20px 24px', maxWidth: 340, margin: '0 auto 16px',
                      textAlign: 'left',
                    }}>
                      <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.2em', color: 'var(--gold-deep)', textTransform: 'uppercase', marginBottom: 12 }}>
                        {Ti('reg.done.dates')}
                      </div>
                      {dates.map((d, i) => (
                        <div key={i} style={{
                          padding: '8px 0',
                          borderBottom: i < dates.length - 1 ? '1px solid rgba(11,45,92,0.1)' : 'none',
                          fontFamily: 'var(--ff-display)', fontSize: 15, color: 'var(--blue)',
                          textTransform: 'capitalize',
                        }}>
                          {d}
                        </div>
                      ))}
                    </div>
                    <p style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.1em', color: 'var(--gold-deep)', textTransform: 'uppercase', marginBottom: 20 }}>
                      {Ti('reg.done.screenshot')}
                    </p>
                  </>
                ) : null}
                <button className="btn btn-primary" onClick={() => onNavigate('home')}>
                  {Ti('reg.done.cta')}
                </button>
              </div>
              );
            })()}
          </div>
        </div>
      </section>
    </>
  );
};

/* ─── GIVE PAGE ─── */
const GivePage = ({ onNavigate }) => {
  useLangInt();
  const [iframeLoaded, setIframeLoaded] = React.useState(false);
  const cards = [
    { icon: '✦', titleKey: 'give.why1.title', bodyKey: 'give.why1.body' },
    { icon: '✦', titleKey: 'give.why2.title', bodyKey: 'give.why2.body' },
    { icon: '✦', titleKey: 'give.why3.title', bodyKey: 'give.why3.body' },
  ];
  return (
    <>
      <PageHeader
        eyebrow={Ti('give.eyebrow')}
        title={Ti('give.title')}
        subtitle={Ti('give.sub')}
      />
      <section style={{ background: 'var(--beige)', padding: '60px 0 80px' }}>
        <div className="u-container" style={{ maxWidth: 520, textAlign: 'center' }}>
          <div style={{ position: 'relative', minHeight: 400 }}>
            {!iframeLoaded && (
              <div style={{
                position: 'absolute', inset: 0,
                display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center',
                background: 'var(--cream)', borderRadius: 14, border: '2px solid rgba(11,45,92,0.1)',
              }}>
                <div style={{ fontSize: 28, marginBottom: 12, color: 'var(--gold-deep)' }}>✦</div>
                <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.15em', color: 'var(--ink-soft)', textTransform: 'uppercase' }}>
                  Loading donation form…
                </div>
              </div>
            )}
            <iframe src="https://donorbox.org/embed/city-pastors-fellowship?designation=Sacramento+Prays&default_interval=o"
              name="donorbox" allowpaymentrequest="" seamless="seamless" frameBorder="0" scrolling="no"
              loading="lazy"
              onLoad={() => setIframeLoaded(true)}
              style={{ width: '100%', maxHeight: 'none', margin: '0 auto', display: 'block', opacity: iframeLoaded ? 1 : 0, transition: 'opacity 0.3s' }}
              allow="payment"
              title="Donate to Sacramento Prays" />
          </div>
          <div style={{
            display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 6,
            marginTop: 16, marginBottom: 48, opacity: 0.5,
          }}>
            <svg width="12" height="14" viewBox="0 0 12 14" fill="none">
              <rect x="0.75" y="5.75" width="10.5" height="7.5" rx="1.5" stroke="var(--ink)" strokeWidth="1.5" fill="none"/>
              <path d="M3.5 5.75V4a2.5 2.5 0 0 1 5 0v1.75" stroke="var(--ink)" strokeWidth="1.5" strokeLinecap="round"/>
            </svg>
            <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.15em', textTransform: 'uppercase', color: 'var(--ink)' }}>
              Secured by Stripe
            </span>
          </div>
        </div>
        <div className="u-container" style={{ maxWidth: 560 }}>
          <p style={{
            textAlign: 'center', fontSize: 16, color: 'var(--ink-soft)',
            lineHeight: 1.7, margin: '0 auto',
          }}>{Ti('give.note')}</p>
        </div>
      </section>
    </>
  );
};

Object.assign(window, { AboutPage, TeamPage, ResourcesPage, IntercessorsPage, CalendarPage, PrayerPage, RegisterPage, GivePage });
