const S = SITE_DATA;

// ─────────────── NAV ───────────────
function NavBar({ dark, onToggleDark }) {
  const [scrolled, setScrolled] = React.useState(false);
  React.useEffect(() => {
    const on = () => setScrolled(window.scrollY > 60);
    window.addEventListener('scroll', on, { passive: true });
    return () => window.removeEventListener('scroll', on);
  }, []);
  return (
    <nav className={`nav ${scrolled ? 'nav-scrolled' : ''}`}>
      <a href="#top" className="logo">
        <span className="logo-mark">◆</span>
        <span className="logo-text">RAHUL</span>
      </a>
      <div className="nav-links">
        {['about', 'skills', 'experience', 'work', 'writing', 'contact'].map(l => (
          <a key={l} href={`#${l}`}>{l}</a>
        ))}
      </div>
      <div className="nav-actions">
        <button className="theme-btn" onClick={onToggleDark} aria-label="toggle theme">
          {dark ? '☾' : '☀'}
        </button>
        <a href={S.resume} target="_blank" className="nav-cta">Resume ↗</a>
      </div>
    </nav>
  );
}

// ─────────────── HERO ───────────────
function Hero({ dark }) {
  const y = useScrollY();
  const p = Math.min(1, y / 600);

  // mouse-reactive tilt on the content block (rAF-throttled to avoid re-render storm)
  const [tilt, setTilt] = React.useState({ x: 0, y: 0 });
  React.useEffect(() => {
    let raf = 0, tx = 0, ty = 0, pending = false;
    const on = (e) => {
      const w = window.innerWidth, h = window.innerHeight;
      tx = (e.clientX / w - 0.5) * 8;
      ty = (e.clientY / h - 0.5) * 8;
      if (!pending) {
        pending = true;
        raf = requestAnimationFrame(() => { pending = false; setTilt({ x: tx, y: ty }); });
      }
    };
    window.addEventListener('mousemove', on);
    return () => { window.removeEventListener('mousemove', on); cancelAnimationFrame(raf); };
  }, []);

  // live clock
  const [now, setNow] = React.useState(() => new Date());
  React.useEffect(() => {
    const id = setInterval(() => setNow(new Date()), 1000);
    return () => clearInterval(id);
  }, []);

  // rotating "now running" phrases — matches the figurines on screen
  const RUNNING_PHRASES = [
  'building scalable web applications',
  'designing REST APIs',
  'optimizing backend performance',
  'solving complex engineering problems',
  'developing full-stack solutions',
  'shipping production-ready features',
];
  const [phraseIdx, setPhraseIdx] = React.useState(0);
  React.useEffect(() => {
    const id = setInterval(() => setPhraseIdx((i) => (i + 1) % RUNNING_PHRASES.length), 2800);
    return () => clearInterval(id);
  }, []);

  // word strip
const WORDS = [
  'FULL STACK',
  'SOFTWARE',
  'REACT',
  'NODE.JS',
  'PYTHON',
  'TYPESCRIPT',
  'API DEVELOPMENT',
  'SYSTEM DESIGN',
  'FULL STACK',
  'SOFTWARE',
  'DOCKER',
  'OPEN SOURCE'
];

  return (
    <section className="hero hero-v5" id="top">
      {/* code rain backdrop */}
      <div
        className="hero-v5-bg"
        style={{
          transform: `translateY(${y * 0.12}px)`,
          opacity: 1 - p * 0.4,
        }}
      >
        <div className="v5-grid" />
        <div className="v5-rain"><CodeRain /></div>
        <div className="v5-vignette" />
        <div className="v5-noise" />
      </div>

      {/* META TOP */}
      <div className="v5-meta-tl">
        <span className="v5-dot" /> SYS · ONLINE
        <span className="v5-sep">/</span>
        {now.toLocaleTimeString('en-US', { hour12: false })} IST
      </div>

      <a href={S.resumeUrl || '#'} className="v5-meta-tr" target="_blank" rel="noreferrer">
        <span>RESUME</span><span className="v5-arrow">↗</span>
      </a>

      {/* TERMINAL PROMPT (oversized) */}
      <div
        className="v5-prompt"
        style={{
          transform: `translate(${tilt.x * 1.5}px, ${tilt.y * 1.5}px)`,
        }}
      >
        <span className="v5-prompt-pre">~ /rahul</span>
        <span className="v5-prompt-arrow">▸</span>
        <span className="v5-prompt-cmd">build agentic_</span>
        <span className="v5-caret" />
      </div>

      {/* GIANT EDITORIAL HEADLINE */}
      <div
        className="v5-content"
        style={{
          transform: `translateY(${y * 0.08}px)`,
          opacity: 1 - p * 1.2,
        }}
      >
        <h1 className="v5-title">
          <span className="v5-line"><FadeWords text="AI engineer." stagger={70} /></span>
          <span className="v5-line v5-line-italic"><FadeWords text="Automation craftsman." delay={220} stagger={70} /></span>
          <span className="v5-line v5-line-outline"><FadeWords text="Open source by default." delay={460} stagger={70} /></span>
        </h1>

        <div className="v5-meta-row">
          <div className="v5-meta-col">
            <span className="v5-meta-key">NAME</span>
            <span className="v5-meta-val">Rahul Raj</span>
          </div>
          <div className="v5-meta-col">
            <span className="v5-meta-key">ROLE</span>
            <span className="v5-meta-val">{S.role}</span>
          </div>
          <div className="v5-meta-col">
            <span className="v5-meta-key">STACK</span>
            <span className="v5-meta-val">{S.stack}</span>
          </div>
          <div className="v5-meta-col">
            <span className="v5-meta-key">BASED</span>
            <span className="v5-meta-val">{S.location}</span>
          </div>
        </div>

        <div className="v5-ctas">
          <a href={`mailto:${S.email}`} className="v5-cta v5-cta-primary">
            <span className="v5-cta-label">Start a project</span>
            <span className="v5-cta-arrow">→</span>
          </a>
          <a href="#work" className="v5-cta v5-cta-ghost">
            <span className="v5-cta-dot" /> See the work
          </a>
        </div>
      </div>

      {/* WORD STRIP — bottom marquee */}
      <div className="v5-strip">
        <div className="v5-strip-track">
          {[...WORDS, ...WORDS].map((w, i) => (
            <span key={i} className="v5-strip-item">
              <span className="v5-strip-mark">✦</span>{w}
            </span>
          ))}
        </div>
      </div>

      {/* BOTTOM-RIGHT HUD */}
      <div className="v5-hud">
        <div className="v5-hud-row">
          <span className="v5-hud-key">NOW</span>
          <span className="v5-hud-val" key={phraseIdx}>{RUNNING_PHRASES[phraseIdx]}</span>
        </div>
        <div className="v5-hud-row v5-hud-scroll">
          <span className="v5-hud-key">SCROLL</span>
          <span className="v5-hud-bar"><span className="v5-hud-bar-fill" style={{ height: `${p * 100}%` }} /></span>
        </div>
      </div>
    </section>
  );
}

// CodeRain — falling glyph columns (canvas-free, pure CSS)
function CodeRain() {
  const columns = 28;
  const glyphs = '01∆◆◇○●▢▣▲▼←→↑↓§¶≈≠≡∞∇∂'.split('');
  return (
    <div className="rain-cols">
      {Array.from({ length: columns }).map((_, i) => {
        const col = [];
        const len = 14 + (i % 4) * 4;
        for (let j = 0; j < len; j++) {
          col.push(glyphs[(i * 13 + j * 7) % glyphs.length]);
        }
        return (
          <div
            key={i}
            className="rain-col"
            style={{
              left: `${(i * 100) / columns}%`,
              animationDelay: `${-(i * 0.5) % 8}s`,
              animationDuration: `${10 + (i % 5) * 2}s`,
            }}
          >
            {col.map((g, j) => (
              <span key={j} style={{ opacity: 1 - j / col.length }}>{g}</span>
            ))}
          </div>
        );
      })}
    </div>
  );
}

// ─────────────── MARQUEE ───────────────
function Marquee() {
  const items = [
    'React',
    'Next.js',
    'Node.js',
    'Express.js',
    'TypeScript',
    'JavaScript',
    'Python',
    'PHP',
    'MongoDB',
    'PostgreSQL',
    'MySQL',
    'Docker',
    'Git',
    'Linux',
    'REST APIs',
    'OpenAI API',
    'Tailwind CSS',
    'AWS'
  ];

  const row = [...items, ...items, ...items];

  return (
    <div className="marquee">
      <div className="marquee-track">
        {row.map((t, i) => (
          <span key={i} className="marquee-item">
            <span className="marquee-dot">●</span> {t}
          </span>
        ))}
      </div>
    </div>
  );
}

// ─────────────── ABOUT ───────────────
function About() {
  return (
    <section className="section about" id="about">
      <Stamp style={{ top: '180px', right: '6%', transform: 'rotate(-8deg)' }}>// shipped 2026</Stamp>
      <Stamp style={{ bottom: '120px', left: '4%', transform: 'rotate(5deg)' }}>// remote ok</Stamp>
      <SectionHeader num="01" label="About" bleed="§ ABOUT — ABOUT" bleedStyle="solid" />
      <div className="about-grid">
        <div>
          <h2 className="h-display">
            <FadeWords text="I build software products" stagger={60} />
            <br/>
            <FadeWords text="which solve real problems" delay={200} stagger={60} style={{ color: 'var(--accent)', fontStyle: 'italic' }} />
            <br/>
            <FadeWords text="so businesses can grow." delay={400} stagger={60} />
          </h2>
        </div>
        <div className="about-right">
          <Reveal delay={200}>
            <p className="lead">
              Software engineer specializing in full-stack development and AI integration. I craft scalable applications that leverage modern technologies to solve real-world problems.
            </p>
          </Reveal>
          <Reveal delay={350}>
            <p>
              Currently building scalable web applications, designing robust backend systems, and crafting intuitive user experiences with clean, maintainable code
            </p>
          </Reveal>
          <div className="stats-row">
            {[
              { n: 20, suf: '+', l: 'API integrations' },
              { n: 40, suf: '%', l: 'Manual work cut' },
              { n: 98, suf: '%', l: 'Workflow success' },
              { n: 5, suf: '', l: 'Projects shipped' },
            ].map((s, i) => (
              <Reveal key={s.l} delay={500 + i * 80} className="stat">
                <div className="stat-n"><CountUp to={s.n} suffix={s.suf} /></div>
                <div className="stat-l">{s.l}</div>
              </Reveal>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

function SectionHeader({ num, label, right, bleed, bleedStyle }) {
  // bleed: text to render as a huge type-bleed label above the section header
  // bleedStyle: 'solid' | 'outline'
  return (
    <>
      {bleed ? (
        <div className={`section-bleed ${bleedStyle === 'outline' ? 'is-outline' : 'is-solid'}`}>
          <div className="section-bleed-text">{bleed}</div>
        </div>
      ) : null}
      <div className="section-header">
        <div className="section-label">
          <span className="section-num">{num}</span>
          <span className="section-bar" />
          <span className="section-name"><Scramble text={label} duration={900} /></span>
        </div>
        {right}
      </div>
    </>
  );
}

function Stamp({ children, style }) {
  return <div className="rk-stamp" style={style}>{children}</div>;
}

// ─────────────── FEATURED WORK ───────────────
function Featured() {
  const [active, setActive] = React.useState(0);
  const p = S.featuredProjects;
  return (
    <section className="section featured" id="work">
      <SectionHeader num="04" label="Featured Work" bleed="FEATURED · WORK" bleedStyle="outline" right={<a className="section-link" href="#grid">all projects →</a>} />
      <div className="featured-list">
        {p.map((proj, i) => (
          <ProjectRow key={proj.id} p={proj} i={i} onHover={() => setActive(i)} active={active === i} />
        ))}
      </div>
    </section>
  );
}

function ProjectRow({ p, i, onHover, active }) {
  const [ref, shown] = useReveal({ threshold: 0.2 });
  return (
    <a href={p.url} target="_blank" rel="noopener noreferrer"
      ref={ref}
      onMouseEnter={onHover}
      className="proj-row"
      style={{
        opacity: shown ? 1 : 0,
        transform: shown ? 'translateY(0)' : 'translateY(60px)',
        transition: 'all 1000ms cubic-bezier(.2,.7,.2,1)',
      }}>
      <div className="proj-row-index">0{i + 1}</div>
      <div className="proj-row-title">
        <div className="proj-period mono-sm">{p.period}</div>
        <h3 className="proj-name">{p.title}</h3>
        <div className="proj-tagline">{p.tagline}</div>
      </div>
      <div className="proj-row-preview">
        <div className="proj-preview-inner">
          <ProjectArtwork id={p.id} />
          <div className="proj-preview-overlay">
            <div className="mono-sm">{p.tags.slice(0, 4).join(' · ')}</div>
          </div>
        </div>
      </div>
      <div className="proj-row-arrow">
        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
          <path d="M7 17L17 7M17 7H9M17 7V15" strokeLinecap="round" strokeLinejoin="round"/>
        </svg>
      </div>
    </a>
  );
}

// Abstract animated artwork per project id
function ProjectArtwork({ id }) {
  if (id === 'mesh') {
    return (
      <svg
        className="artwork"
        viewBox="0 0 200 120"
        preserveAspectRatio="xMidYMid slice"
      >
        <defs>
          <linearGradient id="mesh-g" x1="0" y1="0" x2="1" y2="1">
            <stop offset="0" stopColor="#000000" />
            <stop offset="1" stopColor="#000000" />
          </linearGradient>

          <linearGradient id="mesh-line" x1="0" y1="0" x2="1" y2="0">
            <stop offset="0" stopColor="#111111" />
            <stop offset="1" stopColor="#000000" />
          </linearGradient>
        </defs>

        {/* Background */}
        <rect width="200" height="120" fill="url(#mesh-g)" opacity=".18" />

        {/* Connection Lines */}
        {[
          "M40 35 L100 25",
          "M100 25 L160 40",
          "M40 35 L65 82",
          "M65 82 L135 90",
          "M135 90 L160 40",
          "M100 25 L100 60",
          "M100 60 L135 90",
        ].map((d, i) => (
          <path
            key={i}
            d={d}
            fill="none"
            stroke="url(#mesh-line)"
            strokeWidth="1.3"
            strokeLinecap="round"
            strokeDasharray="4 4"
            opacity=".55"
          >
            <animate
              attributeName="stroke-dashoffset"
              values="20;0"
              dur={`${2 + i * 0.25}s`}
              repeatCount="indefinite"
            />
          </path>
        ))}

        {/* Network Nodes */}
        {[
          [40, 35],
          [100, 25],
          [160, 40],
          [65, 82],
          [100, 60],
          [135, 90],
        ].map(([x, y], i) => (
          <g key={i}>
            <circle cx={x} cy={y} r="8" fill="#000000">
              <animate
                attributeName="r"
                values="8;10;8"
                dur={`${2.5 + i * 0.2}s`}
                repeatCount="indefinite"
              />
            </circle>

            <circle
              cx={x}
              cy={y}
              r="14"
              fill="none"
              stroke="#000000"
              strokeWidth="1"
              opacity=".45"
            >
              <animate
                attributeName="r"
                values="14;22;14"
                dur={`${3 + i * 0.2}s`}
                repeatCount="indefinite"
              />
              <animate
                attributeName="opacity"
                values=".45;0;.45"
                dur={`${3 + i * 0.2}s`}
                repeatCount="indefinite"
              />
            </circle>
          </g>
        ))}

        {/* Floating chat bubbles */}
        {[
          [78, 50],
          [120, 72],
          [82, 95],
        ].map(([x, y], i) => (
          <g key={i}>
            <rect
              x={x}
              y={y}
              width="20"
              height="12"
              rx="6"
              fill="white"
              opacity=".85"
            >
              <animateTransform
                attributeName="transform"
                type="translate"
                values="0 0;0 -2;0 0"
                dur={`${2 + i * 0.4}s`}
                repeatCount="indefinite"
              />
            </rect>

            <circle cx={x + 6} cy={y + 6} r="1.2" fill="#000000" />
            <circle cx={x + 10} cy={y + 6} r="1.2" fill="#000000" />
            <circle cx={x + 14} cy={y + 6} r="1.2" fill="#000000" />
          </g>
        ))}
      </svg>
    );
  }
  if (id === 'paperbox') {
  return (
    <svg
      className="artwork"
      viewBox="0 0 200 120"
      preserveAspectRatio="xMidYMid slice"
    >
      <defs>
        <linearGradient id="paper-g" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#02070e" />
          <stop offset="1" stopColor="#0b0a0e" />
        </linearGradient>

        <linearGradient id="paper-line" x1="0" y1="0" x2="1" y2="0">
          <stop offset="0" stopColor="#050b12" />
          <stop offset="1" stopColor="#04020c" />
        </linearGradient>
      </defs>

      {/* Background */}
      <rect width="200" height="120" fill="url(#paper-g)" opacity=".16" />

      {/* Connecting Lines */}
      {[
        "M100 60 L45 30",
        "M100 60 L155 30",
        "M100 60 L45 92",
        "M100 60 L155 92",
      ].map((d, i) => (
        <path
          key={i}
          d={d}
          fill="none"
          stroke="url(#paper-line)"
          strokeWidth="1.2"
          strokeDasharray="4 4"
          opacity=".55"
        >
          <animate
            attributeName="stroke-dashoffset"
            values="20;0"
            dur={`${2.2 + i * 0.25}s`}
            repeatCount="indefinite"
          />
        </path>
      ))}

      {/* Center Folder */}
      <g>
        <rect
          x="78"
          y="48"
          width="44"
          height="28"
          rx="5"
          fill="#F8FAFC"
        />
        <path
          d="M82 48h12l4-5h20a4 4 0 014 4v3H78v-2a4 4 0 014-4z"
          fill="#8b8d8dcf"
        />

        <animateTransform
          attributeName="transform"
          type="translate"
          values="0 0;0 -1.5;0 0"
          dur="3s"
          repeatCount="indefinite"
        />
      </g>

      {/* Floating Paper Cards */}
      {[
        [32, 18],
        [150, 18],
        [32, 78],
        [150, 78],
      ].map(([x, y], i) => (
        <g key={i}>
          <rect
            x={x}
            y={y}
            width="22"
            height="28"
            rx="3"
            fill="white"
            opacity=".92"
          >
            <animateTransform
              attributeName="transform"
              type="translate"
              values="0 0;0 -2;0 0"
              dur={`${2.5 + i * 0.3}s`}
              repeatCount="indefinite"
            />
          </rect>

          {/* Text lines */}
          <line
            x1={x + 5}
            y1={y + 8}
            x2={x + 17}
            y2={y + 8}
            stroke="#000"
            strokeWidth="1.4"
            opacity=".7"
          />
          <line
            x1={x + 5}
            y1={y + 14}
            x2={x + 15}
            y2={y + 14}
            stroke="#000"
            strokeWidth="1.2"
            opacity=".6"
          />
          <line
            x1={x + 5}
            y1={y + 20}
            x2={x + 18}
            y2={y + 20}
            stroke="#000"
            strokeWidth="1.2"
            opacity=".6"
          />
        </g>
      ))}

      {/* Sparkles */}
      {[
        [66, 26],
        [132, 24],
        [66, 95],
        [132, 95],
      ].map(([x, y], i) => (
        <g key={i}>
          <circle cx={x} cy={y} r="1.8" fill="#FFFFFF">
            <animate
              attributeName="opacity"
              values=".2;1;.2"
              dur={`${2 + i * 0.3}s`}
              repeatCount="indefinite"
            />
          </circle>
        </g>
      ))}
    </svg>
  );
}
  if (id === 'lunara') {
  return (
    <svg
      className="artwork"
      viewBox="0 0 200 120"
      preserveAspectRatio="xMidYMid slice"
    >
      <defs>
        <linearGradient id="moon-g" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#02011b" />
          <stop offset="1" stopColor="#0F172A" />
        </linearGradient>

        <radialGradient id="moon-fill" cx="35%" cy="35%">
          <stop offset="0" stopColor="#FFFFFF" />
          <stop offset="1" stopColor="#D1D5DB" />
        </radialGradient>

        <linearGradient id="orbit-g" x1="0" y1="0" x2="1" y2="0">
          <stop offset="0" stopColor="#A78BFA" />
          <stop offset="1" stopColor="#60A5FA" />
        </linearGradient>
      </defs>

      {/* Space Background */}
      <rect width="200" height="120" fill="url(#moon-g)" />

      {/* Moon */}
      <g>
        <circle cx="62" cy="60" r="22" fill="url(#moon-fill)">
          <animate
            attributeName="r"
            values="22;23.5;22"
            dur="5s"
            repeatCount="indefinite"
          />
        </circle>

        {/* Craters */}
        <circle cx="56" cy="53" r="3" fill="#BFC5CE" opacity=".6" />
        <circle cx="69" cy="65" r="2.5" fill="#BFC5CE" opacity=".5" />
        <circle cx="58" cy="71" r="2" fill="#BFC5CE" opacity=".5" />
      </g>

      {/* Orbit */}
      <ellipse
        cx="62"
        cy="60"
        rx="42"
        ry="18"
        fill="none"
        stroke="url(#orbit-g)"
        strokeWidth="1"
        opacity=".45"
        strokeDasharray="4 4"
      >
        <animateTransform
          attributeName="transform"
          type="rotate"
          from="0 62 60"
          to="360 62 60"
          dur="14s"
          repeatCount="indefinite"
        />
      </ellipse>

      {/* Orbiting Star */}
      <g>
        <circle cx="104" cy="60" r="3" fill="#000000">
          <animateTransform
            attributeName="transform"
            type="rotate"
            from="0 62 60"
            to="360 62 60"
            dur="14s"
            repeatCount="indefinite"
          />
        </circle>
      </g>

      {/* Constellation */}
      <g stroke="#93C5FD" strokeWidth="1" opacity=".6">
        <line x1="130" y1="28" x2="150" y2="42" />
        <line x1="150" y1="42" x2="172" y2="26" />
        <line x1="150" y1="42" x2="164" y2="70" />
        <line x1="164" y1="70" x2="184" y2="82" />
      </g>

      {[
        [130, 28],
        [150, 42],
        [172, 26],
        [164, 70],
        [184, 82],
      ].map(([x, y], i) => (
        <circle key={i} cx={x} cy={y} r="2.2" fill="#E0E7FF">
          <animate
            attributeName="opacity"
            values=".3;1;.3"
            dur={`${2 + i * 0.4}s`}
            repeatCount="indefinite"
          />
        </circle>
      ))}

      {/* Shooting Star */}
      <g>
        <line
          x1="130"
          y1="95"
          x2="158"
          y2="78"
          stroke="#F8FAFC"
          strokeWidth="1.5"
          strokeLinecap="round"
        />
        <circle cx="130" cy="95" r="2" fill="white">
          <animateTransform
            attributeName="transform"
            type="translate"
            values="0 0;28 -17;0 0"
            dur="4s"
            repeatCount="indefinite"
          />
        </circle>
      </g>

      {/* Twinkling Stars */}
      {[
        [26, 22],
        [90, 20],
        [112, 94],
        [178, 56],
        [42, 96],
        [186, 18],
      ].map(([x, y], i) => (
        <circle key={i} cx={x} cy={y} r="1.7" fill="white">
          <animate
            attributeName="opacity"
            values=".2;1;.2"
            dur={`${2 + i * 0.5}s`}
            repeatCount="indefinite"
          />
        </circle>
      ))}
    </svg>
  );
}
if (id === "pantsnpleats") {
  return (
    <svg
      className="artwork"
      viewBox="0 0 200 120"
      preserveAspectRatio="xMidYMid slice"
    >
      <defs>
        <linearGradient id="commerce-bg" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#e3e3ded0" />
          <stop offset="1" stopColor="#f4f3f0d3" />
        </linearGradient>

        <linearGradient id="commerce-line" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#2d2e15" />
          <stop offset="1" stopColor="#c9b627" />
        </linearGradient>

        <linearGradient id="commerce-card" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#080808" stopOpacity=".14" />
          <stop offset="1" stopColor="#0f0e0e" stopOpacity=".05" />
        </linearGradient>
      </defs>

      {/* Background */}
      <rect width="200" height="120" fill="url(#commerce-bg)" />

      {/* Animated Connection Lines */}
      {[
        "M100 60 L52 28",
        "M100 60 L148 28",
        "M100 60 L52 92",
        "M100 60 L148 92",
      ].map((d, i) => (
        <path
          key={i}
          d={d}
          fill="none"
          stroke="url(#commerce-line)"
          strokeWidth="1.2"
          strokeDasharray="4 6"
          opacity=".35"
        >
          <animate
            attributeName="stroke-dashoffset"
            values="20;0"
            dur={`${3 + i * .4}s`}
            repeatCount="indefinite"
          />
        </path>
      ))}

      {/* Center Commerce Hub */}
      <g>
        <circle cx="100" cy="60" r="18" fill="#aea11850" opacity=".18" />

        <circle
          cx="100"
          cy="60"
          r="11"
          fill="none"
          stroke="#00000046"
          strokeWidth="2"
        />

        {/* Cart */}
        <path
          d="M94 58h11l-1.8 5h-7.5l-1.2-8h-2"
          fill="none"
          stroke="#151502"
          strokeWidth="1.8"
          strokeLinecap="round"
          strokeLinejoin="round"
        />

        <circle cx="97" cy="66" r="1.3" fill="#0f0f03" />
        <circle cx="103" cy="66" r="1.3" fill="#151204" />

        <animateTransform
          attributeName="transform"
          type="scale"
          values="1;1.05;1"
          dur="4s"
          repeatCount="indefinite"
        />
      </g>

      {/* Product Card */}
      <g transform="translate(40 16)">
        <rect
          width="24"
          height="30"
          rx="5"
          fill="url(#commerce-card)"
          stroke="#927b14"
          strokeOpacity=".35"
        />
        <rect x="5" y="6" width="14" height="10" rx="2" fill="#463c00" opacity=".5"/>
        <line x1="5" y1="21" x2="19" y2="21" stroke="#000" opacity=".6"/>
        <line x1="5" y1="25" x2="15" y2="25" stroke="#000" opacity=".45"/>
      </g>

      {/* Wishlist */}
      <g transform="translate(136 16)">
        <rect
          width="24"
          height="30"
          rx="5"
          fill="url(#commerce-card)"
          stroke="#463c00"
          strokeOpacity=".35"
        />
        <path
          d="M12 20
             C12 15 18 15 18 20
             C18 23 12 27 12 29
             C12 27 6 23 6 20
             C6 15 12 15 12 20"
          fill="#463c00"
        />
      </g>

      {/* Payment */}
      <g transform="translate(40 74)">
        <rect
          width="24"
          height="18"
          rx="4"
          fill="url(#commerce-card)"
          stroke="#463c00"
          strokeOpacity=".35"
        />
        <rect x="4" y="6" width="16" height="2" fill="#463c00" opacity=".8"/>
        <rect x="4" y="11" width="8" height="2" fill="#463c00" opacity=".5"/>
      </g>

      {/* Analytics */}
      <g transform="translate(136 72)">
        <rect
          width="24"
          height="22"
          rx="4"
          fill="url(#commerce-card)"
          stroke="#463c00"
          strokeOpacity=".35"
        />
        <polyline
          points="4,16 9,12 14,14 20,6"
          fill="none"
          stroke="#463c00"
          strokeWidth="2"
          strokeLinecap="round"
          strokeLinejoin="round"
        />
      </g>

      {/* Floating Particles */}
      {[
        [28, 20],
        [170, 24],
        [174, 98],
        [24, 96],
        [178, 58],
        [22, 58],
      ].map(([x, y], i) => (
        <circle key={i} cx={x} cy={y} r="1.8" fill="#FFFFFF">
          <animate
            attributeName="opacity"
            values=".2;1;.2"
            dur={`${2 + i * .4}s`}
            repeatCount="indefinite"
          />
        </circle>
      ))}

      {/* Rotating Ring */}
      <circle
        cx="100"
        cy="60"
        r="42"
        fill="none"
        stroke="#e6e4ca"
        strokeOpacity=".15"
        strokeDasharray="3 7"
      >
        <animateTransform
          attributeName="transform"
          type="rotate"
          from="0 100 60"
          to="360 100 60"
          dur="20s"
          repeatCount="indefinite"
        />
      </circle>
    </svg>
  );
}
  return <div className="artwork artwork-default" />;
}

// Abstract animated artwork for "More Projects" cards — keyed by title
function MoreProjectArt({ title, idx }) {
  // Deep Facial Verification — siamese face match grid
  if (title.includes('Facial')) {
    return (
      <svg className="artwork" viewBox="0 0 200 120" preserveAspectRatio="xMidYMid slice">
        <rect width="200" height="120" fill="#0d1218"/>
        {/* two face boxes with feature points */}
        {[40, 130].map((cx, k) => (
          <g key={k}>
            <rect x={cx} y="30" width="40" height="50" rx="3" fill="none" stroke="#000000" strokeWidth="1" opacity=".7"/>
            {Array.from({ length: 8 }).map((_, i) => {
              const px = cx + 6 + (i % 4) * 9;
              const py = 38 + Math.floor(i / 4) * 18 + (i % 3) * 4;
              return <circle key={i} cx={px} cy={py} r="1.4" fill="#22d3ee">
                <animate attributeName="opacity" values=".4;1;.4" dur={`${1.5 + i * .1}s`} repeatCount="indefinite"/>
              </circle>;
            })}
          </g>
        ))}
        {/* connecting lines (siamese) */}
        {Array.from({ length: 5 }).map((_, i) => (
          <line key={i} x1={70 + (i % 3) * 4} y1={42 + i * 8} x2={130 + (i % 3) * 4} y2={42 + i * 8}
                stroke="#000000" strokeWidth=".5" strokeDasharray="2 2" opacity=".6">
            <animate attributeName="stroke-dashoffset" from="0" to="-8" dur="1.2s" repeatCount="indefinite"/>
          </line>
        ))}
        <text x="100" y="105" fill="#fff" fontSize="8" fontFamily="monospace" textAnchor="middle" opacity=".55">SIM 0.97</text>
      </svg>
    );
  }
  if (title.includes('Weather App')) {
  return (
    <svg
      className="artwork"
      viewBox="0 0 200 120"
      preserveAspectRatio="xMidYMid slice"
    >
      <defs>
        <linearGradient id="weather-g" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#38BDF8" />
          <stop offset="1" stopColor="#050b17" />
        </linearGradient>

        <linearGradient id="sun-g" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#000000" />
          <stop offset="1" stopColor="#000000" />
        </linearGradient>
      </defs>

      {/* Background */}
      <rect width="200" height="120" fill="url(#weather-g)" opacity=".18" />

      
     

      {/* Cloud */}
      <g>
        <ellipse cx="118" cy="48" rx="20" ry="12" fill="white" opacity=".95" />
        <ellipse cx="104" cy="51" rx="12" ry="10" fill="white" />
        <ellipse cx="132" cy="52" rx="13" ry="10" fill="white" />

        <animateTransform
          attributeName="transform"
          type="translate"
          values="-3 0;3 0;-3 0"
          dur="6s"
          repeatCount="indefinite"
        />
      </g>

      {/* Rain */}
      {[104, 116, 128].map((x, i) => (
        <line
          key={i}
          x1={x}
          y1="66"
          x2={x - 3}
          y2="78"
          stroke="#7DD3FC"
          strokeWidth="2"
          strokeLinecap="round"
        >
          <animate
            attributeName="y1"
            values="66;74;66"
            dur={`${1 + i * 0.2}s`}
            repeatCount="indefinite"
          />
          <animate
            attributeName="y2"
            values="78;86;78"
            dur={`${1 + i * 0.2}s`}
            repeatCount="indefinite"
          />
        </line>
      ))}

      {/* Location Pin */}
      <g transform="translate(150 72)">
        <path
          d="M0-10a8 8 0 0 1 8 8c0 6-8 16-8 16S-8 4-8-2a8 8 0 0 1 8-8z"
          fill="#ed0505ac"
        >
          <animateTransform
            attributeName="transform"
            type="translate"
            values="0 0;0 -2;0 0"
            dur="2.5s"
            repeatCount="indefinite"
          />
        </path>

        <circle cx="0" cy="-2" r="2.5" fill="white" />
      </g>

      {/* Floating Weather Particles */}
      {[
        [35, 90],
        [65, 82],
        [145, 25],
        [170, 55],
      ].map(([x, y], i) => (
        <circle
          key={i}
          cx={x}
          cy={y}
          r="2"
          fill="white"
          opacity=".6"
        >
          <animate
            attributeName="opacity"
            values=".2;.8;.2"
            dur={`${2 + i * 0.4}s`}
            repeatCount="indefinite"
          />
        </circle>
      ))}
    </svg>
  );
}
if (title.includes("MY")) {
  return (
    <svg
      className="artwork"
      viewBox="0 0 200 120"
      preserveAspectRatio="xMidYMid slice"
    >
      <defs>
        <linearGradient id="stellar-bg" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#020617" />
          <stop offset=".5" stopColor="#02010e" />
          <stop offset="1" stopColor="#020208" />
        </linearGradient>

        <radialGradient id="moon-fill" cx="35%" cy="35%">
          <stop offset="0" stopColor="#FFFFFF" />
          <stop offset="1" stopColor="#CBD5E1" />
        </radialGradient>

        <linearGradient id="orbit" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#A78BFA" />
          <stop offset="1" stopColor="#60A5FA" />
        </linearGradient>
      </defs>

      {/* Background */}
      <rect width="200" height="120" fill="url(#stellar-bg)" />

      {/* Orbital Rings */}
      <ellipse
        cx="100"
        cy="60"
        rx="58"
        ry="24"
        fill="none"
        stroke="url(#orbit)"
        strokeWidth="1"
        strokeOpacity=".28"
        strokeDasharray="3 6"
      >
        <animateTransform
          attributeName="transform"
          type="rotate"
          from="0 100 60"
          to="360 100 60"
          dur="28s"
          repeatCount="indefinite"
        />
      </ellipse>

      <ellipse
        cx="100"
        cy="60"
        rx="42"
        ry="42"
        fill="none"
        stroke="#818CF8"
        strokeWidth=".8"
        strokeOpacity=".18"
      />

      {/* Moon */}
      <g>
        <circle cx="100" cy="60" r="18" fill="url(#moon-fill)" />

        <circle cx="94" cy="54" r="2.8" fill="#BFC5CE" opacity=".55" />
        <circle cx="107" cy="66" r="2.2" fill="#BFC5CE" opacity=".5" />
        <circle cx="95" cy="69" r="1.8" fill="#BFC5CE" opacity=".45" />

        <animateTransform
          attributeName="transform"
          type="scale"
          values="1;1.02;1"
          dur="6s"
          repeatCount="indefinite"
        />
      </g>

      {/* Orbiting Celestial Object */}
      <g>
        <circle cx="158" cy="60" r="3" fill="#000000">
          <animateTransform
            attributeName="transform"
            type="rotate"
            from="0 100 60"
            to="360 100 60"
            dur="28s"
            repeatCount="indefinite"
          />
        </circle>
      </g>

      {/* Constellation */}
      <g
        fill="none"
        stroke="#93C5FD"
        strokeWidth="1"
        strokeOpacity=".5"
      >
        <polyline points="30,30 48,42 70,26 86,38 72,56" />
      </g>

      {[30,48,70,86,72].map((x, i) => {
        const y = [30,42,26,38,56][i];
        return (
          <circle key={i} cx={x} cy={y} r="2" fill="#E2E8F0">
            <animate
              attributeName="opacity"
              values=".3;1;.3"
              dur={`${2 + i * .3}s`}
              repeatCount="indefinite"
            />
          </circle>
        );
      })}

      {/* Shooting Star */}
      <g>
        <line
          x1="138"
          y1="26"
          x2="168"
          y2="12"
          stroke="#FFFFFF"
          strokeWidth="1.6"
          strokeLinecap="round"
          opacity=".8"
        />
        <circle cx="138" cy="26" r="2" fill="white">
          <animateTransform
            attributeName="transform"
            type="translate"
            values="0 0;26 -12;0 0"
            dur="5s"
            repeatCount="indefinite"
          />
        </circle>
      </g>

      {/* Twinkling Stars */}
      {[
        [18,18],
        [52,92],
        [128,20],
        [176,42],
        [168,96],
        [22,82],
        [182,16],
        [146,86],
      ].map(([x,y], i) => (
        <circle key={i} cx={x} cy={y} r="1.5" fill="white">
          <animate
            attributeName="opacity"
            values=".2;1;.2"
            dur={`${2 + i * .4}s`}
            repeatCount="indefinite"
          />
        </circle>
      ))}
    </svg>
  );
}
  if (title.includes('Disaster')) {
    return (
      <svg className="artwork" viewBox="0 0 200 120" preserveAspectRatio="xMidYMid slice">
        <rect width="200" height="120" fill="#1a0f08"/>
        {[20, 35, 50].map((r, i) => (
          <circle key={i} cx="100" cy="60" r={r} fill="none" stroke="#000000" strokeWidth=".8" opacity={.6 - i * .15}>
            <animate attributeName="r" values={`${r};${r + 12};${r}`} dur={`${2 + i * .4}s`} repeatCount="indefinite"/>
            <animate attributeName="opacity" values={`${.6 - i * .15};0;${.6 - i * .15}`} dur={`${2 + i * .4}s`} repeatCount="indefinite"/>
          </circle>
        ))}
        <circle cx="100" cy="60" r="3" fill="#000000"/>
        {/* sweep line */}
        <line x1="100" y1="60" x2="160" y2="60" stroke="#22d3ee" strokeWidth="1" opacity=".7">
          <animateTransform attributeName="transform" type="rotate" from="0 100 60" to="360 100 60" dur="3s" repeatCount="indefinite"/>
        </line>
        {/* incident dots */}
        {[[70, 40], [140, 80], [120, 35]].map(([x, y], i) => (
          <circle key={i} cx={x} cy={y} r="2" fill="#ef4444">
            <animate attributeName="opacity" values=".3;1;.3" dur={`${1.2 + i * .3}s`} repeatCount="indefinite"/>
          </circle>
        ))}
      </svg>
    );
  }
  // Omarchy — terminal lines
  if (title.includes('Omarchy')) {
    return (
      <svg className="artwork" viewBox="0 0 200 120" preserveAspectRatio="xMidYMid slice">
        <rect width="200" height="120" fill="#0a0f0a"/>
        {[
          '$ omarchy --launch',
          '> menu: [apps]',
          '> menu: [system]',
          '> menu: [power]',
          '$ _',
        ].map((txt, i) => (
          <text key={i} x="14" y={28 + i * 16} fill={i === 4 ? '#22c55e' : '#86efac'} fontSize="9" fontFamily="monospace" opacity={.5 + i * .1}>
            {txt}
            {i === 4 ? <animate attributeName="opacity" values=".3;1;.3" dur="1s" repeatCount="indefinite"/> : null}
          </text>
        ))}
        <rect x="14" y="100" width="170" height="1" fill="#22c55e" opacity=".5"/>
      </svg>
    );
  }
  // — abstract typography portfolio
  if (title.includes('rahul')) {
    return (
      <svg className="artwork" viewBox="0 0 200 120" preserveAspectRatio="xMidYMid slice">
        <rect width="200" height="120" fill="#fef7e6"/>
        <text x="100" y="78" fill="#0a0a0a" fontSize="62" fontFamily="'Archivo Black', sans-serif" fontWeight="900" textAnchor="middle" letterSpacing="-2">
          rahul
        </text>
        <text x="100" y="78" fill="none" stroke="#000000" strokeWidth=".5" fontSize="62" fontFamily="'Archivo Black', sans-serif" fontWeight="900" textAnchor="middle" letterSpacing="-2" opacity=".7">
          <animate attributeName="opacity" values=".3;.9;.3" dur="2.5s" repeatCount="indefinite"/>
          rahul
        </text>
        <line x1="20" y1="92" x2="180" y2="92" stroke="#0a0a0a" strokeWidth=".5"/>
        <text x="20" y="105" fill="#0a0a0a" fontSize="7" fontFamily="monospace" opacity=".7">// PERSONAL · 2026</text>
      </svg>
    );
  }
  // n8n Workflow — node graph
  if (title.includes('n8n')) {
    return (
      <svg className="artwork" viewBox="0 0 200 120" preserveAspectRatio="xMidYMid slice">
        <rect width="200" height="120" fill="#0f0a1a"/>
        {/* nodes */}
        {[[30, 60], [80, 35], [80, 85], [130, 60], [170, 60]].map(([x, y], i) => (
          <g key={i}>
            <rect x={x - 10} y={y - 8} width="20" height="16" rx="3" fill="#a855f7" opacity=".85">
              <animate attributeName="opacity" values=".5;1;.5" dur={`${1.5 + i * .2}s`} repeatCount="indefinite"/>
            </rect>
            <circle cx={x - 10} cy={y} r="2" fill="#22d3ee"/>
            <circle cx={x + 10} cy={y} r="2" fill="#22d3ee"/>
          </g>
        ))}
        {/* connecting wires */}
        {[
          ['M 40 60 Q 60 60 70 35', 0],
          ['M 40 60 Q 60 60 70 85', .3],
          ['M 90 35 Q 110 35 120 60', .6],
          ['M 90 85 Q 110 85 120 60', .9],
          ['M 140 60 L 160 60', 1.2],
        ].map(([d, delay], i) => (
          <path key={i} d={d} fill="none" stroke="#a855f7" strokeWidth="1" strokeDasharray="3 3" opacity=".7">
            <animate attributeName="stroke-dashoffset" from="0" to="-12" dur="1.2s" repeatCount="indefinite" begin={`${delay}s`}/>
          </path>
        ))}
      </svg>
    );
  }
  // RAG Playground — document chunks + retrieval
  if (title.includes('EDU')) {
    return (
      <svg className="artwork" viewBox="0 0 200 120" preserveAspectRatio="xMidYMid slice">
        <rect width="200" height="120" fill="#0f1410"/>
        {/* document chunks */}
        {Array.from({ length: 12 }).map((_, i) => {
          const col = i % 4;
          const row = Math.floor(i / 4);
          const x = 20 + col * 22;
          const y = 22 + row * 24;
          const highlighted = i === 2 || i === 6 || i === 9;
          return (
            <g key={i}>
              <rect x={x} y={y} width="18" height="18" rx="2" fill={highlighted ? '#000000' : '#22c55e'} opacity={highlighted ? .9 : .25}>
                {highlighted ? <animate attributeName="opacity" values=".4;1;.4" dur={`${1.5 + i * .1}s`} repeatCount="indefinite"/> : null}
              </rect>
              {/* lines inside chunk */}
              <line x1={x + 2} y1={y + 5} x2={x + 14} y2={y + 5} stroke="#fff" strokeWidth=".4" opacity=".5"/>
              <line x1={x + 2} y1={y + 9} x2={x + 12} y2={y + 9} stroke="#fff" strokeWidth=".4" opacity=".5"/>
              <line x1={x + 2} y1={y + 13} x2={x + 14} y2={y + 13} stroke="#fff" strokeWidth=".4" opacity=".5"/>
            </g>
          );
        })}
        {/* query node */}
        <circle cx="170" cy="60" r="8" fill="#22d3ee">
          <animate attributeName="r" values="6;9;6" dur="2s" repeatCount="indefinite"/>
        </circle>
        <text x="170" y="63" fill="#0f1410" fontSize="8" fontFamily="monospace" textAnchor="middle" fontWeight="700">Q</text>
        {/* retrieval lines */}
        {[[60, 30], [128, 54], [82, 78]].map(([x, y], i) => (
          <line key={i} x1="162" y1="60" x2={x} y2={y} stroke="#000000" strokeWidth=".7" opacity=".7" strokeDasharray="2 2">
            <animate attributeName="stroke-dashoffset" from="0" to="-8" dur="1s" repeatCount="indefinite"/>
          </line>
        ))}
      </svg>
    );
  }
  // fallback — animated gradient with glyph (current behavior)
  return (
    <svg className="artwork" viewBox="0 0 200 120" preserveAspectRatio="xMidYMid slice">
      <defs>
        <linearGradient id={`fb-${idx}`} x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor={`oklch(60% 0.18 ${(idx * 60) % 360})`}/>
          <stop offset="1" stopColor={`oklch(50% 0.2 ${(idx * 60 + 120) % 360})`}/>
        </linearGradient>
      </defs>
      <rect width="200" height="120" fill={`url(#fb-${idx})`}/>
      <text x="100" y="78" fill="#fff" fontSize="56" fontFamily="'Comic Neue', cursive" textAnchor="middle" opacity=".75">{title.charAt(0)}</text>
    </svg>
  );
}

// ─────────────── ALL PROJECTS GRID ───────────────
function AllProjects() {
  return (
    <section className="section grid-sec" id="grid">
      <SectionHeader num="05" label="More Projects" bleed="MORE · MORE · MORE" bleedStyle="solid" right={<span className="mono-sm muted">{S.otherProjects.length + S.featuredProjects.length} total</span>} />
      <div className="proj-grid">
        {S.otherProjects.map((p, i) => (
          <Reveal key={p.title} delay={i * 60} className="proj-card-wrap">
            <a href={p.url} target="_blank" rel="noopener noreferrer" className="proj-card">
              <div className="proj-card-art proj-card-art-svg">
                <MoreProjectArt title={p.title} idx={i} />
              </div>
              <div className="proj-card-body">
                <div className="mono-sm muted">{p.period}</div>
                <div className="proj-card-title">{p.title}</div>
                <div className="proj-card-tag">{p.tagline}</div>
                <div className="proj-card-chips">
                  {p.tags.slice(0, 3).map(t => <span key={t} className="chip">{t}</span>)}
                </div>
              </div>
            </a>
          </Reveal>
        ))}
      </div>
    </section>
  );
}

// ─────────────── EXPERIENCE ───────────────
function CompanyLogo({ src, name }) {
  const [ok, setOk] = React.useState(true);
  const initials = name.split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase();
  if (!src || !ok) {
    return <div className="exp-logo exp-logo-fallback" aria-label={name}>{initials}</div>;
  }
  return <img className="exp-logo" src={src} alt={`${name} logo`} onError={() => setOk(false)} />;
}

function Experience() {
  return (
    <section className="section exp" id="experience">
      <SectionHeader num="03" label="Experience" bleed="EXPERIENCE" bleedStyle="outline" />
      <div className="exp-list">
        {S.experience.map((e, i) => {
          const hasRoles = Array.isArray(e.roles) && e.roles.length > 0;
          return (
            <Reveal key={e.company + i} delay={i * 120} className="exp-item">
              <div className="exp-period mono-sm">{e.period}</div>
              <div className="exp-line" />
              <div className="exp-body">
                <div className="exp-head">
                  <CompanyLogo src={e.logo} name={e.company} />
                  <div className="exp-head-text">
                    <h3 className="exp-co-name">{e.company}</h3>
                    <div className="exp-meta mono-sm">
                      {e.type}{e.location ? ` · ${e.location}` : ''}
                    </div>
                  </div>
                </div>
                {hasRoles ? (
                  <ul className="exp-roles">
                    {e.roles.map((r, j) => (
                      <li key={j} className="exp-role-item">
                        <span className="exp-role-dot" />
                        <div className="exp-role-body">
                          <h4 className="exp-role">{r.role}</h4>
                          <div className="exp-role-period mono-sm">{r.period}</div>
                          {r.highlights && r.highlights.length > 0 && (
                            <ul className="exp-hl">
                              {r.highlights.slice(0, 5).map((h, k) => <li key={k}>{h}</li>)}
                            </ul>
                          )}
                        </div>
                      </li>
                    ))}
                  </ul>
                ) : (
                  <>
                    <h4 className="exp-role">{e.role}</h4>
                    <ul className="exp-hl">
                      {(e.highlights || []).slice(0, 5).map((h, j) => <li key={j}>{h}</li>)}
                    </ul>
                  </>
                )}
                {e.tags && e.tags.length > 0 && (
                  <div className="exp-chips">
                    {e.tags.map(t => <span key={t} className="chip">{t}</span>)}
                  </div>
                )}
              </div>
            </Reveal>
          );
        })}
      </div>
    </section>
  );
}

// ─────────────── SKILLS ───────────────
function Skills() {
  const groups = Object.entries(S.skills);
  return (
    <section className="section skills" id="skills">
      <Stamp style={{ top: '160px', right: '5%', transform: 'rotate(7deg)' }}>// production-tested</Stamp>
      <SectionHeader num="02" label="Stack" bleed="STACK · STACK" bleedStyle="solid" />
      <div className="skills-grid">
        {groups.map(([group, items], i) => (
          <Reveal key={group} delay={i * 80} className="skill-group">
            <div className="skill-group-title">{group}</div>
            <div className="skill-items">
              {items.map(it => (
                <span key={it} className="skill-pill">{it}</span>
              ))}
            </div>
          </Reveal>
        ))}
      </div>
    </section>
  );
}

// ─────────────── WRITING ───────────────
function Writing() {
  return (
    <section className="section writing" id="writing">
      <SectionHeader num="06" label="Writing" bleed="WRITING · NOTES" bleedStyle="outline" right={<a className="section-link" href="https://www.nskr.dev/blog" target="_blank">all posts →</a>} />
      <div className="writing-list">
        {S.posts.map((p, i) => (
          <Reveal key={p.title} delay={i * 120}>
            <a href="#" className="post">
              {p.isNew && <span className="new-badge">NEW</span>}
              <div className="post-date mono-sm">{p.date}</div>
              <div className="post-title">{p.title}</div>
              <div className="post-excerpt">{p.excerpt}</div>
              <div className="post-more mono-sm">read →</div>
            </a>
          </Reveal>
        ))}
      </div>
    </section>
  );
}

// ─────────────── EDUCATION + CERTS ───────────────
function EduCerts() {
  return (
    <section className="section edu">
      <SectionHeader num="07" label="Education & Certs" bleed="EDU · CERTS" bleedStyle="solid" />
      <div className="edu-grid">
        <div>
          <div className="subhead">Education</div>
          {S.education.map((e, i) => (
            <Reveal key={e.school} delay={i * 80} className="edu-item">
              <div className="mono-sm muted">{e.period}</div>
              <div className="edu-degree">{e.degree}</div>
              <div className="edu-school">{e.school}</div>
              <div className="edu-note">{e.note}</div>
            </Reveal>
          ))}
        </div>
        <div>
          <div className="subhead">Certifications</div>
          {S.certifications.map((c, i) => (
            <Reveal key={c.title} delay={i * 80} className="edu-item">
              <div className="mono-sm muted">{c.date}</div>
              <div className="edu-degree">{c.title}</div>
              <div className="edu-school">{c.issuer}</div>
            </Reveal>
          ))}
        </div>
      </div>
    </section>
  );
}

// ─────────────── CONTACT ───────────────
function Contact() {
  return (
    <section className="section contact" id="contact">
      <div className="contact-grid">
        <div>
          <div className="section-label">
            <span className="section-num">08</span>
            <span className="section-bar" />
            <span className="section-name">Contact</span>
          </div>
          <h2 className="h-huge">
            <FadeWords text="Got a hard" stagger={80}/>
            <br/>
            <FadeWords text="problem?" delay={200} stagger={80} style={{ fontStyle: 'italic', color: 'var(--accent)' }} />
            <br/>
            <FadeWords text="Let's build it." delay={400} stagger={80} />
          </h2>
          <a href={`mailto:${S.email}`} className="contact-email">
            <Scramble text={S.email} duration={1400} /> <span className="arr">→</span>
          </a>
        </div>
        <div className="contact-right">
          <div className="subhead">Elsewhere</div>
          {S.socials.map((s, i) => (
            <Reveal key={s.label} delay={i * 80}>
              <a href={s.url} target="_blank" rel="noopener noreferrer" className="social-link">
                <span>{s.label}</span>
                <span className="social-url mono-sm">{s.url.replace('https://', '').replace('mailto:', '')}</span>
                <span className="arr">↗</span>
              </a>
            </Reveal>
          ))}
        </div>
      </div>
      <footer className="footer">
        <div className="mono-sm">© 2026 · {S.name}</div>
        <div className="mono-sm muted">Built with care · coffee · ◆</div>
      </footer>
    </section>
  );
}

// ─────────────── HERO V6 — Vortex / Viktor Oddy style ───────────────
function HeroV6() {
  // marquee thumbs — pulled from your project tags / featured projects
  const PROJECTS = S.featuredProjects.concat(S.otherProjects.slice(0, 5));
  const THUMBS = PROJECTS.map((p, i) => ({
    title: p.title,
    tags: (p.tags || []).slice(0, 3).join(' · '),
    hue: [22, 260, 188, 12, 320, 80, 200, 40][i % 8],
    glyph: ['◆','◇','○','●','▲','▼','■','□'][i % 8],
  }));
  const row = [...THUMBS, ...THUMBS];

  // parallax for the social/avatar block
  const [scrollY, setScrollY] = React.useState(0);
  React.useEffect(() => {
    let raf = 0;
    const on = () => {
      cancelAnimationFrame(raf);
      raf = requestAnimationFrame(() => setScrollY(window.scrollY));
    };
    window.addEventListener('scroll', on, { passive: true });
    return () => { window.removeEventListener('scroll', on); cancelAnimationFrame(raf); };
  }, []);

  return (
    <section className="hero-v6" id="top">
      <div className="v6-inner">
        {/* Logo / wordmark */}
        <div className="v6-fade" style={{ animationDelay: '0.1s' }}>
          <div className="v6-logo">Narra Reddy</div>
        </div>

        {/* tagline (mono) */}
        <div className="v6-fade" style={{ animationDelay: '0.2s' }}>
          <div className="v6-tagline">The studio practice of NSKR</div>
        </div>

        {/* main heading — sans + serif italic mix */}
        <h1 className="v6-heading v6-fade" style={{ animationDelay: '0.3s' }}>
          <span className="v6-line">Build the <span className="v6-serif">next wave</span>,</span>
          <span className="v6-line">the <span className="v6-serif">agentic way.</span></span>
        </h1>

        {/* Body copy — three short paragraphs */}
        <div className="v6-body v6-fade" style={{ animationDelay: '0.4s' }}>
          <p>I spent the last two years inside production AI workflows — from real‑time pose detection to e‑commerce automations that saved teams 15+ hours every week.</p>
          <p>The studio is deliberately small. I lead the engineering on every project, backed by the open‑source tooling I trust: n8n, LangChain, Python, and a pile of MCP tools.</p>
          <p>Projects start at a focused two‑week sprint.</p>
        </div>

        {/* CTA pair */}
        <div className="v6-ctas v6-fade" style={{ animationDelay: '0.5s' }}>
          <a href={`mailto:${S.email}`} className="v6-btn v6-btn-primary">Start a chat</a>
          <a href="#work" className="v6-btn v6-btn-secondary">View projects</a>
        </div>

        {/* tiny availability row */}
        <div className="v6-avail v6-fade" style={{ animationDelay: '0.6s' }}>
          <span className="v6-dot" />
          <span>Open for projects · {S.location}</span>
        </div>
      </div>

      {/* infinite marquee strip */}
      <div className="v6-marquee">
        <div className="v6-marquee-track">
          {row.map((t, i) => (
            <div key={i} className="v6-thumb" style={{ '--hue': t.hue }}>
              <div className="v6-thumb-bg">
                <span className="v6-thumb-glyph">{t.glyph}</span>
                <span className="v6-thumb-grid" />
              </div>
              <div className="v6-thumb-meta">
                <span className="v6-thumb-title">{t.title}</span>
                <span className="v6-thumb-tags">{t.tags}</span>
              </div>
            </div>
          ))}
        </div>
      </div>

      {/* bottom-left mini stat block */}
      <div
        className="v6-stat"
        style={{ transform: `translateY(${Math.min(scrollY * 0.2, 60)}px)` }}
      >
        <div className="v6-stat-num">7+</div>
        <div className="v6-stat-label">years writing<br/>production code</div>
      </div>
    </section>
  );
}

Object.assign(window, { NavBar, Hero, HeroV6, HeroV7, Marquee, About, Featured, AllProjects, Experience, Skills, Writing, EduCerts, Contact });

// ─────────────── HERO V7 — Olivia/Vortex bold orange ───────────────
function HeroV7() {
  const SKILLS = [
  'React',
  'Node.js',
  'MongoDB',
  'OpenAI',
  'React Native',
  'TypeScript',
  'PostgreSQL',
  'Socket.IO',
  'Python',
  'MySQL',
  'Docker',
  'AWS',
  'Express.js',
  'Ollama',
  'Git',
  'JavaScript',
];
  const row = [...SKILLS, ...SKILLS];

  const [boost, setBoost] = React.useState(false);
  const [videoOk, setVideoOk] = React.useState(true);
  const [menuOpen, setMenuOpen] = React.useState(false);
  React.useEffect(() => {
    document.body.style.overflow = menuOpen ? 'hidden' : '';
    return () => { document.body.style.overflow = ''; };
  }, [menuOpen]);
  const closeMenu = () => setMenuOpen(false);

  // staged intro: 0=initial, 1=headline, 2=watermark, 3=portrait, 4=ambient (mono blocks)
  const [stage, setStage] = React.useState(0);
  React.useEffect(() => {
    const t1 = setTimeout(() => setStage(1), 250);   // headline rises
    const t2 = setTimeout(() => setStage(2), 1050);  // watermark blooms
    const t3 = setTimeout(() => setStage(3), 1850);  // portrait slides in
    const t4 = setTimeout(() => setStage(4), 2350);  // mono blocks + marquee
    return () => { clearTimeout(t1); clearTimeout(t2); clearTimeout(t3); clearTimeout(t4); };
  }, []);

  // JS-driven marquee — integer-pixel positions per frame = no subpixel shimmer
  const trackRef = React.useRef(null);
  const boostRef = React.useRef(false);
  React.useEffect(() => { boostRef.current = boost; }, [boost]);
  React.useEffect(() => {
    const track = trackRef.current;
    if (!track) return;
    let raf = 0;
    let pos = 0;       // current translateX in px (negative)
    let halfWidth = 0; // width of one duplicated half
    let lastT = performance.now();
    const baseSpeed = 60;   // px/sec
    const boostSpeed = 160; // px/sec
    const measure = () => { halfWidth = track.scrollWidth / 2; };
    measure();
    const ro = new ResizeObserver(measure);
    ro.observe(track);
    const tick = (now) => {
      const dt = Math.min(0.05, (now - lastT) / 1000);
      lastT = now;
      const speed = boostRef.current ? boostSpeed : baseSpeed;
      pos -= speed * dt;
      if (halfWidth > 0 && -pos >= halfWidth) pos += halfWidth;
      track.style.transform = `translate3d(${Math.round(pos)}px, 0, 0)`;
      raf = requestAnimationFrame(tick);
    };
    raf = requestAnimationFrame(tick);
    return () => { cancelAnimationFrame(raf); ro.disconnect(); };
  }, []);

  return (
    <section className="hero-v7" id="top" data-stage={stage}>
      <div className="v7-topbar">
        <div className="v7-brand">◆ RAHUL</div>
        <nav className="v7-nav">
          <a href="#work">PROJECTS</a>
          <a href="#writing">BLOG</a>
          <a href="#about">ABOUT</a>
          <a href={S.resume} target="_blank" rel="noreferrer">RESUME</a>
        </nav>
        <a href="#contact" className="v7-hire">
          // HIRE ME <span className="v7-hire-circle">↗</span>
        </a>
        <button
          className={`v7-burger ${menuOpen ? 'is-open' : ''}`}
          aria-label={menuOpen ? 'Close menu' : 'Open menu'}
          aria-expanded={menuOpen}
          onClick={() => setMenuOpen(o => !o)}
        >
          <span /><span /><span />
        </button>
      </div>

      <div className={`v7-mobile-menu ${menuOpen ? 'is-open' : ''}`} aria-hidden={!menuOpen}>
        <a href="#work" onClick={closeMenu}>PROJECTS</a>
        <a href="#writing" onClick={closeMenu}>BLOG</a>
        <a href="#about" onClick={closeMenu}>ABOUT</a>
        <a href={S.resume} target="_blank" rel="noreferrer" onClick={closeMenu}>RESUME ↗</a>
        <a href="#contact" className="v7-mobile-hire" onClick={closeMenu}>
          // HIRE ME <span className="v7-hire-circle">↗</span>
        </a>
      </div>

      <div className="v7-watermark" aria-hidden="true">
        <span className="v7-watermark-word">RAHUL</span>
      </div>

      <div className="v7-portrait">
        <img className="v7-avatar" src="avatar3.webp?v=4" alt="Rahul" loading="eager" decoding="async" fetchpriority="high" />
      </div>

      <h1 className="v7-headline" aria-label="SOFTWARE ENGINEER">
        <span className="v6-headline-line">DEVELOPER</span>
        
      </h1>

      <div className="v7-tagline">
        <div>// AUTOMATIONS THAT SHIP</div>
        <div className="v7-tagline-indent">WHILE YOU SLEEP</div>
      </div>

      <div className="v7-bio">
        <div>// I'M RAHUL — A SOFTWARE DEVELOPER</div>
        <div className="v7-bio-indent">BUILDING SCALABLE APPLICATIONS</div>
        <div>· OPEN TO PROJECTS.</div>
      </div>

      <div
        className={`v7-marquee ${boost ? 'boost' : ''}`}
        onMouseEnter={() => setBoost(true)}
        onMouseLeave={() => setBoost(false)}
      >
        <div className="v7-marquee-track" ref={trackRef}>
          {row.map((s, i) => (
            <span key={i} className="v7-marquee-item">{s}</span>
          ))}
        </div>
      </div>
    </section>
  );
}

function PortraitPlaceholder() {
  // Stylized silhouette — head, headphones/glasses, shoulders
  return (
    <svg className="v7-silhouette" viewBox="0 0 600 800" preserveAspectRatio="xMidYMax slice" aria-hidden="true">
      <defs>
        <radialGradient id="v7sg" cx="50%" cy="35%" r="60%">
          <stop offset="0%" stopColor="#fff" stopOpacity=".22" />
          <stop offset="100%" stopColor="#fff" stopOpacity="0" />
        </radialGradient>
      </defs>
      {/* shoulders + body */}
      <path
        d="M 60 800 L 60 660 Q 90 580 180 540 Q 230 520 240 480 Q 245 460 240 440 L 360 440 Q 355 460 360 480 Q 370 520 420 540 Q 510 580 540 660 L 540 800 Z"
        fill="rgba(0,0,0,.18)"
      />
      {/* neck */}
      <path d="M 250 470 L 250 410 L 350 410 L 350 470 Q 320 480 300 480 Q 280 480 250 470 Z" fill="rgba(0,0,0,.22)" />
      {/* head */}
      <ellipse cx="300" cy="290" rx="120" ry="150" fill="rgba(0,0,0,.25)" />
      {/* hair top */}
      <path d="M 180 240 Q 200 140 300 130 Q 400 140 420 240 Q 410 200 380 195 Q 340 185 300 195 Q 260 185 220 195 Q 190 200 180 240 Z" fill="rgba(0,0,0,.32)" />
      {/* glasses bar */}
      <rect x="195" y="280" width="210" height="42" rx="20" fill="rgba(255,255,255,.55)" />
      <rect x="200" y="285" width="92" height="32" rx="14" fill="rgba(255,255,255,.85)" />
      <rect x="308" y="285" width="92" height="32" rx="14" fill="rgba(255,255,255,.85)" />
      {/* highlight */}
      <ellipse cx="300" cy="280" rx="220" ry="280" fill="url(#v7sg)" />
    </svg>
  );
}
