# Vortex portfolio hero

> An ad studio portfolio hero where fourteen campaign posters spiral around a point of light and any card peels out into its case study.

- Category: Business
- Version: 1.0
- Source: https://ownlyplans.com/bhaskar/vortex-portfolio-hero/

## Overview

A single-file 3D portfolio hero for an ad studio, built with Three.js and GSAP. Fourteen curved campaign posters orbit a tinted point of light in an endless spiral. Scrolling travels through them and snaps each project to the front, while a rolling counter, a big project title and a tick bar keep track. Hovering shows a brand pill; clicking a card peels it out, flattens it into a case-study view and staggers in stats, role and channels with previous and next. It also has an Index panel, a Contact popover, light and dark themes, a "Start a project" ending and a phone layout. The demo studio is Halcyon with example brands and free Unsplash photos; swap in your own brands in P and photos in IMAGES.

## Tech stack

- CSS
- GSAP
- HTML
- JavaScript
- Three.js

## Build steps

### 1. Draw the poster cards and the spiral

Set up one HTML file with Three.js, paint every campaign as a poster on a canvas, and lay fourteen curved cards on a spiral that sinks toward a point of light.

Prompt:

```text
Create a single-file HTML portfolio hero for an ad studio called "Halcyon". Load Three.js 0.160 and GSAP 3.12 as ES modules from jsDelivr through an import map; nothing else. Full-screen fixed WebGL canvas on a near-black page. Keep a P array of 14 projects (brand, campaign, channels, year, frame colour, ink colour, layout, two-line headline, description, two stats, role, channels) and an IMAGES array of 14 photo URLs. Paint each project on a 1024x732 canvas as an ad poster: a solid frame in the brand colour, a heavy condensed headline (Bricolage Grotesque 800), a round brand pill and the photo with rounded corners, in three layouts: headline on top, a sideways text strip on the left, or text over a full photo. Use the canvas as the texture of a curved plane (bend the edges toward the viewer in the vertex shader, round the corners in the fragment shader). Place card i on a spiral: angle = start + s * 0.86, depth = -(8.6 + s * 2.1), radius 3.9, each card turned slightly toward the axis and rolled by 0.2 * cos(angle).
```

**Done when:** Fourteen curved poster cards sit on a spiral around the centre, getting smaller toward the back.

### 2. Scroll through the vortex

Map scroll to the spiral so each step brings the next card to the front, loop past the last card, and keep the counter, title, ticks and light in sync.

Prompt:

```text
Make the page tall enough for one scroll step (62% of the viewport, min 420px) per project. Turn scroll into a target position, ease the live position toward it every frame, and snap to the nearest whole card 180ms after scrolling stops. For card i use s = (i - position) mod 14; a card that passes the camera grows, slides outward and fades, then comes back at the far end, so the spiral never runs out. Fade and darken cards with depth, add a little mipmap blur to far ones, and let the whole spiral drift slowly with time. Bottom left: a rolling 01 / 14 counter, a huge condensed project name with a coloured dot (blur it out and back in on change) and a "campaign · channels · year" line. Bottom right: 14 thin ticks with the active one tall and coloured, plus a progress line. Tint the central light and its rays with the active project colour.
```

**Done when:** Each scroll step brings the next card to the front, and the counter, title, ticks and light colour follow it.

### 3. Peel a card into its case study

Add the hover pill, then fly the clicked card out of the spiral into a flat case-study view with details on the right and previous and next.

Prompt:

```text
Raycast the cards on pointer move. On hover, lift the card slightly and show a white pill next to the cursor with a ring icon, the brand name and a faded "View". On click, lock scrolling, dim the spiral with a full-screen plane attached to the camera, and fly the card from its spiral pose to a pose that fills a placeholder box on the left of the screen: lerp position, slerp rotation, unbend it, and bump a peel uniform that lifts one corner on the way. Draw it above the dimmer. On the right, stagger in: a coloured dot with "Case 03 / 14 · 2026", the brand as a big title, the campaign, a short description, two stats, Role and Channels rows, a "Full case study" pill and round previous/next buttons. Previous/next sends the current card back to its live spiral pose while the next one flies in. A round X (and Escape) closes it and the spiral moves to the opened project.
```

**Done when:** Clicking any card flies it into the case view; previous, next and close all animate back into the spiral.

### 4. Background, ending and the phone version

Match the soft charcoal background and light, add the Index, Contact and theme controls, finish with a Start a project ending, and fit it all on a phone.

Prompt:

```text
Make the renderer transparent and put a radial charcoal glow (#1d1b1a to #080808) behind it, centred on the projected light, with fine animated SVG grain on top. The light is a small white core, a tinted halo, 12 long faint rays plus 8 short star spikes that slowly rotate, and three soft rings at 4% opacity. Top bar: logo with "Independent ad studio" on the left; a round moon/sun theme button, an "Index 14" pill and a "Contact" pill on the right. Index opens a left glass panel listing all 14 projects (number, colour dot, brand, campaign, year) that scroll to that card. Contact opens a small popover with a studio line, the email with a copy button and three social links. Light theme switches to warm grey. Add one extra scroll step after the last card: the spiral sinks into a brighter light and the title becomes "Start a project." with email and "Back to 01" buttons. Under 860px: wider field of view, smaller narrower spiral, the case card stacked over a scrolling detail panel.
```

**Done when:** Index, Contact and both themes work, the end shows Start a project, and on a phone you can scroll the spiral and open a case.

## Assets

### vortex-portfolio-hero.html — The finished file. Open it in a browser. Edit brands and copy in P and the 14 photo URLs in IMAGES.

```
<!DOCTYPE html>
<html lang="en" data-theme="dark">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<meta name="theme-color" content="#070707" />
<title>Halcyon — Independent Ad Studio</title>
<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=Bricolage+Grotesque:opsz,wdth,wght@12..96,75..100,400..800&display=swap" rel="stylesheet" />
<style>
  :root{
    --font:"Bricolage Grotesque",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
    --ease:cubic-bezier(.16,1,.3,1);
    --pad:clamp(18px,3vw,38px);
    --active:#e5322b;
  }
  html[data-theme="dark"]{--bg:#070707;--fg:#f2efe9;--mute:rgba(242,239,233,.5);--soft:rgba(242,239,233,.28);--line:rgba(242,239,233,.1);--pill:rgba(24,24,24,.72);--pillb:rgba(255,255,255,.1);--panel:rgba(14,14,14,.86);--hoverpill:#f2efe9;--hoverink:#0b0b0b}
  html[data-theme="light"]{--bg:#e8e7e3;--fg:#111;--mute:rgba(17,17,17,.52);--soft:rgba(17,17,17,.3);--line:rgba(17,17,17,.1);--pill:rgba(255,255,255,.7);--pillb:rgba(0,0,0,.08);--panel:rgba(246,245,242,.9);--hoverpill:#111;--hoverink:#f2efe9}
  *{box-sizing:border-box;margin:0;padding:0}
  html,body{background:var(--bg);color:var(--fg);transition:background .6s,color .6s}
  html[data-theme="dark"]{--glowA:#1d1b1a;--glowB:#111010;--glowC:#080808}
  html[data-theme="light"]{--glowA:#fbfaf8;--glowB:#efeeea;--glowC:#e1e0db}
  .bgfx{position:fixed;inset:0;z-index:-1;pointer-events:none;background:radial-gradient(55vmax 55vmax at var(--lx,50%) var(--ly,50%),var(--glowA) 0%,var(--glowB) 38%,var(--glowC) 78%);transition:background .6s}
  body{font-family:var(--font);-webkit-font-smoothing:antialiased;overflow-x:hidden;overscroll-behavior-y:none}
  button{font:inherit;color:inherit;background:none;border:0;cursor:pointer}
  a{color:inherit;text-decoration:none}
  html.locked,html.locked body{overflow:hidden}

  #gl{position:fixed;inset:0;width:100%;height:100%;display:block;z-index:0;touch-action:pan-y}
  #space{position:relative;z-index:-1}

  /* grain + vignette */
  .grain{position:fixed;inset:-50%;z-index:2;pointer-events:none;opacity:.09;mix-blend-mode:overlay;
    background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.15' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    animation:grain 1s steps(6) infinite}
  @keyframes grain{0%{transform:translate(0,0)}20%{transform:translate(-3%,2%)}40%{transform:translate(2%,-3%)}60%{transform:translate(-2%,-1%)}80%{transform:translate(3%,3%)}100%{transform:translate(0,0)}}
  .vig{position:fixed;inset:0;z-index:1;pointer-events:none;background:radial-gradient(130% 100% at 50% 50%,transparent 55%,rgba(0,0,0,.35) 100%);transition:opacity .6s}
  html[data-theme="light"] .vig{opacity:.12}

  /* loader */
  #loader{position:fixed;inset:0;z-index:100;background:var(--bg);display:grid;place-items:center;transition:opacity 1s var(--ease),visibility 1s}
  #loader.done{opacity:0;visibility:hidden}
  #loader span{width:6px;height:6px;border-radius:50%;background:var(--fg);box-shadow:0 0 30px 8px rgba(255,255,255,.35);animation:pulse 1.2s infinite var(--ease)}
  @keyframes pulse{50%{transform:scale(2.2);opacity:.5}}

  /* ---------- top bar ---------- */
  .top{position:fixed;top:0;left:0;right:0;z-index:30;display:flex;justify-content:space-between;align-items:flex-start;padding:var(--pad);padding-top:max(var(--pad),env(safe-area-inset-top));pointer-events:none}
  .top>*{pointer-events:auto}
  .logo b{display:block;font-weight:800;font-stretch:80%;font-size:clamp(24px,2.3vw,30px);letter-spacing:-.045em;line-height:1}
  .logo b sup{font-size:.36em;font-weight:600;vertical-align:top;position:relative;top:.15em;margin-left:1px}
  .logo small{display:block;margin-top:8px;font-size:clamp(12px,1.05vw,14px);color:var(--mute);letter-spacing:-.01em}
  .acts{display:flex;gap:8px;transition:opacity .5s var(--ease),transform .5s var(--ease)}
  .btn{height:38px;padding:0 16px;border-radius:999px;background:var(--pill);border:1px solid var(--pillb);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);font-size:15px;font-weight:600;letter-spacing:-.02em;display:inline-flex;align-items:center;gap:4px;transition:background .3s,transform .3s var(--ease)}
  .btn:hover{transform:translateY(-1px)}
  .btn sup{font-size:10px;opacity:.6;margin-top:-10px}
  .btn.round{width:38px;padding:0;justify-content:center}
  .btn svg{width:16px;height:16px}
  .close{position:fixed;top:max(var(--pad),env(safe-area-inset-top));right:var(--pad);z-index:31;width:42px;height:42px;opacity:0;transform:scale(.8) rotate(-45deg);pointer-events:none;transition:opacity .5s var(--ease),transform .6s var(--ease)}
  .case-open .close{opacity:1;transform:none;pointer-events:auto;transition-delay:.35s}
  .case-open .acts{opacity:0;transform:translateY(-8px);pointer-events:none}

  /* ---------- contact popover ---------- */
  .contact{position:fixed;z-index:29;top:calc(max(var(--pad),env(safe-area-inset-top)) + 48px);right:var(--pad);width:min(320px,calc(100vw - 2*var(--pad)));padding:20px 18px 16px;border-radius:18px;background:var(--panel);border:1px solid var(--line);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);opacity:0;transform:translateY(-8px) scale(.97);transform-origin:top right;pointer-events:none;transition:opacity .4s var(--ease),transform .5s var(--ease)}
  .contact-open .contact{opacity:1;transform:none;pointer-events:auto}
  .contact p{font-size:15px;line-height:1.4;color:var(--mute);color:color-mix(in srgb,var(--fg) 78%,transparent)}
  .mail{margin-top:16px;display:flex;align-items:center;justify-content:space-between;gap:10px;height:46px;padding:0 10px 0 16px;border-radius:999px;border:1px solid var(--line);background:rgba(127,127,127,.06);font-weight:700;font-size:15px;letter-spacing:-.02em}
  .mail button{width:30px;height:30px;border-radius:8px;display:grid;place-items:center;transition:background .3s}
  .mail button:hover{background:rgba(127,127,127,.15)}
  .mail button svg{width:15px;height:15px}
  .socials{margin-top:14px;display:flex;gap:16px;font-size:13px;color:var(--mute)}
  .socials a:hover{color:var(--fg)}

  /* ---------- outro (end of the vortex) ---------- */
  .outro{position:fixed;left:var(--pad);bottom:calc(var(--pad) + 4px);z-index:20;pointer-events:none;opacity:0;transform:translateY(30px);transition:opacity .8s var(--ease),transform 1s var(--ease)}
  .at-end .outro{opacity:1;transform:none;pointer-events:auto}
  .at-end .hero{opacity:0;transform:translateY(-24px)}
  .outro .count{margin-bottom:6px}
  .outro h2{font-weight:800;font-stretch:78%;font-size:clamp(52px,7.2vw,104px);letter-spacing:-.055em;line-height:1.02}
  .outro h2 em{font-style:normal;color:var(--mute)}
  .outro .meta{max-width:44ch}
  .outro .go{margin-top:20px;display:flex;flex-wrap:wrap;gap:10px}
  .outro .full{height:50px}

  /* ---------- hero copy ---------- */
  .hero{position:fixed;left:var(--pad);bottom:calc(var(--pad) + 4px);z-index:20;pointer-events:none;max-width:calc(100vw - 2*var(--pad));transition:opacity .6s var(--ease),transform .7s var(--ease)}
  .index-open .hero,.case-open .hero{opacity:0;transform:translateX(-24px)}
  body:not(.ready) .hero{opacity:0;transform:translateY(30px)}
  body:not(.ready) .ticks{opacity:0}
  .count{display:flex;align-items:center;gap:6px;font-size:13px;font-weight:700;letter-spacing:.02em;margin-bottom:6px}
  .count .wheel{display:inline-block;height:1.15em;overflow:hidden;position:relative;min-width:1.4em}
  .count .wheel span{display:block;line-height:1.15em}
  .count em{font-style:normal;color:var(--mute);font-weight:600}
  .trow{display:flex;align-items:center;gap:clamp(10px,1.2vw,16px)}
  .dot{flex:none;width:clamp(14px,1.5vw,20px);height:clamp(14px,1.5vw,20px);border-radius:50%;background:var(--active);box-shadow:0 0 0 4px rgba(255,255,255,.08);transition:background .6s}
  .title{font-weight:800;font-stretch:78%;font-size:clamp(52px,7.2vw,104px);letter-spacing:-.055em;line-height:1.02;white-space:nowrap;will-change:filter,opacity,transform}
  .meta{margin-top:10px;font-size:clamp(13px,1.2vw,16px);color:var(--mute);letter-spacing:-.01em}
  .meta b{color:var(--fg);font-weight:700}
  .hint{margin-top:22px;display:flex;align-items:center;gap:14px;font-size:13px;color:var(--mute)}
  .hint::before{content:"";width:28px;height:1px;background:var(--soft)}

  /* ---------- ticks ---------- */
  .ticks{position:fixed;right:var(--pad);bottom:calc(var(--pad) + 10px);z-index:20;width:min(196px,36vw);pointer-events:none;transition:opacity .5s}
  .case-open .ticks{opacity:0}
  .ticks .row{display:flex;justify-content:space-between;align-items:flex-end;height:28px}
  .ticks i{width:1.5px;height:12px;background:var(--soft);border-radius:1px;transition:height .5s var(--ease),background .5s}
  .ticks i.on{height:26px;background:var(--active)}
  .ticks .base{margin-top:8px;height:1px;background:var(--line);position:relative}
  .ticks .base b{position:absolute;left:0;top:0;height:1px;background:var(--soft);width:0}

  /* ---------- hover pill ---------- */
  .hpill{position:fixed;left:0;top:0;z-index:40;pointer-events:none;display:flex;align-items:center;gap:8px;padding:8px 14px 8px 12px;border-radius:999px;background:var(--hoverpill);color:var(--hoverink);font-size:15px;font-weight:700;letter-spacing:-.02em;white-space:nowrap;opacity:0;transform:translate(14px,-50%) scale(.85);transform-origin:left center;transition:opacity .25s,transform .35s var(--ease)}
  .hpill.on{opacity:1;transform:translate(18px,-50%) scale(1)}
  .hpill i{width:11px;height:11px;border-radius:50%;border:2px solid currentColor}
  .hpill span{font-weight:500;opacity:.55}
  @media (hover:none){.hpill{display:none}}

  /* ---------- index panel ---------- */
  .index{position:fixed;z-index:25;left:var(--pad);top:calc(var(--pad) + 60px);bottom:calc(var(--pad) + 4px);width:min(480px,calc(100vw - 2*var(--pad)));background:var(--panel);border:1px solid var(--line);border-radius:18px;backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);padding:8px 22px;overflow:auto;opacity:0;transform:translateX(-20px);pointer-events:none;transition:opacity .5s var(--ease),transform .6s var(--ease)}
  .index-open .index{opacity:1;transform:none;pointer-events:auto}
  .index button{width:100%;display:grid;grid-template-columns:34px 14px auto 1fr auto;align-items:center;gap:8px;padding:13px 0;border-bottom:1px solid var(--line);text-align:left;font-size:15px;opacity:0;transform:translateY(8px);transition:opacity .4s,transform .5s var(--ease)}
  .index-open .index button{opacity:1;transform:none}
  .index button:last-child{border-bottom:0}
  .index .n{font-size:12px;color:var(--mute);font-variant-numeric:tabular-nums}
  .index .d{width:9px;height:9px;border-radius:50%}
  .index .b{font-weight:800;font-stretch:85%;font-size:17px;letter-spacing:-.03em;color:var(--mute);transition:color .3s}
  .index .c{color:var(--mute);opacity:.75;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .index .y{font-size:12px;color:var(--mute)}
  .index button:hover .b,.index button.cur .b{color:var(--fg)}

  /* ---------- case study ---------- */
  .case{position:fixed;inset:0;z-index:22;pointer-events:none;display:grid;grid-template-columns:minmax(0,1.32fr) minmax(0,1fr);gap:clamp(24px,4vw,56px);padding:calc(var(--pad) + 62px) var(--pad) var(--pad);align-items:center}
  .case-open .case{pointer-events:auto}
  .media{height:min(70vh,560px);align-self:center}
  .panel{max-width:440px;width:100%}
  .panel>*{opacity:0;transform:translateY(18px);transition:opacity .6s var(--ease),transform .8s var(--ease)}
  .case.show .panel>*{opacity:1;transform:none}
  .case.show .panel>*:nth-child(2){transition-delay:.05s}.case.show .panel>*:nth-child(3){transition-delay:.1s}
  .case.show .panel>*:nth-child(4){transition-delay:.15s}.case.show .panel>*:nth-child(5){transition-delay:.2s}
  .case.show .panel>*:nth-child(6){transition-delay:.25s}.case.show .panel>*:nth-child(7){transition-delay:.3s}
  .case.swap .panel>*{opacity:0!important;transform:translateY(-10px)!important;transition-delay:0s!important;transition-duration:.25s!important}
  .k{display:flex;align-items:center;gap:8px;font-size:13px;font-weight:600;color:var(--mute)}
  .k i{width:8px;height:8px;border-radius:50%;background:var(--active)}
  .panel h2{margin-top:10px;font-weight:800;font-stretch:78%;font-size:clamp(40px,4.6vw,64px);letter-spacing:-.055em;line-height:1}
  .panel h3{margin-top:12px;font-weight:700;font-size:clamp(17px,1.5vw,21px);letter-spacing:-.02em}
  .panel p{margin-top:16px;font-size:clamp(14px,1.2vw,16px);line-height:1.5;color:var(--mute);max-width:36ch}
  .stats{margin-top:24px;padding-top:22px;border-top:1px solid var(--line);display:grid;grid-template-columns:1fr 1fr}
  .stats b{display:block;font-weight:800;font-stretch:80%;font-size:clamp(28px,2.6vw,36px);letter-spacing:-.05em}
  .stats span{font-size:13px;color:var(--mute)}
  .rows{margin-top:20px}
  .rows div{display:flex;justify-content:space-between;gap:16px;padding:12px 0;border-top:1px solid var(--line);font-size:14px}
  .rows div span:first-child{color:var(--mute)}
  .rows div span:last-child{font-weight:700;text-align:right}
  .cta{margin-top:24px;display:flex;justify-content:space-between;align-items:center}
  .full{height:46px;padding:0 22px;border-radius:999px;background:var(--fg);color:var(--bg);font-size:15px;font-weight:700;letter-spacing:-.02em;display:inline-flex;align-items:center;gap:10px;transition:transform .3s var(--ease)}
  .full:hover{transform:scale(1.04)}
  .arrows{display:flex;gap:8px}
  .arrows .btn{width:46px;height:46px;padding:0;justify-content:center}

  /* ---------- responsive ---------- */
  @media (max-width:860px){
    .case{grid-template-columns:1fr;grid-template-rows:auto 1fr;align-items:start;gap:18px;padding-top:calc(var(--pad) + 64px);overflow:hidden}
    .media{height:auto;aspect-ratio:1.4;max-height:36vh;width:100%}
    .panel{max-width:none;overflow:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;height:100%;padding-bottom:20px}
    .panel h2{font-size:clamp(36px,10vw,52px)}
  }
  @media (max-width:560px){
    .logo small{max-width:150px}
    .btn{height:34px;padding:0 12px;font-size:14px}
    .btn.round{width:34px}
    .title{font-size:clamp(36px,11vw,56px)}
    .outro h2{font-size:clamp(40px,12vw,60px)}
    .at-end .ticks{opacity:0}
    .hint{margin-top:14px}
    .ticks{width:120px;bottom:calc(var(--pad) + 6px)}
    .ticks .row{height:22px}.ticks i{height:9px}.ticks i.on{height:20px}
    .hero{bottom:calc(var(--pad) + 40px)}
    .index .c{display:none}
    .index button{grid-template-columns:30px 14px 1fr auto}
  }
  @media (prefers-reduced-motion:reduce){.grain{animation:none}}
</style>
</head>
<body>
<div id="loader"><span></span></div>
<div class="bgfx"></div>
<canvas id="gl" aria-label="Spiral of 14 campaign cards"></canvas>
<div class="vig"></div>
<div class="grain"></div>
<div id="space"></div>

<header class="top">
  <a href="#" class="logo"><b>Halcyon<sup>®</sup></b><small>Independent ad studio, Vizag</small></a>
  <div class="acts">
    <button class="btn round" id="theme" aria-label="Toggle theme">
      <svg id="ico" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg>
    </button>
    <button class="btn" id="indexBtn">Index<sup>14</sup></button>
    <button class="btn" id="contactBtn">Contact</button>
  </div>
</header>
<button class="btn round close" id="close" aria-label="Close case study"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg></button>

<nav class="index" id="index" aria-label="Project index"></nav>
<div class="contact" id="contact" role="dialog" aria-label="Contact">
  <p>We make campaigns people actually stop scrolling for. Fourteen brands, four years, one rule: if it feels like an ad, start again.</p>
  <div class="mail"><a href="mailto:hello@halcyon.studio">hello@halcyon.studio</a><button id="copy" aria-label="Copy email"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V6a2 2 0 0 1 2-2h9"/></svg></button></div>
  <div class="socials"><a href="#">Instagram</a><a href="#">LinkedIn</a><a href="#">Vimeo</a></div>
</div>
<section class="outro" id="outro">
  <div class="count"><span>End</span><em>/ 14 campaigns</em></div>
  <h2>Start a project<em>.</em></h2>
  <div class="meta"><b>Your brand could be fifteen.</b> · Now booking 2027 · Replies within a day</div>
  <div class="go"><a class="full" href="mailto:hello@halcyon.studio">Start a project <svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M3 9l6-6M4 3h5v5"/></svg></a><button class="btn" id="restart" style="height:50px;padding:0 20px">Back to 01</button></div>
</section>

<section class="hero" id="hero">
  <div class="count"><span class="wheel" id="wheel"><span>01</span></span><em>/ 14</em></div>
  <div class="trow"><i class="dot"></i><h1 class="title" id="title">Brand</h1></div>
  <div class="meta" id="meta"></div>
  <div class="hint" id="hint">Scroll to travel · click a card to open</div>
</section>

<div class="ticks"><div class="row" id="ticks"></div><div class="base"><b id="base"></b></div></div>
<div class="hpill" id="hpill"><i></i><b id="hbrand"></b><span>View</span></div>

<section class="case" id="case" aria-hidden="true">
  <div class="media" id="media"></div>
  <div class="panel" id="panel">
    <div class="k"><i></i><span id="ck"></span></div>
    <h2 id="cb"></h2>
    <h3 id="cc"></h3>
    <p id="cd"></p>
    <div class="stats" id="cs"></div>
    <div class="rows" id="cr"></div>
    <div class="cta"><a class="full" href="#">Full case study <svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M3 9l6-6M4 3h5v5"/></svg></a>
      <div class="arrows"><button class="btn" id="prev" aria-label="Previous case"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><path d="M15 6l-6 6 6 6"/></svg></button><button class="btn" id="next" aria-label="Next case"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><path d="M9 6l6 6-6 6"/></svg></button></div>
    </div>
  </div>
</section>

<script type="importmap">
{ "imports": {
  "three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js",
  "gsap": "https://cdn.jsdelivr.net/npm/gsap@3.12.5/+esm"
} }
</script>
<script type="module">
import * as THREE from 'three';
import { gsap } from 'gsap';

/* ============================================================
   PHOTOS — 14 free Unsplash photos (Unsplash License).
   Replace any entry with your own URL (needs CORS) or a local path.
   ============================================================ */
const IMAGES = [
  'https://images.unsplash.com/photo-1475241404975-c3ae90fdd9e6?auto=format&fit=crop&w=960&h=600&q=80',
  'https://images.unsplash.com/photo-1510279770292-4b34de9f5c23?auto=format&fit=crop&w=960&h=600&q=80',
  'https://images.unsplash.com/photo-1476820865390-c52aeebb9891?auto=format&fit=crop&w=960&h=600&q=80',
  'https://images.unsplash.com/photo-1498036882173-b41c28a8ba34?auto=format&fit=crop&w=960&h=600&q=80',
  'https://images.unsplash.com/photo-1500412830877-c77d92c33203?auto=format&fit=crop&w=960&h=600&q=80',
  'https://images.unsplash.com/photo-1443890923422-7819ed4101c0?auto=format&fit=crop&w=960&h=600&q=80',
  'https://images.unsplash.com/photo-1496483353456-90997957cf99?auto=format&fit=crop&w=960&h=600&q=80',
  'https://images.unsplash.com/photo-1500531279542-fc8490c8ea4d?auto=format&fit=crop&w=960&h=600&q=80',
  'https://images.unsplash.com/photo-1485889397316-8393dd065127?auto=format&fit=crop&w=960&h=600&q=80',
  'https://images.unsplash.com/photo-1488190211105-8b0e65b80b4e?auto=format&fit=crop&w=960&h=600&q=80',
  'https://images.unsplash.com/photo-1502133639165-ea20bc43e157?auto=format&fit=crop&w=960&h=600&q=80',
  'https://images.unsplash.com/photo-1446776653964-20c1d3a81b06?auto=format&fit=crop&w=960&h=600&q=80',
  'https://images.unsplash.com/photo-1473308822086-710304d7d30c?auto=format&fit=crop&w=960&h=600&q=80',
  'https://images.unsplash.com/photo-1496264057429-6a331647b69e?auto=format&fit=crop&w=960&h=600&q=80'
];

/* ============================================================
   PROJECTS — edit copy, colours and poster layouts here
   layout: 'top' | 'side' | 'overlay'
   ============================================================ */
const P = [
  { brand:'Ember Coffee',   camp:'Slow Mornings',      ch:'TV · OOH · Social',       year:2026, color:'#8a5534', ink:'#fff6ec', layout:'top',     head:['Slow sips,','loud mornings'], desc:'A morning ritual campaign shot entirely at 6am, in real kitchens, with real (sleepy) regulars.', stats:[['+41%','weekday sales'],['9','cities']], role:'Campaign, film', chan:'TV · OOH · Social' },
  { brand:'Tidewater Gin',  camp:'Taste the Tide',     ch:'OOH · Social · 2026',     year:2026, color:'#1cb6cc', ink:'#05252b', layout:'top',     head:['Taste','the tide'], desc:'Coastal launch built from drone footage of one beach, cut into an oversized OOH run along the waterfront.', stats:[['38M','reach'],['+24%','recall']], role:'Launch, aerial film', chan:'OOH · Social' },
  { brand:'Stride Running', camp:'Run the Long Way',   ch:'OOH · Social · Retail',   year:2026, color:'#f4c41a', ink:'#1b1500', layout:'side',    head:['RUN THE','LONG WAY'], desc:'An autumn platform celebrating the scenic route — every poster is a road somebody actually ran.', stats:[['2.1×','pre-orders'],['640K','saves']], role:'Platform, print', chan:'OOH · Retail · Social' },
  { brand:'Nightline',      camp:'Never Clocks Out',   ch:'Cinema · Digital',        year:2025, color:'#7b3cf0', ink:'#ffffff', layout:'overlay', head:['The city never','clocks out'], desc:'A love letter to the night shift: twelve workers, one city, and the transit line that carries them home.', stats:[['18M','views'],['3','awards']], role:'Film, stills', chan:'Cinema · Digital' },
  { brand:'Mira Skin',      camp:'Soft is Strong',     ch:'Social · Creators',       year:2025, color:'#ec3f8d', ink:'#ffffff', layout:'top',     head:['Soft is','strong'], desc:'Unretouched black-and-white portraits and creator diaries for a skincare line that trusts its skin.', stats:[['9.8%','engagement'],['14K','UGC posts']], role:'Social, photography', chan:'Social · Creators' },
  { brand:'Halden Outdoor', camp:'One More Ridge',     ch:'Film · Print',            year:2025, color:'#efe9dd', ink:'#141414', layout:'top',     head:['One more','ridge'], desc:'A brand platform shot across six countries in one season — always one ridge further than planned.', stats:[['51M','reach'],['+64%','search']], role:'Brand platform', chan:'Film · Print · OOH' },
  { brand:'Blaze Sauce',    camp:'Handle the Heat',    ch:'OOH · Social',            year:2025, color:'#e3262b', ink:'#ffffff', layout:'overlay', head:['Handle','the heat'], desc:'Weather-triggered billboards that turned up the heat as the temperature climbed across nine cities.', stats:[['+55%','sales'],['140','press hits']], role:'OOH, dynamic', chan:'OOH · Social' },
  { brand:'Isla Travel',    camp:'Lost on Purpose',    ch:'Digital · Print',         year:2024, color:'#2563eb', ink:'#ffffff', layout:'overlay', head:['Get lost','on purpose'], desc:'Islands shot from directly above, turning every coastline into a map you want to get lost in.', stats:[['+33%','bookings'],['12','islands']], role:'Campaign, aerial stills', chan:'OOH · Print · Social' },
  { brand:'Nova Audio',     camp:'Hear it Loud',       ch:'Launch · Retail',         year:2024, color:'#9be12b', ink:'#0e1600', layout:'side',    head:['HEAR IT','LOUD'], desc:'A headphone launch staged inside a live show, where the crowd became the cast.', stats:[['6 days','sell-out'],['1.1M','saves']], role:'Launch film', chan:'Retail · Social' },
  { brand:'Folio Bank',     camp:'Every Receipt',      ch:'TV · Direct · App',       year:2024, color:'#18a34a', ink:'#ffffff', layout:'top',     head:['Every receipt','tells a story'], desc:'Turning the dullest thing in banking — statements — into short stories about the moments behind them.', stats:[['+86K','accounts'],['−32%','CPA']], role:'Campaign, CRM', chan:'TV · Direct · App' },
  { brand:'Arc Motors',     camp:'Silent Horsepower',  ch:'TV · Cinema · Digital',   year:2024, color:'#d6d6da', ink:'#121212', layout:'top',     head:['Silent','horsepower'], desc:'A launch for a small electric coupé. One take, one road, and no engine sound at all.', stats:[['2.4k','test drives'],['1','single take']], role:'Launch film', chan:'TV · Cinema · Digital' },
  { brand:'Orbit Telecom',  camp:'Closer Than You Think', ch:'TV · OOH · Social',    year:2023, color:'#0ea5e9', ink:'#ffffff', layout:'overlay', head:['Closer than','you think'], desc:'Families split by time zones and the tiny rituals that keep them close — one call at a time.', stats:[['64M','reach'],['+210K','switchers']], role:'Integrated', chan:'TV · OOH · Social' },
  { brand:'Lumen Energy',   camp:'Light the Late Shift', ch:'OOH · Activation',      year:2023, color:'#f97316', ink:'#ffffff', layout:'side',    head:['LIGHT THE','LATE SHIFT'], desc:'Pop-up light installations for night workers, powered entirely by the people who use them.', stats:[['22M','reach'],['4','awards']], role:'Activation, OOH', chan:'OOH · Activation' },
  { brand:'Solace Hotels',  camp:'First Light',        ch:'Brand film · Web',        year:2023, color:'#fb7185', ink:'#2a0710', layout:'top',     head:['Book the','first light'], desc:'Every hotel photographed only in the first hour of sunlight — mornings worth travelling for.', stats:[['+44%','bookings'],['19M','reach']], role:'Brand film, photo', chan:'Film · Photography · Web' },
];
const N = P.length;
const pad2 = n => String(n).padStart(2, '0');

/* ============================================================
   RENDERER / SCENE
   ============================================================ */
const isTouch = matchMedia('(hover: none)').matches;
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;
const canvas = document.getElementById('gl');
const renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: true, powerPreference: 'high-performance' });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
const THEMES = { dark: new THREE.Color('#070707'), light: new THREE.Color('#e8e7e3') };
let theme = 'dark';
const bgCol = THEMES.dark.clone();
renderer.setClearColor(0x000000, 0);

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(50, innerWidth / innerHeight, 0.1, 400);
scene.add(camera);

/* ============================================================
   POSTER TEXTURES (drawn on canvas: frame + headline + photo)
   ============================================================ */
const TW = 1024, TH = Math.round(1024 / 1.4);
function rr(g, x, y, w, h, r) { g.beginPath(); g.moveTo(x + r, y); g.arcTo(x + w, y, x + w, y + h, r); g.arcTo(x + w, y + h, x, y + h, r); g.arcTo(x, y + h, x, y, r); g.arcTo(x, y, x + w, y, r); g.closePath(); }
function cover(g, img, x, y, w, h) {
  const ir = img.width / img.height, r = w / h;
  let sw = img.width, sh = img.height, sx = 0, sy = 0;
  if (ir > r) { sw = sh * r; sx = (img.width - sw) / 2; } else { sh = sw / r; sy = (img.height - sh) / 2; }
  g.drawImage(img, sx, sy, sw, sh, x, y, w, h);
}
function setFont(g, w, size) {
  g.font = `${w} ${size}px "Bricolage Grotesque", system-ui, sans-serif`;
  if ('fontStretch' in g) g.fontStretch = 'condensed';
  if ('letterSpacing' in g) g.letterSpacing = `${-size * 0.045}px`;
}
function brandPill(g, p, xr, y, onImage) {
  setFont(g, 700, 30);
  if ('letterSpacing' in g) g.letterSpacing = '-1px';
  const tw = g.measureText(p.brand).width, w = tw + 70, h = 50, x = xr - w;
  if (onImage) { g.fillStyle = p.color; rr(g, x, y, w, h, 25); g.fill(); }
  g.strokeStyle = p.ink; g.fillStyle = p.ink; g.lineWidth = 4;
  g.beginPath(); g.arc(x + 30, y + h / 2, 9, 0, Math.PI * 2); g.stroke();
  g.textBaseline = 'middle'; g.fillText(p.brand, x + 50, y + h / 2 + 1);
}
function makePoster(p, img) {
  const c = document.createElement('canvas'); c.width = TW; c.height = TH;
  const g = c.getContext('2d');
  g.fillStyle = p.color; g.fillRect(0, 0, TW, TH);
  // subtle sheen on the frame
  const sh = g.createLinearGradient(0, 0, TW, TH); sh.addColorStop(0, 'rgba(255,255,255,.14)'); sh.addColorStop(.5, 'rgba(255,255,255,0)'); sh.addColorStop(1, 'rgba(0,0,0,.12)');
  g.fillStyle = sh; g.fillRect(0, 0, TW, TH);
  g.textBaseline = 'alphabetic';
  if (p.layout === 'top') {
    g.save(); rr(g, 40, 236, TW - 80, TH - 236 - 40, 26); g.clip(); cover(g, img, 40, 236, TW - 80, TH - 276); g.restore();
    setFont(g, 800, 84); g.fillStyle = p.ink;
    p.head.forEach((l, k) => g.fillText(l, 52, 112 + k * 80));
    brandPill(g, p, TW - 40, 50, false);
  } else if (p.layout === 'side') {
    g.save(); rr(g, 232, 40, TW - 272, TH - 80, 26); g.clip(); cover(g, img, 232, 40, TW - 272, TH - 80); g.restore();
    g.save(); g.translate(0, TH); g.rotate(-Math.PI / 2);
    setFont(g, 800, 96); g.fillStyle = p.ink;
    p.head.forEach((l, k) => g.fillText(l, 50, 112 + k * 88));
    g.restore();
    brandPill(g, p, TW - 64, 64, true);
  } else {
    g.save(); rr(g, 30, 30, TW - 60, TH - 60, 28); g.clip(); cover(g, img, 30, 30, TW - 60, TH - 60);
    const gr = g.createLinearGradient(0, TH * .45, 0, TH); gr.addColorStop(0, 'rgba(0,0,0,0)'); gr.addColorStop(1, 'rgba(0,0,0,.55)');
    g.fillStyle = gr; g.fillRect(0, 0, TW, TH); g.restore();
    setFont(g, 800, 92); g.fillStyle = '#fff';
    g.shadowColor = 'rgba(0,0,0,.35)'; g.shadowBlur = 24;
    p.head.forEach((l, k, a) => g.fillText(l, 72, TH - 78 - (a.length - 1 - k) * 86));
    g.shadowBlur = 0;
    brandPill(g, p, TW - 60, 60, true);
  }
  const t = new THREE.CanvasTexture(c);
  t.colorSpace = THREE.SRGBColorSpace;
  t.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
  return t;
}

/* ============================================================
   CARD MATERIAL — curved, rounded, peel, depth dimming
   ============================================================ */
const CW = 3.3, CH = CW / 1.4;
const vert = `
  uniform float uBend, uPeel, uTime, uSeed;
  varying vec2 vUv;
  void main(){
    vUv = uv;
    vec3 p = position;
    float R = 3.2;
    float a = p.x / R;
    p = mix(p, vec3(sin(a) * R, p.y, (1.0 - cos(a)) * R), uBend);
    float lx = 1.0 - uv.x, ly = 1.0 - uv.y;
    p.z += uPeel * (pow(lx, 2.0) * 1.4 + pow(lx * ly, 2.0) * 0.9);
    p.y += sin(uTime * 0.8 + uSeed * 6.283) * 0.035 * uBend;
    gl_Position = projectionMatrix * modelViewMatrix * vec4(p, 1.0);
  }`;
const frag = `
  uniform sampler2D uTex; uniform float uOpacity, uDim, uHover, uBlur; uniform vec3 uBg;
  varying vec2 vUv;
  float sdR(vec2 p, vec2 b, float r){ vec2 q = abs(p) - b + r; return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r; }
  void main(){
    vec2 sz = vec2(${CW.toFixed(3)}, ${CH.toFixed(3)});
    float d = sdR((vUv - 0.5) * sz, sz * 0.5, 0.15);
    float a = 1.0 - smoothstep(-0.008, 0.0, d);
    vec3 col = texture2D(uTex, vUv, uBlur).rgb;
    col *= 0.9 + 0.14 * vUv.y;                // soft top light
    col += uHover * 0.06;
    col = mix(col, uBg, uDim);
    float alpha = a * uOpacity;
    if (alpha < 0.005) discard;
    gl_FragColor = vec4(col, alpha);
    #include <colorspace_fragment>
  }`;
const geo = new THREE.PlaneGeometry(CW, CH, 40, 10);
const cards = P.map((p, i) => {
  const u = { uTex: { value: null }, uOpacity: { value: 0 }, uDim: { value: 0 }, uBlur: { value: 0 }, uHover: { value: 0 }, uBg: { value: bgCol },
    uBend: { value: 1 }, uPeel: { value: 0 }, uTime: { value: 0 }, uSeed: { value: Math.random() } };
  const mat = new THREE.ShaderMaterial({ uniforms: u, vertexShader: vert, fragmentShader: frag, transparent: true, side: THREE.DoubleSide });
  const mesh = new THREE.Mesh(geo, mat);
  mesh.userData.i = i;
  scene.add(mesh);
  return { mesh, mat, u, mode: 'spiral', hover: 0, from: null, t: 0 };
});

/* ============================================================
   LIGHT — core glow, tinted rays, faint rings
   ============================================================ */
function canvasTex(size, draw) { const c = document.createElement('canvas'); c.width = c.height = size; draw(c.getContext('2d'), size); const t = new THREE.CanvasTexture(c); t.colorSpace = THREE.SRGBColorSpace; return t; }
const glowT = canvasTex(512, (g, s) => { const r = g.createRadialGradient(s/2, s/2, 0, s/2, s/2, s/2);
  r.addColorStop(0, 'rgba(255,255,255,1)'); r.addColorStop(.035, 'rgba(255,255,255,1)'); r.addColorStop(.09, 'rgba(255,255,255,.55)'); r.addColorStop(.2, 'rgba(255,255,255,.16)'); r.addColorStop(.45, 'rgba(255,255,255,.04)'); r.addColorStop(1, 'rgba(255,255,255,0)');
  g.fillStyle = r; g.fillRect(0, 0, s, s); });
const haloT = canvasTex(512, (g, s) => { const r = g.createRadialGradient(s/2, s/2, 0, s/2, s/2, s/2);
  r.addColorStop(0, 'rgba(255,255,255,.55)'); r.addColorStop(.25, 'rgba(255,255,255,.18)'); r.addColorStop(.6, 'rgba(255,255,255,.04)'); r.addColorStop(1, 'rgba(255,255,255,0)');
  g.fillStyle = r; g.fillRect(0, 0, s, s); });
const raysT = canvasTex(2048, (g, s) => { g.translate(s/2, s/2); g.globalCompositeOperation = 'lighter';
  const beam = (a, len, w, alpha, blur) => { g.save(); g.filter = `blur(${blur}px)`; g.rotate(a); const gr = g.createLinearGradient(0, 0, len, 0);
    gr.addColorStop(0, `rgba(255,255,255,${alpha})`); gr.addColorStop(.12, `rgba(255,255,255,${alpha * .55})`); gr.addColorStop(.55, `rgba(255,255,255,${alpha * .18})`); gr.addColorStop(1, 'rgba(255,255,255,0)');
    g.fillStyle = gr; g.beginPath(); g.moveTo(0, -1.5); g.lineTo(len, -len * w); g.lineTo(len, len * w); g.lineTo(0, 1.5); g.closePath(); g.fill(); g.restore(); };
  const n = 12;
  for (let k = 0; k < n; k++) beam(k / n * Math.PI * 2 + ((k * 53) % 7) * .03, s * (.38 + ((k * 31) % 6) * .02), .006 + ((k * 7) % 3) * .003, .55, 4);
  for (let k = 0; k < 8; k++) beam(k / 8 * Math.PI * 2 + .19, s * (k % 2 ? .07 : .11), .01, .9, 1.5);
});
const ringT = canvasTex(1024, (g, s) => { g.translate(s/2, s/2); g.filter = 'blur(3px)';
  [[0.42, .9], [0.64, .65], [0.9, .4]].forEach(([r, a]) => { g.strokeStyle = `rgba(255,255,255,${a})`; g.lineWidth = 5; g.beginPath(); g.arc(0, 0, r * s / 2, 0, Math.PI * 2); g.stroke(); }); });
const mk = (map, op, add = true) => new THREE.Sprite(new THREE.SpriteMaterial({ map, transparent: true, opacity: op, depthWrite: false, blending: add ? THREE.AdditiveBlending : THREE.NormalBlending }));
const rings = mk(ringT, 0.045), rays = mk(raysT, 0.42), rays2 = mk(raysT, 0.16), halo = mk(haloT, 0.55), glow = mk(glowT, 1);
const LZ = -120;
[rings, rays, rays2, halo, glow].forEach((s, k) => { s.position.set(0, 0, LZ + k * 0.1); s.renderOrder = -10 + k; scene.add(s); });

/* dimmer between spiral and the opened card */
const dimMat = new THREE.MeshBasicMaterial({ color: bgCol, transparent: true, opacity: 0, depthTest: false, depthWrite: false });
const dim = new THREE.Mesh(new THREE.PlaneGeometry(2, 2), dimMat);
dim.position.z = -0.5; dim.scale.setScalar(4); dim.renderOrder = 50; camera.add(dim);

/* ============================================================
   LAYOUT (responsive spiral)
   ============================================================ */
const L = { R: 3.7, Z0: 8.2, GAP: 2.05, DTH: 0.86, TH0: 2.5, K: 9, sx: 1, scale: 1, fov: 50, cx: 0, cy: 0, rx: 0, ry: 0 };
let step = 600;
function layout() {
  const w = innerWidth, h = innerHeight, a = w / h;
  renderer.setSize(w, h, false);
  camera.aspect = a;
  if (a < 0.75) Object.assign(L, { fov: 64, R: 2.6, sx: 0.78, scale: 0.72, Z0: 7.4, GAP: 1.9, rx: -0.07, ry: 0 });
  else if (a < 1.15) Object.assign(L, { fov: 56, R: 3.2, sx: 0.9, scale: 0.85, Z0: 8, GAP: 2, rx: -0.02, ry: -0.01 });
  else Object.assign(L, { fov: 50, R: 3.9, sx: 1.08, scale: 0.95, Z0: 8.6, GAP: 2.1, rx: 0.025, ry: -0.035 });
  camera.fov = L.fov; camera.updateProjectionMatrix();
  const wpp = Math.abs(LZ) * 2 * Math.tan(THREE.MathUtils.degToRad(L.fov / 2)) / h; // world units per px at light depth
  const m = Math.min(1, Math.max(w, h) / 1300);
  L.glow = 300 * wpp * Math.max(m, .75);
  glow.scale.setScalar(L.glow); halo.scale.setScalar(L.glow * 1.5);
  rays.scale.setScalar(Math.hypot(w, h) * 1.15 * wpp); rays2.scale.setScalar(Math.hypot(w, h) * .8 * wpp);
  rings.scale.setScalar(Math.min(w, h) * 1.25 * wpp);
  step = Math.max(420, h * 0.62);
  document.getElementById('space').style.height = (h + step * N) + 'px';
}
addEventListener('resize', () => { layout(); if (state.open) placeTargetNow(); });

/* ============================================================
   STATE / SCROLL (smooth + snap)
   ============================================================ */
const state = { glowIn: 1, end: 0, p: 0, pt: 0, intro: 7, open: false, active: -1, hovered: -1, ready: false, mx: 0, my: 0, smx: 0, smy: 0, idx: -1, light: new THREE.Color(P[0].color), time: 0 };
let snapT;
addEventListener('scroll', () => {
  if (state.open) return;
  state.pt = THREE.MathUtils.clamp(scrollY / step, 0, N);
  clearTimeout(snapT);
  snapT = setTimeout(() => { if (!state.open) { const t = Math.round(state.pt) * step; if (Math.abs(scrollY - t) > 2) scrollTo({ top: t, behavior: 'smooth' }); } }, 180);
}, { passive: true });
addEventListener('keydown', e => {
  if (state.open) { if (e.key === 'Escape') closeCase(); if (e.key === 'ArrowRight') switchCase(1); if (e.key === 'ArrowLeft') switchCase(-1); return; }
  if (e.key === 'Escape') { toggleIndex(false); toggleContact(false); }
});

/* ============================================================
   SPIRAL POSE
   ============================================================ */
const tmp = new THREE.Object3D();
function spiralPose(i, out) {
  const pc = Math.min(state.p, N - 1), end = state.end;
  let s = ((i - pc) % N + N) % N;
  if (s > N - 1) s -= N;                     // just passed the camera
  s += state.intro + end * 2.2;              // at the end the whole vortex sinks toward the light
  const th = L.TH0 + s * L.DTH + pc * 0.14 + state.time * 0.045 + end * 0.6;
  let z, r;
  if (s >= 0) { z = -(L.Z0 + s * L.GAP); r = L.R; }
  else { z = -(L.Z0 + s * L.Z0 * 0.8); r = L.R * (1 - s * 0.8); }
  tmp.position.set(Math.cos(th) * r * L.sx + L.cx, Math.sin(th) * r + L.cy, z);
  tmp.rotation.set(0, 0, 0);
  tmp.lookAt(L.cx, L.cy, z + L.K);
  tmp.rotateZ(0.2 * Math.cos(th));
  out.pos.copy(tmp.position); out.quat.copy(tmp.quaternion);
  out.s = s;
  out.op = THREE.MathUtils.clamp(1 + s * 1.5, 0, 1) * THREE.MathUtils.clamp((N - 0.6 - s) / 1.6, 0, 1);
  out.op *= 1 - end * 0.55;
  out.dim = Math.min(.92, Math.pow(THREE.MathUtils.clamp(s / (N - 1), 0, 1), .8) * 0.82 + end * .25);
  out.blur = THREE.MathUtils.clamp((s - 3.5) / 7, 0, 1) * 2.6;
  return out;
}
const pose = { pos: new THREE.Vector3(), quat: new THREE.Quaternion(), s: 0, op: 1, dim: 0, blur: 0 };

/* ============================================================
   HERO / TICKS / INDEX UI
   ============================================================ */
const $ = id => document.getElementById(id);
const root = document.documentElement;
const ticksEl = $('ticks');
ticksEl.innerHTML = P.map(() => '<i></i>').join('');
const ticks = [...ticksEl.children];
$('index').innerHTML = P.map((p, i) => `<button data-i="${i}" style="transition-delay:${i * 25}ms"><span class="n">${pad2(i + 1)}</span><i class="d" style="background:${p.color}"></i><span class="b">${p.brand}</span><span class="c">${p.camp}</span><span class="y">${p.year}</span></button>`).join('');
const idxBtns = [...$('index').children];

function setHero(i, instant) {
  const p = P[i];
  root.style.setProperty('--active', p.color);
  ticks.forEach((t, k) => t.classList.toggle('on', k === i));
  idxBtns.forEach((b, k) => b.classList.toggle('cur', k === i));
  const wheel = $('wheel'), old = wheel.lastElementChild;
  const nu = document.createElement('span'); nu.textContent = pad2(i + 1);
  const meta = `<b>${p.camp}</b> · ${p.ch.replace(/ · \d{4}$/, '')} · ${p.year}`;
  if (instant) { wheel.innerHTML = ''; wheel.appendChild(nu); $('title').textContent = p.brand; $('meta').innerHTML = meta; return; }
  const dir = i > state.idx ? 1 : -1;
  nu.style.position = 'absolute'; nu.style.left = 0; nu.style.top = 0; wheel.appendChild(nu);
  gsap.fromTo(nu, { yPercent: 100 * dir }, { yPercent: 0, duration: .6, ease: 'expo.out' });
  gsap.to(old, { yPercent: -100 * dir, duration: .6, ease: 'expo.out', onComplete: () => { old.remove(); nu.style.position = ''; } });
  const t = $('title');
  gsap.killTweensOf(t);
  gsap.to(t, { opacity: .25, filter: 'blur(10px)', y: -6, duration: .18, ease: 'power2.in', onComplete: () => {
    t.textContent = p.brand; $('meta').innerHTML = meta;
    gsap.fromTo(t, { opacity: .25, filter: 'blur(12px)', y: 10 }, { opacity: 1, filter: 'blur(0px)', y: 0, duration: .6, ease: 'expo.out' });
  }});
}

function toggleIndex(force) {
  const on = force ?? !document.body.classList.contains('index-open');
  document.body.classList.toggle('index-open', on);
  if (on) document.body.classList.remove('contact-open');
}
$('indexBtn').addEventListener('click', e => { e.stopPropagation(); toggleIndex(); });
$('index').addEventListener('click', e => {
  const b = e.target.closest('button'); if (!b) return;
  toggleIndex(false);
  scrollTo({ top: +b.dataset.i * step, behavior: 'smooth' });
});
canvas.addEventListener('pointerdown', () => { toggleIndex(false); toggleContact(false); });
function toggleContact(force) {
  const on = force ?? !document.body.classList.contains('contact-open');
  document.body.classList.toggle('contact-open', on);
  if (on) toggleIndex(false);
}
const COPY_ICO = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V6a2 2 0 0 1 2-2h9"/></svg>';
$('contactBtn').addEventListener('click', e => { e.stopPropagation(); toggleContact(); });
$('copy').addEventListener('click', () => { navigator.clipboard?.writeText('hello@halcyon.studio');
  $('copy').innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4"><path d="M5 12l5 5 9-10"/></svg>';
  setTimeout(() => $('copy').innerHTML = COPY_ICO, 1400); });
$('restart').addEventListener('click', () => scrollTo({ top: 0, behavior: 'smooth' }));

/* theme */
const MOON = '<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/>';
const SUN = '<circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/>';
$('theme').addEventListener('click', () => {
  theme = theme === 'dark' ? 'light' : 'dark';
  root.dataset.theme = theme;
  $('ico').innerHTML = theme === 'dark' ? MOON : SUN;
  const to = THEMES[theme];
  gsap.to(bgCol, { r: to.r, g: to.g, b: to.b, duration: .6, });
  gsap.to(rings.material, { opacity: theme === 'dark' ? 0.05 : 0.22, duration: .6 });
});

/* ============================================================
   HOVER / CLICK
   ============================================================ */
const ray = new THREE.Raycaster(), ndc = new THREE.Vector2();
let cx = -999, cy = -999;
const hpill = $('hpill');
addEventListener('pointermove', e => {
  cx = e.clientX; cy = e.clientY;
  state.mx = cx / innerWidth * 2 - 1; state.my = -(cy / innerHeight) * 2 + 1;
  hpill.style.left = cx + 'px'; hpill.style.top = cy + 'px';
});
function pick(x, y) {
  ndc.set(x / innerWidth * 2 - 1, -(y / innerHeight) * 2 + 1);
  ray.setFromCamera(ndc, camera);
  const hit = ray.intersectObjects(cards.filter(c => c.mode === 'spiral' && c.u.uOpacity.value > 0.35).map(c => c.mesh))[0];
  return hit ? hit.object.userData.i : -1;
}
canvas.addEventListener('click', e => {
  if (!state.ready || state.open) return;
  const i = pick(e.clientX, e.clientY);
  if (i > -1) openCase(i);
});

/* ============================================================
   CASE STUDY
   ============================================================ */
const caseEl = $('case');
function fillCase(i) {
  const p = P[i];
  root.style.setProperty('--active', p.color);
  $('ck').textContent = `Case ${pad2(i + 1)} / ${N} · ${p.year}`;
  $('cb').textContent = p.brand; $('cc').textContent = p.camp; $('cd').textContent = p.desc;
  $('cs').innerHTML = p.stats.map(([v, l]) => `<div><b>${v}</b><span>${l}</span></div>`).join('');
  $('cr').innerHTML = `<div><span>Role</span><span>${p.role}</span></div><div><span>Channels</span><span>${p.chan}</span></div>`;
}
const _v = new THREE.Vector3();
function targetPose() {
  const r = $('media').getBoundingClientRect();
  const D = 6;
  const vh = 2 * D * Math.tan(THREE.MathUtils.degToRad(camera.fov / 2)), vw = vh * camera.aspect;
  const aspect = CW / CH;
  let w = r.width, h = r.height;
  if (w / h > aspect) w = h * aspect; else h = w / aspect;
  const s = (h / innerHeight) * vh / CH;
  const nx = ((r.left + r.width / 2) / innerWidth) * 2 - 1, ny = -((r.top + r.height / 2) / innerHeight) * 2 + 1;
  camera.updateMatrixWorld();
  return { pos: camera.localToWorld(_v.set(nx * vw / 2, ny * vh / 2, -D)).clone(), quat: camera.getWorldQuaternion(new THREE.Quaternion()), s };
}
function placeTargetNow() { const c = cards[state.active]; if (c && c.mode === 'case') { c.to = targetPose(); c.t = 1; } }

function flyIn(c, delay = 0) {
  c.mode = 'fly'; c.from = { pos: c.mesh.position.clone(), quat: c.mesh.quaternion.clone(), s: c.mesh.scale.x }; c.to = targetPose(); c.t = 0;
  c.mesh.renderOrder = 60; c.mat.depthTest = false;
  const d = reduced ? .01 : 1.15;
  gsap.to(c, { t: 1, duration: d, delay, ease: 'expo.inOut', onComplete: () => { c.mode = 'case'; } });
  gsap.to(c.u.uBend, { value: 0, duration: d * .9, delay, ease: 'power3.inOut' });
  gsap.to(c.u.uDim, { value: 0, duration: .5, delay });
  gsap.to(c.u.uOpacity, { value: 1, duration: .3, delay });
  gsap.timeline({ delay }).to(c.u.uPeel, { value: 1, duration: d * .45, ease: 'power2.out' }).to(c.u.uPeel, { value: 0, duration: d * .55, ease: 'power3.inOut' });
}
function flyBack(c, delay = 0) {
  c.mode = 'back'; c.from = { pos: c.mesh.position.clone(), quat: c.mesh.quaternion.clone(), s: c.mesh.scale.x }; c.t = 0;
  const d = reduced ? .01 : 1.1;
  gsap.to(c, { t: 1, duration: d, delay, ease: 'expo.inOut', onComplete: () => { c.mode = 'spiral'; c.mesh.renderOrder = 0; c.mat.depthTest = true; } });
  gsap.to(c.u.uBend, { value: 1, duration: d, delay, ease: 'power3.inOut' });
  gsap.timeline({ delay }).to(c.u.uPeel, { value: .8, duration: d * .4, ease: 'power2.out' }).to(c.u.uPeel, { value: 0, duration: d * .6, ease: 'power3.inOut' });
}
let busy = false;
function openCase(i) {
  busy = true; state.open = true; state.active = i; clearTimeout(snapT);
  hpill.classList.remove('on'); state.hovered = -1; canvas.style.cursor = '';
  toggleIndex(false);
  fillCase(i);
  document.body.classList.add('case-open'); caseEl.setAttribute('aria-hidden', 'false');
  root.classList.add('locked');
  flyIn(cards[i]);
  gsap.to(dimMat, { opacity: theme === 'dark' ? .86 : .8, duration: .9, ease: 'power2.out' });
  setTimeout(() => { caseEl.classList.add('show'); busy = false; }, 520);
  // keep the spiral in sync with the opened project
  state.pt = i;
}
function closeCase() {
  if (!state.open || busy) return;
  const i = state.active;
  caseEl.classList.remove('show');
  document.body.classList.remove('case-open'); caseEl.setAttribute('aria-hidden', 'true');
  gsap.to(dimMat, { opacity: 0, duration: .9, ease: 'power2.inOut' });
  flyBack(cards[i]);
  root.classList.remove('locked');
  scrollTo(0, i * step);
  state.pt = i; state.open = false; state.active = -1;
}
function switchCase(dir) {
  if (!state.open || busy) return;
  busy = true;
  const oi = state.active, ni = (oi + dir + N) % N;
  caseEl.classList.add('swap');
  flyBack(cards[oi]);
  state.active = ni; state.pt = ni;
  flyIn(cards[ni], .12);
  setTimeout(() => { fillCase(ni); caseEl.classList.remove('swap'); busy = false; }, 420);
}
$('close').addEventListener('click', closeCase);
$('next').addEventListener('click', () => switchCase(1));
$('prev').addEventListener('click', () => switchCase(-1));

/* ============================================================
   LOOP
   ============================================================ */
const clock = new THREE.Clock();
const WHITE = new THREE.Color(1, 1, 1), _lp = new THREE.Vector3();
const qa = new THREE.Quaternion();
function tick() {
  const dt = Math.min(clock.getDelta(), 0.05);
  state.time += dt;
  state.p += (state.pt - state.p) * (1 - Math.exp(-dt * 4.2));
  if (!state.open) { state.smx += (state.mx - state.smx) * 0.04; state.smy += (state.my - state.smy) * 0.04; }
  camera.rotation.set(L.rx + state.smy * 0.035, L.ry - state.smx * 0.05, 0);
  camera.position.set(state.smx * 0.25, state.smy * 0.18, 0);

  state.end = THREE.MathUtils.smoothstep(state.p, N - 1, N);
  document.body.classList.toggle('at-end', state.end > .55 && !state.open);
  const ai = THREE.MathUtils.clamp(Math.round(Math.min(state.p, N - 1)), 0, N - 1);
  if (ai !== state.idx && state.ready && !state.open) { setHero(ai, state.idx < 0); state.idx = ai; }
  if (state.end <= .55 && state._wasEnd) ticks.forEach((t, k) => t.classList.toggle('on', k === ai));
  state._wasEnd = state.end > .55;

  // hover
  if (!isTouch && state.ready && !state.open) {
    const h = pick(cx, cy);
    if (h !== state.hovered) {
      state.hovered = h;
      if (h > -1) { $('hbrand').textContent = P[h].brand; hpill.classList.add('on'); canvas.style.cursor = 'pointer'; }
      else { hpill.classList.remove('on'); canvas.style.cursor = ''; }
    }
  }

  cards.forEach((c, i) => {
    c.u.uTime.value = state.time;
    spiralPose(i, pose);
    c.hover += ((state.hovered === i ? 1 : 0) - c.hover) * 0.12;
    c.u.uHover.value = c.hover;
    const baseS = L.scale * (1 + c.hover * 0.07);
    if (c.mode === 'spiral') {
      c.mesh.position.copy(pose.pos); c.mesh.position.z += c.hover * 0.35;
      c.mesh.quaternion.copy(pose.quat);
      c.mesh.scale.setScalar(baseS);
      c.u.uOpacity.value = pose.op * Math.min(1, (state.ready ? 1 : 0));
      c.u.uDim.value = pose.dim * (1 - c.hover);
      c.u.uBlur.value = pose.blur;
    } else if (c.mode === 'fly' || c.mode === 'case') {
      c.u.uBlur.value = 0;
      const to = c.mode === 'case' ? targetPose() : c.to;
      if (c.mode === 'case') { c.mesh.position.copy(to.pos); c.mesh.quaternion.copy(to.quat); c.mesh.scale.setScalar(to.s); }
      else {
        c.mesh.position.lerpVectors(c.from.pos, to.pos, c.t);
        c.mesh.quaternion.slerpQuaternions(c.from.quat, to.quat, c.t);
        c.mesh.scale.setScalar(THREE.MathUtils.lerp(c.from.s, to.s, c.t));
        // little extra tilt mid-flight
        c.mesh.rotateZ(Math.sin(c.t * Math.PI) * 0.12);
      }
    } else if (c.mode === 'back') {
      c.mesh.position.lerpVectors(c.from.pos, pose.pos, c.t);
      c.mesh.quaternion.slerpQuaternions(c.from.quat, pose.quat, c.t);
      c.mesh.scale.setScalar(THREE.MathUtils.lerp(c.from.s, baseS, c.t));
      c.u.uOpacity.value = THREE.MathUtils.lerp(1, pose.op, c.t);
      c.u.uDim.value = THREE.MathUtils.lerp(0, pose.dim, c.t);
    }
  });

  // light: tint with active card colour, slow rotation, breathing
  const lc = new THREE.Color(P[state.open ? state.active : ai].color);
  state.light.lerp(lc, 0.05);
  rays.material.color.copy(state.light).lerp(WHITE, 0.15 + state.end * .5);
  rays2.material.color.copy(state.light);
  halo.material.color.copy(state.light).lerp(WHITE, 0.25 + state.end * .4);
  glow.material.color.set(1, 1, 1).lerp(state.light, 0.08);
  const gsz = L.glow * (1 + state.end * 1.8) * state.glowIn;
  glow.scale.setScalar(gsz); halo.scale.setScalar(gsz * 1.5);
  rays.material.opacity = 0.42 + state.end * .25;
  _lp.copy(glow.position).project(camera);
  root.style.setProperty('--lx', ((_lp.x + 1) / 2 * 100).toFixed(2) + '%');
  root.style.setProperty('--ly', ((1 - _lp.y) / 2 * 100).toFixed(2) + '%');
  rays.material.rotation = state.time * 0.035 + state.p * 0.12;
  rays2.material.rotation = -state.time * 0.025 - state.p * 0.08;
  const breathe = 1 + Math.sin(state.time * 1.6) * 0.03;
  glow.material.opacity = 0.95 * breathe;

  // ticks progress line
  $('base').style.width = (Math.min(state.p / (N - 1), 1) * 100) + '%';
  if (state.end > .55) ticks.forEach(t => t.classList.add('on'));

  renderer.render(scene, camera);
  requestAnimationFrame(tick);
}

/* ============================================================
   BOOT
   ============================================================ */
async function boot() {
  layout();
  try { await Promise.race([document.fonts.load('800 80px "Bricolage Grotesque"'), new Promise(r => setTimeout(r, 2500))]); } catch (e) {}
  await Promise.all(P.map((p, i) => new Promise(res => {
    const img = new Image();
    img.crossOrigin = 'anonymous';
    img.onload = () => { cards[i].u.uTex.value = makePoster(p, img); res(); };
    img.onerror = () => { const c = document.createElement('canvas'); c.width = 16; c.height = 10; const g = c.getContext('2d'); g.fillStyle = '#333'; g.fillRect(0, 0, 16, 10); cards[i].u.uTex.value = makePoster(p, c); res(); };
    img.src = IMAGES[i];
  })));
  state.p = state.pt = THREE.MathUtils.clamp(scrollY / step, 0, N);
  requestAnimationFrame(tick);
  document.getElementById('loader').classList.add('done');
  state.ready = true;
  gsap.to(state, { intro: 0, duration: reduced ? .01 : 2.6, ease: 'expo.out' });
  gsap.fromTo(state, { glowIn: 0.15 }, { glowIn: 1, duration: 2.2, ease: 'expo.out' });
  setTimeout(() => document.body.classList.add('ready'), 500);
}
boot();
</script>
</body>
</html>
```


## Build instructions by tool

### Claude Code

Open a terminal in an empty folder, run `claude`, then paste the prompt.

```text
Build the "Vortex portfolio hero" app from the OwnlyPlans blueprint at https://ownlyplans.com/bhaskar/vortex-portfolio-hero/.
Stack: CSS, GSAP, HTML, JavaScript, Three.js.
Follow the plan's steps in order: Draw the poster cards and the spiral → Scroll through the vortex → Peel a card into its case study → Background, ending and the phone version.
Download the full plan (Markdown) from the link above and keep it in the project root as PLAN.md.
Ask me before adding anything not in the plan. (Prepared for Claude Code.)
```

### Cursor

Open an empty folder in Cursor, start an Agent chat, then paste the prompt.

```text
Build the "Vortex portfolio hero" app from the OwnlyPlans blueprint at https://ownlyplans.com/bhaskar/vortex-portfolio-hero/.
Stack: CSS, GSAP, HTML, JavaScript, Three.js.
Follow the plan's steps in order: Draw the poster cards and the spiral → Scroll through the vortex → Peel a card into its case study → Background, ending and the phone version.
Download the full plan (Markdown) from the link above and keep it in the project root as PLAN.md.
Ask me before adding anything not in the plan. (Prepared for Cursor.)
```

### Lovable

Start a new Lovable project and paste the prompt as your first message.

```text
Build the "Vortex portfolio hero" app from the OwnlyPlans blueprint at https://ownlyplans.com/bhaskar/vortex-portfolio-hero/.
Stack: CSS, GSAP, HTML, JavaScript, Three.js.
Follow the plan's steps in order: Draw the poster cards and the spiral → Scroll through the vortex → Peel a card into its case study → Background, ending and the phone version.
Download the full plan (Markdown) from the link above and keep it in the project root as PLAN.md.
Ask me before adding anything not in the plan. (Prepared for Lovable.)
```

## Definition of done

- Every build step is complete and the app runs locally.
- The main user flow works end to end.
- Share your build on OwnlyPlans with a demo link, build time and tool.
