/* Shared SVG visuals for Liquid Data */

/* ---------- Block C with Gamecock head — official asset ---------- */
function BlockC({ size = 200, tone = 'garnet', className = '' }) {
  // tone="white" inverts the logo for use on dark/garnet backgrounds.
  // Other tones use the official asset as-is.
  const filter = tone === 'white' ? 'brightness(0) invert(1)' : 'none';
  return (
    <img
      src="assets/sc-block-c.png"
      alt="South Carolina Gamecocks Block C"
      width={size}
      height={size}
      className={className}
      style={{ filter, display: 'block', objectFit: 'contain' }}
    />
  );
}

/* ---------- University of South Carolina formal wordmark ---------- */
function SCWordmark({ height = 48, tone = 'color', className = '' }) {
  // 2400 × 651 — aspect ratio ~3.69:1
  const width = height * (2400 / 651);
  const filter = tone === 'white' ? 'brightness(0) invert(1)' : 'none';
  return (
    <img
      src="assets/sc-wordmark.png"
      alt="University of South Carolina"
      width={width}
      height={height}
      className={className}
      style={{ filter, display: 'block', objectFit: 'contain' }}
    />
  );
}

/* ---------- Wordmark: GAMECOCKS / South Carolina ---------- */
function Wordmark({ small = false, light = false }) {
  return (
    <div className={"flex flex-col items-center " + (small ? 'gap-0.5' : 'gap-1')}>
      <div
        className="display"
        style={{
          fontWeight: 700,
          fontSize: small ? 18 : 30,
          color: light ? '#fff' : '#fff',
          letterSpacing: '0.08em',
        }}
      >
        GAMECOCKS
      </div>
      <div
        className="font-serif italic"
        style={{
          fontSize: small ? 10 : 14,
          color: light ? 'rgba(255,255,255,0.7)' : 'rgba(255,255,255,0.55)',
          letterSpacing: '0.04em',
        }}
      >
        South Carolina
      </div>
    </div>
  );
}

/* ---------- The Custom Can — real product photo ---------- */
function CustomCan({ width = 280, rotate = 0, condensation, showQR, uid }) {
  // Subtle Y-axis tilt for scroll-based motion
  const r = Math.max(-32, Math.min(32, rotate || 0));
  // Real can asset is 1024×1536 (2:3 portrait aspect)
  const height = width * (1536 / 1024);
  return (
    <div
      className="relative"
      style={{
        width,
        height,
        perspective: 1400,
        transformStyle: 'preserve-3d',
      }}
    >
      <img
        src="assets/sc-can-600.png"
        alt="South Carolina Gamecocks custom water can"
        width={width}
        height={height}
        style={{
          width: '100%',
          height: '100%',
          objectFit: 'contain',
          display: 'block',
          transform: `rotateY(${r}deg)`,
          transition: 'transform 100ms linear',
          filter: 'drop-shadow(0 30px 30px rgba(58,30,15,0.35))',
        }}
        draggable={false}
      />
    </div>
  );
}

/* ---------- QR code pattern (decorative) ---------- */
function QRPattern({ x = 0, y = 0, size = 60 }) {
  // simple deterministic pattern of squares — looks like a QR code
  const cells = 17;
  const cell = size / cells;
  const dots = [];
  // seed pattern
  const seed = [
    "11111110011111111",
    "10000010101000001",
    "10111010110101101",
    "10111010001011101",
    "10111010111010101",
    "10000010010011001",
    "11111110101010111",
    "00000000111000000",
    "10110101010110110",
    "01001110011001011",
    "11010001100101100",
    "00100110010111011",
    "11111110101011010",
    "10000010100010110",
    "10111010111110011",
    "10111010001001100",
    "11111110110110110",
  ];
  for (let r = 0; r < cells; r++) {
    for (let c = 0; c < cells; c++) {
      if (seed[r][c] === '1') {
        dots.push(<rect key={`${r}-${c}`} x={x + c * cell} y={y + r * cell} width={cell} height={cell} fill="#0A0A0A" />);
      }
    }
  }
  return <g>{dots}</g>;
}

/* ---------- Welcome Kit — gift box, slightly open ---------- */
function WelcomeKit({ width = 520 }) {
  const h = width * 0.78;
  return (
    <svg viewBox="0 0 720 560" width="100%" height={h} style={{maxWidth: width}}>
      <defs>
        <linearGradient id="kitBg" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#0A0A0A" />
          <stop offset="1" stopColor="#000" />
        </linearGradient>
        <linearGradient id="boxBody" x1="0" x2="1">
          <stop offset="0" stopColor="#0e0e0e" />
          <stop offset="0.5" stopColor="#1a1a1a" />
          <stop offset="1" stopColor="#080808" />
        </linearGradient>
        <linearGradient id="boxLid" x1="0" x2="1">
          <stop offset="0" stopColor="#161616" />
          <stop offset="0.5" stopColor="#222" />
          <stop offset="1" stopColor="#0c0c0c" />
        </linearGradient>
        <linearGradient id="tissue" x1="0" x2="1">
          <stop offset="0" stopColor="#73000A" />
          <stop offset="0.5" stopColor="#8B0010" />
          <stop offset="1" stopColor="#4A0007" />
        </linearGradient>
        <radialGradient id="spotlight" cx="0.5" cy="0.2" r="0.6">
          <stop offset="0" stopColor="rgba(255,255,255,0.08)" />
          <stop offset="1" stopColor="rgba(0,0,0,0)" />
        </radialGradient>
      </defs>
      <rect width="720" height="560" fill="url(#kitBg)" />
      <rect width="720" height="560" fill="url(#spotlight)" />

      {/* Surface line */}
      <line x1="0" y1="440" x2="720" y2="440" stroke="rgba(255,255,255,0.06)" />

      {/* Box body (3/4 overhead) */}
      <path d="M 140 280 L 580 280 L 600 480 L 120 480 Z" fill="url(#boxBody)" stroke="#000" strokeWidth="1" />
      {/* Inner tissue paper bunched */}
      <path d="M 160 280 L 560 280 L 575 360 Q 360 410 145 360 Z" fill="url(#tissue)" opacity="0.95" />
      <path d="M 200 290 Q 360 360 520 290" stroke="rgba(255,255,255,0.15)" fill="none" strokeWidth="1.2" />
      <path d="M 220 310 Q 360 380 500 310" stroke="rgba(0,0,0,0.3)" fill="none" strokeWidth="1.2" />

      {/* Can inside box */}
      <g transform="translate(280,140) scale(0.42)">
        <CanMini />
      </g>

      {/* Letterpress card */}
      <g transform="translate(380,330) rotate(-6)">
        <rect width="200" height="120" rx="2" fill="#F5F2EC" stroke="#d4cfc4" />
        <g transform="translate(100,60)">
          <g transform="translate(-22,-30) scale(0.22)">
            <path d="M 168 52 L 168 30 C 145 14, 118 8, 96 8 C 50 8, 14 44, 14 100 C 14 156, 50 192, 96 192 C 118 192, 145 186, 168 170 L 168 148 L 138 148 L 138 158 C 124 166, 110 168, 96 168 C 64 168, 44 142, 44 100 C 44 58, 64 32, 96 32 C 110 32, 124 34, 138 42 L 138 52 Z" fill="#73000A" />
          </g>
        </g>
        <text x="100" y="100" textAnchor="middle" fontFamily="Source Serif 4, serif" fontStyle="italic" fontSize="10" fill="#0A0A0A">Welcome to the Cocky Coalition.</text>
      </g>

      {/* Sticker sheet */}
      <g transform="translate(150,320) rotate(8)">
        <rect width="160" height="120" fill="#0A0A0A" stroke="#222" />
        <g transform="translate(30,30)">
          <g transform="scale(0.18)"><path d="M 168 52 L 168 30 C 145 14, 118 8, 96 8 C 50 8, 14 44, 14 100 C 14 156, 50 192, 96 192 C 118 192, 145 186, 168 170 L 168 148 L 138 148 L 138 158 C 124 166, 110 168, 96 168 C 64 168, 44 142, 44 100 C 44 58, 64 32, 96 32 C 110 32, 124 34, 138 42 L 138 52 Z" fill="#73000A" /></g>
        </g>
        <g transform="translate(95,30)">
          <g transform="scale(0.18)"><path d="M 168 52 L 168 30 C 145 14, 118 8, 96 8 C 50 8, 14 44, 14 100 C 14 156, 50 192, 96 192 C 118 192, 145 186, 168 170 L 168 148 L 138 148 L 138 158 C 124 166, 110 168, 96 168 C 64 168, 44 142, 44 100 C 44 58, 64 32, 96 32 C 110 32, 124 34, 138 42 L 138 52 Z" fill="#73000A" /></g>
        </g>
        <text x="80" y="100" textAnchor="middle" fontFamily="JetBrains Mono, monospace" fontSize="7" letterSpacing="3" fill="#9A9A9A">GAMECOCK STICKER PACK</text>
      </g>

      {/* Box LID propped open at back */}
      <g transform="translate(80,160)">
        <path d="M 0 140 L 460 100 L 560 140 L 80 200 Z" fill="url(#boxLid)" stroke="#000" />
        {/* Embossed Block C in garnet foil on lid */}
        <g transform="translate(200,90) rotate(-6)">
          <g transform="scale(0.45)">
            <path d="M 168 52 L 168 30 C 145 14, 118 8, 96 8 C 50 8, 14 44, 14 100 C 14 156, 50 192, 96 192 C 118 192, 145 186, 168 170 L 168 148 L 138 148 L 138 158 C 124 166, 110 168, 96 168 C 64 168, 44 142, 44 100 C 44 58, 64 32, 96 32 C 110 32, 124 34, 138 42 L 138 52 Z" fill="#73000A" stroke="#C9A961" strokeWidth="2" />
            {/* mini head */}
            <g transform="translate(78,52) scale(0.55)">
              <path d="M 60 30 C 40 30, 22 44, 18 64 C 14 84, 18 102, 32 116 L 28 130 L 44 126 C 56 138, 78 142, 96 132 L 108 152 L 116 134 C 130 124, 138 108, 138 90 C 138 82, 136 76, 132 70 L 154 66 L 138 56 C 130 38, 110 26, 88 26 C 80 26, 70 28, 60 30 Z" fill="#000" />
              <circle cx="78" cy="74" r="5" fill="#73000A" />
            </g>
          </g>
        </g>
      </g>
    </svg>
  );
}

function CanMini() {
  // A simplified can used inside the welcome kit (already scaled by parent)
  return (
    <svg viewBox="0 0 240 640" width="240" height="640">
      <defs>
        <linearGradient id="miniBody" x1="0" x2="1">
          <stop offset="0" stopColor="#3a0005" />
          <stop offset="0.5" stopColor="#8a0010" />
          <stop offset="1" stopColor="#2a0004" />
        </linearGradient>
      </defs>
      <ellipse cx="120" cy="32" rx="84" ry="12" fill="#2a2a2a" />
      <path d="M 36 36 L 36 60 Q 120 78 204 60 L 204 36 Z" fill="#0a0a0a" />
      <path d="M 36 60 Q 120 78 204 60 L 204 580 Q 120 600 36 580 Z" fill="url(#miniBody)" />
      <g transform="translate(120,310)">
        <g transform="translate(-70,-90) scale(0.85)">
          <path d="M 168 36 L 168 18 C 148 6, 124 0, 102 0 C 56 0, 22 38, 22 100 C 22 162, 56 200, 102 200 C 124 200, 148 194, 168 182 L 168 164 L 140 164 L 140 172 C 128 178, 114 182, 102 182 C 70 182, 50 154, 50 100 C 50 46, 70 18, 102 18 C 114 18, 128 22, 140 28 L 140 36 Z" fill="#fff" />
        </g>
      </g>
      <ellipse cx="120" cy="580" rx="84" ry="12" fill="#000" />
    </svg>
  );
}

/* ---------- South Carolina state map ---------- */
function SCStateMap({ height = 360 }) {
  // Approximate South Carolina outline — viewBox 640×400
  // Anchored: NW corner (Oconee), N border with NC, NE Pee Dee, E coast, S Savannah River
  const scPath = `
    M 70 142
    C 100 116, 150 96, 210 92
    C 270 90, 330 88, 388 92
    C 430 96, 470 108, 502 130
    C 522 144, 540 168, 552 192
    C 558 208, 562 222, 562 232
    L 552 244
    C 540 256, 520 268, 498 278
    C 470 290, 440 298, 408 302
    C 376 304, 346 304, 320 300
    C 290 292, 262 280, 240 264
    C 218 248, 198 230, 178 212
    C 158 194, 138 178, 118 164
    C 100 154, 84 148, 70 142
    Z
  `;

  // Major cities with scan activity (x, y, intensity 1-5)
  const cities = [
    { name: 'GREENVILLE', x: 158, y: 138, hits: 4, dx: 0, dy: -10, anchor: 'middle' },
    { name: 'SPARTANBURG', x: 198, y: 124, hits: 3, dx: 0, dy: -10, anchor: 'middle' },
    { name: 'ROCK HILL', x: 280, y: 110, hits: 3, dx: 0, dy: -10, anchor: 'middle' },
    { name: 'COLUMBIA', x: 314, y: 196, hits: 5, dx: 0, dy: 16, anchor: 'middle' },
    { name: 'FLORENCE', x: 416, y: 168, hits: 3, dx: 0, dy: -10, anchor: 'middle' },
    { name: 'MYRTLE BEACH', x: 510, y: 198, hits: 4, dx: 14, dy: 0, anchor: 'start' },
    { name: 'CHARLESTON', x: 432, y: 268, hits: 5, dx: 0, dy: 16, anchor: 'middle' },
    { name: 'HILTON HEAD', x: 348, y: 296, hits: 3, dx: 0, dy: 16, anchor: 'middle' },
    { name: 'AIKEN', x: 230, y: 240, hits: 2, dx: -10, dy: 4, anchor: 'end' },
  ];

  // Random-feeling but deterministic scan dots
  const scanDots = React.useMemo(() => {
    const dots = [];
    const seed = (i) => Math.sin(i * 12.9898 + 78.233) * 43758.5453;
    const frac = (x) => x - Math.floor(x);
    for (const c of cities) {
      const count = c.hits * 6;
      for (let i = 0; i < count; i++) {
        const a = frac(seed(c.x + i)) * Math.PI * 2;
        const r = frac(seed(c.x + i + 1000)) * (10 + c.hits * 2.5);
        dots.push({
          x: c.x + Math.cos(a) * r,
          y: c.y + Math.sin(a) * r,
          rad: 0.6 + frac(seed(c.x + i + 500)) * 1.4,
          op: 0.35 + frac(seed(c.x + i + 200)) * 0.55,
        });
      }
    }
    // sprinkle a few random dots in the state
    for (let i = 0; i < 60; i++) {
      const x = 90 + frac(seed(i * 7)) * 460;
      const y = 110 + frac(seed(i * 11)) * 180;
      dots.push({ x, y, rad: 0.4 + frac(seed(i * 13)) * 0.8, op: 0.15 + frac(seed(i * 17)) * 0.3 });
    }
    return dots;
  }, []);

  return (
    <svg viewBox="0 0 640 400" width="100%" style={{ height, maxHeight: height }}>
      <defs>
        <linearGradient id="sc-fill" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#181818" />
          <stop offset="1" stopColor="#0a0a0a" />
        </linearGradient>
        <radialGradient id="sc-glow" cx="0.5" cy="0.5" r="0.7">
          <stop offset="0" stopColor="rgba(115,0,10,0.18)" />
          <stop offset="1" stopColor="rgba(115,0,10,0)" />
        </radialGradient>
        <filter id="sc-blur"><feGaussianBlur stdDeviation="0.8" /></filter>
      </defs>

      {/* Background glow */}
      <ellipse cx="320" cy="200" rx="240" ry="120" fill="url(#sc-glow)" />

      {/* Faint coordinate grid */}
      <g opacity="0.04" stroke="#fff">
        {Array.from({ length: 16 }).map((_, i) => (
          <line key={`v${i}`} x1={i * 40} y1="0" x2={i * 40} y2="400" />
        ))}
        {Array.from({ length: 10 }).map((_, i) => (
          <line key={`h${i}`} x1="0" y1={i * 40} x2="640" y2={i * 40} />
        ))}
      </g>

      {/* State fill */}
      <path d={scPath} fill="url(#sc-fill)" stroke="rgba(115,0,10,0.5)" strokeWidth="1.2" />
      {/* Inner highlight along NW border */}
      <path d={scPath} fill="none" stroke="rgba(255,255,255,0.05)" strokeWidth="0.6" transform="translate(0,1)" />

      {/* Savannah River — dashed line along southern border */}
      <path
        d="M 70 142 C 100 156, 140 180, 180 210 C 220 240, 270 270, 320 300"
        fill="none"
        stroke="rgba(115,0,10,0.4)"
        strokeWidth="0.8"
        strokeDasharray="3 3"
      />

      {/* Compass tick marks */}
      <g fontFamily="JetBrains Mono, monospace" fontSize="7" fill="rgba(255,255,255,0.25)" letterSpacing="1">
        <text x="14" y="22">N 35°00'</text>
        <text x="14" y="385">N 32°00'</text>
        <text x="572" y="385">W 79°00'</text>
      </g>

      {/* Scan dots */}
      <g>
        {scanDots.map((d, i) => (
          <circle key={i} cx={d.x} cy={d.y} r={d.rad} fill="#73000A" opacity={d.op} />
        ))}
      </g>

      {/* City markers */}
      {cities.map((c, i) => (
        <g key={i}>
          {/* outer halo */}
          <circle cx={c.x} cy={c.y} r={3 + c.hits} fill="rgba(115,0,10,0.18)" />
          {/* pulse animation */}
          <circle cx={c.x} cy={c.y} r={3} fill="#73000A" className="map-pulse" style={{animationDelay: `${i * 0.3}s`}} />
          {/* solid */}
          <circle cx={c.x} cy={c.y} r={2.5 + c.hits * 0.4} fill="#73000A" stroke="rgba(255,255,255,0.8)" strokeWidth="0.6" />
          {/* connector tick */}
          <line x1={c.x} y1={c.y} x2={c.x + (c.dx || 0)} y2={c.y + (c.dy > 0 ? c.dy - 8 : c.dy + 4)} stroke="rgba(255,255,255,0.2)" strokeWidth="0.4" />
          {/* label */}
          <text
            x={c.x + c.dx}
            y={c.y + c.dy}
            textAnchor={c.anchor}
            fontFamily="JetBrains Mono, monospace"
            fontSize="9"
            letterSpacing="2"
            fill="rgba(255,255,255,0.75)"
          >
            {c.name}
          </text>
          <text
            x={c.x + c.dx}
            y={c.y + c.dy + (c.dy > 0 ? 11 : -11)}
            textAnchor={c.anchor}
            fontFamily="JetBrains Mono, monospace"
            fontSize="7"
            letterSpacing="1.5"
            fill="#73000A"
          >
            {String(c.hits * 47 + 12).padStart(3, '0')} scans / 24h
          </text>
        </g>
      ))}

      {/* Live cursor — currently scanning marker, animated subtle */}
      <g transform="translate(454, 260)">
        <circle r="6" fill="none" stroke="#73000A" strokeWidth="1" className="map-pulse" />
        <circle r="3" fill="#fff" />
        <circle r="1.6" fill="#73000A" />
      </g>
      <text x="468" y="256" fontFamily="JetBrains Mono, monospace" fontSize="8" letterSpacing="1.5" fill="#fff">● LIVE</text>
      <text x="468" y="266" fontFamily="JetBrains Mono, monospace" fontSize="7" letterSpacing="1.2" fill="rgba(255,255,255,0.5)">Mt. Pleasant · just now</text>

      {/* North arrow */}
      <g transform="translate(596, 36)">
        <circle r="14" fill="none" stroke="rgba(255,255,255,0.2)" strokeWidth="0.6" />
        <path d="M 0 -10 L 4 8 L 0 4 L -4 8 Z" fill="#73000A" />
        <text textAnchor="middle" y="22" fontFamily="JetBrains Mono, monospace" fontSize="7" letterSpacing="1.5" fill="rgba(255,255,255,0.5)">N</text>
      </g>

      {/* SC label */}
      <text x="320" y="234" textAnchor="middle" fontFamily="Oswald, sans-serif" fontWeight="600" fontSize="36" letterSpacing="12" fill="rgba(115,0,10,0.18)">SC</text>
    </svg>
  );
}

/* ---------- Phone (iPhone) mock for QR landing ---------- */
function PhoneMock({ width = 220 }) {
  const h = width * 2.1;
  return (
    <svg viewBox="0 0 220 460" width={width} height={h}>
      <defs>
        <linearGradient id="phoneBezel" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#1a1a1a" />
          <stop offset="1" stopColor="#0a0a0a" />
        </linearGradient>
      </defs>
      <rect x="2" y="2" width="216" height="456" rx="36" fill="url(#phoneBezel)" stroke="#2a2a2a" />
      <rect x="10" y="10" width="200" height="440" rx="28" fill="#000" />
      {/* notch */}
      <rect x="80" y="14" width="60" height="14" rx="7" fill="#0a0a0a" />
      {/* Screen content */}
      <g clipPath="url(#screenClip)">
        <defs>
          <clipPath id="screenClip">
            <rect x="14" y="14" width="192" height="432" rx="24" />
          </clipPath>
        </defs>
        {/* status bar */}
        <text x="28" y="44" fontFamily="JetBrains Mono, monospace" fontSize="9" fill="#fff">9:41</text>
        {/* hero block - garnet */}
        <rect x="14" y="58" width="192" height="160" fill="#73000A" />
        <g transform="translate(80,90)">
          <g transform="scale(0.32)">
            <path d="M 168 52 L 168 30 C 145 14, 118 8, 96 8 C 50 8, 14 44, 14 100 C 14 156, 50 192, 96 192 C 118 192, 145 186, 168 170 L 168 148 L 138 148 L 138 158 C 124 166, 110 168, 96 168 C 64 168, 44 142, 44 100 C 44 58, 64 32, 96 32 C 110 32, 124 34, 138 42 L 138 52 Z" fill="#fff" />
          </g>
        </g>
        <text x="110" y="195" textAnchor="middle" fontFamily="Oswald, sans-serif" fontWeight="700" fontSize="14" fill="#fff" letterSpacing="2">WELCOME,</text>
        <text x="110" y="212" textAnchor="middle" fontFamily="Oswald, sans-serif" fontWeight="700" fontSize="14" fill="#fff" letterSpacing="2">GAMECOCK NATION</text>
        {/* divider */}
        <line x1="30" y1="232" x2="190" y2="232" stroke="rgba(255,255,255,0.2)" />
        {/* Steps */}
        <g fontFamily="Inter, sans-serif" fill="#fff">
          <text x="28" y="254" fontSize="9" opacity="0.5" letterSpacing="2">SCAN 01</text>
          <text x="28" y="270" fontSize="11" fontWeight="600">Claim your subscription</text>
          <text x="28" y="282" fontSize="8" opacity="0.6">14.99/mo · ships free</text>

          <text x="28" y="304" fontSize="9" opacity="0.5" letterSpacing="2">REWARDS</text>
          <text x="28" y="320" fontSize="11" fontWeight="600">Unlock a recruit drop</text>
          <text x="28" y="332" fontSize="8" opacity="0.6">Limited Gamecock x Ape pack</text>

          <text x="28" y="354" fontSize="9" opacity="0.5" letterSpacing="2">NIL</text>
          <text x="28" y="370" fontSize="11" fontWeight="600">Fund a Gamecock</text>
          <text x="28" y="382" fontSize="8" opacity="0.6">100% to NIL collective</text>
        </g>
        {/* CTA */}
        <rect x="28" y="402" width="164" height="32" rx="2" fill="#73000A" />
        <text x="110" y="421" textAnchor="middle" fontFamily="JetBrains Mono, monospace" fontSize="9" fill="#fff" letterSpacing="3">JOIN THE COALITION →</text>
      </g>
    </svg>
  );
}

/* ---------- Small inline icons ---------- */
const Icon = {
  Pipeline: ({size=22}) => (
    <svg viewBox="0 0 24 24" width={size} height={size} fill="none" stroke="#73000A" strokeWidth="1.6" strokeLinecap="square">
      <path d="M3 6 L9 6 M3 12 L9 12 M3 18 L9 18" />
      <path d="M9 6 L15 6 L21 12 L15 18 L9 18" />
    </svg>
  ),
  Revenue: ({size=22}) => (
    <svg viewBox="0 0 24 24" width={size} height={size} fill="none" stroke="#73000A" strokeWidth="1.6" strokeLinecap="square">
      <path d="M4 20 L4 4 L20 4" />
      <path d="M4 16 L9 11 L13 14 L20 7" />
    </svg>
  ),
  People: ({size=22}) => (
    <svg viewBox="0 0 24 24" width={size} height={size} fill="none" stroke="#73000A" strokeWidth="1.6" strokeLinecap="square">
      <circle cx="9" cy="8" r="3" />
      <circle cx="17" cy="9" r="2" />
      <path d="M3 20 C 3 16, 6 14, 9 14 C 12 14, 15 16, 15 20" />
      <path d="M15 20 C 15 17, 17 16, 19 16 C 21 16, 22 17, 22 20" />
    </svg>
  ),
  Data: ({size=22}) => (
    <svg viewBox="0 0 24 24" width={size} height={size} fill="none" stroke="#73000A" strokeWidth="1.6" strokeLinecap="square">
      <rect x="4" y="4" width="6" height="6" />
      <rect x="14" y="4" width="6" height="6" />
      <rect x="4" y="14" width="6" height="6" />
      <rect x="14" y="14" width="6" height="6" />
    </svg>
  ),
  Arrow: ({size=14}) => (
    <svg viewBox="0 0 24 24" width={size} height={size} fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="square">
      <path d="M5 12 L19 12 M14 7 L19 12 L14 17" />
    </svg>
  ),
};

/* ---------- Sparkline ---------- */
function Sparkline({ data, color = '#73000A', width = 90, height = 28 }) {
  if (!data || !data.length) return null;
  const min = Math.min(...data);
  const max = Math.max(...data);
  const rng = max - min || 1;
  const pts = data.map((v, i) => {
    const x = (i / (data.length - 1)) * width;
    const y = height - ((v - min) / rng) * height * 0.9 - height * 0.05;
    return `${x.toFixed(1)},${y.toFixed(1)}`;
  });
  return (
    <svg className="spark" viewBox={`0 0 ${width} ${height}`} width={width} height={height}>
      <polyline points={pts.join(' ')} fill="none" stroke={color} strokeWidth="1.4" />
      <polyline points={`0,${height} ${pts.join(' ')} ${width},${height}`} fill={color} opacity="0.12" />
    </svg>
  );
}

/* Expose to global */
Object.assign(window, {
  BlockC, SCWordmark, Wordmark, CustomCan, WelcomeKit, QRPattern, SCStateMap, PhoneMock, Icon, Sparkline
});
