/* CollabIQ — Logo Marks
   Six explorations of "the intersection is the product".
   Each <CIQMark> is parameterized so it can be rasterized
   at any size; favicon-first sizing means the nucleus dot
   and white ring stay legible at 16px. */

const { useEffect, useRef, useState } = React;

/* ─── 01. CLASSIC — the spec mark ─────────────────────
   Three lobes, white-ringed nucleus, teal core dot.
   This is the reference. Everything else is a remix. */
function MarkClassic({ size = 96, glow = true }) {
  return (
    <svg width={size} height={size} viewBox="0 0 52 52" style={{
      filter: glow ? 'drop-shadow(0 0 8px rgba(45,212,191,0.45)) drop-shadow(0 0 22px rgba(45,212,191,0.16))' : 'none'
    }}>
      <defs>
        <radialGradient id="lobeA" cx="0.35" cy="0.35" r="0.85">
          <stop offset="0%" stopColor="rgba(94,224,210,0.85)" />
          <stop offset="100%" stopColor="rgba(45,212,191,0.45)" />
        </radialGradient>
        <radialGradient id="lobeB" cx="0.5" cy="0.65" r="0.8">
          <stop offset="0%" stopColor="rgba(56,189,248,0.55)" />
          <stop offset="100%" stopColor="rgba(56,189,248,0.20)" />
        </radialGradient>
        <radialGradient id="core" cx="0.4" cy="0.4" r="0.7">
          <stop offset="0%" stopColor="#A6F4EA" />
          <stop offset="50%" stopColor="#2DD4BF" />
          <stop offset="100%" stopColor="#0F8A82" />
        </radialGradient>
      </defs>
      <circle cx="18" cy="19" r="14" fill="url(#lobeA)" />
      <circle cx="34" cy="19" r="14" fill="url(#lobeA)" />
      <circle cx="26" cy="33" r="14" fill="url(#lobeB)" />
      <circle cx="26" cy="25" r="9.5" fill="none" stroke="rgba(255,255,255,0.92)" strokeWidth="2.2" />
      <circle cx="26" cy="25" r="6.5" fill="url(#core)" />
      <circle cx="24.4" cy="23.4" r="2" fill="rgba(255,255,255,0.55)" />
    </svg>
  );
}

/* ─── 02. BIOLUMINESCENT — alive, not chrome ──────────
   Lobes are translucent membranes; the nucleus pulses
   like a deep-sea organism. CSS animations carry the
   biological rhythm (4-6s, micro-varied per loop). */
function MarkBiolum({ size = 96 }) {
  return (
    <svg width={size} height={size} viewBox="0 0 52 52" className="ciq-biolum">
      <defs>
        <radialGradient id="bio-membrane" cx="0.5" cy="0.5" r="0.55">
          <stop offset="40%" stopColor="rgba(45,212,191,0.0)" />
          <stop offset="78%" stopColor="rgba(94,224,210,0.55)" />
          <stop offset="100%" stopColor="rgba(15,138,130,0.85)" />
        </radialGradient>
        <radialGradient id="bio-core" cx="0.5" cy="0.5" r="0.5">
          <stop offset="0%" stopColor="#FFFFFF" />
          <stop offset="35%" stopColor="#A6F4EA" />
          <stop offset="100%" stopColor="#2DD4BF" />
        </radialGradient>
        <filter id="bio-blur"><feGaussianBlur stdDeviation="0.6" /></filter>
      </defs>
      <g filter="url(#bio-blur)">
        <circle cx="18" cy="19" r="14" fill="url(#bio-membrane)" className="lobe lobe-a" />
        <circle cx="34" cy="19" r="14" fill="url(#bio-membrane)" className="lobe lobe-b" />
        <circle cx="26" cy="33" r="14" fill="url(#bio-membrane)" className="lobe lobe-c" />
      </g>
      <circle cx="26" cy="25" r="9.5" fill="none" stroke="rgba(255,255,255,0.85)" strokeWidth="1.6" className="ring" />
      <circle cx="26" cy="25" r="6.5" fill="url(#bio-core)" className="nucleus" />
    </svg>
  );
}

/* ─── 03. SCANNING — the radar reading ──────────────
   A sweep arc passes across the lobes; the nucleus
   "locks" when the sweep crosses center. */
function MarkScanning({ size = 96 }) {
  return (
    <svg width={size} height={size} viewBox="0 0 52 52" className="ciq-scan">
      <defs>
        <linearGradient id="scan-sweep" x1="0" x2="1">
          <stop offset="0%" stopColor="rgba(45,212,191,0)" />
          <stop offset="50%" stopColor="rgba(94,224,210,0.65)" />
          <stop offset="100%" stopColor="rgba(45,212,191,0)" />
        </linearGradient>
        <clipPath id="scan-clip">
          <circle cx="18" cy="19" r="14" />
          <circle cx="34" cy="19" r="14" />
          <circle cx="26" cy="33" r="14" />
        </clipPath>
      </defs>
      <circle cx="18" cy="19" r="14" fill="rgba(45,212,191,0.18)" stroke="rgba(45,212,191,0.55)" strokeWidth="0.6" />
      <circle cx="34" cy="19" r="14" fill="rgba(45,212,191,0.18)" stroke="rgba(45,212,191,0.55)" strokeWidth="0.6" />
      <circle cx="26" cy="33" r="14" fill="rgba(56,189,248,0.10)" stroke="rgba(56,189,248,0.45)" strokeWidth="0.6" />
      <g clipPath="url(#scan-clip)">
        <rect x="-10" y="-10" width="14" height="80" fill="url(#scan-sweep)" className="sweep" />
      </g>
      <circle cx="26" cy="25" r="9.5" fill="rgba(2,6,15,0.6)" stroke="rgba(255,255,255,0.92)" strokeWidth="2" />
      <circle cx="26" cy="25" r="6" fill="#2DD4BF" className="nucleus-lock" />
    </svg>
  );
}

/* ─── 04. ECLIPSE — three rings, no fill ─────────────
   Maximum precision. The intersection is implied by
   overlap weights (stroke darkens at crossings). */
function MarkEclipse({ size = 96 }) {
  return (
    <svg width={size} height={size} viewBox="0 0 52 52">
      <g style={{ mixBlendMode: 'screen' }}>
        <circle cx="18" cy="19" r="14" fill="none" stroke="#2DD4BF" strokeWidth="1.8" opacity="0.85" />
        <circle cx="34" cy="19" r="14" fill="none" stroke="#2DD4BF" strokeWidth="1.8" opacity="0.85" />
        <circle cx="26" cy="33" r="14" fill="none" stroke="#5EE0D2" strokeWidth="1.8" opacity="0.85" />
      </g>
      <circle cx="26" cy="25" r="3.4" fill="#FFFFFF" style={{ filter: 'drop-shadow(0 0 6px rgba(94,224,210,0.85))' }} />
    </svg>
  );
}

/* ─── 05. SIGNAL-LOCK — crosshair on the nucleus ────
   Reads as a scientific instrument. Reticule lines
   from edge of mark to nucleus. */
function MarkSignalLock({ size = 96 }) {
  return (
    <svg width={size} height={size} viewBox="0 0 52 52">
      <defs>
        <radialGradient id="lock-core" cx="0.5" cy="0.5" r="0.5">
          <stop offset="0%" stopColor="#FFFFFF" />
          <stop offset="60%" stopColor="#5EE0D2" />
          <stop offset="100%" stopColor="#0F8A82" />
        </radialGradient>
      </defs>
      <circle cx="18" cy="19" r="14" fill="rgba(45,212,191,0.45)" />
      <circle cx="34" cy="19" r="14" fill="rgba(45,212,191,0.45)" />
      <circle cx="26" cy="33" r="14" fill="rgba(56,189,248,0.28)" />
      {/* reticule */}
      <g stroke="rgba(255,255,255,0.7)" strokeWidth="0.8" fill="none">
        <line x1="26" y1="6" x2="26" y2="16" />
        <line x1="26" y1="34" x2="26" y2="46" />
        <line x1="6" y1="25" x2="16" y2="25" />
        <line x1="36" y1="25" x2="46" y2="25" />
      </g>
      <circle cx="26" cy="25" r="9.5" fill="none" stroke="rgba(255,255,255,0.95)" strokeWidth="1.6" />
      <circle cx="26" cy="25" r="5.5" fill="url(#lock-core)" />
      <circle cx="26" cy="25" r="1.6" fill="#FFFFFF" />
    </svg>
  );
}

/* ─── 06. MONOLITH — pure geometric, dark mode hero ─
   Lobes are flat-filled, intersection is a CUTOUT
   showing pure white. The signal is a void in the noise. */
function MarkMonolith({ size = 96 }) {
  return (
    <svg width={size} height={size} viewBox="0 0 52 52">
      <defs>
        <mask id="mono-mask">
          <rect x="0" y="0" width="52" height="52" fill="black" />
          <circle cx="18" cy="19" r="14" fill="white" />
          <circle cx="34" cy="19" r="14" fill="white" />
          <circle cx="26" cy="33" r="14" fill="white" />
          <circle cx="26" cy="25" r="6.5" fill="black" />
        </mask>
        <radialGradient id="mono-fill" cx="0.5" cy="0.4" r="0.7">
          <stop offset="0%" stopColor="#5EE0D2" />
          <stop offset="100%" stopColor="#0F8A82" />
        </radialGradient>
      </defs>
      <rect x="0" y="0" width="52" height="52" fill="url(#mono-fill)" mask="url(#mono-mask)" />
      <circle cx="26" cy="25" r="6.5" fill="#FFFFFF" style={{
        filter: 'drop-shadow(0 0 4px rgba(255,255,255,0.6)) drop-shadow(0 0 12px rgba(94,224,210,0.5))'
      }} />
    </svg>
  );
}

window.MarkClassic = MarkClassic;
window.MarkBiolum = MarkBiolum;
window.MarkScanning = MarkScanning;
window.MarkEclipse = MarkEclipse;
window.MarkSignalLock = MarkSignalLock;
window.MarkMonolith = MarkMonolith;
