// illustrations.jsx — FA-energy: bold icon graphics, stacked color blocks,
// stamp/badge shapes. No mascots. Icons as design elements.

// ─────────────────────────────────────────────────────────────
// AwesomeStar — 8-point bold star (FA's brand star). Used for
// streak/award stamps. Filled, with a small dot inside.
// ─────────────────────────────────────────────────────────────
function AwesomeStar({ size = 32, color = 'var(--yellow)', dot = false }) {
  return (
    <svg width={size} height={size} viewBox="0 0 64 64" fill="none">
      <path
        d="M32 2 L37 22 L57 18 L43 33 L62 42 L41 43 L46 62 L32 50 L18 62 L23 43 L2 42 L21 33 L7 18 L27 22 Z"
        fill={color}
      />
      {dot && <circle cx="32" cy="33" r="4" fill="var(--text)"/>}
    </svg>
  );
}

// ─────────────────────────────────────────────────────────────
// BigGlyph — single huge icon on a colored disc. Used as the
// centerpiece illustration (hero positions where the blob used to be).
// kind: 'mic' | 'headphones' | 'wave' | 'sparks' | 'box' | 'play'
// ─────────────────────────────────────────────────────────────
function BigGlyph({ size = 140, kind = 'mic', bg = 'var(--accent)', fg = '#fff', rotate = -6 }) {
  const glyphs = {
    mic: (
      <g transform="translate(50,40)">
        {/* Microphone */}
        <rect x="-12" y="0" width="24" height="36" rx="12" fill={fg}/>
        <path d="M-22 28 a22 22 0 0 0 44 0" stroke={fg} strokeWidth="6" fill="none" strokeLinecap="round"/>
        <line x1="0" y1="50" x2="0" y2="64" stroke={fg} strokeWidth="6" strokeLinecap="round"/>
        <line x1="-12" y1="64" x2="12" y2="64" stroke={fg} strokeWidth="6" strokeLinecap="round"/>
      </g>
    ),
    headphones: (
      <g transform="translate(50,46)">
        <path d="M-30 8 C -30 -16, -16 -28, 0 -28 C 16 -28, 30 -16, 30 8"
          stroke={fg} strokeWidth="7" fill="none" strokeLinecap="round"/>
        <rect x="-34" y="2" width="14" height="22" rx="5" fill={fg}/>
        <rect x="20" y="2" width="14" height="22" rx="5" fill={fg}/>
      </g>
    ),
    wave: (
      <g transform="translate(50,50)">
        <rect x="-30" y="-6" width="6" height="12" rx="3" fill={fg}/>
        <rect x="-19" y="-14" width="6" height="28" rx="3" fill={fg}/>
        <rect x="-8" y="-22" width="6" height="44" rx="3" fill={fg}/>
        <rect x="3" y="-16" width="6" height="32" rx="3" fill={fg}/>
        <rect x="14" y="-10" width="6" height="20" rx="3" fill={fg}/>
        <rect x="25" y="-4" width="6" height="8" rx="3" fill={fg}/>
      </g>
    ),
    sparks: (
      <g transform="translate(50,50)">
        <path d="M0 -34 L4 -8 L30 -4 L4 0 L0 26 L-4 0 L-30 -4 L-4 -8 Z" fill={fg}/>
        <circle cx="-22" cy="20" r="4" fill={fg}/>
        <circle cx="22" cy="-22" r="3" fill={fg}/>
      </g>
    ),
    box: (
      <g transform="translate(50,50)">
        <rect x="-24" y="-24" width="48" height="48" rx="8" fill={fg}/>
        <path d="M-12 -4 L-4 4 L12 -12" stroke={bg} strokeWidth="6" fill="none" strokeLinecap="round" strokeLinejoin="round"/>
      </g>
    ),
    play: (
      <g transform="translate(50,50)">
        <path d="M-12 -20 L20 0 L-12 20 Z" fill={fg}/>
      </g>
    ),
    bolt: (
      <g transform="translate(50,50)">
        <path d="M2 -32 L-22 6 L-2 6 L-6 32 L22 -6 L4 -6 Z" fill={fg}/>
      </g>
    ),
    chat: (
      <g transform="translate(50,50)">
        <path d="M-28 -14 a14 14 0 0 1 14 -14 H14 a14 14 0 0 1 14 14 v6 a14 14 0 0 1 -14 14 H0 L-14 16 L-10 6 H-14 a14 14 0 0 1 -14 -14 Z" fill={fg}/>
        <circle cx="-10" cy="-8" r="3" fill={bg}/>
        <circle cx="0" cy="-8" r="3" fill={bg}/>
        <circle cx="10" cy="-8" r="3" fill={bg}/>
      </g>
    ),
  };
  return (
    <div style={{ width: size, height: size, display: 'inline-block', transform: `rotate(${rotate}deg)` }}>
      <svg width={size} height={size} viewBox="0 0 100 100" fill="none">
        <circle cx="50" cy="50" r="44" fill={bg}/>
        {glyphs[kind] || glyphs.mic}
      </svg>
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// IconStack — a confident cluster of icon glyphs in different
// colors, scaled & rotated. The FA-style hero illustration.
// ─────────────────────────────────────────────────────────────
function IconStack({ size = 200 }) {
  return (
    <div style={{
      position: 'relative', width: size, height: size,
      display: 'inline-block',
    }}>
      <div style={{ position: 'absolute', top: '4%',  left: '12%' }}><BigGlyph size={size*0.5}  kind="mic"        bg="var(--accent)" rotate={-8}/></div>
      <div style={{ position: 'absolute', top: '40%', left: '54%' }}><BigGlyph size={size*0.42} kind="headphones" bg="var(--magenta)" rotate={10}/></div>
      <div style={{ position: 'absolute', top: '55%', left: '4%'  }}><BigGlyph size={size*0.32} kind="wave"       bg="var(--yellow)" fg="var(--text)" rotate={-4}/></div>
      <div style={{ position: 'absolute', top: '2%',  left: '62%' }}><BigGlyph size={size*0.24} kind="sparks"     bg="var(--text)" rotate={14}/></div>
      <div style={{ position: 'absolute', top: '70%', left: '46%' }}><BigGlyph size={size*0.20} kind="bolt"       bg="var(--accent-deep)" rotate={6}/></div>
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// ColorChip — small chunky colored block with an icon. Used as
// the "category" decoration on interest cards / etc.
// ─────────────────────────────────────────────────────────────
function ColorChip({ size = 44, kind = 'wave', bg = 'var(--accent)', fg = '#fff', rotate = 0, radius = 12 }) {
  return (
    <div style={{
      width: size, height: size, borderRadius: radius,
      background: bg, color: fg,
      display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
      transform: `rotate(${rotate}deg)`,
      boxShadow: '0 4px 10px rgba(24,30,50,0.10)',
    }}>
      <svg width={size * 0.6} height={size * 0.6} viewBox="0 0 100 100" fill="none">
        <BigGlyphInner kind={kind} fg={fg} bg={bg}/>
      </svg>
    </div>
  );
}

function BigGlyphInner({ kind = 'mic', fg = '#fff', bg = '#000' }) {
  switch (kind) {
    case 'mic': return (<g transform="translate(50,40)"><rect x="-12" y="0" width="24" height="36" rx="12" fill={fg}/><path d="M-22 28 a22 22 0 0 0 44 0" stroke={fg} strokeWidth="6" fill="none" strokeLinecap="round"/><line x1="0" y1="50" x2="0" y2="64" stroke={fg} strokeWidth="6" strokeLinecap="round"/><line x1="-12" y1="64" x2="12" y2="64" stroke={fg} strokeWidth="6" strokeLinecap="round"/></g>);
    case 'headphones': return (<g transform="translate(50,46)"><path d="M-30 8 C -30 -16, -16 -28, 0 -28 C 16 -28, 30 -16, 30 8" stroke={fg} strokeWidth="7" fill="none" strokeLinecap="round"/><rect x="-34" y="2" width="14" height="22" rx="5" fill={fg}/><rect x="20" y="2" width="14" height="22" rx="5" fill={fg}/></g>);
    case 'wave': return (<g transform="translate(50,50)"><rect x="-30" y="-6" width="6" height="12" rx="3" fill={fg}/><rect x="-19" y="-14" width="6" height="28" rx="3" fill={fg}/><rect x="-8" y="-22" width="6" height="44" rx="3" fill={fg}/><rect x="3" y="-16" width="6" height="32" rx="3" fill={fg}/><rect x="14" y="-10" width="6" height="20" rx="3" fill={fg}/><rect x="25" y="-4" width="6" height="8" rx="3" fill={fg}/></g>);
    case 'bolt': return (<g transform="translate(50,50)"><path d="M2 -32 L-22 6 L-2 6 L-6 32 L22 -6 L4 -6 Z" fill={fg}/></g>);
    case 'chip': return (<g transform="translate(50,50)"><rect x="-20" y="-20" width="40" height="40" rx="6" fill={fg}/><rect x="-10" y="-10" width="20" height="20" fill={bg}/></g>);
    case 'globe': return (<g transform="translate(50,50)"><circle cx="0" cy="0" r="24" stroke={fg} strokeWidth="5" fill="none"/><ellipse cx="0" cy="0" rx="12" ry="24" stroke={fg} strokeWidth="5" fill="none"/><line x1="-24" y1="0" x2="24" y2="0" stroke={fg} strokeWidth="5"/></g>);
    case 'leaf': return (<g transform="translate(50,50)"><path d="M-20 24 C -28 -8, 4 -28, 24 -24 C 24 4, -8 24, -20 24 Z" fill={fg}/><line x1="-20" y1="24" x2="10" y2="-10" stroke={bg} strokeWidth="3.5" strokeLinecap="round"/></g>);
    case 'chart': return (<g transform="translate(50,50)"><rect x="-26" y="6" width="10" height="16" rx="2" fill={fg}/><rect x="-8" y="-6" width="10" height="28" rx="2" fill={fg}/><rect x="10" y="-20" width="10" height="42" rx="2" fill={fg}/></g>);
    case 'basket': return (<g transform="translate(50,50)"><circle cx="0" cy="0" r="22" stroke={fg} strokeWidth="5" fill="none"/><line x1="-22" y1="0" x2="22" y2="0" stroke={fg} strokeWidth="5"/><path d="M-15 -16 Q 0 0 -15 16" stroke={fg} strokeWidth="5" fill="none"/><path d="M15 -16 Q 0 0 15 16" stroke={fg} strokeWidth="5" fill="none"/></g>);
    case 'sparks': return (<g transform="translate(50,50)"><path d="M0 -28 L4 -6 L26 -2 L4 2 L0 24 L-4 2 L-26 -2 L-4 -6 Z" fill={fg}/></g>);
    case 'plus': return (<g transform="translate(50,50)"><rect x="-4" y="-22" width="8" height="44" rx="3" fill={fg}/><rect x="-22" y="-4" width="44" height="8" rx="3" fill={fg}/></g>);
    default: return null;
  }
}

// ─────────────────────────────────────────────────────────────
// AwesomeBadge — a stamp-like badge: large star + label
// Used on Today / streak celebrations.
// ─────────────────────────────────────────────────────────────
function AwesomeBadge({ count = 42 }) {
  return (
    <div style={{ position: 'relative', width: 64, height: 64, display: 'inline-block' }}>
      <AwesomeStar size={64} color="var(--yellow)"/>
      <div style={{
        position: 'absolute', inset: 0,
        display: 'flex', alignItems: 'center', justifyContent: 'center',
        fontFamily: 'var(--display)', fontWeight: 800, fontSize: 18,
        color: 'var(--text)', letterSpacing: '-0.04em',
      }}>{count}</div>
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// Sticker — a rotated rectangular "sticker" with rounded corners,
// shadow, and text. FA-style.
// ─────────────────────────────────────────────────────────────
function Sticker({ children, bg = 'var(--magenta)', fg = '#fff', rotate = -4, style = {} }) {
  return (
    <span style={{
      display: 'inline-flex', alignItems: 'center', gap: 5,
      padding: '4px 9px', borderRadius: 8,
      background: bg, color: fg,
      fontFamily: 'var(--display)', fontWeight: 700, fontSize: 11,
      letterSpacing: '0.08em', textTransform: 'uppercase',
      transform: `rotate(${rotate}deg)`,
      boxShadow: '0 2px 0 rgba(24,30,50,0.18), 0 4px 10px rgba(24,30,50,0.10)',
      ...style,
    }}>{children}</span>
  );
}

Object.assign(window, {
  AwesomeStar, BigGlyph, IconStack, ColorChip, BigGlyphInner, AwesomeBadge, Sticker,
});
