function Pillars() {
  return (
    <section className="section" id="capabilities" style={{ padding: '50px 0px 50px' }}>
      <div className="container">
        <div className="section-head reveal">
          <span className="eyebrow-row"><i className="dot"></i>Our patent-pending technology</span>
          <h2 style={{ textWrap: 'balance' }}>That's one incident. Here's <span style={{ color: 'var(--accent)', whiteSpace: 'nowrap' }}>everything else</span> Krew handles.</h2>
        </div>

        <div className="pillars">
          <Pillar
            num="01 / Q&A"
            title="On-demand production intelligence"
            body="Any question about any person, document, or communication — answered in minutes, with sourced references. Ask over text, email, or iMessage."
            illustration={<IllusChat />} />
          
          <Pillar
            num="02 / Change tracking"
            title="Revisions, tracked across every doc"
            body="When a new script revision or schedule change drops, Krew maps what changed and what it affects — scenes, characters, locations, pages — department by department."
            illustration={<IllusDiff />} />
          
          <Pillar
            num="03 / Errors"
            title="Catches mistakes before they bite"
            body="Cross-checks the documents and timesheets that should agree, and flags the conflicts and contradictions that manual review misses at scale — so they don't turn into overages."
            illustration={<IllusGrid />} />
          
          <Pillar
            num="04 / Conflicts"
            title="Proactive conflict detection"
            body="Watches weather and airline delays against travel memos, and checks last-minute schedule changes against booked flights — so nothing goes unnoticed."
            illustration={<IllusConflict />} />
          
          <Pillar
            num="05 / Interactive Charts"
            title="Production health in real-time"
            body="Custom, interactive dashboards — schedule, budget, and variance tracked live, with predictive analytics that flag overages before they hit. Tailored to each exec's metrics."
            illustration={<IllusChart />} />
          
          <Pillar
            num="06 / Daily briefs"
            title="The morning brief, tailored to you"
            body="Every role needs different info each morning. Tell Krew what metrics, flags, and updates you actually care about — and get an update daily. Reply to drill in."
            illustration={<IllusBrief />} />
          
        </div>
      </div>
    </section>);

}

function Pillar({ num, title, body, illustration }) {
  return (
    <article className="pillar reveal">
      <div className="illustration" aria-hidden="true">{illustration}</div>
      <div className="num">{num}</div>
      <h3>{title}</h3>
      <p>{body}</p>
    </article>);

}

/* ---------- 01 Q&A — conversational answer styled like hero SMS ----------
   Mirrors the hero phone bubble system:
   - User outgoing bubble = warm grain paper, right-aligned, ink border,
     bottom-right tail (3px corner).
   - Krew incoming reply = brand orange, left-aligned, ink border,
     bottom-left tail (3px corner), white text.
   The answer streams in via a clip-path width animation. */
function IllusQA() {
  // Bubble paths — match hero geometry (10px radius w/ 3px tail corner).
  // User bubble (right-aligned): bottom-right tail at 3px, others at 10px.
  // Bounds: x ∈ [42, 190], y ∈ [6, 39]. Drawn clockwise from top-left start.
  const userTailPath =
  "M52,6 H180 A10,10 0 0 1 190,16 V36 A3,3 0 0 1 187,39 H52 A10,10 0 0 1 42,29 V16 A10,10 0 0 1 52,6 Z";
  // Krew bubble (left-aligned): bottom-left tail at 3px, others at 10px.
  // Bounds: x ∈ [10, 172], y ∈ [54, 112].
  const krewTailPath =
  "M20,54 H162 A10,10 0 0 1 172,64 V102 A10,10 0 0 1 162,112 H13 A3,3 0 0 1 10,109 V64 A10,10 0 0 1 20,54 Z";

  return (
    <svg aria-hidden="true" focusable="false" width="200" height="120" viewBox="0 0 200 120" fill="none" className="illus-qa">
      <defs>
        {/* Clip for the streaming answer text — width grows over time */}
        <clipPath id="qaAnswerClip">
          <rect className="qa-answer-mask" x="20" y="58" width="0" height="50" />
        </clipPath>
      </defs>

      {/* User question — warm grain paper, right tail, ink border. */}
      <g className="qa-question">
        <path d={userTailPath}
        fill="var(--krew-grain-pale)"
        stroke="var(--krew-ink)" strokeWidth="1" />
        <text x="52" y="20" fontSize="8.4"
        fill="var(--fg-1)"
        fontFamily="var(--font-sans)"
        fontWeight="600">
          <tspan x="52" dy="0">Do the latest schedule changes</tspan>
          <tspan x="52" dy="11">trigger consecutive employment?</tspan>
        </text>
      </g>

      {/* Krew reply — orange bubble, left tail, ink border, white text. */}
      <g className="qa-reply">
        <path d={krewTailPath}
        fill="var(--accent)"
        stroke="var(--krew-ink)" strokeWidth="1" />

        {/* Streaming answer text */}
        <g clipPath="url(#qaAnswerClip)">
          <text x="22" y="68" fontSize="8"
          fill="#fff"
          fontFamily="var(--font-sans)"
          fontWeight="600">
            <tspan x="22" dy="0">Based on talent deal memos, the</tspan>
            <tspan x="22" dy="10">schedule changes may trigger</tspan>
            <tspan x="22" dy="10" fontWeight="800">SAG consecutive employment</tspan>
            <tspan x="22" dy="10" fontWeight="600">for </tspan>
            <tspan fontWeight="800">#4 (Maya Smith).</tspan>
          </text>
        </g>

        {/* Typing caret — blinks before the answer starts streaming */}
        <rect className="qa-typing-caret" x="22" y="61" width="1.6" height="9"
        fill="#fff" />
      </g>
    </svg>);

}

/* ---------- 02 Change tracking ---------- */
/* Sequence:
     1. ONE centered page visible (WHITE — the prior version).
     2. It shifts LEFT; a second page (BLUE — the new revision)
        fades + slides in on the RIGHT. Version labels animate on.
     3. A diff arrow appears between them (fully clear of both page
        edges); on the BLUE (right) page, one of the grey rows gets
        progressively highlighted in orange by a left-to-right sweep
        — like a highlighter pass. */
function IllusDiff() {
  return (
    <svg aria-hidden="true" focusable="false" width="200" height="120" viewBox="0 0 200 120" fill="none" className="illus-diff">
      {/* WHITE page — starts centered, shifts LEFT on reveal. */}
      <g className="diff-page diff-page-white">
        <rect x="65" y="20" width="70" height="80" fill="var(--bg-surface)" stroke="var(--krew-ink)" />
        <text x="75" y="14" fontSize="8" fill="var(--fg-4)" letterSpacing="1" fontWeight="700" className="diff-label">WHITE</text>
        {[28, 40, 52, 64, 76].map((y, i) =>
        <rect key={`w-${i}`} x="71" y={y} width={50 - i * 4} height="4" fill="var(--border-hair)" />
        )}
      </g>

      {/* BLUE page — enters from RIGHT on reveal. Drawn at x=65;
           ends at translateX(+52) on the right side. */}
      <g className="diff-page diff-page-blue">
        <rect x="65" y="20" width="70" height="80" fill="var(--bg-surface)" stroke="var(--krew-ink)" />
        <text x="75" y="14" fontSize="8" fill="var(--accent)" letterSpacing="1" fontWeight="700" className="diff-label">BLUE</text>
        <rect x="71" y="28" width="46" height="4" fill="var(--border-hair)" />
        <rect x="71" y="40" width="42" height="4" fill="var(--border-hair)" />
        {/* Row 3 — the changed line. A clipped orange overlay sweeps
             left→right across it. */}
        <rect x="71" y="52" width="38" height="4" fill="var(--border-hair)" />
        <clipPath id="diff-sweep-clip">
          <rect x="71" y="52" width="38" height="4" className="diff-sweep-mask" />
        </clipPath>
        <rect x="71" y="52" width="38" height="4" fill="var(--accent)" clipPath="url(#diff-sweep-clip)" className="diff-sweep-fill" />
        <rect x="71" y="64" width="34" height="4" fill="var(--border-hair)" />
        <rect x="71" y="76" width="30" height="4" fill="var(--border-hair)" />
      </g>

      {/* Arrow — sits in the gap between the two pages. WHITE ends at
           tx=-52 so its right edge is x=135-52=83. BLUE ends at tx=+52
           so its left edge is x=65+52=117. Gap spans x:83..117;
           arrow runs 89→111 entirely inside that gap. */}
      <g className="diff-arrow">
        <line x1="89" y1="60" x2="107" y2="60" stroke="var(--accent)" strokeWidth="2" />
        <polygon points="103,55 113,60 103,65" fill="var(--accent)" />
      </g>
    </svg>);

}

/* ---------- 03 QA grid ---------- */
/* Original layout preserved (two fixed "fail" cells). Elegant looping
   motion added: a thin scan line traces down the grid, and the flagged
   cells pulse from grey to orange on loop — quick in, long hold, gentle
   out. */
function IllusGrid() {
  return (
    <svg aria-hidden="true" focusable="false" width="200" height="120" viewBox="0 0 200 120" fill="none" className="illus-grid">
      {[0, 1, 2, 3].map((r) => [0, 1, 2, 3, 4].map((c) => {
        const fail = r === 1 && c === 3 || r === 2 && c === 1;
        // Flag-index 0 = the left cell (c=1), 1 = the right cell (c=3)
        // The scan sweeps left→right, so left cell flips first.
        const flagIdx = fail ? c === 1 ? 0 : 1 : -1;
        return (
          <rect
            key={`${r}-${c}`}
            x={20 + c * 32} y={20 + r * 20}
            width="26" height="14" rx="2"
            fill="var(--krew-grain-pale)"
            stroke="var(--border-soft)"
            strokeWidth="1"
            className={fail ? `qa-cell qa-cell-flag qa-cell-flag-${flagIdx}` : "qa-cell"} />);


      }))}
      {/* Scan sweep — thin orange line traces left→right during the reveal. */}
      <rect x="18" y="18" width="1.5" height="80" fill="var(--accent)" className="qa-scan" opacity="0.8" />
      <text x="20" y="14" fontSize="8" fill="var(--fg-4)" letterSpacing="1" fontWeight="700">PR ↔ CALL SHEET</text>
    </svg>);

}

/* ---------- 04 Flight watchtower ---------- */
/*
  A live "control tower" that loops through alerts on multiple
  crew members at once. Each row is a person + their flight; the
  chip on the right cycles through DELAYED / WEATHER / GATE
  changes on a stagger, with a soft scanning sweep across the
  panel and a radar pulse in the corner. Designed to read as
  "constantly watching everyone, all the time."
*/
function IllusConflict() {
  // Six crew rows. Each row's chip cycles through 4 states with
  // a per-row offset so something is always animating somewhere.
  const crew = [
  { name: "SHAWN", route: "JFK → LAX", code: "DL 2147" },
  { name: "MAYA", route: "ATL → LAX", code: "AA 1820" },
  { name: "RIO", route: "LHR → LAX", code: "BA  113" },
  { name: "PRIYA", route: "ORD → LAX", code: "UA  401" },
  { name: "NOAH", route: "SFO → LAX", code: "DL 1208" },
  { name: "ELI", route: "MIA → LAX", code: "AA 2266" }];

  const W = 220,H = 108;
  const rowH = 13;
  const rowsTop = 26;
  return (
    <svg aria-hidden="true" focusable="false" width={W} height={H} viewBox={`0 0 ${W} ${H}`} fill="none" className="illus-watch">
      {/* panel */}
      <rect x="0.5" y="0.5" width={W - 1} height={H - 1} rx="6"
      fill="var(--krew-grain-pale)" stroke="var(--border-soft)" />
      {/* header */}
      <text x="10" y="13" fontSize="7" fontWeight="800" letterSpacing="1.2"
      fill="var(--fg-4)" fontFamily="var(--font-mono)">
        WATCHTOWER · LIVE
      </text>
      {/* live dot — top right, just a steady accent dot */}
      <circle cx={W - 12} cy="10" r="2.4" fill="var(--accent)" />
      {/* divider */}
      <line x1="10" y1="20" x2={W - 10} y2="20" stroke="var(--border-soft)" />

      {/* crew rows */}
      {crew.map((p, i) => {
        const y = rowsTop + i * rowH;
        return (
          <g key={i} className="watch-row" style={{ '--i': i }}>
            {/* name */}
            <text x="13" y={y + 8} fontSize="7.2" fontWeight="800"
            fill="var(--fg-1)" fontFamily="var(--font-sans)">
              {p.name}
            </text>
            {/* route */}
            <text x="48" y={y + 8} fontSize="6.8" fontWeight="600"
            fill="var(--fg-3)" fontFamily="var(--font-mono)" letterSpacing="0.5">
              {p.route}
            </text>
            {/* flight code */}
            <text x="98" y={y + 8} fontSize="6.4" fontWeight="600"
            fill="var(--fg-4)" fontFamily="var(--font-mono)" letterSpacing="0.5">
              {p.code}
            </text>

            {/* status chip — 4-state cycle: ON TIME → DELAY → WEATHER → GATE */}
            <g transform={`translate(${W - 78}, ${y})`} className="watch-chip-stack">
              <ChipState label="ON TIME" tone="ok" index={0} />
              <ChipState label="DELAY 22m" tone="alert" index={1} />
              <ChipState label="WEATHER" tone="alert" index={2} />
              <ChipState label="GATE B14" tone="warn" index={3} />
            </g>
          </g>);

      })}
    </svg>);

}

/*
  One status chip in the cycle. Four chips share the same slot
  but only one is visible at a time — `--state` on the parent
  row decides which. The chip animates in from the right with
  a quick scale-snap, then drifts off as the next one slides in.
*/
function ChipState({ label, tone, index }) {
  const fill = tone === "ok" ? "var(--krew-ok, #2f6f3e)" :
  tone === "warn" ? "var(--krew-blue, #2f55a8)" :
  "var(--accent)";
  return (
    <g className={`watch-chip watch-chip-${index}`}>
      <rect width="62" height="11" rx="2" fill={fill} />
      <text x="31" y="8" fontSize="6.4" fontWeight="800"
      textAnchor="middle"
      fill="rgb(248,243,231)" fontFamily="var(--font-mono)" letterSpacing="0.6">
        {label}
      </text>
    </g>);

}

/* ---------- 05 Chart ---------- */
function IllusChart() {
  // Bar heights, precomputed so animation uses stable values
  const bars = [0, 1, 2, 3, 4, 5, 6].map((i) => 20 + i * 7 % 5 * 12 + (i === 4 ? 20 : 0));
  return (
    <svg aria-hidden="true" focusable="false" width="200" height="120" viewBox="0 0 200 120" fill="none" className="illus-chart">
      <line x1="20" y1="95" x2="180" y2="95" stroke="var(--border-soft)" />
      {/* Bars — each rises on loop, with staggered delay */}
      <g className="chart-bars">
        {bars.map((h, i) =>
        <rect
          key={i}
          x={28 + i * 22}
          y={95 - h}
          width="14"
          height={h}
          fill={i === 4 ? "var(--accent)" : "var(--krew-slate)"}
          className="chart-bar"
          style={{
            transformOrigin: `${28 + i * 22 + 7}px 95px`,
            animationDelay: `${i * 0.18}s`
          }} />

        )}
      </g>
      {/* Trendline — dashed stroke animates drawing itself */}
      <path
        d="M 28 60 Q 60 40, 90 50 T 150 30"
        stroke="var(--accent)"
        strokeWidth="2"
        fill="none"
        strokeDasharray="2 3"
        className="chart-trendline"
        pathLength="1" />
      
      {/* Hover dot — rides along the trendline */}
      <g className="chart-dot-wrap">
        <circle r="4" fill="var(--accent)" stroke="var(--krew-ink)" strokeWidth="1">
          <animateMotion
            dur="6s"
            repeatCount="indefinite"
            rotate="auto"
            keyTimes="0;0.45;0.55;1"
            keyPoints="0;1;1;0"
            calcMode="spline"
            keySplines="0.45 0 0.15 1; 0 0 1 1; 0.45 0 0.15 1"
            path="M 28 60 Q 60 40, 90 50 T 150 30" />
          
        </circle>
      </g>
      <text x="20" y="14" fontSize="8" fill="var(--fg-4)" letterSpacing="1" fontWeight="700">PAGES SHOT / DAY · INTERACTIVE</text>
    </svg>);

}

/* ---------- 06 Daily Brief — personalized morning brief ---------- */
/*
  A single brief card on top, with two stacked card edges peeking out
  behind it (different role tags) — reads as "every role gets their
  own version every morning." The role tag, timestamp, and bullets
  all subtly cycle through three personas (RONNIE, AD, UPM) so the
  card feels alive without being noisy. Pure CSS animation via
  keyframes on the .brief-* classes (defined in landing.css).
*/
function IllusBrief() {
  return (
    <svg aria-hidden="true" focusable="false" width="220" height="130" viewBox="0 0 220 130" fill="none" className="illus-brief">
      {/* Two cards behind — show role tag only, peek out on the right
           and bottom to suggest "everyone gets their own". */}
      <g className="brief-stack-back-2">
        <rect x="20" y="22" width="184" height="100" rx="6"
        fill="var(--krew-grain-pale)"
        stroke="var(--krew-ink)" strokeWidth="1" />
      </g>
      <g className="brief-stack-back-1">
        <rect x="14" y="16" width="184" height="100" rx="6"
        fill="var(--krew-grain-warm)"
        stroke="var(--krew-ink)" strokeWidth="1" />
      </g>

      {/* Top card — the personalized brief itself */}
      <g className="brief-card-top">
        <rect x="8" y="10" width="184" height="100" rx="6"
        fill="var(--bg-surface)"
        stroke="var(--krew-ink)" strokeWidth="1" />

        {/* Header strip */}
        <text x="16" y="22" fontSize="7" fontWeight="800" letterSpacing="1.2"
        fill="var(--fg-4)" fontFamily="var(--font-mono)">
          YOUR BRIEF · TUE 5:42 AM
        </text>

        {/* Role tag — fades through three roles. Three text labels
             stacked, opacity-cycled by .brief-role-{1,2,3}. */}
        <g transform="translate(16, 28)">
          <rect width="80" height="14" rx="3" fill="var(--accent)" />
          <text className="brief-role brief-role-1" x="40" y="10"
          fontSize="7" fontWeight="900" textAnchor="middle"
          fontFamily="var(--font-mono)" letterSpacing="0.4"
          fill="#fff">ELI · POST SUP</text>
          <text className="brief-role brief-role-2" x="40" y="10"
          fontSize="7" fontWeight="900" textAnchor="middle"
          fontFamily="var(--font-mono)" letterSpacing="0.4"
          fill="#fff">PRIYA · 1ST AD</text>
          <text className="brief-role brief-role-3" x="40" y="10"
          fontSize="7" fontWeight="900" textAnchor="middle"
          fontFamily="var(--font-mono)" letterSpacing="0.4"
          fill="#fff">JORDAN · UPM</text>
        </g>

        {/* Divider */}
        <line x1="16" y1="50" x2="184" y2="50" stroke="var(--border-soft)" />

        {/* Bullets — three sets stacked, each set fades in/out in sync
             with its matching role tag. Each set has its own bullet
             colors (orange = info, blue = flag). */}
        <g transform="translate(16, 58)">
          {/* Set 1 — ELI · DIT */}
          <g className="brief-set brief-set-1">
            <circle cx="3" cy="3" r="2" fill="var(--accent)" />
            <text x="11" y="6" fontSize="7.4" fontWeight="700"
            fill="var(--fg-1)" fontFamily="var(--font-sans)">
              Sound notes from yesterday landed
            </text>
            <circle cx="3" cy="17" r="2" fill="var(--accent)" />
            <text x="11" y="20" fontSize="7.4" fontWeight="700"
            fill="var(--fg-1)" fontFamily="var(--font-sans)">
              VFX comments on sc. 47B — 3 shots
            </text>
            <circle cx="3" cy="31" r="2" fill="var(--krew-blue, #2f55a8)" />
            <text x="11" y="34" fontSize="7.4" fontWeight="700"
            fill="var(--fg-1)" fontFamily="var(--font-sans)">
              Flag: dailies turnaround at 14h
            </text>
          </g>

          {/* Set 2 — PRIYA · 1ST AD */}
          <g className="brief-set brief-set-2">
            <circle cx="3" cy="3" r="2" fill="var(--accent)" />
            <text x="11" y="6" fontSize="7.4" fontWeight="700"
            fill="var(--fg-1)" fontFamily="var(--font-sans)">
              Cast arrival: 6 talents, first 6:15
            </text>
            <circle cx="3" cy="17" r="2" fill="var(--accent)" />
            <text x="11" y="20" fontSize="7.4" fontWeight="700"
            fill="var(--fg-1)" fontFamily="var(--font-sans)">
              Meal penalty window: 12:48 – 1:18
            </text>
            <circle cx="3" cy="31" r="2" fill="var(--krew-blue, #2f55a8)" />
            <text x="11" y="34" fontSize="7.4" fontWeight="700"
            fill="var(--fg-1)" fontFamily="var(--font-sans)">
              Flag: scene 14 added overnight
            </text>
          </g>

          {/* Set 3 — JORDAN · UPM */}
          <g className="brief-set brief-set-3">
            <circle cx="3" cy="3" r="2" fill="var(--accent)" />
            <text x="11" y="6" fontSize="7.4" fontWeight="700"
            fill="var(--fg-1)" fontFamily="var(--font-sans)">
              Weather: 30% rain, 2 EXT scenes
            </text>
            <circle cx="3" cy="17" r="2" fill="var(--accent)" />
            <text x="11" y="20" fontSize="7.4" fontWeight="700"
            fill="var(--fg-1)" fontFamily="var(--font-sans)">
              Burn: $48k under, day 22 of 38
            </text>
            <circle cx="3" cy="31" r="2" fill="var(--krew-blue, #2f55a8)" />
            <text x="11" y="34" fontSize="7.4" fontWeight="700"
            fill="var(--fg-1)" fontFamily="var(--font-sans)">
              Flag: OT exposure on B-cam crew
            </text>
          </g>
        </g>
      </g>
    </svg>);

}
function IllusChat() {
  return (
    <svg aria-hidden="true" focusable="false" width="220" height="130" viewBox="0 0 220 130" fill="none">
      {/* User bubble 1 — 138px wide, fits "what's the latest dood?" (~118px text + 10px padding each side) */}
      <g>
        <rect x="14" y="6" width="138" height="22" rx="11" fill="var(--krew-grain-warm)" stroke="var(--border-soft)" />
        <text x="24" y="21" fontSize="10" fill="var(--fg-2)" fontFamily="var(--font-sans)" fontWeight="600">what's the latest dood?</text>
      </g>

      {/* Krew 1 — PDF attachment bubble, right-aligned. Width: 14 badge + 4 gap + ~100 filename + 20 padding ≈ 138px. */}
      <g transform="translate(68, 34)">
        <rect width="138" height="24" rx="12" fill="var(--krew-ink)" />
        <rect x="10" y="6" width="14" height="12" rx="1.5" fill="var(--accent)" />
        <text x="14" y="15" fontSize="7" fill="#fff" fontWeight="900" fontFamily="var(--font-mono)">PDF</text>
        <text x="30" y="16" fontSize="9.5" fill="var(--krew-grain)" fontFamily="var(--font-sans)" fontWeight="700">DOOD_BLUE_v3.pdf</text>
      </g>

      {/* User bubble 2 — 114px wide, fits "ty! what changed?" (~93px text + padding) */}
      <g>
        <rect x="14" y="66" width="114" height="22" rx="11" fill="var(--krew-grain-warm)" stroke="var(--border-soft)" />
        <text x="24" y="81" fontSize="10" fill="var(--fg-2)" fontFamily="var(--font-sans)" fontWeight="600">ty! what changed?</text>
      </g>

      {/* Krew 2 — typing indicator, right */}
      <g transform="translate(154, 96)">
        <rect width="52" height="22" rx="11" fill="var(--krew-ink)" />
        <circle cx="14" cy="11" r="2.5" fill="var(--krew-grain)">
          <animate attributeName="opacity" values="0.35;1;0.35" dur="1.1s" repeatCount="indefinite" />
        </circle>
        <circle cx="26" cy="11" r="2.5" fill="var(--krew-grain)">
          <animate attributeName="opacity" values="0.35;1;0.35" dur="1.1s" begin="0.15s" repeatCount="indefinite" />
        </circle>
        <circle cx="38" cy="11" r="2.5" fill="var(--krew-grain)">
          <animate attributeName="opacity" values="0.35;1;0.35" dur="1.1s" begin="0.3s" repeatCount="indefinite" />
        </circle>
      </g>
    </svg>);

}

window.Pillars = Pillars;