// SVG illustrations for landing page

// Stadium scene - hero backdrop (1600x700)
const StadiumScene = () => (
  <svg viewBox="0 0 1600 700" preserveAspectRatio="xMidYMid slice" className="illus-stadium" aria-hidden>
    <defs>
      <linearGradient id="sky" x1="0" x2="0" y1="0" y2="1">
        <stop offset="0" stopColor="#ffd89a"/>
        <stop offset="0.5" stopColor="#f5b96b"/>
        <stop offset="1" stopColor="#d97a4a"/>
      </linearGradient>
      <linearGradient id="pitch" x1="0" x2="0" y1="0" y2="1">
        <stop offset="0" stopColor="#4fa85c"/>
        <stop offset="1" stopColor="#2f7a3f"/>
      </linearGradient>
      <linearGradient id="stand" x1="0" x2="0" y1="0" y2="1">
        <stop offset="0" stopColor="#1d2f22"/>
        <stop offset="1" stopColor="#0e1a13"/>
      </linearGradient>
      <radialGradient id="lamp" cx="0.5" cy="0" r="1">
        <stop offset="0" stopColor="#fffcdc" stopOpacity="0.8"/>
        <stop offset="0.4" stopColor="#fff3a8" stopOpacity="0.2"/>
        <stop offset="1" stopColor="#fff3a8" stopOpacity="0"/>
      </radialGradient>
    </defs>

    {/* Sky gradient */}
    <rect width="1600" height="340" fill="url(#sky)"/>

    {/* Distant hills / fade */}
    <path d="M0,320 Q400,280 800,310 T1600,300 L1600,340 L0,340 Z" fill="#b8593a" opacity="0.3"/>

    {/* Floodlight beams */}
    <path d="M150,0 L50,340 L300,340 L250,0 Z" fill="url(#lamp)" opacity="0.6"/>
    <path d="M1450,0 L1350,340 L1600,340 L1550,0 Z" fill="url(#lamp)" opacity="0.6"/>

    {/* Floodlight towers */}
    <rect x="180" y="20" width="6" height="320" fill="#2a3a2f"/>
    <rect x="155" y="10" width="56" height="16" rx="3" fill="#3a4a3f"/>
    <circle cx="165" cy="18" r="3" fill="#fffcdc"/>
    <circle cx="183" cy="18" r="3" fill="#fffcdc"/>
    <circle cx="201" cy="18" r="3" fill="#fffcdc"/>
    <rect x="1414" y="20" width="6" height="320" fill="#2a3a2f"/>
    <rect x="1389" y="10" width="56" height="16" rx="3" fill="#3a4a3f"/>
    <circle cx="1399" cy="18" r="3" fill="#fffcdc"/>
    <circle cx="1417" cy="18" r="3" fill="#fffcdc"/>
    <circle cx="1435" cy="18" r="3" fill="#fffcdc"/>

    {/* Stands - back */}
    <path d="M0,280 L280,220 L1320,220 L1600,280 L1600,340 L0,340 Z" fill="url(#stand)"/>

    {/* Crowd pixels (tiny rects as fans) */}
    <g opacity="0.7">
      {Array.from({length: 120}).map((_,i) => (
        <rect key={i}
          x={120 + (i * 11)}
          y={245 + (i % 3) * 8}
          width="6" height="6"
          fill={["#e0b878","#4a7cc8","#c85050","#f0c040","#9a4b8c","#5ba868"][i % 6]}
        />
      ))}
    </g>

    {/* Stand trim line */}
    <rect x="0" y="335" width="1600" height="5" fill="#c79a2a"/>

    {/* Pitch */}
    <path d="M0,340 L1600,340 L1600,700 L0,700 Z" fill="url(#pitch)"/>

    {/* Pitch stripes */}
    <g opacity="0.15">
      {[0,1,2,3,4,5,6,7].map(i => (
        <rect key={i} x="0" y={340 + i * 50} width="1600" height="25" fill={i % 2 ? "#ffffff" : "transparent"}/>
      ))}
    </g>

    {/* Pitch lines - perspective */}
    <g fill="none" stroke="#f2faf0" strokeWidth="3" opacity="0.8">
      {/* Halfway line */}
      <line x1="800" y1="340" x2="800" y2="700"/>
      {/* Center circle */}
      <ellipse cx="800" cy="520" rx="120" ry="50"/>
      <circle cx="800" cy="520" r="4" fill="#f2faf0"/>
      {/* Goal boxes */}
      <path d="M0,440 L300,440 L300,600 L0,600"/>
      <path d="M1600,440 L1300,440 L1300,600 L1600,600"/>
      {/* 6-yard boxes */}
      <path d="M0,490 L120,490 L120,550 L0,550"/>
      <path d="M1600,490 L1480,490 L1480,550 L1600,550"/>
    </g>

    {/* Player silhouettes running */}
    <g>
      {/* Team A - red */}
      <g transform="translate(600, 500)">
        <ellipse cx="0" cy="36" rx="14" ry="3" fill="#000" opacity="0.3"/>
        <rect x="-7" y="8" width="14" height="20" rx="3" fill="#d8423a"/>
        <rect x="-7" y="27" width="5" height="10" fill="#f0e0c0"/>
        <rect x="2" y="27" width="5" height="10" fill="#f0e0c0"/>
        <circle cx="0" cy="2" r="6" fill="#e8c29a"/>
      </g>
      <g transform="translate(720, 540)">
        <ellipse cx="0" cy="36" rx="14" ry="3" fill="#000" opacity="0.3"/>
        <rect x="-7" y="8" width="14" height="20" rx="3" fill="#d8423a"/>
        <rect x="-7" y="27" width="5" height="10" fill="#f0e0c0"/>
        <rect x="2" y="27" width="5" height="10" fill="#f0e0c0"/>
        <circle cx="0" cy="2" r="6" fill="#e8c29a"/>
      </g>

      {/* Ball */}
      <g transform="translate(790, 548)">
        <ellipse cx="0" cy="6" rx="8" ry="2" fill="#000" opacity="0.3"/>
        <circle cx="0" cy="0" r="7" fill="#fff" stroke="#111" strokeWidth="1"/>
        <path d="M-3,-3 L0,-6 L3,-3 L2,1 L-2,1 Z" fill="#111"/>
      </g>

      {/* Team B - blue */}
      <g transform="translate(860, 510)">
        <ellipse cx="0" cy="36" rx="14" ry="3" fill="#000" opacity="0.3"/>
        <rect x="-7" y="8" width="14" height="20" rx="3" fill="#2f5fb5"/>
        <rect x="-7" y="27" width="5" height="10" fill="#fff"/>
        <rect x="2" y="27" width="5" height="10" fill="#fff"/>
        <circle cx="0" cy="2" r="6" fill="#e8c29a"/>
      </g>
      <g transform="translate(940, 560)">
        <ellipse cx="0" cy="36" rx="14" ry="3" fill="#000" opacity="0.3"/>
        <rect x="-7" y="8" width="14" height="20" rx="3" fill="#2f5fb5"/>
        <rect x="-7" y="27" width="5" height="10" fill="#fff"/>
        <rect x="2" y="27" width="5" height="10" fill="#fff"/>
        <circle cx="0" cy="2" r="6" fill="#e8c29a"/>
      </g>

      {/* GK */}
      <g transform="translate(80, 500)">
        <ellipse cx="0" cy="36" rx="14" ry="3" fill="#000" opacity="0.3"/>
        <rect x="-7" y="8" width="14" height="20" rx="3" fill="#f4c040"/>
        <rect x="-7" y="27" width="5" height="10" fill="#111"/>
        <rect x="2" y="27" width="5" height="10" fill="#111"/>
        <circle cx="0" cy="2" r="6" fill="#e8c29a"/>
      </g>
    </g>
  </svg>
);

// Team crest - parametric SVG. Pass `size` (in px) to override the default
// 80×90 CSS sizing when embedding in a smaller slot (e.g. the claim preview).
const Crest = ({ primary = "#2a6a3a", secondary = "#f4c040", initials = "FC", size }) => (
  <svg viewBox="0 0 64 72" className="crest" aria-hidden
       style={size ? { width: size, height: Math.round(size * (72 / 64)) } : undefined}>
    <defs>
      <linearGradient id={`cr-${primary}`} x1="0" y1="0" x2="0" y2="1">
        <stop offset="0" stopColor={primary}/>
        <stop offset="1" stopColor="#000" stopOpacity="0.4"/>
      </linearGradient>
    </defs>
    <path d="M32,2 L58,10 L58,38 C58,52 45,66 32,70 C19,66 6,52 6,38 L6,10 Z"
          fill={primary} stroke="#1a1a1a" strokeWidth="2"/>
    <path d="M32,2 L58,10 L58,38 C58,52 45,66 32,70 C19,66 6,52 6,38 L6,10 Z"
          fill={`url(#cr-${primary})`}/>
    <path d="M6,28 L58,28" stroke={secondary} strokeWidth="4"/>
    <path d="M6,34 L58,34" stroke="#1a1a1a" strokeWidth="1" opacity="0.4"/>
    <text x="32" y="24" fontFamily="Archivo, sans-serif" fontWeight="900" fontSize="14" fill="#fff" textAnchor="middle">★</text>
    <text x="32" y="52" fontFamily="Archivo, sans-serif" fontWeight="900" fontSize="18" fill="#fff" textAnchor="middle" letterSpacing="1">{initials}</text>
  </svg>
);

// Trophy SVG
const TrophyIllus = ({ tone = "gold" }) => {
  const col = tone === "gold" ? "#f5c344" : tone === "silver" ? "#d8dde2" : "#d49064";
  const dark = tone === "gold" ? "#a07a1a" : tone === "silver" ? "#8a9099" : "#8a4a24";
  return (
    <svg viewBox="0 0 80 100" className="trophy-illus" aria-hidden>
      <defs>
        <linearGradient id={`tg-${tone}`} x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stopColor={col}/>
          <stop offset="1" stopColor={dark}/>
        </linearGradient>
      </defs>
      {/* Handles */}
      <path d="M14,26 Q4,26 4,40 Q4,54 18,54" fill="none" stroke={`url(#tg-${tone})`} strokeWidth="5" strokeLinecap="round"/>
      <path d="M66,26 Q76,26 76,40 Q76,54 62,54" fill="none" stroke={`url(#tg-${tone})`} strokeWidth="5" strokeLinecap="round"/>
      {/* Cup */}
      <path d="M14,18 L66,18 L60,54 Q60,64 40,64 Q20,64 20,54 Z" fill={`url(#tg-${tone})`} stroke={dark} strokeWidth="1.5"/>
      <ellipse cx="40" cy="18" rx="26" ry="4" fill={col} stroke={dark} strokeWidth="1.5"/>
      {/* Stem */}
      <rect x="34" y="64" width="12" height="10" fill={`url(#tg-${tone})`}/>
      {/* Base */}
      <path d="M22,74 L58,74 L62,84 L18,84 Z" fill={`url(#tg-${tone})`} stroke={dark} strokeWidth="1.5"/>
      {/* Star */}
      <path d="M40,36 L43,42 L49,43 L45,48 L46,54 L40,51 L34,54 L35,48 L31,43 L37,42 Z" fill="#fff" opacity="0.9"/>
    </svg>
  );
};

// Player illustration for tactics board
const PlayerIllus = ({ num, isGk }) => {
  const jersey = isGk ? "#f4c040" : "#ffffff";
  const shorts = isGk ? "#111" : "#1a4a24";
  const stroke = "#1a1a1a";
  return (
    <svg viewBox="0 0 40 48" className="player-illus" aria-hidden>
      <ellipse cx="20" cy="44" rx="12" ry="2" fill="#000" opacity="0.35"/>
      <circle cx="20" cy="10" r="6" fill="#e8c29a" stroke={stroke} strokeWidth="1"/>
      <path d="M11,16 L29,16 L31,32 L26,33 L26,42 L14,42 L14,33 L9,32 Z" fill={jersey} stroke={stroke} strokeWidth="1"/>
      <rect x="14" y="32" width="12" height="7" fill={shorts}/>
      <text x="20" y="28" fontFamily="Archivo, sans-serif" fontWeight="900" fontSize="9" fill={isGk ? "#111" : "#1a4a24"} textAnchor="middle">{num}</text>
    </svg>
  );
};

Object.assign(window, { StadiumScene, Crest, TrophyIllus, PlayerIllus });
