const { useEffect, useRef, useState } = React;

/* ————————————————————————————————— Reveal on scroll */
function useReveal() {
  useEffect(() => {
    const els = document.querySelectorAll(".r");
    const vh = window.innerHeight;
    els.forEach((el) => {
      const r = el.getBoundingClientRect();
      if (r.top < vh * 0.95) el.classList.add("in");
    });
    const io = new IntersectionObserver(
      (entries) => entries.forEach((e) => {
        if (e.isIntersecting) { e.target.classList.add("in"); io.unobserve(e.target); }
      }),
      { threshold: 0, rootMargin: "0px 0px -8% 0px" }
    );
    els.forEach((el) => { if (!el.classList.contains("in")) io.observe(el); });
    return () => io.disconnect();
  }, []);
}

/* ————————————————————————————————— Parallax for key art */
function useParallax() {
  const [y, setY] = useState(0);
  useEffect(() => {
    const f = () => setY(Math.min(window.scrollY, 900));
    window.addEventListener("scroll", f, { passive: true });
    return () => window.removeEventListener("scroll", f);
  }, []);
  return y;
}

/* ————————————————————————————————— SVG key-art: sea at night with ship + fog + lantern
   Layered, atmospheric, minimal — not trying to be realistic. */
function KeyArt({ scroll = 0 }) {
  // Theatrical interior — heavy velvet drapes parted around a warm violet-green glow.
  // Reads as intimate, adult drama — not horror. Minimal, stylised, not literal.
  const oGlow = scroll * 0.05;
  const oDrapeL = scroll * 0.12;
  const oDrapeR = scroll * 0.12;
  const oFloor = scroll * 0.2;

  // Vertical pleat path for a drape panel
  const pleat = (x0, x1, yTop, yBot, folds) => {
    const w = x1 - x0;
    const step = w / folds;
    let d = `M ${x0} ${yTop} `;
    for (let i = 0; i <= folds; i++) {
      const x = x0 + i * step;
      const depth = (i % 2 === 0) ? 0 : 18;
      d += `L ${x} ${yBot - depth} `;
    }
    d += `L ${x1} ${yTop} Z`;
    return d;
  };

  return (
    <svg viewBox="0 0 1600 900" preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg">
      <defs>
        {/* back wall — deep moss green, slight vignette */}
        <radialGradient id="wall" cx="50%" cy="50%" r="70%">
          <stop offset="0%" stopColor="#1F5638" />
          <stop offset="45%" stopColor="#10331F" />
          <stop offset="100%" stopColor="#040B07" />
        </radialGradient>
        {/* central glow — violet heart bleeding into green */}
        <radialGradient id="heartGlow" cx="50%" cy="50%" r="50%">
          <stop offset="0%" stopColor="#D9C4F0" stopOpacity="0.55" />
          <stop offset="25%" stopColor="#B89AE3" stopOpacity="0.4" />
          <stop offset="55%" stopColor="#8E5ED0" stopOpacity="0.22" />
          <stop offset="100%" stopColor="#8E5ED0" stopOpacity="0" />
        </radialGradient>
        <radialGradient id="heartCore" cx="50%" cy="50%" r="50%">
          <stop offset="0%" stopColor="#F5EBD6" stopOpacity="0.5" />
          <stop offset="60%" stopColor="#F5EBD6" stopOpacity="0" />
        </radialGradient>
        {/* drape gradients — left lit, right lit */}
        <linearGradient id="drapeL" x1="0" x2="1">
          <stop offset="0%" stopColor="#061812" />
          <stop offset="55%" stopColor="#0B2418" />
          <stop offset="90%" stopColor="#1F5638" />
          <stop offset="100%" stopColor="#2D7A52" />
        </linearGradient>
        <linearGradient id="drapeR" x1="1" x2="0">
          <stop offset="0%" stopColor="#061812" />
          <stop offset="55%" stopColor="#0B2418" />
          <stop offset="90%" stopColor="#1F5638" />
          <stop offset="100%" stopColor="#2D7A52" />
        </linearGradient>
        {/* inner violet rim on drape edge (where light grazes) */}
        <linearGradient id="rimL" x1="0" x2="1">
          <stop offset="0%" stopColor="#8E5ED0" stopOpacity="0" />
          <stop offset="90%" stopColor="#8E5ED0" stopOpacity="0" />
          <stop offset="100%" stopColor="#B89AE3" stopOpacity="0.55" />
        </linearGradient>
        <linearGradient id="rimR" x1="1" x2="0">
          <stop offset="0%" stopColor="#8E5ED0" stopOpacity="0" />
          <stop offset="90%" stopColor="#8E5ED0" stopOpacity="0" />
          <stop offset="100%" stopColor="#B89AE3" stopOpacity="0.55" />
        </linearGradient>

        {/* floor — dark polished surface */}
        <linearGradient id="floorG" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0%" stopColor="#0B2418" />
          <stop offset="100%" stopColor="#020604" />
        </linearGradient>

        <filter id="softBlur"><feGaussianBlur stdDeviation="8" /></filter>
        <filter id="heavyBlur"><feGaussianBlur stdDeviation="32" /></filter>
      </defs>

      {/* back wall */}
      <rect width="1600" height="900" fill="url(#wall)" />

      {/* distant violet haze layer */}
      <ellipse cx="800" cy="420" rx="760" ry="380" fill="#8E5ED0" opacity="0.12" filter="url(#heavyBlur)" />

      {/* central warm glow — the "stage light" */}
      <g transform={`translate(0 ${-oGlow})`}>
        <ellipse cx="800" cy="440" rx="520" ry="340" fill="url(#heartGlow)" />
        <ellipse cx="800" cy="460" rx="240" ry="160" fill="url(#heartCore)" />
      </g>

      {/* subtle floating dust motes — warm violet-ivory */}
      <g opacity="0.55">
        {Array.from({length: 26}).map((_, i) => {
          const x = 300 + (i * 46.5) % 1000;
          const y = 200 + (i * 37) % 500;
          const r = (i % 5 === 0) ? 1.6 : 0.8;
          const c = i % 3 === 0 ? "#B89AE3" : "#F5EBD6";
          return <circle key={i} cx={x} cy={y} r={r} fill={c} opacity={0.25 + (i % 4) * 0.1} />;
        })}
      </g>

      {/* floor */}
      <g transform={`translate(0 ${-oFloor})`}>
        <rect x="0" y="720" width="1600" height="180" fill="url(#floorG)" />
        {/* floor reflection of centre glow */}
        <ellipse cx="800" cy="740" rx="480" ry="36" fill="#B89AE3" opacity="0.18" filter="url(#softBlur)" />
        <ellipse cx="800" cy="760" rx="320" ry="20" fill="#F5EBD6" opacity="0.12" filter="url(#softBlur)" />
        {/* horizon line between wall and floor */}
        <rect x="0" y="718" width="1600" height="1.5" fill="#8E5ED0" opacity="0.35" />
      </g>

      {/* LEFT drape — parted, hanging from top, revealing centre */}
      <g transform={`translate(${-oDrapeL} 0)`}>
        {/* drape body */}
        <path d="M 0 0 L 520 0 Q 440 260 360 480 Q 300 660 260 900 L 0 900 Z"
              fill="url(#drapeL)" />
        {/* vertical pleats — dark lines */}
        <g stroke="#040B07" strokeOpacity="0.55" strokeWidth="1.2" fill="none">
          <path d="M 60 0 Q 52 240 40 500 Q 30 700 20 900" />
          <path d="M 140 0 Q 124 240 108 500 Q 94 700 82 900" />
          <path d="M 220 0 Q 200 240 180 500 Q 160 700 148 900" />
          <path d="M 300 0 Q 276 240 252 500 Q 228 700 214 900" />
          <path d="M 380 0 Q 352 240 322 500 Q 292 700 272 900" />
          <path d="M 460 0 Q 428 240 396 500 Q 358 700 328 900" />
        </g>
        {/* highlight pleats — moss green catching the centre light */}
        <g stroke="#4FB581" strokeOpacity="0.25" strokeWidth="0.8" fill="none">
          <path d="M 100 0 Q 90 240 76 500 Q 62 700 50 900" />
          <path d="M 260 0 Q 238 240 216 500 Q 194 700 180 900" />
          <path d="M 420 0 Q 392 240 362 500 Q 326 700 300 900" />
        </g>
        {/* inner edge rim light — violet */}
        <path d="M 500 0 Q 420 260 340 480 Q 280 660 240 900 L 280 900 Q 320 660 380 480 Q 460 260 540 0 Z"
              fill="url(#rimL)" opacity="0.9" />
        {/* soft shadow where drape meets floor */}
        <ellipse cx="200" cy="880" rx="260" ry="18" fill="#020604" opacity="0.7" filter="url(#softBlur)" />
      </g>

      {/* RIGHT drape — mirror */}
      <g transform={`translate(${oDrapeR} 0)`}>
        <path d="M 1600 0 L 1080 0 Q 1160 260 1240 480 Q 1300 660 1340 900 L 1600 900 Z"
              fill="url(#drapeR)" />
        <g stroke="#040B07" strokeOpacity="0.55" strokeWidth="1.2" fill="none">
          <path d="M 1540 0 Q 1548 240 1560 500 Q 1570 700 1580 900" />
          <path d="M 1460 0 Q 1476 240 1492 500 Q 1506 700 1518 900" />
          <path d="M 1380 0 Q 1400 240 1420 500 Q 1440 700 1452 900" />
          <path d="M 1300 0 Q 1324 240 1348 500 Q 1372 700 1386 900" />
          <path d="M 1220 0 Q 1248 240 1278 500 Q 1308 700 1328 900" />
          <path d="M 1140 0 Q 1172 240 1204 500 Q 1242 700 1272 900" />
        </g>
        <g stroke="#4FB581" strokeOpacity="0.25" strokeWidth="0.8" fill="none">
          <path d="M 1500 0 Q 1510 240 1524 500 Q 1538 700 1550 900" />
          <path d="M 1340 0 Q 1362 240 1384 500 Q 1406 700 1420 900" />
          <path d="M 1180 0 Q 1208 240 1238 500 Q 1274 700 1300 900" />
        </g>
        <path d="M 1100 0 Q 1180 260 1260 480 Q 1320 660 1360 900 L 1320 900 Q 1280 660 1220 480 Q 1140 260 1060 0 Z"
              fill="url(#rimR)" opacity="0.9" />
        <ellipse cx="1400" cy="880" rx="260" ry="18" fill="#020604" opacity="0.7" filter="url(#softBlur)" />
      </g>

      {/* valance — a swag hanging from top across the gap, partially obscuring upper glow */}
      <path d="M 460 0 Q 600 120 800 140 Q 1000 120 1140 0 L 1140 40 Q 1000 160 800 180 Q 600 160 460 40 Z"
            fill="#0B2418" opacity="0.95" />
      <path d="M 460 0 Q 600 120 800 140 Q 1000 120 1140 0"
            stroke="#B89AE3" strokeWidth="1" strokeOpacity="0.3" fill="none" />

      {/* centre vignette — darken below-logo zone for text contrast */}
      <ellipse cx="800" cy="460" rx="620" ry="200" fill="#040B07" opacity="0.35" filter="url(#heavyBlur)" />

      {/* final bottom gradient — help the hero bottom text */}
      <rect x="0" y="700" width="1600" height="200" fill="url(#floorG)" opacity="0.5" />
    </svg>
  );
}

/* ————————————————————————————————— Nav */
function Nav() {
  const [scrolled, setScrolled] = useState(false);
  useEffect(() => {
    const f = () => setScrolled(window.scrollY > 40);
    window.addEventListener("scroll", f, { passive: true });
    return () => window.removeEventListener("scroll", f);
  }, []);
  return (
    <nav className={`nav ${scrolled ? "scrolled" : ""}`}>
      <a href="#top" className="brand">Wicked Tales <span className="dot">·</span> Interactive</a>
      <ul>
        <li><a href="#studio">Studio</a></li>
        <li><a href="#work">Work</a></li>
        <li><a href="#principles">Principles</a></li>
        <li><a href="#join">Join</a></li>
      </ul>
    </nav>
  );
}

/* ————————————————————————————————— Hero */
function Hero() {
  const y = useParallax();
  return (
    <section id="top" className="hero">
      <div className="keyart"><KeyArt scroll={y} /></div>
      <div className="hero-vignette" />
      <div className="hero-inner">
        <div className="hero-rule r" />
        <div className="hero-kicker r">
          Independent Studio <span className="bul">·</span> Est. 2025
        </div>
        <h1 className="hero-mark r">
          <span className="l1">Wicked Tales</span>
          <span className="l2">Interactive</span>
        </h1>
        <p className="hero-tag r">Adult visual novels for readers who stay for the story.</p>
      </div>
      <div className="hero-bottom">
        <span>01 / Wicked Tales Interactive</span>
        <span className="hero-scroll"><span className="bar" /><span>Scroll</span></span>
        <span>Adults · 18+</span>
      </div>
    </section>
  );
}

/* ————————————————————————————————— Studio */
function Studio() {
  return (
    <section id="studio">
      <div className="wrap">
        <div className="sec-tag r"><span className="n">01</span><span className="sep">/</span> The Studio</div>
        <h2 className="sec-title r">A small studio making <em>adult visual novels</em>, written for readers first.</h2>

        <div className="studio-grid">
          <div className="studio-body r">
            <p className="lead">We write before we build. The prose is the <em>engine</em> — every scene, every choice, every silence is drafted on the page.</p>
            <p>We are a small independent studio founded in 2025. We work slowly. We believe adult narrative deserves the same craft as any other form: characters with interior lives, worlds built by the sentence, scenes written rather than assembled.</p>
            <p>We answer to no one but the story.</p>
          </div>
          <aside className="studio-meta r">
            <div className="row"><div className="k">Founded</div><div className="v">2025</div></div>
            <div className="row"><div className="k">Form</div><div className="v">Visual novel</div></div>
            <div className="row"><div className="k">Register</div><div className="v"><em>Adult, literary</em></div></div>
            <div className="row"><div className="k">Rating</div><div className="v">18+</div></div>
            <div className="row"><div className="k">Status</div><div className="v" style={{color:"var(--plum-bright)"}}>Independent</div></div>
          </aside>
        </div>
      </div>
    </section>
  );
}

/* ————————————————————————————————— Featured project cover
   Put a file at assets/pirate-privates-loot/cover.jpg (or .png / .webp)
   and it will replace the stylised SVG fallback. */
const PROJECT_COVER_SRC = "assets/pirate-privates-loot/cover.webp";

function ProjectCover() {
  const [hasImg, setHasImg] = React.useState(null); // null = unknown, true/false = checked
  React.useEffect(() => {
    const img = new Image();
    img.onload = () => setHasImg(true);
    img.onerror = () => setHasImg(false);
    img.src = PROJECT_COVER_SRC;
  }, []);

  if (hasImg) {
    return (
      <div className="proj-cover">
        <img src={PROJECT_COVER_SRC} alt="Pirate Privates Loot — cover art"
             style={{width:"100%", height:"100%", objectFit:"cover", display:"block"}} />
        <div className="proj-cover-gradient" />
        <div className="proj-cover-chip"><span className="pulse" />Early Access</div>
        <div className="proj-cover-meta">Chapters I – III<br/><span style={{color:"var(--plum-bright)"}}>Now playing</span></div>
      </div>
    );
  }

  return (
    <div className="proj-cover">
      <svg viewBox="0 0 1600 900" preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg">
        <defs>
          <linearGradient id="pcSky" x1="0" x2="0" y1="0" y2="1">
            <stop offset="0%" stopColor="#1A0F2E" />
            <stop offset="50%" stopColor="#0C1A12" />
            <stop offset="100%" stopColor="#050D09" />
          </linearGradient>
          <radialGradient id="pcMoon">
            <stop offset="0%" stopColor="#EAE3D2" stopOpacity="0.9" />
            <stop offset="55%" stopColor="#B89AE3" stopOpacity="0.4" />
            <stop offset="100%" stopColor="#8E5ED0" stopOpacity="0" />
          </radialGradient>
          <radialGradient id="pcLantern">
            <stop offset="0%" stopColor="#E8B76E" stopOpacity="0.95" />
            <stop offset="55%" stopColor="#E8B76E" stopOpacity="0.25" />
            <stop offset="100%" stopColor="#E8B76E" stopOpacity="0" />
          </radialGradient>
          <linearGradient id="pcFog" x1="0" x2="1">
            <stop offset="0%" stopColor="#2D7A52" stopOpacity="0" />
            <stop offset="50%" stopColor="#2D7A52" stopOpacity="0.35" />
            <stop offset="100%" stopColor="#2D7A52" stopOpacity="0" />
          </linearGradient>
          <filter id="pcBlur"><feGaussianBlur stdDeviation="14" /></filter>
          <filter id="pcBlurS"><feGaussianBlur stdDeviation="4" /></filter>
        </defs>

        <rect width="1600" height="900" fill="url(#pcSky)" />
        <ellipse cx="400" cy="260" rx="420" ry="200" fill="#8E5ED0" opacity="0.16" filter="url(#pcBlur)" />

        {/* moon */}
        <circle cx="340" cy="240" r="140" fill="url(#pcMoon)" />
        <circle cx="340" cy="240" r="52" fill="#EAE3D2" opacity="0.8" />

        {/* stars */}
        <g fill="#EAE3D2" opacity="0.55">
          {Array.from({length: 40}).map((_, i) => {
            const x = (i * 211) % 1600;
            const y = (i * 53) % 440;
            return <circle key={i} cx={x} cy={y} r={i % 6 === 0 ? 1.2 : 0.6} />;
          })}
        </g>

        {/* cliff/headland right */}
        <path d="M 1100 900 L 1100 520 Q 1180 490 1260 510 Q 1340 530 1400 500 Q 1480 475 1600 500 L 1600 900 Z"
              fill="#050D09" />
        <g fill="#030806" opacity="0.9">
          {/* castle silhouette on cliff */}
          <rect x="1240" y="440" width="12" height="80" />
          <rect x="1256" y="460" width="10" height="60" />
          <rect x="1270" y="430" width="16" height="90" />
          <rect x="1290" y="450" width="10" height="70" />
          <rect x="1304" y="440" width="14" height="80" />
          <polygon points="1240,440 1246,428 1252,440" />
          <polygon points="1270,430 1278,416 1286,430" />
          <polygon points="1304,440 1311,426 1318,440" />
        </g>

        {/* sea */}
        <rect x="0" y="520" width="1600" height="380" fill="#050D09" />

        {/* horizon fog */}
        <ellipse cx="800" cy="560" rx="1000" ry="22" fill="url(#pcFog)" filter="url(#pcBlur)" />

        {/* far ships, small */}
        <g opacity="0.45" stroke="#4FB581" strokeWidth="0.4" fill="#050D09">
          <g transform="translate(180 540)">
            <line x1="0" y1="0" x2="0" y2="-36" />
            <path d="M -14 0 L 14 0 L 10 6 L -10 6 Z" />
          </g>
          <g transform="translate(1420 560)">
            <line x1="0" y1="0" x2="0" y2="-40" />
            <path d="M -16 0 L 16 0 L 12 6 L -12 6 Z" />
          </g>
        </g>

        {/* MAIN SHIP — pirate vessel, hero-left composition */}
        <g transform="translate(820 540)">
          {/* halo behind */}
          <ellipse cx="0" cy="100" rx="360" ry="50" fill="#E8B76E" opacity="0.08" filter="url(#pcBlur)" />
          <ellipse cx="0" cy="80" rx="280" ry="40" fill="#8E5ED0" opacity="0.14" filter="url(#pcBlur)" />

          {/* hull */}
          <path d="M -220 100 Q -200 140 -140 150 L 140 150 Q 200 140 220 100 L 196 90 L -196 90 Z"
                fill="#050D09" stroke="#4FB581" strokeWidth="1" strokeOpacity="0.4" />
          <path d="M -196 90 L 196 90" stroke="#4FB581" strokeWidth="0.5" strokeOpacity="0.3" />
          {/* hull windows */}
          {[-120, -80, -40, 0, 40, 80, 120].map((x) => (
            <circle key={x} cx={x} cy="110" r="2" fill="#E8B76E" opacity="0.9" />
          ))}

          {/* masts */}
          <line x1="-120" y1="90" x2="-120" y2="-200" stroke="#0A1812" strokeWidth="3" />
          <line x1="0" y1="90" x2="0" y2="-260" stroke="#0A1812" strokeWidth="3.5" />
          <line x1="120" y1="90" x2="120" y2="-210" stroke="#0A1812" strokeWidth="3" />

          {/* sails — black with green hint */}
          <path d="M -6 -250 Q 68 -200 -6 -150 Z" fill="#0E231A" stroke="#4FB581" strokeWidth="0.6" strokeOpacity="0.5" />
          <path d="M -6 -250 Q -80 -200 -6 -150 Z" fill="#0E231A" stroke="#4FB581" strokeWidth="0.6" strokeOpacity="0.5" />
          <path d="M -6 -140 Q 70 -90 -6 -40 Z" fill="#0E231A" stroke="#4FB581" strokeWidth="0.5" strokeOpacity="0.45" />
          <path d="M -6 -140 Q -80 -90 -6 -40 Z" fill="#0E231A" stroke="#4FB581" strokeWidth="0.5" strokeOpacity="0.45" />

          <path d="M -126 -190 Q -86 -146 -126 -104 Z" fill="#0E231A" stroke="#4FB581" strokeWidth="0.45" strokeOpacity="0.45" />
          <path d="M -126 -190 Q -166 -146 -126 -104 Z" fill="#0E231A" stroke="#4FB581" strokeWidth="0.45" strokeOpacity="0.45" />
          <path d="M -126 -90 Q -90 -54 -126 -16 Z" fill="#0E231A" stroke="#4FB581" strokeWidth="0.4" strokeOpacity="0.4" />
          <path d="M -126 -90 Q -160 -54 -126 -16 Z" fill="#0E231A" stroke="#4FB581" strokeWidth="0.4" strokeOpacity="0.4" />

          <path d="M 114 -200 Q 160 -154 114 -110 Z" fill="#0E231A" stroke="#4FB581" strokeWidth="0.45" strokeOpacity="0.45" />
          <path d="M 114 -200 Q 70 -154 114 -110 Z" fill="#0E231A" stroke="#4FB581" strokeWidth="0.45" strokeOpacity="0.45" />
          <path d="M 114 -100 Q 154 -58 114 -20 Z" fill="#0E231A" stroke="#4FB581" strokeWidth="0.4" strokeOpacity="0.4" />
          <path d="M 114 -100 Q 76 -58 114 -20 Z" fill="#0E231A" stroke="#4FB581" strokeWidth="0.4" strokeOpacity="0.4" />

          {/* flag on top — violet */}
          <path d="M 0 -260 L 34 -250 L 26 -244 L 34 -238 L 0 -230 Z" fill="#8E5ED0" opacity="0.9" />

          {/* rigging */}
          <g stroke="#4FB581" strokeWidth="0.3" strokeOpacity="0.35" fill="none">
            <line x1="-120" y1="-200" x2="0" y2="-120" />
            <line x1="120" y1="-210" x2="0" y2="-130" />
            <line x1="-220" y1="95" x2="0" y2="-260" />
            <line x1="220" y1="95" x2="0" y2="-260" />
            <line x1="-120" y1="-200" x2="-220" y2="95" />
            <line x1="120" y1="-210" x2="220" y2="95" />
          </g>

          {/* lanterns */}
          <circle cx="200" cy="76" r="3.5" fill="#E8B76E" />
          <circle cx="200" cy="76" r="36" fill="url(#pcLantern)" />
          <circle cx="200" cy="76" r="78" fill="url(#pcLantern)" opacity="0.6" filter="url(#pcBlurS)" />

          <circle cx="-200" cy="76" r="3" fill="#E8B76E" />
          <circle cx="-200" cy="76" r="30" fill="url(#pcLantern)" opacity="0.85" />

          <circle cx="0" cy="-250" r="2" fill="#B89AE3" />
          <circle cx="0" cy="-250" r="16" fill="#8E5ED0" opacity="0.35" filter="url(#pcBlurS)" />
        </g>

        {/* reflection */}
        <g opacity="0.8">
          <path d="M 620 660 Q 820 668 1020 660 L 1020 674 Q 820 684 620 674 Z" fill="#E8B76E" opacity="0.14" filter="url(#pcBlurS)" />
          <path d="M 680 690 Q 820 694 960 690 L 960 700 Q 820 706 680 700 Z" fill="#EAE3D2" opacity="0.1" filter="url(#pcBlurS)" />
          <path d="M 540 730 Q 820 738 1100 730 L 1100 736 Q 820 746 540 738 Z" fill="#8E5ED0" opacity="0.2" filter="url(#pcBlurS)" />
        </g>

        {/* fg fog */}
        <ellipse cx="800" cy="820" rx="1200" ry="50" fill="url(#pcFog)" filter="url(#pcBlur)" opacity="0.9" />
        <ellipse cx="400" cy="760" rx="500" ry="28" fill="#4FB581" opacity="0.1" filter="url(#pcBlur)" />
      </svg>

      <div className="proj-cover-gradient" />
      <div className="proj-cover-chip"><span className="pulse" />Early Access</div>
      <div className="proj-cover-meta">Chapters I – III<br/><span style={{color:"var(--plum-bright)"}}>Now playing</span></div>
    </div>
  );
}

function Work() {
  return (
    <section id="work">
      <div className="wrap">
        <div className="sec-tag r"><span className="n">02</span><span className="sep">/</span> Current Work</div>
        <h2 className="sec-title r">One voyage, already <em>in the water</em>.</h2>

        <article className="proj r">
          <ProjectCover />
          <div className="proj-info">
            <div>
              <h3 className="proj-title">Pirate Privates <em>Loot</em></h3>
              <p className="proj-desc">An adult visual novel set in the world of <em className="l">One Piece</em>. Join the Straw Hats and sail the Grand Line one city at a time — from Shells Town to Syrup Village to the Baratie — as your choices shape trust, affection, and respect with each crewmate.</p>
              <p className="proj-desc" style={{marginTop: "18px"}}>Full date system with layered events and minigames woven into the story. Take Nami on a beach picnic, a bar night, or a luxury dinner — what you say and how you read the moment decides the ending. Available in English, Spanish, French, Italian &amp; Portuguese, with regular updates.</p>
            </div>
            <div className="proj-side">
              <div className="proj-specs">
                <div className="row"><span className="k">Form</span><span className="v">Visual Novel</span></div>
                <div className="row"><span className="k">Status</span><span className="v plum">Early Access</span></div>
                <div className="row"><span className="k">Rating</span><span className="v">Adults · 18+</span></div>
                <div className="row"><span className="k">Chapters</span><span className="v">I – III Live</span></div>
              </div>
              <a className="proj-cta" href="https://pirateprivateloot.wickedtalesinteractive.com" target="_blank" rel="noopener noreferrer">
                <span>Play / Learn more</span>
                <span className="arrow">→</span>
              </a>
            </div>
          </div>
        </article>
      </div>
    </section>
  );
}

/* ————————————————————————————————— Principles */
const IconQuill = () => (
  <svg className="icon" viewBox="0 0 48 48" fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round">
    <path d="M8 40 L20 28" />
    <path d="M14 34 C 18 18, 30 8, 42 6 C 40 18, 30 30, 14 34 Z" />
    <path d="M20 28 L 28 20" strokeOpacity="0.5" />
  </svg>
);
const IconLamp = () => (
  <svg className="icon" viewBox="0 0 48 48" fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round">
    <path d="M24 4 L24 10" />
    <path d="M16 16 L32 16 L28 32 L20 32 Z" />
    <ellipse cx="24" cy="16" rx="8" ry="1.5" />
    <path d="M20 32 L20 40 L28 40 L28 32" />
    <circle cx="24" cy="24" r="2.5" strokeOpacity="0.7" />
  </svg>
);
const IconFog = () => (
  <svg className="icon" viewBox="0 0 48 48" fill="none" stroke="currentColor" strokeLinecap="round">
    <path d="M6 14 H 30" />
    <path d="M12 22 H 42" strokeOpacity="0.85" />
    <path d="M6 30 H 34" strokeOpacity="0.6" />
    <path d="M16 38 H 40" strokeOpacity="0.4" />
  </svg>
);

function Principles() {
  const items = [
    { icon: <IconQuill />, n: "i.", h: <>Narrative <em>craft</em>.</>, p: "Prose is the engine. We write scenes rather than scripts and revise until the sentences carry their own weight." },
    { icon: <IconLamp />,  n: "ii.", h: <>Mature, not <em>exploitative</em>.</>, p: "Adult material earns its place by the same rules as every other scene: it tells us who these people are." },
    { icon: <IconFog />,   n: "iii.", h: <>Atmosphere over <em>spectacle</em>.</>, p: "Mood, weather, silence. We'd rather build a room you can feel than a cinematic you can't remember." },
  ];
  return (
    <section id="principles">
      <div className="wrap">
        <div className="sec-tag r"><span className="n">03</span><span className="sep">/</span> Principles</div>
        <h2 className="sec-title r">Three rules. <em>No manifesto wall.</em></h2>
        <div className="phil-grid r">
          {items.map((it) => (
            <div key={it.n} className="phil-cell">
              <div className="top">{it.icon}<span className="pn">{it.n}</span></div>
              <div>
                <h3 className="ph">{it.h}</h3>
                <p className="pp">{it.p}</p>
              </div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

/* ————————————————————————————————— Community */
const IconPatreon = () => (
  <svg className="icon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
    <circle cx="15" cy="9.5" r="5.5" />
    <rect x="3" y="4" width="3" height="17" />
  </svg>
);
const IconItch = () => (
  <svg className="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" aria-hidden="true">
    <path d="M3 6 L12 3 L21 6 L21 10 L3 10 Z" />
    <path d="M4 10 L4 20 L20 20 L20 10" />
    <path d="M10 14 L14 14 L14 18 L10 18 Z" />
  </svg>
);

function Community() {
  return (
    <section id="join" className="community">
      <div className="community-inner">
        <div className="sec-tag r" style={{justifyContent:"center"}}><span className="n">04</span><span className="sep">/</span> Correspondence</div>
        <h2 className="r">Follow the <em>voyage</em>.</h2>
        <p className="sub r">New chapters, design notes, and the occasional postcard from port.</p>
        <div className="comm-btns r">
          <a className="btn green" href="https://www.patreon.com/c/PiratePrivateLoot" target="_blank" rel="noopener noreferrer">
            <IconPatreon /><span>Patreon</span>
          </a>
          <a className="btn plum" href="https://wicked2509.itch.io" target="_blank" rel="noopener noreferrer">
            <IconItch /><span>itch.io</span>
          </a>
        </div>
        <p className="legal r">All characters depicted are fictional adults 18+. Fan-made. Not affiliated with original rights holders.</p>
      </div>
    </section>
  );
}

function Footer() {
  return (
    <footer>
      <div className="foot-inner">
        <div className="foot-brand">Wicked Tales <span className="dot">·</span> Interactive</div>
        <div className="foot-copy">© 2026 Wicked Tales Interactive</div>
        <div className="foot-links">
          <a href="https://www.patreon.com/c/PiratePrivateLoot" target="_blank" rel="noopener noreferrer">Patreon</a>
          <a href="https://wicked2509.itch.io" target="_blank" rel="noopener noreferrer">itch.io</a>
        </div>
      </div>
    </footer>
  );
}

function App() {
  useReveal();
  return (
    <>
      <Nav />
      <Hero />
      <Studio />
      <Work />
      <Principles />
      <Community />
      <Footer />
    </>
  );
}

ReactDOM.createRoot(document.getElementById("root")).render(<App />);
