/* Indian art SVG components — mandala, marigold, paisley, peacock, toran, doors, ganesh icon */
const { useMemo } = React;

/* MANDALA — radial decorative pattern */
function Mandala({ size = 200, color = "#c2185b", accent = "#ef8c1a", strokeW = 1.5, rings = 4 }) {
  const cx = size / 2, cy = size / 2;
  const petalGroups = [
    { count: 8, r1: 18, r2: 36, fill: accent },
    { count: 12, r1: 40, r2: 70, fill: color },
    { count: 16, r1: 76, r2: 100, fill: accent },
    { count: 24, r1: 104, r2: 124, fill: color },
  ];
  return (
    <svg viewBox={`0 0 ${size} ${size}`} width={size} height={size}>
      {/* center */}
      <circle cx={cx} cy={cy} r={10} fill={color} />
      <circle cx={cx} cy={cy} r={5} fill={accent} />
      {petalGroups.slice(0, rings).map((g, gi) => (
        <g key={gi}>
          {Array.from({ length: g.count }).map((_, i) => {
            const a = (i / g.count) * Math.PI * 2;
            const x1 = cx + Math.cos(a) * g.r1;
            const y1 = cy + Math.sin(a) * g.r1;
            const x2 = cx + Math.cos(a) * g.r2;
            const y2 = cy + Math.sin(a) * g.r2;
            const mx = (x1 + x2) / 2 + Math.cos(a + Math.PI / 2) * 6;
            const my = (y1 + y2) / 2 + Math.sin(a + Math.PI / 2) * 6;
            const mx2 = (x1 + x2) / 2 - Math.cos(a + Math.PI / 2) * 6;
            const my2 = (y1 + y2) / 2 - Math.sin(a + Math.PI / 2) * 6;
            return (
              <path
                key={i}
                d={`M${x1},${y1} Q${mx},${my} ${x2},${y2} Q${mx2},${my2} ${x1},${y1}`}
                fill="none"
                stroke={g.fill}
                strokeWidth={strokeW}
              />
            );
          })}
          {/* concentric ring */}
          <circle cx={cx} cy={cy} r={g.r1} fill="none" stroke={g.fill} strokeWidth={strokeW * 0.6} opacity=".5" strokeDasharray="2 3" />
        </g>
      ))}
      {/* outer ring */}
      <circle cx={cx} cy={cy} r={size * 0.46} fill="none" stroke={color} strokeWidth={strokeW} />
      <circle cx={cx} cy={cy} r={size * 0.48} fill="none" stroke={accent} strokeWidth={strokeW * 0.5} />
    </svg>
  );
}

/* MARIGOLD FLOWER */
function Marigold({ size = 60, color = "#ef8c1a", center = "#d96e09" }) {
  const cx = size / 2, cy = size / 2;
  const petals = 14;
  return (
    <svg viewBox={`0 0 ${size} ${size}`} width={size} height={size}>
      {Array.from({ length: petals }).map((_, i) => {
        const a = (i / petals) * Math.PI * 2;
        const x = cx + Math.cos(a) * (size * 0.32);
        const y = cy + Math.sin(a) * (size * 0.32);
        return <circle key={i} cx={x} cy={y} r={size * 0.13} fill={color} opacity=".95" />;
      })}
      {Array.from({ length: petals }).map((_, i) => {
        const a = ((i + 0.5) / petals) * Math.PI * 2;
        const x = cx + Math.cos(a) * (size * 0.22);
        const y = cy + Math.sin(a) * (size * 0.22);
        return <circle key={`b${i}`} cx={x} cy={y} r={size * 0.11} fill={center} opacity=".9" />;
      })}
      <circle cx={cx} cy={cy} r={size * 0.13} fill={center} />
      <circle cx={cx} cy={cy} r={size * 0.06} fill="#7a3d05" />
    </svg>
  );
}

/* PAISLEY (Mango / Boota) */
function Paisley({ size = 80, color = "#c2185b", accent = "#ef8c1a" }) {
  return (
    <svg viewBox="0 0 80 80" width={size} height={size}>
      <path
        d="M 40,8 C 64,8 70,32 60,52 C 52,68 32,72 24,60 C 18,50 24,42 32,44 C 38,46 40,52 36,56"
        fill="none"
        stroke={color}
        strokeWidth="2"
        strokeLinecap="round"
      />
      <path
        d="M 40,16 C 58,16 64,34 56,50 C 50,62 36,64 30,56"
        fill="none"
        stroke={accent}
        strokeWidth="1.4"
      />
      <circle cx="42" cy="28" r="2" fill={color} />
      <circle cx="50" cy="36" r="2" fill={accent} />
      <circle cx="46" cy="44" r="1.6" fill={color} />
    </svg>
  );
}

/* PEACOCK FEATHER */
function PeacockFeather({ size = 80, tint = "#06727d" }) {
  return (
    <svg viewBox="0 0 80 120" width={size} height={size * 1.5}>
      <path d="M 40,118 Q 38,80 40,40" stroke="#4a7c3a" strokeWidth="1.5" fill="none" />
      <ellipse cx="40" cy="32" rx="20" ry="28" fill={tint} opacity=".85" />
      <ellipse cx="40" cy="28" rx="14" ry="20" fill="#0a9bab" />
      <ellipse cx="40" cy="24" rx="9" ry="13" fill="#1a0e2e" />
      <ellipse cx="40" cy="22" rx="5" ry="7" fill="#ef8c1a" />
      <circle cx="40" cy="22" r="2.5" fill="#1a0e2e" />
      {/* barbs */}
      {Array.from({ length: 8 }).map((_, i) => {
        const t = i / 7;
        const x = 40 + Math.sin(t * 6) * (28 - t * 16);
        return null;
      })}
    </svg>
  );
}

/* TORAN — door garland of leaves + marigolds */
function Toran({ width = 800 }) {
  const items = 18;
  return (
    <svg viewBox={`0 0 ${width} 80`} width="100%" height="80" preserveAspectRatio="none">
      <path d={`M 0,8 Q ${width/2},48 ${width},8`} stroke="#a7873b" strokeWidth="2" fill="none" />
      {Array.from({ length: items }).map((_, i) => {
        const t = i / (items - 1);
        const x = t * width;
        const y = 8 + 40 * Math.sin(t * Math.PI);
        const isFlower = i % 3 === 0;
        return (
          <g key={i} transform={`translate(${x},${y})`}>
            <line x1="0" y1="0" x2="0" y2={isFlower ? 14 : 22} stroke="#a7873b" strokeWidth="1" />
            {isFlower ? (
              <g transform={`translate(0,${20})`}>
                {Array.from({ length: 8 }).map((_, j) => {
                  const a = (j / 8) * Math.PI * 2;
                  return <circle key={j} cx={Math.cos(a)*5} cy={Math.sin(a)*5} r={3.5} fill="#ef8c1a" />;
                })}
                <circle cx={0} cy={0} r={3} fill="#d96e09" />
              </g>
            ) : (
              <path d={`M 0,${22} Q -6,${30} 0,${38} Q 6,${30} 0,${22} Z`} fill="#4a7c3a" />
            )}
          </g>
        );
      })}
    </svg>
  );
}

/* DOOR carved pattern (decorative for the welcome doors) */
function DoorPattern({ side = "left" }) {
  return (
    <svg viewBox="0 0 200 600" width="100%" height="100%" preserveAspectRatio="none">
      <defs>
        <pattern id={`dp-${side}`} x="0" y="0" width="80" height="100" patternUnits="userSpaceOnUse">
          <circle cx="40" cy="50" r="22" fill="none" stroke="#fff8ec" strokeWidth="1" opacity=".5" />
          <circle cx="40" cy="50" r="10" fill="none" stroke="#fff8ec" strokeWidth="1" opacity=".5" />
          <path d="M 40,28 Q 50,50 40,72 Q 30,50 40,28" fill="none" stroke="#fff8ec" strokeWidth="1" opacity=".5" />
        </pattern>
      </defs>
      <rect x="0" y="0" width="200" height="600" fill={`url(#dp-${side})`} />
      {/* arch */}
      <path d="M 20,40 Q 100,-20 180,40 L 180,560 L 20,560 Z" fill="none" stroke="#c9a961" strokeWidth="3" />
      <path d="M 30,50 Q 100,0 170,50 L 170,550 L 30,550 Z" fill="none" stroke="#c9a961" strokeWidth="1.5" opacity=".6" />
      {/* center medallion */}
      <g transform="translate(100,300)">
        {Array.from({ length: 12 }).map((_, i) => {
          const a = (i / 12) * Math.PI * 2;
          return <ellipse key={i} cx={Math.cos(a) * 36} cy={Math.sin(a) * 36} rx="10" ry="4" transform={`rotate(${(a*180/Math.PI)} ${Math.cos(a)*36} ${Math.sin(a)*36})`} fill="#c9a961" opacity=".6" />;
        })}
        <circle r="14" fill="#c9a961" />
        <circle r="6" fill="#1a0e2e" />
      </g>
    </svg>
  );
}

/* DIYA (oil lamp) */
function Diya({ size = 40 }) {
  return (
    <svg viewBox="0 0 60 60" width={size} height={size}>
      <ellipse cx="30" cy="44" rx="22" ry="8" fill="#7a3d05" />
      <path d="M 8,40 Q 30,52 52,40 L 50,46 Q 30,56 10,46 Z" fill="#5a2d05" />
      {/* flame */}
      <path d="M 30,18 C 24,28 24,38 30,40 C 36,38 36,28 30,18 Z" fill="#ef8c1a" />
      <path d="M 30,24 C 27,32 27,38 30,39 C 33,38 33,32 30,24 Z" fill="#fff3b0" />
    </svg>
  );
}

/* GANESH / OM placeholder icon for events */
function EventIcon({ name, color = "#c2185b" }) {
  const M = {
    haldi: (
      <g><circle cx="20" cy="20" r="14" fill="#ef8c1a" /><circle cx="20" cy="20" r="8" fill="#fff3b0" /></g>
    ),
    mehendi: (
      <g>
        <path d="M 20,8 C 30,8 32,20 28,28 C 24,32 16,32 12,28 C 8,20 10,8 20,8 Z" fill={color} />
        <circle cx="20" cy="20" r="3" fill="#fff" />
      </g>
    ),
    sangeet: (
      <g>
        <circle cx="14" cy="22" r="4" fill={color} />
        <circle cx="26" cy="22" r="4" fill={color} />
        <path d="M 14,22 L 14,8 L 26,6 L 26,22" stroke={color} strokeWidth="2" fill="none" />
      </g>
    ),
    wedding: (
      <g>
        <circle cx="14" cy="22" r="6" fill="none" stroke="#c9a961" strokeWidth="2" />
        <circle cx="26" cy="22" r="6" fill="none" stroke="#c9a961" strokeWidth="2" />
      </g>
    ),
    reception: (
      <g>
        <path d="M 10,28 L 20,8 L 30,28 Z" fill={color} />
        <circle cx="20" cy="14" r="2" fill="#c9a961" />
      </g>
    ),
    baraat: (
      <g>
        <rect x="12" y="14" width="16" height="12" rx="2" fill={color} />
        <circle cx="20" cy="10" r="4" fill="#ef8c1a" />
      </g>
    ),
  };
  return (
    <svg viewBox="0 0 40 40" width="36" height="36">
      {M[name] || M.wedding}
    </svg>
  );
}

/* TRAVEL ICONS */
function TravelIcon({ kind }) {
  const stroke = "#9d0d4a";
  if (kind === "plane")
    return <svg viewBox="0 0 24 24" width="20" height="20"><path d="M2 16l20-8-9 13-2-6-9-1z" fill="none" stroke={stroke} strokeWidth="1.6" strokeLinejoin="round"/></svg>;
  if (kind === "train")
    return <svg viewBox="0 0 24 24" width="20" height="20"><rect x="5" y="4" width="14" height="14" rx="2" fill="none" stroke={stroke} strokeWidth="1.6"/><circle cx="9" cy="20" r="1.5" fill={stroke}/><circle cx="15" cy="20" r="1.5" fill={stroke}/></svg>;
  if (kind === "car")
    return <svg viewBox="0 0 24 24" width="20" height="20"><path d="M4 14l2-6h12l2 6v4H4z" fill="none" stroke={stroke} strokeWidth="1.6"/><circle cx="8" cy="18" r="1.5" fill={stroke}/><circle cx="16" cy="18" r="1.5" fill={stroke}/></svg>;
  if (kind === "hotel")
    return <svg viewBox="0 0 24 24" width="20" height="20"><path d="M3 18V8h10v4h8v6" fill="none" stroke={stroke} strokeWidth="1.6"/><circle cx="7" cy="12" r="1.5" fill={stroke}/></svg>;
  return null;
}

/* CHARACTERS (used in maze) — hand-drawn paper-cutout style, matching the reference card */
/* "ME" — stick figure holding a sparkling heart */
function MeChar({ size = 60 }) {
  const ink = "#1a0e2e";
  return (
    <svg viewBox="0 0 70 80" width={size} height={size * 80 / 70}
         style={{ filter: "drop-shadow(0 1px 0 rgba(0,0,0,.06))" }}>
      {/* head — slightly wobbly circle (hand drawn feel) */}
      <path
        d="M 22,14 C 14,14 12,22 14,28 C 16,34 24,36 30,32 C 35,28 34,18 28,15 C 26,14 24,14 22,14 Z"
        fill="#fff8ec" stroke={ink} strokeWidth="1.4" strokeLinejoin="round"
      />
      {/* eyes */}
      <circle cx="20" cy="23" r="1.1" fill={ink} />
      <circle cx="27" cy="23" r="1.1" fill={ink} />
      {/* smile */}
      <path d="M 19,27 Q 23,30 28,27" stroke={ink} strokeWidth="1.2" fill="none" strokeLinecap="round" />
      {/* cheek hint */}
      <circle cx="17" cy="27" r="1" fill="#ef8c1a" opacity=".5" />
      <circle cx="30" cy="27" r="1" fill="#ef8c1a" opacity=".5" />
      {/* body — body outline with arms */}
      {/* left arm reaching down */}
      <path d="M 14,38 Q 8,46 10,56" stroke={ink} strokeWidth="1.4" fill="none" strokeLinecap="round" />
      {/* right arm reaching to heart */}
      <path d="M 30,38 Q 38,42 44,48" stroke={ink} strokeWidth="1.4" fill="none" strokeLinecap="round" />
      {/* torso */}
      <path d="M 16,36 Q 22,42 28,36 L 30,60 Q 22,64 14,60 Z"
            fill="#fff8ec" stroke={ink} strokeWidth="1.4" strokeLinejoin="round" />
      {/* sparkle rays around heart */}
      <g stroke="#1a0e2e" strokeWidth="1" strokeLinecap="round">
        <line x1="50" y1="44" x2="52" y2="40" />
        <line x1="56" y1="48" x2="60" y2="46" />
        <line x1="58" y1="54" x2="63" y2="54" />
        <line x1="56" y1="60" x2="60" y2="63" />
        <line x1="50" y1="62" x2="51" y2="66" />
        <line x1="44" y1="60" x2="40" y2="63" />
      </g>
      {/* heart */}
      <path
        d="M 50,48 C 44,44 44,52 50,57 C 56,52 56,44 50,48 Z"
        fill="#d7263d" stroke={ink} strokeWidth="1.2" strokeLinejoin="round"
        transform="translate(0,0)"
      />
      {/* tiny highlight on heart */}
      <path d="M 47,49 Q 46,51 47,53" stroke="#fff8ec" strokeWidth="1" fill="none" strokeLinecap="round" />
    </svg>
  );
}

/* "YOU" — stick figure wearing a striped party hat */
function YouChar({ size = 60 }) {
  const ink = "#1a0e2e";
  return (
    <svg viewBox="0 0 70 80" width={size} height={size * 80 / 70}
         style={{ filter: "drop-shadow(0 1px 0 rgba(0,0,0,.06))" }}>
      {/* party hat */}
      <g>
        <path d="M 30,18 L 40,2 L 50,18 Z" fill="#c2185b" stroke={ink} strokeWidth="1.3" strokeLinejoin="round" />
        {/* stripes */}
        <path d="M 33,13 L 47,13" stroke="#fbf3e1" strokeWidth="2" />
        <path d="M 35,9 L 45,9" stroke="#fbf3e1" strokeWidth="1.6" />
        <path d="M 37,5 L 43,5" stroke="#fbf3e1" strokeWidth="1.2" />
        {/* pompom */}
        <circle cx="40" cy="2" r="2.2" fill="#ef8c1a" stroke={ink} strokeWidth="1" />
      </g>
      {/* head — slightly wobbly */}
      <path
        d="M 33,20 C 26,20 23,28 25,34 C 27,40 35,42 41,38 C 47,34 46,22 40,19 C 38,18 35,19 33,20 Z"
        fill="#fff8ec" stroke={ink} strokeWidth="1.4" strokeLinejoin="round"
      />
      {/* eyes */}
      <circle cx="31" cy="28" r="1.1" fill={ink} />
      <circle cx="38" cy="28" r="1.1" fill={ink} />
      {/* tiny shy smile */}
      <path d="M 31,33 Q 34,35 38,33" stroke={ink} strokeWidth="1.2" fill="none" strokeLinecap="round" />
      <circle cx="28" cy="32" r="1" fill="#ef8c1a" opacity=".5" />
      <circle cx="41" cy="32" r="1" fill="#ef8c1a" opacity=".5" />
      {/* arms — one down at side, one slightly out */}
      <path d="M 26,46 Q 18,52 18,62" stroke={ink} strokeWidth="1.4" fill="none" strokeLinecap="round" />
      <path d="M 44,46 Q 52,50 54,60" stroke={ink} strokeWidth="1.4" fill="none" strokeLinecap="round" />
      {/* torso */}
      <path d="M 27,44 Q 35,50 43,44 L 45,66 Q 35,70 25,66 Z"
            fill="#fff8ec" stroke={ink} strokeWidth="1.4" strokeLinejoin="round" />
    </svg>
  );
}

/* MAP SVG — stylized city map background */
function MapArt() {
  return (
    <svg viewBox="0 0 600 460" width="100%" height="100%" preserveAspectRatio="xMidYMid slice" style={{ display: "block" }}>
      <defs>
        <pattern id="mapGrid" x="0" y="0" width="40" height="40" patternUnits="userSpaceOnUse">
          <path d="M 40 0 L 0 0 0 40" fill="none" stroke="#c9a961" strokeWidth=".5" opacity=".25"/>
        </pattern>
      </defs>
      <rect width="600" height="460" fill="#fbf3e1"/>
      <rect width="600" height="460" fill="url(#mapGrid)"/>
      {/* river */}
      <path d="M -20,360 Q 150,310 300,340 Q 450,370 620,330" stroke="#06727d" strokeWidth="22" fill="none" opacity=".25"/>
      <path d="M -20,360 Q 150,310 300,340 Q 450,370 620,330" stroke="#06727d" strokeWidth="2" fill="none" opacity=".5"/>
      {/* main roads */}
      <path d="M 0,140 L 600,180" stroke="#a7873b" strokeWidth="6" opacity=".5"/>
      <path d="M 220,0 L 260,460" stroke="#a7873b" strokeWidth="6" opacity=".5"/>
      <path d="M 0,260 L 600,240" stroke="#a7873b" strokeWidth="4" opacity=".4"/>
      <path d="M 420,0 L 380,460" stroke="#a7873b" strokeWidth="4" opacity=".4"/>
      {/* park */}
      <rect x="50" y="60" width="120" height="80" rx="8" fill="#4a7c3a" opacity=".2"/>
      <text x="110" y="105" textAnchor="middle" fontFamily="JetBrains Mono" fontSize="9" fill="#4a7c3a">CITY PARK</text>
      {/* temple */}
      <g transform="translate(490,90)">
        <path d="M -16,30 L 0,0 L 16,30 Z" fill="#ef8c1a" opacity=".5"/>
        <rect x="-14" y="30" width="28" height="20" fill="#ef8c1a" opacity=".5"/>
        <text x="0" y="62" textAnchor="middle" fontFamily="JetBrains Mono" fontSize="8" fill="#9d0d4a">TEMPLE</text>
      </g>
      {/* station */}
      <g transform="translate(120,300)">
        <rect x="-22" y="-12" width="44" height="22" rx="4" fill="#1a0e2e" opacity=".2"/>
        <text x="0" y="24" textAnchor="middle" fontFamily="JetBrains Mono" fontSize="8" fill="#1a0e2e">RAILWAY STN</text>
      </g>
      {/* airport */}
      <g transform="translate(520,400)">
        <path d="M -16,4 L 16,-4 L 12,8 L 0,4 Z" fill="#06727d" opacity=".5"/>
        <text x="0" y="22" textAnchor="middle" fontFamily="JetBrains Mono" fontSize="8" fill="#06727d">AIRPORT</text>
      </g>
      {/* street labels */}
      <text x="40" y="180" fontFamily="JetBrains Mono" fontSize="8" fill="#9d0d4a" opacity=".7">MG ROAD</text>
      <text x="280" y="430" fontFamily="JetBrains Mono" fontSize="8" fill="#9d0d4a" opacity=".7" transform="rotate(-90 280 430)">CIVIL LINES</text>
    </svg>
  );
}

/* ===================================================================
   TRADITIONAL ART OF INDIA — folk motifs from different states
   Each is a flat hand-drawn SVG, single-color palette,
   meant to be tinted via props.
=================================================================== */

/* MADHUBANI (Bihar) — decorative fish with eye-petal patterns */
function MadhubaniFish({ size = 120, color = "#9d0d4a", accent = "#ef8c1a" }) {
  return (
    <svg viewBox="0 0 200 120" width={size} height={size * 0.6}>
      {/* body */}
      <path d="M 20,60 Q 60,10 130,30 Q 170,40 180,60 Q 170,80 130,90 Q 60,110 20,60 Z"
            fill="none" stroke={color} strokeWidth="2.5" strokeLinejoin="round" />
      {/* scales rows */}
      {[40, 60, 80].map((y, i) => (
        <g key={i}>
          {Array.from({ length: 8 }).map((_, j) => (
            <path key={j} d={`M ${40 + j * 14},${y} q 6,-6 12,0`} fill="none" stroke={color} strokeWidth="1.5" />
          ))}
        </g>
      ))}
      {/* eye */}
      <circle cx="140" cy="50" r="9" fill="none" stroke={color} strokeWidth="2" />
      <circle cx="140" cy="50" r="5" fill={color} />
      <circle cx="142" cy="48" r="1.5" fill="#fbf3e1" />
      {/* lashes */}
      {Array.from({ length: 6 }).map((_, i) => {
        const a = (i / 6) * Math.PI - Math.PI / 2;
        return <line key={i} x1={140 + Math.cos(a) * 10} y1={50 + Math.sin(a) * 10}
                     x2={140 + Math.cos(a) * 15} y2={50 + Math.sin(a) * 15}
                     stroke={color} strokeWidth="1.5" />;
      })}
      {/* tail decoration */}
      <path d="M 20,60 L 8,38 L 14,60 L 8,82 Z" fill="none" stroke={color} strokeWidth="2" />
      <line x1="14" y1="50" x2="14" y2="70" stroke={accent} strokeWidth="1.5" />
      {/* fins */}
      <path d="M 90,30 q 4,-12 12,-14 q -2,8 -6,18" fill="none" stroke={color} strokeWidth="2" />
      <path d="M 90,90 q 4,12 12,14 q -2,-8 -6,-18" fill="none" stroke={color} strokeWidth="2" />
      {/* accent dots */}
      <circle cx="60" cy="60" r="2.5" fill={accent} />
      <circle cx="100" cy="60" r="2.5" fill={accent} />
    </svg>
  );
}

/* WARLI (Maharashtra) — circle of dancing stick figures */
function WarliDance({ size = 140, color = "#6b3a0a" }) {
  const cx = 100, cy = 100;
  const N = 8;
  const r = 60;
  return (
    <svg viewBox="0 0 200 200" width={size} height={size}>
      {/* center drum */}
      <circle cx={cx} cy={cy} r="14" fill="none" stroke={color} strokeWidth="1.6" />
      <line x1={cx - 14} y1={cy} x2={cx + 14} y2={cy} stroke={color} strokeWidth="1.6" />
      <line x1={cx} y1={cy - 14} x2={cx} y2={cy + 14} stroke={color} strokeWidth="1.6" />
      {/* dancers */}
      {Array.from({ length: N }).map((_, i) => {
        const a = (i / N) * Math.PI * 2 - Math.PI / 2;
        const x = cx + Math.cos(a) * r;
        const y = cy + Math.sin(a) * r;
        const nextA = ((i + 1) / N) * Math.PI * 2 - Math.PI / 2;
        const nx = cx + Math.cos(nextA) * r;
        const ny = cy + Math.sin(nextA) * r;
        return (
          <g key={i}>
            {/* two triangles for body */}
            <path d={`M ${x},${y - 10} L ${x - 7},${y + 2} L ${x + 7},${y + 2} Z`} fill="none" stroke={color} strokeWidth="1.6" />
            <path d={`M ${x},${y + 6} L ${x - 7},${y + 2} L ${x + 7},${y + 2} Z`} fill="none" stroke={color} strokeWidth="1.6" />
            {/* head */}
            <circle cx={x} cy={y - 14} r="4" fill="none" stroke={color} strokeWidth="1.6" />
            {/* legs */}
            <line x1={x} y1={y + 6} x2={x - 5} y2={y + 18} stroke={color} strokeWidth="1.4" />
            <line x1={x} y1={y + 6} x2={x + 5} y2={y + 18} stroke={color} strokeWidth="1.4" />
            {/* arms joining next dancer */}
            <line x1={x} y1={y - 2} x2={nx} y2={ny - 2} stroke={color} strokeWidth="1.4" />
          </g>
        );
      })}
      {/* outer dots */}
      {Array.from({ length: 24 }).map((_, i) => {
        const a = (i / 24) * Math.PI * 2;
        return <circle key={i} cx={cx + Math.cos(a) * 92} cy={cy + Math.sin(a) * 92} r="1.4" fill={color} />;
      })}
    </svg>
  );
}

/* KALAMKARI (Andhra/Telangana) — flowing flowering vine */
function KalamkariVine({ size = 160, color = "#06727d", accent = "#9d0d4a" }) {
  return (
    <svg viewBox="0 0 200 160" width={size} height={size * 0.8}>
      <path d="M 10,150 C 40,100 80,130 100,80 C 120,30 160,60 190,20"
            fill="none" stroke={color} strokeWidth="2.4" strokeLinecap="round" />
      {/* leaves */}
      {[
        { x: 40, y: 118, r: 14, rot: -30 },
        { x: 100, y: 80, r: 18, rot: 20 },
        { x: 160, y: 42, r: 14, rot: 50 },
        { x: 70, y: 110, r: 10, rot: -60 },
        { x: 140, y: 60, r: 11, rot: 70 },
      ].map((l, i) => (
        <g key={i} transform={`translate(${l.x},${l.y}) rotate(${l.rot})`}>
          <path d={`M 0,0 Q ${l.r},${-l.r} ${l.r * 2},0 Q ${l.r},${l.r} 0,0`}
                fill={color} opacity=".75" />
          <line x1="0" y1="0" x2={l.r * 2} y2="0" stroke="#fbf3e1" strokeWidth="1" />
        </g>
      ))}
      {/* flowers */}
      {[{ x: 60, y: 130 }, { x: 130, y: 65 }, { x: 180, y: 25 }].map((f, i) => (
        <g key={`f${i}`} transform={`translate(${f.x},${f.y})`}>
          {Array.from({ length: 6 }).map((_, j) => {
            const a = (j / 6) * Math.PI * 2;
            return <ellipse key={j} cx={Math.cos(a) * 6} cy={Math.sin(a) * 6}
                            rx="5" ry="3"
                            transform={`rotate(${a * 180 / Math.PI} ${Math.cos(a) * 6} ${Math.sin(a) * 6})`}
                            fill={accent} opacity=".85" />;
          })}
          <circle r="3" fill={color} />
        </g>
      ))}
    </svg>
  );
}

/* GOND (Madhya Pradesh) — dotted decorative peacock */
function GondPeacock({ size = 140, color = "#4a7c3a", accent = "#ef8c1a" }) {
  return (
    <svg viewBox="0 0 200 200" width={size} height={size}>
      {/* body */}
      <ellipse cx="80" cy="120" rx="44" ry="32" fill={color} />
      {/* neck */}
      <path d="M 110,110 Q 130,70 120,40" stroke={color} strokeWidth="14" fill="none" strokeLinecap="round" />
      {/* head */}
      <circle cx="120" cy="38" r="14" fill={color} />
      {/* crown feathers */}
      {[-1, 0, 1].map((d, i) => (
        <line key={i} x1="120" y1="24" x2={120 + d * 6} y2="8" stroke={color} strokeWidth="2" />
      ))}
      {[-1, 0, 1].map((d, i) => (
        <circle key={`c${i}`} cx={120 + d * 6} cy="8" r="2" fill={accent} />
      ))}
      {/* beak */}
      <path d="M 132,38 L 144,40 L 132,42 Z" fill={accent} />
      {/* eye */}
      <circle cx="118" cy="36" r="2.5" fill="#fbf3e1" />
      <circle cx="118" cy="36" r="1.2" fill="#1a0e2e" />
      {/* feathers tail */}
      {Array.from({ length: 7 }).map((_, i) => {
        const a = (-Math.PI / 1.8) + (i / 6) * (Math.PI / 1.2);
        const tx = 80 + Math.cos(a) * 90;
        const ty = 120 + Math.sin(a) * 90;
        return (
          <g key={i}>
            <line x1="80" y1="120" x2={tx} y2={ty} stroke={color} strokeWidth="2" />
            <ellipse cx={tx} cy={ty} rx="14" ry="9"
                     transform={`rotate(${a * 180 / Math.PI} ${tx} ${ty})`}
                     fill={accent} opacity=".85" />
            <circle cx={tx + Math.cos(a) * 6} cy={ty + Math.sin(a) * 6} r="3" fill="#06727d" />
          </g>
        );
      })}
      {/* signature gond dots all over body */}
      {Array.from({ length: 26 }).map((_, i) => {
        const a = (i / 26) * Math.PI * 2;
        return <circle key={i} cx={80 + Math.cos(a) * (30 + (i % 3) * 6)} cy={120 + Math.sin(a) * (22 + (i % 3) * 4)} r="1.5" fill="#fbf3e1" />;
      })}
      {/* legs */}
      <line x1="70" y1="150" x2="66" y2="170" stroke={color} strokeWidth="2" />
      <line x1="90" y1="150" x2="94" y2="170" stroke={color} strokeWidth="2" />
    </svg>
  );
}

/* PHAD / RAJASTHANI — flat folk lotus medallion */
function PhadLotus({ size = 130, color = "#d7263d", accent = "#ef8c1a" }) {
  return (
    <svg viewBox="0 0 200 200" width={size} height={size}>
      {Array.from({ length: 8 }).map((_, i) => {
        const a = (i / 8) * Math.PI * 2;
        const x = 100 + Math.cos(a) * 50;
        const y = 100 + Math.sin(a) * 50;
        return (
          <g key={i} transform={`translate(${x},${y}) rotate(${a * 180 / Math.PI + 90})`}>
            <path d="M 0,-30 Q 16,-10 0,28 Q -16,-10 0,-30 Z" fill={color} stroke="#1a0e2e" strokeWidth="1.4" strokeLinejoin="round" />
            <path d="M 0,-20 Q 8,-4 0,18 Q -8,-4 0,-20 Z" fill={accent} />
          </g>
        );
      })}
      <circle cx="100" cy="100" r="20" fill={accent} stroke="#1a0e2e" strokeWidth="1.5" />
      <circle cx="100" cy="100" r="10" fill={color} />
      <circle cx="100" cy="100" r="4" fill="#fbf3e1" />
    </svg>
  );
}

/* PATTACHITRA (Odisha) — tree-of-life decorative branch */
function PattachitraTree({ size = 140, color = "#9d0d4a", accent = "#ef8c1a", leaf = "#4a7c3a" }) {
  return (
    <svg viewBox="0 0 160 200" width={size * 0.8} height={size}>
      {/* trunk */}
      <path d="M 80,196 Q 76,150 80,110 Q 84,80 80,40" stroke={color} strokeWidth="4" fill="none" strokeLinecap="round" />
      {/* branches */}
      <path d="M 80,140 Q 50,130 28,110" stroke={color} strokeWidth="2.6" fill="none" />
      <path d="M 80,120 Q 110,112 130,90" stroke={color} strokeWidth="2.6" fill="none" />
      <path d="M 80,90 Q 56,80 38,60" stroke={color} strokeWidth="2.6" fill="none" />
      <path d="M 80,70 Q 108,62 126,42" stroke={color} strokeWidth="2.6" fill="none" />
      {/* leaves and blossoms */}
      {[
        { x: 28, y: 110, c: leaf },
        { x: 130, y: 90, c: leaf },
        { x: 38, y: 60, c: accent },
        { x: 126, y: 42, c: accent },
        { x: 80, y: 26, c: color },
      ].map((p, i) => (
        <g key={i} transform={`translate(${p.x},${p.y})`}>
          <circle r="10" fill={p.c} stroke="#1a0e2e" strokeWidth="1.2" />
          <circle r="4" fill="#fbf3e1" />
        </g>
      ))}
      {/* small leaves */}
      {[[60, 100], [104, 78], [58, 70], [106, 56]].map(([x, y], i) => (
        <ellipse key={`l${i}`} cx={x} cy={y} rx="6" ry="3"
                 transform={`rotate(${i % 2 ? 30 : -30} ${x} ${y})`}
                 fill={leaf} opacity=".85" />
      ))}
      {/* roots / base */}
      <path d="M 60,196 Q 80,184 100,196" fill="none" stroke={color} strokeWidth="2" />
    </svg>
  );
}

/* KERALA mural — elephant silhouette with bells (very stylized) */
function KeralaElephant({ size = 150, color = "#06727d", accent = "#ef8c1a" }) {
  return (
    <svg viewBox="0 0 220 140" width={size} height={size * 0.64}>
      {/* body */}
      <ellipse cx="110" cy="80" rx="70" ry="40" fill={color} />
      {/* head */}
      <ellipse cx="180" cy="70" rx="34" ry="32" fill={color} />
      {/* ear */}
      <path d="M 158,52 Q 130,38 132,80 Q 148,74 162,72 Z" fill={color} />
      {/* trunk */}
      <path d="M 198,86 Q 214,108 200,128 Q 188,124 194,110 Q 188,100 196,90"
            stroke={color} strokeWidth="14" fill="none" strokeLinecap="round" />
      {/* tusk */}
      <path d="M 200,92 Q 206,104 200,110" stroke="#fbf3e1" strokeWidth="3" fill="none" strokeLinecap="round" />
      {/* eye */}
      <circle cx="186" cy="60" r="3" fill="#fbf3e1" />
      <circle cx="186" cy="60" r="1.4" fill="#1a0e2e" />
      {/* legs */}
      {[60, 100, 130, 170].map((x, i) => (
        <rect key={i} x={x - 7} y="116" width="14" height="20" fill={color} />
      ))}
      {/* caparison band on back */}
      <path d="M 60,56 Q 110,40 168,52 L 168,66 Q 110,52 60,68 Z" fill={accent} />
      {/* bells */}
      {[55, 80, 105, 130, 155].map((x, i) => (
        <g key={i}>
          <line x1={x} y1="74" x2={x} y2="86" stroke="#1a0e2e" strokeWidth="1" />
          <circle cx={x} cy="90" r="3.5" fill="#c9a961" />
        </g>
      ))}
    </svg>
  );
}

/* Pick a state-art component by key (used in event cards + section gallery) */
function StateArt({ kind, size, color, accent }) {
  const map = {
    madhubani: <MadhubaniFish size={size} color={color} accent={accent} />,
    warli:     <WarliDance size={size} color={color} />,
    kalamkari: <KalamkariVine size={size} color={color} accent={accent} />,
    gond:      <GondPeacock size={size} color={color} accent={accent} />,
    phad:      <PhadLotus size={size} color={color} accent={accent} />,
    pattachitra: <PattachitraTree size={size} color={color} accent={accent} />,
    kerala:    <KeralaElephant size={size} color={color} accent={accent} />,
  };
  return map[kind] || null;
}

Object.assign(window, {
  Mandala, Marigold, Paisley, PeacockFeather, Toran, DoorPattern,
  Diya, EventIcon, TravelIcon, MeChar, YouChar, MapArt,
  MadhubaniFish, WarliDance, KalamkariVine, GondPeacock, PhadLotus,
  PattachitraTree, KeralaElephant, StateArt
});
