<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Liz Personal Compact — V2</title>
<meta name="description" content="A compact personal-site template with editorial warmth, systems structure, and lightweight motion." />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:wght@400&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
<style>
:root {
  --paper: #faf9f5;
  --paper-warm: #fffdf8;
  --paper-muted: #f1eee6;
  --ink: #141413;
  --ink-soft: #3a3630;
  --muted: #716d64;
  --faint: #9b9488;
  --line: #ddd7ca;
  --line-strong: #c9c1b1;
  --accent: #b14e22;
  --blue: #4f6f8f;
  --green: #6f8f72;
  --selection: #c0fe04;
  --container: 1120px;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --ease-66: cubic-bezier(0.66, 0, 0.01, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection { background: var(--selection); color: #000; }

a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-weight: 400; }

/* ── Canvas background ────────────────────────────── */
#bg-canvas {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.06;
}

/* ── Layout ────────────────────────────────────────── */
.container { width: min(var(--container), calc(100% - 40px)); margin: 0 auto; position: relative; z-index: 1; }
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); }

/* ── Scroll reveal ─────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.8s var(--ease-66), transform 0.8s var(--ease-66); }
.reveal.in { opacity: 1; transform: translateY(0); }

/* ── Dotted hover (haoqi signature) ─────────────────── */
.dot-hover { position: relative; }
.dot-hover::before {
  content: "";
  position: absolute; inset: 0;
  border: 2px dotted transparent;
  pointer-events: none;
  transition: border-color 0.2s;
  z-index: 1;
}
.dot-hover:hover::before { border-color: var(--ink); }

/* ── Mono label ─────────────────────────────────────── */
.mono {
  font-family: var(--mono);
  font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
}
.mono-accent { color: var(--accent); }

/* ── Header ────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 249, 245, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--sans); font-weight: 600; font-size: 0.875rem; letter-spacing: -0.02em; }
.brand-mark {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 999px;
  background: var(--ink); color: var(--paper);
  font-size: 13px; font-weight: 700;
}
.nav-links { display: flex; gap: 20px; }
.nav-links a { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); transition: color 0.15s; }
.nav-links a:hover { color: var(--ink); }
.nav-links a.active { color: var(--ink); font-weight: 500; }
.sys-strip { display: flex; align-items: center; gap: 12px; }
.live-dot { display: inline-block; width: 6px; height: 6px; border-radius: 999px; background: var(--green); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* ── Hero ──────────────────────────────────────────── */
.hero { padding: 100px 0 80px; }
.hero-grid { grid-template-columns: minmax(0, 0.95fr) minmax(380px, 0.85fr); gap: 60px; align-items: center; }
.hero-label { margin-bottom: 20px; }
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(44px, 6.5vw, 80px);
  font-weight: 400; line-height: 1; letter-spacing: -0.025em;
  max-width: 780px;
}
.hero h1 .accent { color: var(--accent); }
.hero h1 .blue { color: var(--blue); }
.hero-sub {
  font-family: var(--serif); font-size: clamp(18px, 1.6vw, 22px);
  line-height: 1.6; color: var(--muted); max-width: 600px;
  margin-top: 22px;
}
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.tag {
  padding: 0.2em 0.6em; border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--sans); font-size: 0.72rem; font-weight: 500;
  color: var(--muted); background: rgba(255,253,248,0.6);
  transition: border-color 0.15s, color 0.15s;
}
.tag:hover { border-color: var(--accent); color: var(--ink); }

/* ── Hero panel (3D tilt card) ─────────────────────── */
.hero-panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,253,248,0.96), rgba(241,238,230,0.72));
  box-shadow: 0 22px 70px rgba(43,37,27,0.09);
  overflow: hidden;
  transform-style: preserve-3d;
  transition: transform 0.3s var(--ease-66);
  min-height: 460px;
}
.hero-panel-tilt {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.5s var(--ease-66);
}
.panel-bar { border-bottom: 1px solid var(--line); padding: 16px 20px; display: flex; justify-content: space-between; font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); }
.panel-stage { position: relative; min-height: 400px; display: grid; place-items: center; }
.orbit { position: absolute; top: 50%; left: 50%; border-radius: 50%; transform: translate(-50%, -50%); }
.orbit-a { width: 280px; height: 280px; border: 1px solid rgba(177,78,34,0.18); }
.orbit-b { width: 190px; height: 190px; border: 1px solid rgba(79,111,143,0.16); }
.orbit-c { width: 110px; height: 110px; border: 1px solid rgba(111,143,114,0.18); }
.node { position: absolute; width: 12px; height: 12px; border-radius: 999px; box-shadow: 0 0 0 10px rgba(255,255,255,0.16); transform: translateZ(30px); }
.node-a { background: var(--accent); top: 80px; right: 100px; }
.node-b { background: var(--blue); bottom: 100px; left: 80px; }
.node-c { background: var(--green); bottom: 140px; right: 60px; }
.orbit-spin { animation: orbit-spin 20s linear infinite; }
.orbit-spin-rev { animation: orbit-spin 24s linear infinite reverse; }
@keyframes orbit-spin { from { transform: translate(-50%,-50%) rotate(0); } to { transform: translate(-50%,-50%) rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .orbit-spin, .orbit-spin-rev { animation: none; } }
.panel-pill {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%) translateZ(20px);
  padding: 8px 16px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255,253,248,0.82);
  font-family: var(--sans); font-size: 0.72rem; font-weight: 600; color: var(--ink-soft); letter-spacing: 0.02em;
}

/* ── Display text ───────────────────────────────────── */
.display {
  font-family: var(--sans); font-weight: 700;
  text-transform: uppercase; letter-spacing: -0.04em;
  line-height: 0.85;
  font-size: clamp(2.8rem, 9vw, 7rem);
  color: var(--ink);
}
.display-soft { color: var(--muted); }

/* ── Section labels ─────────────────────────────────── */
.section-label { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; }
.section-label .mono { white-space: nowrap; }
.section-label .line { flex: 1; height: 1px; background: var(--line); }

/* ── Capability clusters ───────────────────────────── */
.clusters { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.clusters-inner { padding: 72px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.cluster { display: flex; flex-direction: column; gap: 12px; }
.cluster-index { color: var(--accent); font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.14em; }
.cluster h3 { font-family: var(--serif); font-size: 1.5rem; line-height: 1.05; letter-spacing: -0.02em; }
.cluster-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.cluster p { font-family: var(--sans); font-size: 0.88rem; line-height: 1.65; color: var(--muted); max-width: 280px; }

/* ── Projects grid (asymmetric 12-col) ──────────────── */
.projects { padding: 80px 0; }
.project-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 28px; }
.project-card {
  display: block; cursor: pointer;
  transition: transform 0.4s var(--ease-66);
  transform-style: preserve-3d;
}
.project-card:hover { transform: translateY(-4px); }
.project-ph {
  position: relative;
  width: 100%; aspect-ratio: 1/1;
  border: 1px solid var(--line);
  border-radius: 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(250,249,245,0.9), rgba(241,238,230,0.6));
  overflow: hidden;
  transform-style: preserve-3d;
}
.project-ph::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(177,78,34,0.05) 0%, transparent 60%);
}
.project-ph .shapes {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  transform: translateZ(20px);
}
.project-meta { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; }
.project-tag { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.12em; color: var(--accent); }
.project-year { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.08em; color: var(--muted); }
.project-title { margin-top: 4px; font-family: var(--serif); font-size: 1.18rem; line-height: 1.1; }

/* asym col positions */
.p1 { grid-column: span 6; }
.p2 { grid-column: span 4; }
.p3 { grid-column: span 3; }
.p4 { grid-column: span 4; }
.p5 { grid-column: span 5; }
.p6 { grid-column: span 3; }

/* ── Writing rows ──────────────────────────────────── */
.writing { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(255,253,248,0.5); }
.writing-inner { padding: 80px 0; }
.write-row { border-top: 1px solid var(--line); padding: 1.1rem 0; transition: padding-left 0.3s var(--ease-66); }
.write-row:hover { padding-left: 0.6rem; }
.write-row:last-child { border-bottom: 1px solid var(--line); }
.write-row-grid { display: grid; grid-template-columns: 1fr auto; gap: 1.5rem; align-items: baseline; }
.write-row h3 { font-family: var(--serif); font-size: 1.2rem; line-height: 1.25; }
.write-row p { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.write-row .date { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }

/* ── Footer ────────────────────────────────────────── */
.site-footer { padding: 80px 0 60px; }
.foot-display {
  font-family: var(--sans); font-weight: 700;
  text-transform: uppercase; letter-spacing: -0.04em; line-height: 0.82;
  font-size: clamp(2.5rem, 8vw, 6rem); color: var(--ink);
}
.foot-display .soft { color: var(--muted); }
.foot-bar { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 48px; border-top: 1px solid var(--line); padding-top: 24px; }
.foot-col { display: flex; flex-direction: column; gap: 6px; }
.foot-link { font-family: var(--mono); font-size: 0.7rem; color: var(--ink); position: relative; }
.foot-meta { font-family: var(--mono); font-size: 0.68rem; color: var(--faint); }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 1060px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-panel { min-height: 360px; margin-top: 20px; }
  .clusters-inner { grid-template-columns: 1fr; }
  .project-grid { grid-template-columns: repeat(6, 1fr); }
  .p1,.p2,.p3,.p4,.p5,.p6 { grid-column: span 3; }
}
@media (max-width: 640px) {
  .hero { padding-top: 60px; }
  .hero h1 { font-size: clamp(36px, 12vw, 56px); }
  .nav-links { display: none; }
  .project-grid { grid-template-columns: 1fr; }
  .p1,.p2,.p3,.p4,.p5,.p6 { grid-column: 1; }
  .foot-bar { flex-direction: column; gap: 20px; }
}
</style>
</head>
<body>

<canvas id="bg-canvas"></canvas>

<!-- ── Header ─────────────────────────────────────── -->
<header class="site-header">
  <div class="container header-inner">
    <div class="brand">
      <span class="brand-mark">L</span>
      <span>lizliz.xyz</span>
    </div>
    <nav class="nav-links" aria-label="Primary">
      <a href="#identity">Index</a>
      <a href="#capabilities">Work</a>
      <a href="#writing">Writing</a>
      <a href="#contact">Contact</a>
    </nav>
    <div class="sys-strip">
      <span class="mono" style="cursor:pointer">THEME</span>
      <span class="mono" style="cursor:pointer">SOUND</span>
      <span class="mono flex items-center" style="display:inline-flex;align-items:center;gap:6px">
        <span class="live-dot"></span>GMT+8
      </span>
    </div>
  </div>
</header>

<main>

<!-- ── Identity / Hero ───────────────────────────── -->
<section id="identity" class="hero">
  <div class="container">
    <p class="mono mono-accent reveal" style="margin-bottom:20px">00 / IDENTITY</p>
    <div class="grid-12 hero-grid">
      <div class="reveal">
        <h1>
          Independent<br />
          developer building<br />
          at the edge of<br />
          <span class="accent">agents</span>,<br />
          <span class="blue">markets</span>, and <em>words</em>.
        </h1>
        <p class="hero-sub">
          Hi — I&rsquo;m Liz. I build agent systems, ship products, and write about the infrastructure of how we work and think.
        </p>
        <div class="hero-tags">
          <span class="tag">Agent systems</span>
          <span class="tag">Product</span>
          <span class="tag">Writing</span>
          <span class="tag">Markets</span>
        </div>
      </div>

      <!-- 3D tilt panel -->
      <div class="hero-panel reveal" id="tiltPanel">
        <div class="hero-panel-tilt" id="tiltInner">
          <div class="panel-bar">
            <span>THEME</span>
            <span>SOUND</span>
            <span>GMT+8</span>
          </div>
          <div class="panel-stage">
            <div class="orbit orbit-a orbit-spin" style="transform:translate(-50%,-50%) translateZ(10px)"></div>
            <div class="orbit orbit-b orbit-spin-rev" style="transform:translate(-50%,-50%) translateZ(20px)"></div>
            <div class="orbit orbit-c orbit-spin" style="transform:translate(-50%,-50%) translateZ(30px)"></div>
            <span class="node node-a"></span>
            <span class="node node-b"></span>
            <span class="node node-c"></span>
          </div>
          <div class="panel-pill">writing / projects / experiments</div>
        </div>
      </div>
    </div>

    <div class="reveal" style="margin-top:72px">
      <p class="display">ship signal,<br /><span class="display-soft">not noise</span></p>
    </div>
  </div>
</section>

<!-- ── Capability clusters ───────────────────────── -->
<section id="capabilities" class="clusters">
  <div class="container">
    <div class="section-label reveal" style="padding-top:72px">
      <span class="mono mono-accent">01 / CAPABILITIES</span>
      <span class="line"></span>
    </div>
    <div class="clusters-inner">
      <div class="cluster reveal">
        <span class="cluster-index">01</span>
        <h3>Agent systems</h3>
        <div class="cluster-tags">
          <span class="tag">autonomous workflows</span>
          <span class="tag">tool routing</span>
          <span class="tag">eval loops</span>
        </div>
        <p>Building agents that ship real output — not demos. From multi-provider orchestration to cron-driven autonomous tasks.</p>
      </div>
      <div class="cluster reveal">
        <span class="cluster-index">02</span>
        <h3>Product &amp; writing</h3>
        <div class="cluster-tags">
          <span class="tag">personal site</span>
          <span class="tag">content pipeline</span>
          <span class="tag">GEO</span>
        </div>
        <p>Writing about the systems that shape how we work. Publishing infrastructure that treats content as product.</p>
      </div>
      <div class="cluster reveal">
        <span class="cluster-index">03</span>
        <h3>Markets &amp; health</h3>
        <div class="cluster-tags">
          <span class="tag">trading systems</span>
          <span class="tag">risk control</span>
          <span class="tag">health tech</span>
        </div>
        <p>Exploring the intersection of market structure, payments, and health data — where engineering compounds into outcomes.</p>
      </div>
    </div>
  </div>
</section>

<!-- ── Selected work ─────────────────────────────── -->
<section class="projects">
  <div class="container">
    <div class="section-label reveal">
      <span class="mono mono-accent">02 / SELECTED WORK</span>
      <span class="line"></span>
      <span class="mono">6 PROJECTS</span>
    </div>
    <div class="project-grid">
      <a href="#" class="project-card p1 reveal dot-hover">
        <div class="project-ph"><div class="shapes" style="font-size:2rem"></div></div>
        <div class="project-meta"><span class="project-tag">PLATFORM</span><span class="project-year">2024—26</span></div>
        <h3 class="project-title">Hermes Agent</h3>
      </a>
      <a href="#" class="project-card p2 reveal dot-hover">
        <div class="project-ph"></div>
        <div class="project-meta"><span class="project-tag">SITE</span><span class="project-year">2023—26</span></div>
        <h3 class="project-title">lizliz.xyz</h3>
      </a>
      <a href="#" class="project-card p3 reveal dot-hover">
        <div class="project-ph"></div>
        <div class="project-meta"><span class="project-tag">WEB GAME</span><span class="project-year">2024</span></div>
        <h3 class="project-title">Pep Words</h3>
      </a>
      <a href="#" class="project-card p4 reveal dot-hover">
        <div class="project-ph"></div>
        <div class="project-meta"><span class="project-tag">EDTECH</span><span class="project-year">2025</span></div>
        <h3 class="project-title">BrainRush</h3>
      </a>
      <a href="#" class="project-card p5 reveal dot-hover">
        <div class="project-ph"></div>
        <div class="project-meta"><span class="project-tag">SYSTEM</span><span class="project-year">2025</span></div>
        <h3 class="project-title">Writing pipeline</h3>
      </a>
      <a href="#" class="project-card p6 reveal dot-hover">
        <div class="project-ph"></div>
        <div class="project-meta"><span class="project-tag">TOOLING</span><span class="project-year">2026</span></div>
        <h3 class="project-title">Orion review</h3>
      </a>
    </div>
  </div>
</section>

<!-- ── Writing proof ─────────────────────────────── -->
<section id="writing" class="writing">
  <div class="container writing-inner">
    <div class="section-label reveal">
      <span class="mono mono-accent">03 / WRITING</span>
      <span class="line"></span>
    </div>
    <div class="reveal">
      <div class="write-row">
        <div class="write-row-grid">
          <div><h3>The anti-echo-chamber principle for AI agents</h3><p>Progress is not defined by system growth — but by externally verified output.</p></div>
          <span class="date">2026.06</span>
        </div>
      </div>
      <div class="write-row">
        <div class="write-row-grid">
          <div><h3>Wealth is value exchange, not magic</h3><p>Any system that claims to generate money without strategy, risk, and validation is a scam.</p></div>
          <span class="date">2026.05</span>
        </div>
      </div>
      <div class="write-row">
        <div class="write-row-grid">
          <div><h3>Slow is fast: building assets with friction</h3><p>The path that looks slower — building durable systems — is the one that compounds.</p></div>
          <span class="date">2026.04</span>
        </div>
      </div>
    </div>
  </div>
</section>

<!-- ── About strip ───────────────────────────────── -->
<section class="projects" style="padding-bottom:40px">
  <div class="container">
    <div class="grid-12" style="gap:40px">
      <div class="reveal" style="grid-column:span 4">
        <span class="mono mono-accent">04 / ABOUT</span>
      </div>
      <div class="reveal" style="grid-column:span 7;grid-column-start:6">
        <p style="font-family:var(--serif);font-size:1.15rem;line-height:1.7;color:var(--ink-soft)">
          I run a small cloud server with AI agents that ship real output — content pipelines, monitoring systems, and autonomous tasks.
          Outside of building, I write about the intersection of agent systems, market structure, and the writing craft.
          Based in GMT+8. Independent by choice.
        </p>
        <div style="margin-top:24px;display:flex;gap:16px">
          <a href="#" class="mono dot-hover" style="padding:2px 4px">GitHub ↗</a>
          <a href="#" class="mono dot-hover" style="padding:2px 4px">X / Twitter ↗</a>
          <a href="#" class="mono dot-hover" style="padding:2px 4px">RSS ↗</a>
        </div>
      </div>
    </div>
  </div>
</section>

<!-- ── Footer ────────────────────────────────────── -->
<footer id="contact" class="site-footer">
  <div class="container">
    <div class="reveal">
      <p class="foot-display">let&rsquo;s make<br /><span class="soft">something</span><br />that matters</p>
    </div>
    <div class="foot-bar reveal">
      <div class="foot-col">
        <span class="mono">CONTACT</span>
        <a href="mailto:" class="dot-hover" style="font-family:var(--serif);font-size:1.1rem">liz@lizliz.xyz</a>
      </div>
      <div style="text-align:center">
        <span class="mono">BUILT IN GMT+8</span><br />
        <span class="foot-meta">© 2026 Liz</span>
      </div>
      <div class="foot-col" style="align-items:flex-end">
        <span class="mono">ELSEWHERE</span>
        <div style="display:flex;gap:12px">
          <a href="#" class="mono dot-hover" style="padding:2px 4px">GH</a>
          <a href="#" class="mono dot-hover" style="padding:2px 4px">X</a>
          <a href="#" class="mono dot-hover" style="padding:2px 4px">RSS</a>
        </div>
      </div>
    </div>
  </div>
</footer>

</main>

<script>
/* ── Canvas background: subtle grain/noise ────────── */
(() => {
  const canvas = document.getElementById('bg-canvas');
  if (!canvas) return;
  const ctx = canvas.getContext('2d');
  let w, h, dots = [];

  function resize() {
    w = canvas.width = window.innerWidth * 0.5;
    h = canvas.height = window.innerHeight * 0.5;
    canvas.style.width = window.innerWidth + 'px';
    canvas.style.height = window.innerHeight + 'px';
    dots = [];
    const count = 40;
    for (let i = 0; i < count; i++) {
      dots.push({
        x: Math.random() * w, y: Math.random() * h,
        vx: (Math.random() - 0.5) * 0.3,
        vy: (Math.random() - 0.5) * 0.3,
        r: Math.random() * 1.5 + 0.5,
      });
    }
  }

  function draw() {
    ctx.clearRect(0, 0, w, h);
    for (const d of dots) {
      d.x += d.vx; d.y += d.vy;
      if (d.x < 0 || d.x > w) d.vx *= -1;
      if (d.y < 0 || d.y > h) d.vy *= -1;
      ctx.beginPath();
      ctx.arc(d.x, d.y, d.r, 0, Math.PI * 2);
      ctx.fillStyle = 'rgba(177, 78, 34, 0.4)';
      ctx.fill();
    }
    requestAnimationFrame(draw);
  }

  resize();
  window.addEventListener('resize', resize);
  if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) draw();
})();

/* ── 3D tilt panel ────────────────────────────────── */
(() => {
  const panel = document.getElementById('tiltPanel');
  const inner = document.getElementById('tiltInner');
  if (!panel || !inner) return;
  if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
  if (!window.matchMedia('(hover: hover)').matches) return;

  let raf = null;
  panel.addEventListener('mousemove', (e) => {
    if (raf) cancelAnimationFrame(raf);
    raf = requestAnimationFrame(() => {
      const rect = panel.getBoundingClientRect();
      const cx = rect.left + rect.width / 2;
      const cy = rect.top + rect.height / 2;
      const dx = (e.clientX - cx) / (rect.width / 2);
      const dy = (e.clientY - cy) / (rect.height / 2);
      const maxTilt = 8;
      const ry = dx * maxTilt;
      const rx = -dy * maxTilt;
      inner.style.transform = `perspective(800px) rotateX(${rx}deg) rotateY(${ry}deg)`;
    });
  });
  panel.addEventListener('mouseleave', () => {
    if (raf) cancelAnimationFrame(raf);
    inner.style.transform = 'perspective(800px) rotateX(0) rotateY(0)';
  });
})();

/* ── Project card 3D tilt ────────────────────────── */
(() => {
  if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
  if (!window.matchMedia('(hover: hover)').matches) return;

  document.querySelectorAll('.project-card').forEach(card => {
    const ph = card.querySelector('.project-ph');
    if (!ph) return;
    let raf = null;
    card.addEventListener('mousemove', (e) => {
      if (raf) cancelAnimationFrame(raf);
      raf = requestAnimationFrame(() => {
        const rect = ph.getBoundingClientRect();
        const cx = rect.left + rect.width / 2;
        const cy = rect.top + rect.height / 2;
        const dx = (e.clientX - cx) / (rect.width / 2);
        const dy = (e.clientY - cy) / (rect.height / 2);
        const max = 6;
        ph.style.transform = `perspective(600px) rotateX(${-dy * max}deg) rotateY(${dx * max}deg) translateZ(0)`;
      });
    });
    card.addEventListener('mouseleave', () => {
      if (raf) cancelAnimationFrame(raf);
      ph.style.transform = 'perspective(600px) rotateX(0) rotateY(0)';
    });
  });
})();

/* ── Scroll reveal (IntersectionObserver) ─────────── */
(() => {
  if (!('IntersectionObserver' in window)) {
    document.querySelectorAll('.reveal').forEach(el => el.classList.add('in'));
    return;
  }
  const obs = new IntersectionObserver((entries) => {
    entries.forEach(entry => {
      if (entry.isIntersecting) {
        entry.target.classList.add('in');
        obs.unobserve(entry.target);
      }
    });
  }, { threshold: 0.12, rootMargin: '0px 0px -40px 0px' });

  document.querySelectorAll('.reveal').forEach(el => obs.observe(el));
})();

/* ── Active nav highlight ──────────────────────────── */
(() => {
  const sections = document.querySelectorAll('section[id], footer[id]');
  const links = document.querySelectorAll('.nav-links a');
  if (!sections.length || !links.length) return;
  const obs = new IntersectionObserver((entries) => {
    entries.forEach(entry => {
      if (entry.isIntersecting) {
        const id = entry.target.id;
        links.forEach(a => {
          a.classList.toggle('active', a.getAttribute('href') === '#' + id);
        });
      }
    });
  }, { threshold: 0.2 });
  sections.forEach(s => obs.observe(s));
})();
</script>

</body>
</html>