/* global React */

// ── Inject animation keyframes — DO NOT REMOVE ─────────────────────────────────
const _owCss = document.createElement('style');
_owCss.textContent = `
  @keyframes ow-modal-in {
    0%   { opacity: 0; transform: scale(0.84) translateY(24px); }
    65%  { opacity: 1; }
    100% { opacity: 1; transform: scale(1) translateY(0); }
  }
  @keyframes ow-modal-out {
    from { opacity: 1; transform: scale(1) translateY(0); }
    to   { opacity: 0; transform: scale(0.92) translateY(18px); }
  }
  @keyframes ow-overlay-in  { from { opacity: 0; } to { opacity: 1; } }
  @keyframes ow-overlay-out { from { opacity: 1; } to { opacity: 0; } }

  @keyframes ow-slide-out-left {
    from { transform: translateX(0);     opacity: 1; }
    to   { transform: translateX(-52px); opacity: 0; }
  }
  @keyframes ow-slide-in-right {
    from { transform: translateX(52px);  opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
  }
  @keyframes ow-slide-out-right {
    from { transform: translateX(0);     opacity: 1; }
    to   { transform: translateX(52px);  opacity: 0; }
  }
  @keyframes ow-slide-in-left {
    from { transform: translateX(-52px); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
  }
  @keyframes ow-img-in {
    from { opacity: 0; transform: scale(1.05); }
    to   { opacity: 1; transform: scale(1); }
  }

  .ow-thumb { transition: transform 500ms cubic-bezier(.4,0,.2,1); }
  .ow-thumb-wrap { overflow: hidden; }
  .ow-card-art:hover .ow-thumb { transform: scale(1.05) !important; }
  .ow-year-btn { transition: background 140ms, color 140ms, border-color 140ms; }
  .ow-nav-btn  { transition: border-color 140ms, color 140ms; }
  .ow-nav-btn:hover:not(:disabled) { border-color: rgba(11,110,104,0.8) !important; color: var(--peacock-bright) !important; }
  .ow-nav-btn:disabled { opacity: 0.28; cursor: default; }
`;
document.head.appendChild(_owCss);

// ── Data ──────────────────────────────────────────────────────────────────────
const CAMPAIGNS = [
  {
    id: 1, year: "2026", state: "Pune", leader: "Maruti Aba Tupe (BJP)",
    title: "Ward 16 victory — 6,000 vote margin in PMC elections.",
    lede: "Comprehensive ward-level campaign in Hadapsar-Satavadi resulting in decisive victory against NCP and incumbent MLA's candidate.",
    detail: "Pravah Solution executed a 60-day ground operation across 14 micro-localities, deploying 120 booth-level volunteers with daily reporting structures. Voter sentiment was tracked weekly through 800+ door-to-door interviews, allowing real-time message pivots that proved decisive in the final week of campaigning.",
    stats: "85K voters · 6K margin · BJP win",
    statsArr: ["85K voters", "6K margin", "BJP win"],
    imgs: [
      { src: "./assets/our%20work/marutiTupe/1.jpeg", position: "center top" },
      { src: "./assets/our%20work/marutiTupe/2.jpeg", position: "center center" },
    ], gradient: ["#0a4f58", "#1a3060"],
  },
  {
    id: 9, year: "2026", state: "Punjab", leader: "Randeep Singh Nabha",
    title: "Amloh assembly — 'Amloh Da Kaka' personal outreach campaign.",
    lede: "Comprehensive audio-visual and on-ground engagement campaign deepening the personal connect of 'Kaka Ji' with constituents across the Amloh Assembly Constituency.",
    detail: "The 'Amloh Da Kaka' campaign systematically documented key welfare, developmental, social, and cultural initiatives by Shri Randeep Singh Nabha, reinforced through authentic beneficiary testimonials collected across 34 villages. A dual-track strategy combined targeted audio-visual content with direct personal visits — 46 constituency touchpoints in 90 days — to showcase his effective stewardship of cabinet portfolios. Supplementary programmes were organised to consolidate grassroots rapport, resulting in measurably higher candidate recognition in previously low-engagement pockets.",
    stats: "72K voters · 46 personal visits · 34 villages covered",
    statsArr: ["72K voters", "46 personal visits", "34 villages covered"],
    imgs: [
      { src: "./assets/our%20work/Nabha/1.jpeg", position: "center center" },
      { src: "./assets/our%20work/Nabha/2.jpeg", position: "center center" },
      { src: "./assets/our%20work/Nabha/4.jpeg", position: "center center" },
    ], gradient: ["#4a2060", "#b8520a"],
  },
  {
    id: 10, year: "2026", state: "Himachal Pradesh", leader: "Vijay Jyoti Sen",
    title: "Kasumpati assembly — 'Janmanch Ki Jyoti' candidate-connect campaign.",
    lede: "Research-backed constituency campaign in Shimla's Kasumpati seat, positioning the candidate as an accessible and responsive leader amid strong anti-incumbency sentiment against the incumbent.",
    detail: "Grounded in 220+ field surveys and ward-level focus groups across Kasumpati Assembly Constituency, the 'Janmanch Ki Jyoti' campaign built a sharp contrast between the candidate's empathetic, people-first approach and the incumbent's perceived disconnect. Key concern clusters — civic amenities, healthcare access, and youth employment — informed a hyper-targeted messaging framework. Twenty-six jan sabhas and a structured social media outreach (reaching 31,000 unique accounts) translated research into visible public engagement, significantly strengthening the candidate's image as a dependable representative aligned with constituents' aspirations.",
    stats: "48K voters · 220 field surveys · 26 jan sabhas",
    statsArr: ["48K voters", "220 field surveys", "26 jan sabhas"],
    imgs: [
      { src: "./assets/our%20work/vijaysen/1.jpeg", position: "center center" },
      { src: "./assets/our%20work/vijaysen/3.jpeg", position: "center center" },
      { src: "./assets/our%20work/vijaysen/4.jpeg", position: "center center" },
      { src: "./assets/our%20work/vijaysen/6.jpeg", position: "center center" },
    ], gradient: ["#1a3a60", "#0a5840"],
  },
  {
    id: 2, year: "2024", state: "Maharashtra", leader: "Prashant Jagtap (NCP)",
    title: "Hadapsar assembly — 40% vote share, first runner-up.",
    lede: "Strategic assembly campaign that significantly strengthened candidate visibility and voter engagement across the constituency.",
    detail: "A data-driven messaging strategy built around hyper-local issues — water supply, road conditions, and school infrastructure — drove a 12-point swing in urban booth clusters. The campaign's digital component reached 80,000 unique voters across WhatsApp, Instagram, and YouTube Shorts.",
    stats: "1.28L votes · 40.22% share · 2.24% margin",
    statsArr: ["1.28L votes", "40.22% share", "2.24% margin"],
    imgs: [
      { src: "./assets/our%20work/prashantjagtap/1.jpeg", position: "center 20%" },
      { src: "./assets/our%20work/prashantjagtap/2.jpeg", position: "center 20%" },
      { src: "./assets/our%20work/prashantjagtap/3.jpeg", position: "center top" },
    ], gradient: ["#7a1f1f", "#c8860a"],
  },
  {
    id: 3, year: "2024", state: "Pimpri-Chinchwad", leader: "Gautam Chabukswar (SS-UBT)",
    title: "Pimpri assembly — constituency survey & groundwork.",
    lede: "Extensive constituency surveys and campaign planning for former MLA. Seat reallocation due to alliance changes affected final outcome.",
    detail: "Pravah Solution delivered a full constituency audit across 22 wards — 14,000 voter interactions in 45 days. The resulting profile was adopted by the alliance for its broader Maharashtra strategy. Despite seat-level reallocation disrupting the plan, all ground intelligence assets were transferred and utilised by allied candidates.",
    stats: "Survey-led · ground research · alliance shift",
    statsArr: ["Survey-led", "Ground research", "Alliance shift"],
    img: null, gradient: ["#1a3060", "#0a4f58"],
  },
  {
    id: 4, year: "2024", state: "Maharashtra", leader: "Dr. Hulgesh Chalwadi (BSP)",
    title: "BSP statewide branding — social media, events & podcast.",
    lede: "Personal branding campaign across social media with high-profile political events and podcast production on major social issues.",
    detail: "A 90-day brand-building sprint established the candidate's digital presence from scratch: Instagram grew 0→18K, a weekly podcast on Dalit rights hit 4,200 average listeners, and three flagship public events in Pune, Nagpur, and Aurangabad were produced end-to-end by the Pravah team.",
    stats: "Statewide reach · social + events · podcasts",
    statsArr: ["Statewide reach", "Social + events", "Podcasts"],
    img: null, gradient: ["#2d1a5c", "#7a1f1f"],
  },
  {
    id: 5, year: "2022", state: "Assam", leader: "Phany Bhushan Chaudhuri",
    title: "Assembly Constituency Bongaigaon, Assam — 'Ghore Ghore Hathi' campaign.",
    lede: "Strategically planned and executed assembly campaign widely appreciated by party leadership for impactful voter outreach.",
    detail: "Operating in Assam's Bongaigaon Assembly Constituency, Pravah Solution adapted its Maharashtra playbook to a linguistically and culturally distinct environment. The 'Ghore Ghore Hathi' door-to-door program reached 78% of registered households. The campaign's visual identity was cited by party leadership as a model for future contests.",
    stats: "AGP win · campaign theme led · party appreciated",
    statsArr: ["AGP win", "Campaign theme led", "Party appreciated"],
    imgs: [
      { src: "./assets/our%20work/AGP/1.jpeg", position: "center center" },
      { src: "./assets/our%20work/AGP/2.jpeg", position: "center center" },
      { src: "./assets/our%20work/AGP/3.jpeg", position: "center center" },
      { src: "./assets/our%20work/AGP/4.jpeg", position: "center center" },
    ], gradient: ["#1a4a2a", "#0a4f58"],
  },
];

const YEARS = ["All", "2026", "2024", "2022"];

// ── Campaign image / gradient placeholder ─────────────────────────────────────
const CampaignHero = ({ c, animate }) => {
  const images = c.imgs
    ? c.imgs.map(i => typeof i === 'string' ? { src: i, position: 'center center' } : i)
    : c.img ? [{ src: c.img, position: 'center center' }] : [];
  const len = images.length;
  const [slide, setSlide] = React.useState(0);
  const slideRef = React.useRef(0);

  React.useEffect(() => {
    slideRef.current = 0;
    setSlide(0);
    if (len <= 1) return;
    const t = setInterval(() => {
      slideRef.current = (slideRef.current + 1) % len;
      setSlide(slideRef.current);
    }, 2000);
    return () => clearInterval(t);
  }, [c.id, len]);

  return (
  <div className="ow-thumb-wrap" style={{ width: '100%', height: 240, position: 'relative', flexShrink: 0 }}>
    {len > 0 ? (
      <>
        {images.map((img, i) => (
          <img
            key={i}
            src={img.src} alt={`${c.title} ${i + 1}`}
            className="ow-thumb"
            style={{
              position: 'absolute', inset: 0,
              width: '100%', height: '100%', objectFit: 'cover', display: 'block',
              objectPosition: img.position,
              opacity: i === slide ? 1 : 0,
              transition: 'opacity 700ms ease',
              animation: animate && i === slide ? 'ow-img-in 500ms ease forwards' : 'none'
            }}
          />
        ))}
        {len > 1 && (
          <div style={{
            position: 'absolute', bottom: 38, left: '50%',
            transform: 'translateX(-50%)',
            display: 'flex', gap: 6, zIndex: 5,
            background: 'rgba(10,14,20,0.45)', backdropFilter: 'blur(4px)',
            padding: '5px 10px', borderRadius: 99
          }}>
            {images.map((_, i) => (
              <button
                key={i}
                onClick={e => { e.stopPropagation(); slideRef.current = i; setSlide(i); }}
                style={{
                  width: i === slide ? 20 : 7, height: 7, borderRadius: 4,
                  border: 'none', padding: 0, cursor: 'pointer',
                  background: i === slide ? 'var(--gold)' : 'rgba(240,233,216,0.5)',
                  transition: 'width 200ms, background 200ms'
                }}
              />
            ))}
          </div>
        )}
      </>
    ) : (
      <div style={{
        width: '100%', height: '100%',
        background: `linear-gradient(135deg, ${c.gradient[0]} 0%, ${c.gradient[1]} 100%)`,
        display: 'flex', flexDirection: 'column',
        alignItems: 'center', justifyContent: 'center', gap: 10,
        animation: animate ? 'ow-img-in 500ms ease forwards' : 'none'
      }}>
        <svg width="32" height="32" viewBox="0 0 24 24" fill="none"
          stroke="rgba(240,233,216,0.3)" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
          <path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/>
          <circle cx="12" cy="13" r="4"/>
        </svg>
        <span style={{
          fontSize: 10, fontWeight: 600, letterSpacing: '0.12em',
          textTransform: 'uppercase', color: 'rgba(240,233,216,0.3)',
          fontFamily: 'var(--font-mono)'
        }}>Campaign photo coming soon</span>
      </div>
    )}
    {/* Scrim */}
    <div style={{
      position: 'absolute', inset: 0,
      background: 'linear-gradient(to top, rgba(12,26,40,0.72) 0%, rgba(12,26,40,0.08) 55%, transparent 100%)'
    }}/>
    {/* Badges */}
    <div style={{ position: 'absolute', top: 14, left: 18, right: 18, display: 'flex', justifyContent: 'space-between' }}>
      <span style={{
        fontFamily: 'var(--font-condensed)', fontSize: 11, fontWeight: 700,
        letterSpacing: '0.1em', textTransform: 'uppercase',
        color: 'var(--parchment)', background: 'rgba(12,26,40,0.55)', backdropFilter: 'blur(4px)',
        padding: '4px 10px', borderRadius: 2
      }}>{c.state}</span>
      <span style={{
        fontFamily: 'var(--font-mono)', fontSize: 10, fontWeight: 700,
        color: 'var(--gold)',
        background: 'rgba(12,26,40,0.55)', backdropFilter: 'blur(4px)',
        padding: '4px 10px', borderRadius: 2
      }}>{c.year}</span>
    </div>
    <div style={{
      position: 'absolute', bottom: 14, left: 18,
      fontFamily: 'var(--font-condensed)', fontSize: 13, fontWeight: 700,
      letterSpacing: '0.06em', textTransform: 'uppercase',
      color: 'rgba(240,233,216,0.85)'
    }}>{c.leader}</div>
  </div>
  );
};

// ── Animated case study modal ─────────────────────────────────────────────────
const SLIDE_DUR = 220;

const CaseModal = ({ cases, index, onClose }) => {
  const [current, setCurrent]         = React.useState(index);
  const [contentAnim, setContentAnim] = React.useState(null);
  const [imgKey, setImgKey]           = React.useState(0);
  const [closing, setClosing]         = React.useState(false);
  const busyRef                       = React.useRef(false);
  const touchStartX                   = React.useRef(null);

  React.useEffect(() => {
    document.body.style.overflow = 'hidden';
    return () => { document.body.style.overflow = ''; };
  }, []);

  React.useEffect(() => {
    const h = (e) => {
      if (e.key === 'ArrowRight') go(1);
      if (e.key === 'ArrowLeft')  go(-1);
      if (e.key === 'Escape')     handleClose();
    };
    window.addEventListener('keydown', h);
    return () => window.removeEventListener('keydown', h);
  });

  const handleClose = () => {
    setClosing(true);
    setTimeout(onClose, 300);
  };

  const go = (delta) => {
    const next = current + delta;
    if (next < 0 || next >= cases.length || busyRef.current) return;
    busyRef.current = true;
    const outAnim = delta > 0 ? 'ow-slide-out-left' : 'ow-slide-out-right';
    const inAnim  = delta > 0 ? 'ow-slide-in-right' : 'ow-slide-in-left';
    setContentAnim(`${outAnim} ${SLIDE_DUR}ms ease forwards`);
    setTimeout(() => {
      setCurrent(next);
      setImgKey(k => k + 1);
      setContentAnim(`${inAnim} ${SLIDE_DUR}ms ease forwards`);
      setTimeout(() => { setContentAnim(null); busyRef.current = false; }, SLIDE_DUR);
    }, SLIDE_DUR);
  };

  const jumpTo = (i) => {
    if (i === current || busyRef.current) return;
    go(i - current);
  };

  const onTouchStart = (e) => { touchStartX.current = e.changedTouches[0].clientX; };
  const onTouchEnd   = (e) => {
    if (touchStartX.current === null) return;
    const diff = touchStartX.current - e.changedTouches[0].clientX;
    if (Math.abs(diff) > 50) go(diff > 0 ? 1 : -1);
    touchStartX.current = null;
  };

  const c = cases[current];

  return (
    <div
      onClick={handleClose}
      style={{
        position: 'fixed', inset: 0, zIndex: 200,
        background: 'rgba(8,15,24,0.82)', backdropFilter: 'blur(8px)',
        display: 'flex', alignItems: 'center', justifyContent: 'center',
        padding: '32px 24px', overflowY: 'auto',
        animation: closing ? 'ow-overlay-out 300ms ease forwards' : 'ow-overlay-in 260ms ease forwards'
      }}
    >
      <div
        onClick={e => e.stopPropagation()}
        onTouchStart={onTouchStart}
        onTouchEnd={onTouchEnd}
        style={{
          background: 'var(--parchment)', borderRadius: 2, overflow: 'hidden',
          width: 'min(760px, 100%)', margin: 'auto',
          boxShadow: '0 4px 6px rgba(0,0,0,0.12), 0 28px 72px rgba(8,15,24,0.5)',
          display: 'flex', flexDirection: 'column',
          animation: closing
            ? 'ow-modal-out 280ms cubic-bezier(.4,0,.2,1) forwards'
            : 'ow-modal-in 460ms cubic-bezier(.34,1.48,.64,1) forwards'
        }}
      >
        {/* Peacock top strip */}
        <div style={{ height: 3, background: 'linear-gradient(90deg, var(--peacock) 0%, var(--gold) 100%)', flexShrink: 0 }}/>

        {/* AGP campaign audio — rendered directly so browser autoplay treats it as declarative */}
        {cases[current] && cases[current].id === 5 && (
          <audio
            key={`agp-audio-${current}`}
            autoPlay
            loop
            preload="auto"
            src="./assets/our%20work/AGP/AGP.m4a"
            style={{ display: 'none' }}
            ref={(el) => { if (el) el.play().catch(e => console.error('AGP audio error:', e)); }}
          />
        )}

        {/* Sliding image + content pane */}
        <div style={{ animation: contentAnim || 'none', overflow: 'hidden' }}>
          <CampaignHero key={imgKey} c={c} animate={imgKey > 0}/>

          <div style={{ padding: '26px 32px 22px' }}>
            <div style={{
              display: 'flex', justifyContent: 'space-between',
              alignItems: 'flex-start', marginBottom: 14, gap: 16
            }}>
              <span style={{
                fontFamily: 'var(--font-condensed)', fontSize: 12, fontWeight: 700,
                letterSpacing: '0.1em', textTransform: 'uppercase',
                color: 'var(--peacock)'
              }}>{c.leader}</span>
              <button
                onClick={handleClose}
                style={{
                  border: '1px solid var(--vellum)', background: 'transparent',
                  width: 30, height: 30, borderRadius: 2, cursor: 'pointer',
                  color: 'var(--slate-soft)', display: 'flex', alignItems: 'center',
                  justifyContent: 'center', flexShrink: 0
                }}
              ><Icon name="x" size={14}/></button>
            </div>

            <h2 style={{
              fontFamily: 'var(--font-display)', fontWeight: 700,
              fontSize: 'clamp(20px, 3vw, 26px)', lineHeight: 1.15,
              letterSpacing: '-0.02em', color: 'var(--slate)', margin: '0 0 14px'
            }}>{c.title}</h2>

            <div style={{ borderTop: '1px solid var(--vellum)', margin: '0 0 14px' }}/>

            <p style={{
              fontSize: 15, lineHeight: 1.65, color: 'var(--slate-mid)', fontStyle: 'italic',
              margin: '0 0 14px', borderLeft: '3px solid var(--peacock)', paddingLeft: 14
            }}>{c.lede}</p>

            <p style={{ fontSize: 14, lineHeight: 1.8, color: 'var(--slate-mid)', margin: '0 0 20px' }}>
              {c.detail}
            </p>

            <div style={{ display: 'flex', flexWrap: 'wrap', gap: 7 }}>
              {c.statsArr.map((s, i) => (
                <span key={i} style={{
                  fontFamily: 'var(--font-mono)', fontSize: 11, fontWeight: 600,
                  letterSpacing: '0.06em', padding: '4px 12px', borderRadius: 999,
                  background: i === 0 ? 'var(--peacock)' : 'var(--ink)',
                  color: 'var(--parchment)'
                }}>{s}</span>
              ))}
            </div>
          </div>
        </div>

        {/* Nav bar */}
        <div style={{
          background: 'var(--ink)', padding: '13px 32px',
          display: 'flex', alignItems: 'center', justifyContent: 'space-between',
          flexShrink: 0
        }}>
          <button className="ow-nav-btn" onClick={() => go(-1)} disabled={current === 0}
            style={{
              background: 'transparent', border: '1px solid rgba(11,110,104,0.35)',
              color: 'rgba(240,233,216,0.65)', padding: '7px 16px', borderRadius: 1,
              cursor: 'pointer', fontSize: 11, fontWeight: 700,
              letterSpacing: '0.1em', textTransform: 'uppercase', fontFamily: 'var(--font-mono)'
            }}>← Prev</button>

          <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 5 }}>
            <div style={{ display: 'flex', gap: 6 }}>
              {cases.map((_, i) => (
                <button key={i} onClick={() => jumpTo(i)} style={{
                  width: i === current ? 22 : 7, height: 7, borderRadius: 4,
                  border: 'none', cursor: 'pointer', padding: 0,
                  background: i === current ? 'var(--gold)' : 'rgba(240,233,216,0.2)',
                  transition: 'width 220ms, background 220ms'
                }}/>
              ))}
            </div>
            <span style={{
              fontFamily: 'var(--font-mono)', fontSize: 10,
              color: 'rgba(240,233,216,0.35)', letterSpacing: '0.12em'
            }}>{current + 1} / {cases.length}</span>
          </div>

          <button className="ow-nav-btn" onClick={() => go(1)} disabled={current === cases.length - 1}
            style={{
              background: 'transparent', border: '1px solid rgba(11,110,104,0.35)',
              color: 'rgba(240,233,216,0.65)', padding: '7px 16px', borderRadius: 1,
              cursor: 'pointer', fontSize: 11, fontWeight: 700,
              letterSpacing: '0.1em', textTransform: 'uppercase', fontFamily: 'var(--font-mono)'
            }}>Next →</button>
        </div>
      </div>
    </div>
  );
};

// ── Campaign card ─────────────────────────────────────────────────────────────
const CaseStudyCard = ({ c, onClick }) => (
  <article
    onClick={onClick}
    style={{
      background: "var(--paper)",
      border: "1px solid var(--vellum)",
      borderRadius: 2, cursor: "pointer",
      transition: "border-color 200ms, box-shadow 200ms",
      boxShadow: "0 1px 4px rgba(12,26,40,0.05)",
      display: "flex", flexDirection: "column",
      height: "100%", overflow: "hidden"
    }}
    onMouseEnter={e => {
      e.currentTarget.style.borderColor = "var(--peacock)";
      e.currentTarget.style.boxShadow = "0 6px 24px rgba(11,110,104,0.12)";
    }}
    onMouseLeave={e => {
      e.currentTarget.style.borderColor = "var(--vellum)";
      e.currentTarget.style.boxShadow = "0 1px 4px rgba(12,26,40,0.05)";
    }}
  >
    {/* Peacock top strip */}
    <div style={{ height: 3, background: "var(--peacock)", flexShrink: 0 }}/>

    <div style={{ padding: "20px 22px 18px", display: "flex", flexDirection: "column", gap: 10, flex: 1 }}>
      <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
        <span style={{
          fontFamily: "var(--font-condensed)", fontSize: 13, fontWeight: 700,
          letterSpacing: "0.1em", textTransform: "uppercase", color: "var(--peacock)"
        }}>{c.state}</span>
        <span style={{
          fontFamily: "var(--font-mono)", fontSize: 11, color: "var(--slate-soft)"
        }}>{c.year}</span>
      </div>

      <h3 style={{
        fontFamily: "var(--font-display)", fontWeight: 600,
        fontSize: 20, lineHeight: 1.2, letterSpacing: "-0.02em",
        margin: 0, color: "var(--slate)"
      }}>{c.title}</h3>

      <div style={{
        fontFamily: "var(--font-condensed)", fontSize: 13, fontWeight: 700,
        letterSpacing: "0.06em", textTransform: "uppercase", color: "var(--gold)"
      }}>{c.leader}</div>

      <p style={{ fontSize: 14, color: "var(--slate-soft)", lineHeight: 1.6, margin: 0, flex: 1 }}>
        {c.lede}
      </p>

      <div style={{
        paddingTop: 12, borderTop: "1px solid var(--parchment-deep)",
        display: "flex", justifyContent: "space-between", alignItems: "center", marginTop: "auto"
      }}>
        <span style={{ fontFamily: "var(--font-mono)", fontSize: 11, color: "var(--slate-soft)" }}>{c.stats}</span>
        <span style={{ color: "var(--peacock)", fontWeight: 700, fontSize: 16 }}>→</span>
      </div>
    </div>
  </article>
);

// ── OurWork section ───────────────────────────────────────────────────────────
const OurWork = () => {
  const [year, setYear]       = React.useState("All");
  const [openIdx, setOpenIdx] = React.useState(null);

  const filtered = year === "All" ? CAMPAIGNS : CAMPAIGNS.filter(c => c.year === year);

  React.useEffect(() => {
    const handler = () => setOpenIdx(0);
    window.addEventListener("pravah:openWork", handler);
    return () => window.removeEventListener("pravah:openWork", handler);
  }, []);

  return (
    <>
      <section id="work" className="section-pad" style={{
        background: "var(--parchment-deep)",
        padding: "clamp(80px, 10vw, 128px) 32px",
        borderTop: "1px solid var(--vellum)"
      }}>
        <div style={{ maxWidth: 1280, margin: "0 auto" }}>

          {/* Section header — broadsheet style */}
          <div style={{
            display: "flex", alignItems: "center", gap: 24,
            paddingBottom: 20, marginBottom: 48,
            borderBottom: "2px solid var(--slate)"
          }}>
            <Eyebrow>Our Work</Eyebrow>
            <div style={{ flex: 1, height: 1, background: "var(--vellum)" }}/>
          </div>

          <div style={{
            display: "flex", justifyContent: "space-between",
            alignItems: "flex-end", gap: 32, flexWrap: "wrap", marginBottom: 40
          }}>
            <h2 style={{
              fontFamily: "var(--font-condensed)", fontWeight: 800,
              fontSize: "clamp(44px, 6.5vw, 80px)", lineHeight: 0.93,
              letterSpacing: "-0.01em", textTransform: "uppercase",
              margin: 0, color: "var(--slate)", textWrap: "balance"
            }}>
              End-to-end campaigns<br/>across Maharashtra & beyond.
            </h2>

            <div style={{ display: "flex", flexWrap: "wrap", gap: 6 }}>
              {YEARS.map(y => (
                <button key={y} className="ow-year-btn" onClick={() => setYear(y)} style={{
                  fontFamily: "var(--font-mono)", fontSize: 11, fontWeight: 600,
                  padding: "6px 14px", borderRadius: 2,
                  background: year === y ? "var(--peacock)" : "transparent",
                  color: year === y ? "var(--parchment)" : "var(--slate-mid)",
                  border: `1px solid ${year === y ? "var(--peacock)" : "var(--vellum)"}`,
                  cursor: "pointer", letterSpacing: "0.06em"
                }}>{y}</button>
              ))}
            </div>
          </div>

          <div className="grid-3" style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 18 }}>
            {filtered.map((c, i) => (
              <CaseStudyCard key={c.id} c={c} onClick={() => setOpenIdx(i)}/>
            ))}
          </div>

          {filtered.length === 0 && (
            <div style={{ padding: 64, textAlign: "center", color: "var(--slate-soft)" }}>
              No campaigns in this year.
            </div>
          )}
        </div>
      </section>

      {openIdx !== null && (
        <CaseModal
          cases={filtered}
          index={openIdx}
          onClose={() => setOpenIdx(null)}
        />
      )}
    </>
  );
};

window.OurWork = OurWork;
