/**
 * vault-rank-avatars.jsx
 *
 * Static-SVG ports of the rank icons from `frontend/components/RankIcon.tsx`.
 * The app version is heavily animated via react-native-reanimated; these are
 * the equivalent designs at rest, suitable for the marketing site's vanilla
 * React stack.
 *
 * Exposed as `window.GA` so `avatar.jsx`'s glyph delegate finds them.
 *
 *   <GA glyph="phone"   hi=… mid=… />   →  Addicted (cracked phone + red dot)
 *   <GA glyph="feed"    hi=… mid=… />   →  Scroller (stacked cards + arrows)
 *   <GA glyph="compass" hi=… mid=… />   →  Seeker   (faceted octagonal compass)
 *   <GA glyph="eye"     hi=… mid=… />   →  Lucid    (open eye + iris)
 *   <GA glyph="crystal" hi=… mid=… />   →  Clairvoyant (octahedron + orbit rings)
 */

function GA({ glyph }) {
  switch (glyph) {
    case 'phone':   return <AddictedSVG/>;
    case 'feed':    return <ScrollerSVG/>;
    case 'compass': return <SeekerSVG/>;
    case 'eye':     return <LucidSVG/>;
    case 'crystal': return <ClairvoyantSVG/>;
    default:        return <AddictedSVG/>;
  }
}

// ── Addicted ─────────────────────────────────────────────────────────────
function AddictedSVG() {
  return (
    <svg width="100%" height="100%" viewBox="0 0 48 48" preserveAspectRatio="xMidYMid meet">
      <defs>
        <linearGradient id="addictedBody" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#FCA5A5"/>
          <stop offset="1" stopColor="#7F1D1D"/>
        </linearGradient>
        <linearGradient id="addictedBodyFill" x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stopColor="#2A0E12" stopOpacity="0.9"/>
          <stop offset="1" stopColor="#120407" stopOpacity="0.95"/>
        </linearGradient>
        <linearGradient id="addictedCrack" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#FEE2E2"/>
          <stop offset="1" stopColor="#EF4444"/>
        </linearGradient>
        <radialGradient id="addictedDot" cx="0.5" cy="0.5" r="0.5">
          <stop offset="0" stopColor="#FFD6C0"/>
          <stop offset="0.4" stopColor="#F87171"/>
          <stop offset="1" stopColor="#B91C1C"/>
        </radialGradient>
      </defs>
      <rect x="15" y="7" width="18" height="34" rx="3" ry="3" fill="url(#addictedBodyFill)" stroke="url(#addictedBody)" strokeWidth="1.8"/>
      <line x1="21" y1="11" x2="27" y2="11" stroke="#FCA5A5" strokeWidth="1.2" strokeLinecap="round" opacity="0.6"/>
      <line x1="20" y1="37" x2="28" y2="37" stroke="#FCA5A5" strokeWidth="1.4" strokeLinecap="round" opacity="0.5"/>
      <path d="M17 15 L22 20 L19 23 L24 30 L21 34" fill="none" stroke="url(#addictedCrack)" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round"/>
      <path d="M22 20 L27 18 L25 24 L31 26" fill="none" stroke="url(#addictedCrack)" strokeWidth="1" strokeLinecap="round" strokeLinejoin="round" opacity="0.85"/>
      <path d="M24 30 L29 32 L28 36" fill="none" stroke="url(#addictedCrack)" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" opacity="0.7"/>
      <circle cx="33" cy="10" r="6" fill="url(#addictedDot)" opacity="0.45"/>
      <circle cx="33" cy="10" r="3" fill="url(#addictedDot)"/>
    </svg>
  );
}

// ── Scroller ─────────────────────────────────────────────────────────────
function ScrollerSVG() {
  return (
    <svg width="100%" height="100%" viewBox="0 0 48 48" preserveAspectRatio="xMidYMid meet">
      <defs>
        <linearGradient id="scrollerCard" x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stopColor="#FCD34D"/>
          <stop offset="1" stopColor="#F59E0B"/>
        </linearGradient>
        <linearGradient id="scrollerFill" x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stopColor="#3F2E08" stopOpacity="0.9"/>
          <stop offset="1" stopColor="#1F1604" stopOpacity="0.95"/>
        </linearGradient>
        <radialGradient id="scrollerPulse" cx="0.5" cy="0.5" r="0.5">
          <stop offset="0" stopColor="#FEF3C7"/>
          <stop offset="1" stopColor="#F59E0B"/>
        </radialGradient>
      </defs>
      {/* Three receding feed cards */}
      <rect x="14" y="13" width="20" height="5" rx="1.5" fill="url(#scrollerFill)" stroke="url(#scrollerCard)" strokeWidth="1.1" opacity="0.6"/>
      <rect x="12" y="20" width="24" height="6" rx="1.8" fill="url(#scrollerFill)" stroke="url(#scrollerCard)" strokeWidth="1.3" opacity="0.85"/>
      <rect x="10" y="28" width="28" height="7" rx="2" fill="url(#scrollerFill)" stroke="url(#scrollerCard)" strokeWidth="1.6"/>
      {/* Up + down arrows */}
      <path d="M20 7 L24 3 L28 7" fill="none" stroke="url(#scrollerCard)" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"/>
      <path d="M20 41 L24 45 L28 41" fill="none" stroke="url(#scrollerCard)" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"/>
      {/* Pulse */}
      <circle cx="40" cy="24" r="2.4" fill="url(#scrollerPulse)"/>
    </svg>
  );
}

// ── Seeker ───────────────────────────────────────────────────────────────
function SeekerSVG() {
  // 8-vertex octagonal ring on radius 20, offset by -22.5° so flats top/right.
  const facetPoints = Array.from({ length: 8 }, (_, i) => {
    const a = (i * 45 - 22.5) * Math.PI / 180;
    return `${24 + Math.cos(a) * 20},${24 + Math.sin(a) * 20}`;
  }).join(' ');
  const spokes = Array.from({ length: 8 }, (_, i) => {
    const a = (i * 45 - 22.5) * Math.PI / 180;
    const x = 24 + Math.cos(a) * 20;
    const y = 24 + Math.sin(a) * 20;
    return <line key={i} x1="24" y1="24" x2={x} y2={y} stroke="#FCD34D" strokeWidth="0.5" opacity="0.18"/>;
  });
  return (
    <svg width="100%" height="100%" viewBox="0 0 48 48" preserveAspectRatio="xMidYMid meet">
      <defs>
        <linearGradient id="seekerRing" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#FCD34D"/>
          <stop offset="1" stopColor="#92400E"/>
        </linearGradient>
        <radialGradient id="seekerFacet" cx="0.45" cy="0.35" r="0.7">
          <stop offset="0" stopColor="#3A2108" stopOpacity="0.9"/>
          <stop offset="1" stopColor="#1A0E03" stopOpacity="0.95"/>
        </radialGradient>
        <linearGradient id="seekerNorth" x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stopColor="#FEF3C7"/>
          <stop offset="1" stopColor="#F59E0B"/>
        </linearGradient>
      </defs>
      <polygon points={facetPoints} fill="url(#seekerFacet)" stroke="url(#seekerRing)" strokeWidth="1.8" strokeLinejoin="round"/>
      {spokes}
      <line x1="24" y1="6" x2="24" y2="10" stroke="#F5C86E" strokeWidth="1.8" strokeLinecap="round"/>
      <line x1="24" y1="38" x2="24" y2="42" stroke="#F5C86E" strokeWidth="1.2" strokeLinecap="round" opacity="0.5"/>
      <line x1="6" y1="24" x2="10" y2="24" stroke="#F5C86E" strokeWidth="1.2" strokeLinecap="round" opacity="0.5"/>
      <line x1="38" y1="24" x2="42" y2="24" stroke="#F5C86E" strokeWidth="1.2" strokeLinecap="round" opacity="0.5"/>
      {/* Needle pointing slightly NE for visual interest */}
      <g transform="rotate(20 24 24)">
        <path d="M24 9 L27.2 24 L24 24 Z" fill="url(#seekerNorth)"/>
        <path d="M24 39 L20.8 24 L24 24 Z" fill="#92400E" opacity="0.75"/>
      </g>
      <circle cx="24" cy="24" r="2" fill="#92400E"/>
      <circle cx="23.3" cy="23.3" r="0.6" fill="rgba(255,255,255,0.9)"/>
    </svg>
  );
}

// ── Lucid ────────────────────────────────────────────────────────────────
function LucidSVG() {
  return (
    <svg width="100%" height="100%" viewBox="0 0 48 48" preserveAspectRatio="xMidYMid meet">
      <defs>
        <linearGradient id="lucidAlmond" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#A7F3D0"/>
          <stop offset="1" stopColor="#0E7490"/>
        </linearGradient>
        <radialGradient id="lucidAlmondFill" cx="0.5" cy="0.5" r="0.6">
          <stop offset="0" stopColor="#E0F7FA"/>
          <stop offset="1" stopColor="#B5EAD6"/>
        </radialGradient>
        <radialGradient id="lucidIris" cx="0.45" cy="0.4" r="0.6">
          <stop offset="0" stopColor="#99F6E4"/>
          <stop offset="0.5" stopColor="#14B8A6"/>
          <stop offset="1" stopColor="#064E3B"/>
        </radialGradient>
      </defs>
      <path d="M4 24 Q24 9 44 24 Q24 39 4 24 Z" fill="url(#lucidAlmondFill)" stroke="url(#lucidAlmond)" strokeWidth="1.8" strokeLinejoin="round"/>
      <circle cx="24" cy="24" r="7.5" fill="url(#lucidIris)" stroke="#0E7490" strokeWidth="1.1"/>
      <circle cx="24" cy="24" r="3.2" fill="#042F2E"/>
      <circle cx="26" cy="21.5" r="1.3" fill="rgba(255,255,255,0.9)"/>
      <circle cx="22.5" cy="22.5" r="0.5" fill="rgba(255,255,255,0.7)"/>
      <path d="M7 22 Q24 11 41 22" fill="none" stroke="#0E7490" strokeWidth="0.7" opacity="0.35" strokeLinecap="round"/>
    </svg>
  );
}

// ── Clairvoyant ──────────────────────────────────────────────────────────
function ClairvoyantSVG() {
  return (
    <svg width="100%" height="100%" viewBox="0 0 48 48" preserveAspectRatio="xMidYMid meet">
      <defs>
        <radialGradient id="claivDepth" cx="0.5" cy="0.5" r="0.55">
          <stop offset="0" stopColor="#3B1F6B" stopOpacity="0.55"/>
          <stop offset="0.75" stopColor="#1A0B34" stopOpacity="0.3"/>
          <stop offset="1" stopColor="#1A0B34" stopOpacity="0"/>
        </radialGradient>
        <linearGradient id="claivGemLight" x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stopColor="#F5F3FF"/>
          <stop offset="0.5" stopColor="#C4B5FD"/>
          <stop offset="1" stopColor="#8B5CF6"/>
        </linearGradient>
        <linearGradient id="claivGemDark" x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stopColor="#7C3AED"/>
          <stop offset="1" stopColor="#2E1065"/>
        </linearGradient>
        <linearGradient id="claivRing" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#EDE9FE" stopOpacity="0.95"/>
          <stop offset="0.5" stopColor="#A78BFA" stopOpacity="0.8"/>
          <stop offset="1" stopColor="#7C3AED" stopOpacity="0.4"/>
        </linearGradient>
        <radialGradient id="claivGlow" cx="0.5" cy="0.5" r="0.5">
          <stop offset="0" stopColor="#EDE9FE" stopOpacity="0.9"/>
          <stop offset="0.55" stopColor="#8B5CF6" stopOpacity="0.35"/>
          <stop offset="1" stopColor="#7C3AED" stopOpacity="0"/>
        </radialGradient>
      </defs>
      <circle cx="24" cy="24" r="22" fill="url(#claivDepth)"/>
      <circle cx="24" cy="24" r="10" fill="url(#claivGlow)" opacity="0.75"/>
      {/* Two tilted ellipse rings, counter-tilted */}
      <g transform="rotate(25 24 24)">
        <ellipse cx="24" cy="24" rx="20" ry="7" fill="none" stroke="url(#claivRing)" strokeWidth="1.2"/>
        <circle cx="44" cy="24" r="1.3" fill="#EDE9FE"/>
      </g>
      <g transform="rotate(-25 24 24)">
        <ellipse cx="24" cy="24" rx="20" ry="7" fill="none" stroke="url(#claivRing)" strokeWidth="1.2" opacity="0.85"/>
        <circle cx="4" cy="24" r="1.1" fill="#C4B5FD"/>
      </g>
      {/* Octahedron gem (4 facets) */}
      <polygon points="24,8 14,24 24,24" fill="url(#claivGemLight)"/>
      <polygon points="24,8 34,24 24,24" fill="url(#claivGemDark)"/>
      <polygon points="14,24 24,40 24,24" fill="url(#claivGemDark)" opacity="0.85"/>
      <polygon points="34,24 24,40 24,24" fill="url(#claivGemLight)" opacity="0.7"/>
    </svg>
  );
}

window.GA = GA;
