/* ────────────────────────────────────────────────────────────────────────── * HiveGrid — Honeycomb Integrations Element — V6 "Honig A + Sog" * Wie Honig A, plus: der G-Hover-Effekt (alles driftet weg, Wabe atmet) * gilt abgestuft für JEDES Hexagon. Hover auf eine Tool-Zelle oder eine * Deko-Wabe erzeugt einen Mini-Sog um genau dieses Hexagon — Nachbarn * weichen aus, mit Distanz-Falloff (exp), die Stränge folgen ihren Zellen. * Stärke: G (Mitte) > Tool-Ring > Deko-Ring — von innen nach außen weniger. * * (Basis-Header von V4:) * Dunkle Basis; Verbindungen sind berechnete Honig-Stränge (Metaball-Pfad): * gefüllte Pfade, die an beiden Enden aufweiten und mittig eine Taille haben. * Dehnen (Zelle poppt raus, G wächst) dünnt die Taille aus, Stauchen macht * sie dicker — Volumenerhaltung. Optionaler Scroll-Reveal: erst die Waben, * danach die Verbindungen; ohne Prop steht das Grid weiterhin sofort. * Zell-Hover schiebt die Zelle radial raus, der Strang folgt bündig. * G-Hover: gesamte Wabe inkl. Hintergrund-Feld atmet mit (kein Licht-Wash). * Alle äußeren Hexagone einheitlich flach. Cursor-Parallax auf der Wabe. * * Flat-top hex "honeycomb": HiveGrid-Hub in der Mitte, 6 Tool-Logos im inneren * Ring, faint Deko-Ring + ausgedehntes Hintergrund-Feld das radial + von oben * einfadet. Hover: Zellen "poppen" raus, Linien leuchten, Daten-Pakete laufen * Tool → Hub. Alles hinter prefers-reduced-motion gegated. * * ── Verwendung ────────────────────────────────────────────────────────────── * import HoneycombSection from "./HoneycombSection"; * // standalone, vertikal einfadendes Feld * // absolute Full-Bleed-BG (nur lg+) * // eigene Section mit Headline/Badge * theme default = "light" (White-Mode); für Dark-BG theme="dark". * ────────────────────────────────────────────────────────────────────────── */ "use client"; import { useRef, useState } from "react"; import { useGSAP } from "@gsap/react"; import { gsap } from "gsap"; import { ScrollTrigger } from "gsap/dist/ScrollTrigger"; gsap.registerPlugin(ScrollTrigger, useGSAP); /* ── Sog physics — one repulsion model for EVERY comb (ring 1, ring 2 and * the whole background field behave identically). Tunable per variant: * falloff px — reach of the push (exp kernel); bigger = the whole comb * moves together and rings don't get squeezed into each other * hub/cell/outer push strength by which element is hovered * outerScale how much a hovered background comb grows * in/out timing + easing of push and settle * ripple stagger the push by distance → wave running outward */ export type SogPhysics = { falloff: number; hub: number; cell: number; outer: number; outerScale: number; inDur: number; inEase: string; outDur: number; outEase: string; ripple: boolean; }; export const PHYSICS_PRESETS: Record = { // ruhig & edel: moderater Schub, weiches Settle soft: { falloff: 280, hub: 22, cell: 14, outer: 10, outerScale: 1.12, inDur: 0.7, inEase: "power2.out", outDur: 0.8, outEase: "power2.out", ripple: false }, // verspielt: kräftiger Schub, federt elastisch zurück bouncy: { falloff: 260, hub: 26, cell: 18, outer: 14, outerScale: 1.2, inDur: 0.55, inEase: "back.out(2.2)", outDur: 1.15, outEase: "elastic.out(1, 0.5)", ripple: false }, // physisch: kurzer Radius, harter lokaler Abstoß, Hexes wachsen stark repulsion: { falloff: 170, hub: 30, cell: 22, outer: 18, outerScale: 1.25, inDur: 0.45, inEase: "power3.out", outDur: 0.8, outEase: "power3.out", ripple: false }, // organisch: weiter Radius, Schub läuft als Welle nach außen welle: { falloff: 340, hub: 24, cell: 16, outer: 12, outerScale: 1.15, inDur: 0.8, inEase: "power2.out", outDur: 0.9, outEase: "power2.out", ripple: true }, }; /* ────────────────────────────────────────────────────────────────────────── * Honeycomb integrations element. * * A flat-top hex honeycomb in HiveGrid's honey/amber: the HiveGrid "G" hub in * the centre, the tools it connects in the six surrounding cells, and a faint * outer ring for comb texture. Glowing data packets travel each connection line * into the hub. * * Hovering a cell pops it gently out of the comb (the cells sit on wide seams so * a hover never overlaps a neighbour) and lights up its connection line. * * Built with useGSAP. Hover handlers are wrapped in contextSafe() and removed on * cleanup; all ambient + entrance motion is gated behind prefers-reduced-motion. * ────────────────────────────────────────────────────────────────────────── */ // ── hex geometry (flat-top) ──────────────────────────────────────────────── const R = 62; // circumradius — everything derives from this const W = 2 * R; // hex width (point to point, horizontal) const H = Math.sqrt(3) * R; // hex height (flat to flat) const PAD = 24; // face size factors — < 1 opens a seam between cells so hovers never overlap const CELL_SIZE = 0.84; const CENTER_SIZE = 0.88; const HOVER_SCALE = 1.06; const DEBUG_CELL_NUMBERS = false; // axial (q,r) → pixel centre for a flat-top hex grid const axialToPx = (q: number, r: number) => ({ x: R * 1.5 * q, y: R * Math.sqrt(3) * (r + q / 2), }); // the six neighbour directions in axial space const DIRS = [ [1, 0], [1, -1], [0, -1], [-1, 0], [-1, 1], [0, 1], ]; // all hexes exactly `radius` rings out from the centre (redblobgames ring walk) function hexRing(radius: number) { if (radius === 0) return [[0, 0]]; const out: number[][] = []; let q = DIRS[4][0] * radius; let r = DIRS[4][1] * radius; for (let side = 0; side < 6; side++) { for (let step = 0; step < radius; step++) { out.push([q, r]); q += DIRS[side][0]; r += DIRS[side][1]; } } return out; } export type HoneycombLogoPlacements = Partial>; // Final landing-page composition. Cell 1 remains the HiveGrid hub and is // deliberately not a logo slot; the grid lab can still override this map. export const HONEYCOMB_DEFAULT_LOGO_PLACEMENTS: Readonly = { 9: "DATEV", 10: "PandaDoc", 12: "Outlook", 13: "Google Drive", 15: "Claude", 17: "kwp", 18: "Bauhow", 19: "PDS", 21: "Aircall", 22: "Onepage", 26: "Teams", 28: "Google Calendar", 30: "OpenAI", 36: "Hallo Petra", }; // real logos keyed by tool label; an unkeyed label renders a blank cell. // `scale` lets each logo fill the cell to a comparable optical size; // `cornerRadius` keeps square app tiles soft without changing the source PNG. // Logos sit flat on the cell — no drop shadows. Production assets live in // /public (real branded PNGs for kwp/DATEV, brand SVGs for the rest). export type HoneycombLogoAsset = { src: string; scale?: number; cornerRadius?: string; }; export const HONEYCOMB_LOGOS: Readonly> = { kwp: { src: "/kwp.png" }, DATEV: { src: "/datev.png" }, "Google Drive": { src: "/google-drive.svg", scale: 1.05 }, Teams: { src: "/ms-teams.svg", scale: 1.0 }, Outlook: { src: "/ms-outlook.svg", scale: 1.05 }, "Google Calendar": { src: "/google-calendar.svg", scale: 1.0 }, Bauhow: { src: "/bauhow.png", scale: 1.08 }, PDS: { src: "/pds.svg", scale: 1.38 }, Aircall: { src: "/aircall.svg", scale: 1.3 }, "Hallo Petra": { src: "/hallopetra.png", scale: 1.18 }, Claude: { src: "/claude.svg", scale: 1.12 }, OpenAI: { src: "/openai.svg", scale: 1.12 }, PandaDoc: { src: "/pandadoc.png", scale: 1.08, cornerRadius: "18%" }, Onepage: { src: "/onepage.png", scale: 1.12 }, }; export const HONEYCOMB_DEFAULT_ACTIVE_CELL_IDS = Object.freeze([ 3, 5, 7, ...Object.keys(HONEYCOMB_DEFAULT_LOGO_PLACEMENTS).map(Number), ].filter((id, index, ids) => ids.indexOf(id) === index)); const HONEYCOMB_DEFAULT_ACTIVE_CELL_ID_SET = new Set( HONEYCOMB_DEFAULT_ACTIVE_CELL_IDS ); export type HoneycombAppearance = "solid" | "glass" | "outline" | "frosted"; export type HoneycombLayers = { hub: boolean; innerRing: boolean; outerRing: boolean; field: boolean; strands: boolean; packets: boolean; glow: boolean; }; export const HONEYCOMB_DEFAULT_LAYERS: HoneycombLayers = { hub: true, innerRing: true, outerRing: true, field: true, strands: true, packets: true, glow: true, }; export type HoneycombPlacementTool = string | "__erase__" | null; // build cell list: centre hub, inner tool ring (6), outer ring (12) type Cell = { x: number; y: number; kind: "center" | "tool" | "deco"; i: number; debugId: number; label?: string; }; const rawCells: Cell[] = [ { ...axialToPx(0, 0), kind: "center", i: 0, debugId: 1 }, ...hexRing(1).map(([q, r], i) => ({ ...axialToPx(q, r), kind: "tool" as const, i, debugId: i + 2, })), ...hexRing(2).map(([q, r], i) => ({ ...axialToPx(q, r), kind: "deco" as const, i, debugId: i + 8, })), ]; // the SAME honeycomb, continued outward in further rings — these are the static // background field that fills the section. 1:1 the same grid as the deco ring, // just more layers (rings 3..N). Reaches far enough that even a 4K screen is // covered edge-to-edge once scaled; the radial fade below hides the outer rows. const FIELD_MAX_RING = 18; // EVERY background comb (rings 3–18) is an individual, hoverable SVG path — // same colour, same interaction everywhere. The Sog loops skip hexes outside // its falloff reach, so the cost per hover stays tiny despite the count. const fieldRaw: { x: number; y: number; ring: number; debugId: number }[] = []; for (let k = 3; k <= FIELD_MAX_RING; k++) { for (const [q, r] of hexRing(k)) { fieldRaw.push({ ...axialToPx(q, r), ring: k, debugId: rawCells.length + fieldRaw.length + 1 }); } } // normalise everything (interactive cells + field) into a positive box (+ padding) const allRaw = [...rawCells, ...fieldRaw]; const xs = allRaw.map((c) => c.x); const ys = allRaw.map((c) => c.y); const minX = Math.min(...xs) - W / 2 - PAD; const minY = Math.min(...ys) - H / 2 - PAD; const BOX_W = Math.max(...xs) + W / 2 + PAD - minX; const BOX_H = Math.max(...ys) + H / 2 + PAD - minY; const cells = rawCells.map((c) => ({ ...c, x: c.x - minX, y: c.y - minY })); const fieldCells = fieldRaw.map((c) => ({ x: c.x - minX, y: c.y - minY, ring: c.ring, debugId: c.debugId, })); const nearField = fieldCells; // all of them — no static far layer anymore const center = cells.find((c) => c.kind === "center")!; const toolCells = cells.filter((c) => c.kind === "tool"); const decoCells = cells.filter((c) => c.kind === "deco"); // Connection lines and packets stop at the outer edge of the G instead of // running underneath it — the hub logo stands free but stays connected. // The G is a flat-top hex the size of a cell face; lines approach it through // the edge midpoints, so the cut distance is its inradius. The ends sit flush // on the G's edge; while the hub is hovered they track the scaled-up G // (lineEndsHover) so the line always meets the edge, never gaps or tucks under. // Math.sqrt, not Math.hypot — see the SSR note at the field render below. const HUB_HOVER_SCALE = 1.12; const HUB_EDGE = R * CELL_SIZE * 0.8660254; const cutTowardHub = (p: { x: number; y: number }, edge: number) => { const dx = center.x - p.x; const dy = center.y - p.y; const len = Math.sqrt(dx * dx + dy * dy) || 1; return { x: center.x - (dx / len) * edge, y: center.y - (dy / len) * edge }; }; // Where the travelling data packets aim: the G's edge. They still flow the // whole way in — a clipPath around the central G hex (see the render) hides the // dot AND its glow the instant they cross into the logo, so nothing shows // inside the transparent cut-out while the outer flow stays intact. const lineEnds = toolCells.map((p) => cutTowardHub(p, HUB_EDGE)); /* ── honey strands (V4) ───────────────────────────────────────────────────── * Each connection is a filled path shaped like a strand of honey: it flares * where it roots on the tool cell and on the G, and necks down to a waist in * the middle. The shape is rebuilt from its two endpoints every frame while * they animate; the waist obeys a volume-conservation rule — stretching the * strand (longer) thins it, squashing it (shorter) fattens it. */ const STRAND_END_TOOL = 14; // half-width where the strand roots on a tool cell const STRAND_END_G = 16; // half-width where it roots on the G const STRAND_WAIST = 4.5; // half-width mid-strand at rest length // How deep the strand tips sit under the faces. Must be generous: when a // cell is displaced sideways by the Sog the strand ROTATES around its tip, // and the tip corners swing out from under the edge — 3px left visible gaps // at certain positions. 8px keeps the joint buried at every angle (the tip // is hidden by the opaque cell face resp. the G's band + interior plate). const STRAND_TUCK = 8; // point at `dist` from a tool cell's centre toward the hub const cutFromTool = (p: { x: number; y: number }, dist: number) => { const dx = center.x - p.x; const dy = center.y - p.y; const len = Math.sqrt(dx * dx + dy * dy) || 1; return { x: p.x + (dx / len) * dist, y: p.y + (dy / len) * dist }; }; const strandRest = toolCells.map((p) => { const a = cutFromTool(p, HUB_EDGE - STRAND_TUCK); // tool face inradius == HUB_EDGE const b = cutTowardHub(p, HUB_EDGE - STRAND_TUCK); const dx = b.x - a.x; const dy = b.y - a.y; return { a, b, len: Math.sqrt(dx * dx + dy * dy) || 1 }; }); // strand endpoints while the hub is hovered: cells get pushed 18px outward // and the G grows — the strand stretches between both const strandHover = toolCells.map((p, i) => { const dx = p.x - center.x; const dy = p.y - center.y; const len = Math.sqrt(dx * dx + dy * dy) || 1; const b = cutTowardHub(p, HUB_EDGE * HUB_HOVER_SCALE - STRAND_TUCK); return { ax: strandRest[i].a.x + (dx / len) * 18, ay: strandRest[i].a.y + (dy / len) * 18, bx: b.x, by: b.y, }; }); // flat-top hex path at arbitrary radius const hexPathR = (cx: number, cy: number, rr: number) => { const hh = rr * 0.8660254; const f = (v: number) => v.toFixed(1); return `M${f(cx + rr)} ${f(cy)} L${f(cx + rr / 2)} ${f(cy + hh)} L${f(cx - rr / 2)} ${f(cy + hh)} L${f(cx - rr)} ${f(cy)} L${f(cx - rr / 2)} ${f(cy - hh)} L${f(cx + rr / 2)} ${f(cy - hh)} Z`; }; function strandPath(a: { x: number; y: number }, b: { x: number; y: number }, restLen: number) { const dx = b.x - a.x; const dy = b.y - a.y; const len = Math.sqrt(dx * dx + dy * dy) || 1; const ux = dx / len; const uy = dy / len; const nx = -uy; const ny = ux; // volume conservation: waist scales with (restLen/len)^1.6, clamped const squash = Math.min(2.2, Math.max(0.4, Math.pow(restLen / len, 1.6))); const wa = STRAND_END_TOOL * (0.85 + 0.15 * squash); const wb = STRAND_END_G * (0.85 + 0.15 * squash); // never let the waist collapse — the strand must stay visibly connected no // matter how far the ends are stretched apart const wm = Math.max(2.5, STRAND_WAIST * squash); const wc = (8 * wm - wa - wb) / 6; // cubic control offset that yields `wm` mid-strand const c1x = a.x + ux * len * 0.35; const c1y = a.y + uy * len * 0.35; const c2x = a.x + ux * len * 0.65; const c2y = a.y + uy * len * 0.65; const f = (v: number) => v.toFixed(2); return ( `M${f(a.x + nx * wa)} ${f(a.y + ny * wa)} ` + `C${f(c1x + nx * wc)} ${f(c1y + ny * wc)} ${f(c2x + nx * wc)} ${f(c2y + ny * wc)} ${f(b.x + nx * wb)} ${f(b.y + ny * wb)} ` + `L${f(b.x - nx * wb)} ${f(b.y - ny * wb)} ` + `C${f(c2x - nx * wc)} ${f(c2y - ny * wc)} ${f(c1x - nx * wc)} ${f(c1y - ny * wc)} ${f(a.x - nx * wa)} ${f(a.y - ny * wa)} Z` ); } // flat-top hex outline path (same radius as a deco cell's face) for the static // background field — drawn as light SVG paths instead of hundreds of DOM nodes. const FIELD_RR = R * CELL_SIZE; // matches the deco face circumradius const FIELD_HH = FIELD_RR * 0.8660254; const FIELD_LOGO_BOX = W * 0.48; const fieldHexPath = (cx: number, cy: number) => { const f = (x: number, y: number) => `${x.toFixed(1)} ${y.toFixed(1)}`; return `M${f(cx + FIELD_RR, cy)} L${f(cx + FIELD_RR / 2, cy + FIELD_HH)} L${f(cx - FIELD_RR / 2, cy + FIELD_HH)} L${f(cx - FIELD_RR, cy)} L${f(cx - FIELD_RR / 2, cy - FIELD_HH)} L${f(cx + FIELD_RR / 2, cy - FIELD_HH)} Z`; }; const HEX_CLIP = "polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)"; // honey/amber brand fill for the tool cells — flat, no gradient const CELL_BG = "var(--accent-yellow)"; type HoneycombVisual = { activeFill: string; inactiveFill: string; hoverFill: string; activeOutline?: string; inactiveOutline?: string; outlineWidth?: number; backdropFilter?: string; activeShadow?: string; inactiveShadow?: string; fieldFill: string; fieldActiveOpacity: number; fieldInactiveOpacity: number; fieldHoverOpacity: number; fieldActiveStroke?: string; fieldInactiveStroke?: string; fieldStrokeWidth?: number; strand: string; packet: string; glow: string; flare: string; }; const HONEYCOMB_VISUALS: Record = { solid: { activeFill: CELL_BG, inactiveFill: "rgba(241,183,41,0.08)", hoverFill: "rgba(241,183,41,0.16)", activeShadow: "0 0 26px -8px rgba(241,183,41,0.3)", fieldFill: "#F1B729", fieldActiveOpacity: 1, fieldInactiveOpacity: 0.08, fieldHoverOpacity: 0.16, strand: "#F1B729", packet: "#F1B729", glow: "radial-gradient(closest-side, rgba(241,183,41,0.6), rgba(241,183,41,0.12) 58%, transparent 72%)", flare: "radial-gradient(closest-side, rgba(241,183,41,0.65), rgba(241,183,41,0.15) 55%, transparent 70%)", }, glass: { activeFill: "rgba(241,183,41,0.25)", inactiveFill: "rgba(241,183,41,0.055)", hoverFill: "rgba(241,183,41,0.13)", activeOutline: "rgba(255,239,184,0.72)", inactiveOutline: "rgba(255,228,139,0.22)", outlineWidth: 1.5, backdropFilter: "blur(16px) saturate(1.35)", activeShadow: "inset 0 1px 0 rgba(255,255,255,0.55), 0 18px 38px -22px rgba(105,70,0,0.68), 0 0 28px -14px rgba(241,183,41,0.72)", inactiveShadow: "inset 0 1px 0 rgba(255,255,255,0.2)", fieldFill: "#F1B729", fieldActiveOpacity: 0.26, fieldInactiveOpacity: 0.045, fieldHoverOpacity: 0.13, fieldActiveStroke: "rgba(255,232,155,0.62)", fieldInactiveStroke: "rgba(241,183,41,0.16)", fieldStrokeWidth: 1.2, strand: "rgba(241,183,41,0.58)", packet: "#FFE7A3", glow: "radial-gradient(closest-side, rgba(241,183,41,0.38), rgba(241,183,41,0.08) 58%, transparent 72%)", flare: "radial-gradient(closest-side, rgba(255,221,124,0.45), rgba(241,183,41,0.1) 55%, transparent 70%)", }, outline: { activeFill: "rgba(241,183,41,0.11)", inactiveFill: "rgba(241,183,41,0.018)", hoverFill: "rgba(241,183,41,0.075)", activeOutline: "rgba(241,183,41,0.96)", inactiveOutline: "rgba(241,183,41,0.19)", outlineWidth: 1.7, activeShadow: "0 0 28px -15px rgba(241,183,41,0.88)", fieldFill: "#F1B729", fieldActiveOpacity: 0.1, fieldInactiveOpacity: 0.012, fieldHoverOpacity: 0.07, fieldActiveStroke: "rgba(241,183,41,0.9)", fieldInactiveStroke: "rgba(241,183,41,0.16)", fieldStrokeWidth: 1.5, strand: "rgba(241,183,41,0.78)", packet: "#F1B729", glow: "radial-gradient(closest-side, rgba(241,183,41,0.3), rgba(241,183,41,0.045) 58%, transparent 72%)", flare: "radial-gradient(closest-side, rgba(241,183,41,0.38), rgba(241,183,41,0.07) 55%, transparent 70%)", }, frosted: { activeFill: "rgba(255,218,112,0.48)", inactiveFill: "rgba(255,246,214,0.1)", hoverFill: "rgba(255,225,139,0.22)", activeOutline: "rgba(255,251,236,0.82)", inactiveOutline: "rgba(255,240,190,0.28)", outlineWidth: 1.2, backdropFilter: "blur(9px) saturate(1.18)", activeShadow: "inset 0 1px 0 rgba(255,255,255,0.72), 0 18px 44px -26px rgba(77,48,0,0.72)", inactiveShadow: "inset 0 1px 0 rgba(255,255,255,0.3)", fieldFill: "#FFD96F", fieldActiveOpacity: 0.46, fieldInactiveOpacity: 0.075, fieldHoverOpacity: 0.19, fieldActiveStroke: "rgba(255,250,229,0.66)", fieldInactiveStroke: "rgba(255,226,139,0.22)", fieldStrokeWidth: 1, strand: "rgba(255,210,86,0.66)", packet: "#FFF4D0", glow: "radial-gradient(closest-side, rgba(255,215,102,0.42), rgba(255,229,151,0.09) 58%, transparent 72%)", flare: "radial-gradient(closest-side, rgba(255,242,197,0.52), rgba(241,183,41,0.1) 55%, transparent 70%)", }, }; function HexShell({ x, y, children, bg, border, outline, outlineWidth = 2, dataAttr, z = 1, faceShadow, faceBackdropFilter, size = 1, debugNumber, active, }: { x: number; y: number; children?: React.ReactNode; bg: string; border?: string; outline?: string; // a true hex-shaped outline (a CSS border gets clipped on the slants) outlineWidth?: number; dataAttr?: Record; z?: number; faceShadow?: string; faceBackdropFilter?: string; size?: number; // shrink the face to open a honeycomb seam between cells debugNumber?: number; active?: boolean; }) { const interactive = dataAttr?.["data-hex"] === "cell" || dataAttr?.["data-hex"] === "center"; return (
{/* the hexagon face — a separate node so it can scale/lift without moving the wrapper's hit-area origin. When `outline` is set, the face becomes the outline-coloured hex and an inset inner hex carries the fill, so the outline follows the hex shape (a CSS border would be clipped). */}
{outline ? (
{children}
) : ( children )} {debugNumber !== undefined && ( )}
); } export type HoneycombSectionProps = { bare?: boolean; inline?: boolean; theme?: "dark" | "light"; physics?: SogPhysics; appearance?: HoneycombAppearance; layers?: Partial; showCellNumbers?: boolean; showInlineFade?: boolean; logoPlacements?: Readonly; onLogoPlacementsChange?: (placements: HoneycombLogoPlacements) => void; activeCellIds?: readonly number[]; onActiveCellIdsChange?: (cellIds: number[]) => void; editorMode?: boolean; placementTool?: HoneycombPlacementTool; revealOnScroll?: boolean; }; export default function HoneycombSection({ bare = false, inline = false, theme = "light", physics = PHYSICS_PRESETS.soft, appearance = "solid", layers: layerOverrides, showCellNumbers = DEBUG_CELL_NUMBERS, showInlineFade = true, logoPlacements: controlledLogoPlacements, onLogoPlacementsChange, activeCellIds, onActiveCellIdsChange, editorMode = false, placementTool = null, revealOnScroll = false, }: HoneycombSectionProps = {}) { const root = useRef(null); const [internalLogoPlacements, setInternalLogoPlacements] = useState(() => ({ ...HONEYCOMB_DEFAULT_LOGO_PLACEMENTS, })); const logoPlacements = controlledLogoPlacements ?? internalLogoPlacements; const activeCellIdSet = activeCellIds === undefined ? null : new Set(activeCellIds); const commitLogoPlacements = ( update: (current: Readonly) => HoneycombLogoPlacements ) => { const next = update(logoPlacements); if (controlledLogoPlacements === undefined) setInternalLogoPlacements(next); onLogoPlacementsChange?.(next); }; const commitCellActive = (cellId: number, active: boolean) => { const current = activeCellIdSet; if (!current) return; const next = new Set(current); if (active) next.add(cellId); else next.delete(cellId); onActiveCellIdsChange?.([...next].sort((a, b) => a - b)); }; const isCellActive = (cellId: number, defaultActive: boolean) => activeCellIdSet?.has(cellId) ?? defaultActive; const layers: HoneycombLayers = { ...HONEYCOMB_DEFAULT_LAYERS, ...layerOverrides, }; const visual = HONEYCOMB_VISUALS[appearance]; const activeStateKey = activeCellIds === undefined ? "internal" : [...activeCellIds].sort((a, b) => a - b).join(","); const layerStateKey = Object.values(layers).map((enabled) => (enabled ? "1" : "0")).join(""); const dark = theme !== "light"; // edge-fade gradient in the current background colour const fadeBg = dark ? "linear-gradient(to right, #171106 0%, rgba(23,17,6,0) 24%, rgba(23,17,6,0) 76%, #171106 100%), linear-gradient(to bottom, rgba(23,17,6,0.85) 0%, rgba(23,17,6,0) 18%, rgba(23,17,6,0) 80%, #171106 100%)" : "linear-gradient(to right, #FFFFFF 0%, rgba(255,255,255,0) 24%, rgba(255,255,255,0) 76%, #FFFFFF 100%), linear-gradient(to bottom, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0) 18%, rgba(255,255,255,0) 80%, #FFFFFF 100%)"; // Inline (pain-point) usage is full-bleed on the section's own bg (#FAFAFA = // var(--bg-primary)); fade EVERY edge to that colour so clipped "half" hexes // dissolve into whitespace instead of being hard-cut. Percent-based, so it // holds on every viewport height. const inlineFade = "linear-gradient(to bottom, #FAFAFA 0%, rgba(250,250,250,0) 15%, rgba(250,250,250,0) 85%, #FAFAFA 100%), " + "linear-gradient(to right, #FAFAFA 0%, rgba(250,250,250,0) 13%, rgba(250,250,250,0) 87%, #FAFAFA 100%)"; useGSAP( (_context, contextSafe) => { const q = gsap.utils.selector(root); const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches; const centerEl = q("[data-hex='center']"); const cellEls = q("[data-hex='cell']"); const decoEls = q("[data-hex='deco']"); const baseLines = q("[data-line='base']"); const packets = q("[data-packet]"); const glow = q("[data-glow]"); const toolCellIsActive = (index: number) => isCellActive( toolCells[index].debugId, HONEYCOMB_DEFAULT_ACTIVE_CELL_ID_SET.has(toolCells[index].debugId) ); const activeBaseLines = baseLines.filter((_line, index) => toolCellIsActive(index)); // live strand endpoints — tweened; every update rebuilds the honey paths const sState = strandRest.map((s) => ({ ax: s.a.x, ay: s.a.y, bx: s.b.x, by: s.b.y })); const redrawStrands = () => sState.forEach((st, i) => baseLines[i]?.setAttribute( "d", strandPath({ x: st.ax, y: st.ay }, { x: st.bx, y: st.by }, strandRest[i].len) ) ); const cleanups: Array<() => void> = []; // ── graded "Sog": the G-hover effect, scaled down, for EVERY hex ───── // Hovering any hexagon pushes its neighbours away from it with an // exponential distance falloff; the strands follow their cells so the // honey never detaches. Strength: G 16 > tool 13 > deco 8 > field 6. // Long durations + power2 (no overshoot) keep it soft, never choppy. const nearEls = q("[data-nearhex]"); const nearMoveEls = q("[data-nearcell]"); const PHY = physics; const SOG_IN = { duration: PHY.inDur, ease: PHY.inEase, overwrite: "auto" as const }; const SOG_OUT = { duration: PHY.outDur, ease: PHY.outEase, overwrite: "auto" as const }; // ripple mode: the push starts later the further out a comb sits — // the displacement runs outward as a wave const rippleDelay = (d: number) => (PHY.ripple ? d * 0.0009 : 0); // with ALL field combs animatable (1000+), only touch the ones inside // the falloff reach and only reset the ones that actually moved const displacedNear = new Set(); const sogNear = (ox: number, oy: number, strength: number) => { nearMoveEls.forEach((el, j) => { const dx = nearField[j].x - ox; const dy = nearField[j].y - oy; const d = Math.sqrt(dx * dx + dy * dy) || 1; const amt = strength * Math.exp(-d / PHY.falloff); if (amt < 0.3) return; // beyond reach — skip the tween entirely displacedNear.add(el); gsap.to(el, { x: (dx / d) * amt, y: (dy / d) * amt, delay: rippleDelay(d), ...SOG_IN }); }); }; const releaseNear = () => { if (!displacedNear.size) return; gsap.to(Array.from(displacedNear), { x: 0, y: 0, ...SOG_OUT }); displacedNear.clear(); }; const applySog = (ox: number, oy: number, strength: number, skipCell = -1) => { cellEls.forEach((el, j) => { if (j === skipCell) return; const dx = toolCells[j].x - ox; const dy = toolCells[j].y - oy; const d = Math.sqrt(dx * dx + dy * dy) || 1; const amt = strength * Math.exp(-d / PHY.falloff); gsap.to(el, { x: (dx / d) * amt, y: (dy / d) * amt, delay: rippleDelay(d), ...SOG_IN }); gsap.to(sState[j], { ax: strandRest[j].a.x + (dx / d) * amt, ay: strandRest[j].a.y + (dy / d) * amt, delay: rippleDelay(d), ...SOG_IN, onUpdate: redrawStrands, }); }); decoEls.forEach((el, j) => { const dx = decoCells[j].x - ox; const dy = decoCells[j].y - oy; const d = Math.sqrt(dx * dx + dy * dy) || 1; const amt = strength * Math.exp(-d / PHY.falloff); gsap.to(el, { x: (dx / d) * amt, y: (dy / d) * amt, delay: rippleDelay(d), ...SOG_IN }); }); sogNear(ox, oy, strength); }; const releaseSog = (skipCell = -1) => { cellEls.forEach((el, j) => { if (j === skipCell) return; gsap.to(el, { x: 0, y: 0, ...SOG_OUT }); gsap.to(sState[j], { ax: strandRest[j].a.x, ay: strandRest[j].a.y, ...SOG_OUT, onUpdate: redrawStrands, }); }); gsap.to(decoEls, { x: 0, y: 0, ...SOG_OUT }); releaseNear(); }; // ── near-field hover: even the outer honeycomb rings interact ──────── nearEls.forEach((hex, k) => { const moveEl = nearMoveEls[k] ?? hex; const enter = contextSafe!(() => { gsap.to(moveEl, { scale: PHY.outerScale, transformOrigin: "50% 50%", duration: PHY.inDur * 0.6, ease: "back.out(2)", overwrite: "auto", }); gsap.to(hex, { // click-activated combs are solid — hover must not dim them attr: { "fill-opacity": (hex as HTMLElement).dataset.active ? visual.fieldActiveOpacity : visual.fieldHoverOpacity, }, duration: PHY.inDur * 0.6, ease: "power2.out", overwrite: "auto", }); if (!reduce) applySog(nearField[k].x, nearField[k].y, PHY.outer); }); const leave = contextSafe!(() => { gsap.to(moveEl, { scale: 1, duration: PHY.outDur, ease: PHY.outEase, overwrite: "auto", }); gsap.to(hex, { attr: { "fill-opacity": (hex as HTMLElement).dataset.active ? visual.fieldActiveOpacity : visual.fieldInactiveOpacity, }, duration: PHY.outDur, ease: PHY.outEase, overwrite: "auto", }); if (!reduce) releaseSog(); }); hex.addEventListener("mouseenter", enter); hex.addEventListener("mouseleave", leave); cleanups.push(() => { hex.removeEventListener("mouseenter", enter); hex.removeEventListener("mouseleave", leave); }); }); // ── hover: a gentle pop, line highlight, packet boost ──────────────── cellEls.forEach((cell) => { const face = cell.querySelector(".hex-face") as HTMLElement; const i = Number((cell as HTMLElement).dataset.index); const base = baseLines[i]; const packet = packets[i]; // radial outward direction of this cell — hover pops the cell away // from the G and the honey strand stretches after it const dxo = toolCells[i].x - center.x; const dyo = toolCells[i].y - center.y; const dlen = Math.sqrt(dxo * dxo + dyo * dyo) || 1; const ox = (dxo / dlen) * 10; const oy = (dyo / dlen) * 10; const enter = contextSafe!(() => { (cell as HTMLElement).style.zIndex = "30"; gsap.to(cell, { x: reduce ? 0 : ox, y: reduce ? 0 : oy, duration: 0.4, ease: "back.out(2)", overwrite: "auto" }); gsap.to(face, { scale: reduce ? 1.03 : HOVER_SCALE, duration: 0.4, ease: "back.out(2)", boxShadow: visual.activeShadow ?? "0 0 42px -6px rgba(241,183,41,0.75)", overwrite: "auto", }); if (!reduce) gsap.to(sState[i], { ax: strandRest[i].a.x + ox, ay: strandRest[i].a.y + oy, duration: 0.4, ease: "back.out(2)", overwrite: "auto", onUpdate: redrawStrands, }); if (base) gsap.to(base, { attr: { "fill-opacity": toolCellIsActive(i) ? 0.95 : 0 }, duration: 0.3, overwrite: "auto" }); if (packet) gsap.to(packet, { scale: 1.8, transformOrigin: "50% 50%", duration: 0.3, overwrite: "auto" }); // mini-Sog around this cell — neighbours give way, graded by distance if (!reduce) applySog(toolCells[i].x, toolCells[i].y, PHY.cell, i); }); const leave = contextSafe!(() => { gsap.to(cell, { x: 0, y: 0, duration: 0.5, ease: "power3.out", overwrite: "auto" }); gsap.to(face, { scale: 1, duration: 0.5, ease: "power3.out", boxShadow: toolCellIsActive(i) ? visual.activeShadow ?? "none" : visual.inactiveShadow ?? "none", overwrite: "auto", onComplete: () => { (cell as HTMLElement).style.zIndex = "2"; }, }); gsap.to(sState[i], { ax: strandRest[i].a.x, ay: strandRest[i].a.y, duration: 0.5, ease: "power3.out", overwrite: "auto", onUpdate: redrawStrands, }); if (base) gsap.to(base, { attr: { "fill-opacity": toolCellIsActive(i) ? 0.7 : 0 }, duration: 0.45, overwrite: "auto" }); if (packet) gsap.to(packet, { scale: 1, transformOrigin: "50% 50%", duration: 0.45, overwrite: "auto" }); if (!reduce) releaseSog(i); }); // tap on touch devices pops the cell then settles it again — touch only, // a mouse click while hovering must not schedule a delayed collapse const tap = contextSafe!((e: Event) => { if ((e as PointerEvent).pointerType !== "touch") return; enter(); gsap.delayedCall(1, leave); }); cell.addEventListener("mouseenter", enter); cell.addEventListener("mouseleave", leave); cell.addEventListener("pointerdown", tap); cleanups.push(() => { cell.removeEventListener("mouseenter", enter); cell.removeEventListener("mouseleave", leave); cell.removeEventListener("pointerdown", tap); }); }); // ── deco hover (ring 2): behaves EXACTLY like the background combs — // same brighten, same grow, same Sog tier. The hit area is the // clip-path'd hex face (not the rectangular wrapper), so ring 2 feels // identical to the SVG hexes around it; the wrapper lets events // through to whatever sits beneath its corners. decoEls.forEach((deco, k) => { const face = deco.querySelector(".hex-face") as HTMLElement; const paint = (face.querySelector("[data-hex-fill]") as HTMLElement | null) ?? face; if (isCellActive(decoCells[k].debugId, Boolean(logoPlacements[decoCells[k].debugId]))) { face.dataset.active = "1"; } const isActive = () => Boolean(face.dataset.active); (deco as HTMLElement).style.pointerEvents = "none"; face.style.pointerEvents = "auto"; const enter = contextSafe!(() => { gsap.to(face, { scale: PHY.outerScale, duration: PHY.inDur * 0.6, ease: "back.out(2)", overwrite: "auto", }); gsap.to(paint, { backgroundColor: isActive() ? visual.activeFill : visual.hoverFill, duration: PHY.inDur * 0.6, ease: "power2.out", overwrite: "auto", }); if (!reduce) applySog(decoCells[k].x, decoCells[k].y, PHY.outer); }); const leave = contextSafe!(() => { gsap.to(face, { scale: 1, duration: PHY.outDur, ease: PHY.outEase, overwrite: "auto", }); gsap.to(paint, { backgroundColor: isActive() ? visual.activeFill : visual.inactiveFill, duration: PHY.outDur, ease: PHY.outEase, overwrite: "auto", }); if (!reduce) releaseSog(); }); face.addEventListener("mouseenter", enter); face.addEventListener("mouseleave", leave); cleanups.push(() => { face.removeEventListener("mouseenter", enter); face.removeEventListener("mouseleave", leave); }); }); // failsafe: leaving the section always brings every comb back to its // exact home position, whatever hover races happened before const sectionEl = root.current; const resetAllSog = contextSafe!(() => releaseSog()); sectionEl?.addEventListener("pointerleave", resetAllSog); cleanups.push(() => sectionEl?.removeEventListener("pointerleave", resetAllSog)); // ── click-to-connect ───────────────────────────────────────────────── // Klick auf eine äußere Wabe (Ring 2 oder Feld) aktiviert sie: volle // Amber-Füllung + Honig-Stränge zu allen direkt benachbarten // "besetzten" Waben (Tool-Zellen und andere aktivierte). Nochmal // klicken löst sie. Die Stränge lesen jede Frame die Live-Transforms // BEIDER Enden (gsap.ticker) — sie bleiben also auch unter Sog, // Hover-Pop und Elastik-Nachschwingen bündig verbunden. type CombNode = { x: number; y: number; debugId: number; moveEl: Element; // carries the x/y transform (wrapper resp. path) visEl: HTMLElement | SVGElement; // carries fill + click + cursor paintEl: HTMLElement | SVGElement; // carries the active/inactive fill logoLabel?: string; logoEl?: Element | null; kind: "tool" | "partner" | "deco" | "fieldPartner" | "near"; solid: boolean; }; const NEIGHBOR_DIST = R * 1.8; // direct hex neighbours sit at sqrt(3)·R const combNodes: CombNode[] = []; cellEls.forEach((el, i) => { const debugId = toolCells[i].debugId; const logoLabel = logoPlacements[debugId]; combNodes.push({ x: toolCells[i].x, y: toolCells[i].y, debugId, moveEl: el, visEl: el as HTMLElement, paintEl: (el.querySelector("[data-hex-fill]") as HTMLElement | null) ?? (el.querySelector(".hex-face") as HTMLElement), logoLabel, logoEl: el.querySelector("[data-cell-logo]"), kind: "tool", solid: isCellActive( debugId, HONEYCOMB_DEFAULT_ACTIVE_CELL_ID_SET.has(debugId) ), }); }); decoEls.forEach((el, i) => { const debugId = decoCells[i].debugId; const logoLabel = logoPlacements[debugId]; combNodes.push({ x: decoCells[i].x, y: decoCells[i].y, debugId, moveEl: el, visEl: el.querySelector(".hex-face") as HTMLElement, paintEl: (el.querySelector("[data-hex-fill]") as HTMLElement | null) ?? (el.querySelector(".hex-face") as HTMLElement), logoLabel, logoEl: el.querySelector("[data-cell-logo]"), kind: logoLabel ? "partner" : "deco", solid: isCellActive(debugId, Boolean(logoLabel)), }); }); nearEls.forEach((el, i) => { const debugId = nearField[i].debugId; const logoLabel = logoPlacements[debugId]; const moveEl = nearMoveEls[i] ?? el; combNodes.push({ x: nearField[i].x, y: nearField[i].y, debugId, moveEl, visEl: el as unknown as SVGElement, paintEl: el as unknown as SVGElement, logoLabel, logoEl: moveEl.querySelector("[data-cell-logo]"), kind: logoLabel ? "fieldPartner" : "near", solid: isCellActive(debugId, Boolean(logoLabel)), }); }); combNodes.forEach((node) => { if (!node.solid && node.logoEl) { gsap.set(node.logoEl, { autoAlpha: 0, scale: 0.72, transformOrigin: "50% 50%" }); } }); const dynGroup = q("[data-dyn]")[0]; type DynStrand = { el: SVGPathElement; a: CombNode; b: CombNode; aBase: { x: number; y: number }; bBase: { x: number; y: number }; rest: number; grow: number; }; const dynStrands: DynStrand[] = []; const updateDynStrands = () => { if (!dynStrands.length) return; dynStrands.forEach((s) => { const ax = s.aBase.x + Number(gsap.getProperty(s.a.moveEl, "x")) || s.aBase.x; const ay = s.aBase.y + Number(gsap.getProperty(s.a.moveEl, "y")) || s.aBase.y; const bxF = s.bBase.x + Number(gsap.getProperty(s.b.moveEl, "x")) || s.bBase.x; const byF = s.bBase.y + Number(gsap.getProperty(s.b.moveEl, "y")) || s.bBase.y; // grow: the strand pours from the clicked comb toward its neighbour const bx = ax + (bxF - ax) * s.grow; const by = ay + (byF - ay) * s.grow; s.el.setAttribute("d", strandPath({ x: ax, y: ay }, { x: bx, y: by }, s.rest)); }); }; gsap.ticker.add(updateDynStrands); cleanups.push(() => { gsap.ticker.remove(updateDynStrands); dynStrands.forEach((strand) => strand.el.remove()); dynStrands.length = 0; }); const connectNodes = contextSafe!((a: CombNode, b: CombNode, animate = true) => { const alreadyConnected = dynStrands.some( (strand) => (strand.a === a && strand.b === b) || (strand.a === b && strand.b === a) ); if (alreadyConnected) return; const dx = b.x - a.x; const dy = b.y - a.y; const len = Math.sqrt(dx * dx + dy * dy) || 1; const ux = dx / len; const uy = dy / len; const cut = HUB_EDGE - STRAND_TUCK; const aBase = { x: a.x + ux * cut, y: a.y + uy * cut }; const bBase = { x: b.x - ux * cut, y: b.y - uy * cut }; const rdx = bBase.x - aBase.x; const rdy = bBase.y - aBase.y; const el = document.createElementNS("http://www.w3.org/2000/svg", "path"); el.setAttribute("fill", visual.strand); el.setAttribute("fill-opacity", animate ? "0" : "0.7"); dynGroup?.appendChild(el); const s: DynStrand = { el, a, b, aBase, bBase, rest: Math.sqrt(rdx * rdx + rdy * rdy) || 1, grow: animate ? 0 : 1, }; dynStrands.push(s); if (animate) { gsap.to(s, { grow: 1, duration: 0.55, ease: "power2.out" }); gsap.to(el, { attr: { "fill-opacity": 0.7 }, duration: 0.4 }); } else { updateDynStrands(); } }); const disconnectNode = contextSafe!((n: CombNode) => { for (let i = dynStrands.length - 1; i >= 0; i--) { const s = dynStrands[i]; if (s.a !== n && s.b !== n) continue; dynStrands.splice(i, 1); gsap.to(s.el, { attr: { "fill-opacity": 0 }, duration: 0.3, onComplete: () => s.el.remove() }); } }); // Logo cells are already active on first paint. Build their links without // an activation animation, and only for pairs that involve an outer logo // (the six inner tools should not connect into an extra hexagon ring). const initiallySolid = combNodes.filter((node) => node.solid); initiallySolid.forEach((a, i) => { initiallySolid.slice(i + 1).forEach((b) => { if (a.kind === "tool" && b.kind === "tool") return; const dx = b.x - a.x; const dy = b.y - a.y; if (Math.sqrt(dx * dx + dy * dy) < NEIGHBOR_DIST) { connectNodes(a, b, false); } }); }); const setNodeSolid = contextSafe!((n: CombNode, active: boolean) => { if (n.solid === active) return; const isSvgCell = n.kind === "near" || n.kind === "fieldPartner"; const cellLogo = n.logoEl; const face = n.kind === "tool" ? n.visEl.querySelector(".hex-face") as HTMLElement | null : n.visEl; if (!active) { n.solid = false; delete (face as HTMLElement).dataset.active; if (isSvgCell) { gsap.to(n.paintEl, { attr: { "fill-opacity": visual.fieldInactiveOpacity }, duration: 0.35, overwrite: "auto" }); } else { gsap.to(n.paintEl, { backgroundColor: visual.inactiveFill, duration: 0.35, overwrite: "auto" }); } if (cellLogo) { gsap.to(cellLogo, { autoAlpha: 0, scale: 0.72, transformOrigin: "50% 50%", duration: 0.22, ease: "power2.in", overwrite: "auto", }); } disconnectNode(n); } else { n.solid = true; (face as HTMLElement).dataset.active = "1"; if (isSvgCell) { gsap.to(n.paintEl, { attr: { "fill-opacity": visual.fieldActiveOpacity }, duration: 0.35, overwrite: "auto" }); } else { gsap.to(n.paintEl, { backgroundColor: visual.activeFill, duration: 0.35, overwrite: "auto" }); } if (cellLogo) { gsap.to(cellLogo, { autoAlpha: 1, scale: 1, transformOrigin: "50% 50%", duration: 0.34, ease: "back.out(2)", overwrite: "auto", }); } combNodes.forEach((m) => { if (m === n || !m.solid) return; const ndx = m.x - n.x; const ndy = m.y - n.y; if (Math.sqrt(ndx * ndx + ndy * ndy) < NEIGHBOR_DIST) connectNodes(n, m); }); } commitCellActive(n.debugId, active); }); const toggleNode = contextSafe!((n: CombNode) => { if (n.kind === "tool" && !editorMode) return; setNodeSolid(n, !n.solid); }); // ── temporary logo layout editor ──────────────────────────────────── // A short move starts a drag; a normal click still toggles outer cells. // Dropping on an occupied slot swaps both logos, dropping on an empty // slot moves the logo. The centre hub deliberately has no logo-slot ID. type LogoDragState = { source: CombNode; pointerId: number; startX: number; startY: number; dragging: boolean; ghost: HTMLDivElement | null; targetSlot: Element | null; previousCursor: string; previousUserSelect: string; moveHandler: (event: PointerEvent) => void; endHandler: (event: PointerEvent) => void; cancelHandler: (event: PointerEvent) => void; }; let logoDrag: LogoDragState | null = null; let suppressClickEl: Element | null = null; let suppressClickUntil = 0; const dragGhosts = new Set(); const findLogoSlot = (clientX: number, clientY: number) => { for (const element of document.elementsFromPoint(clientX, clientY)) { const slot = element.closest("[data-logo-slot]"); if (slot && root.current?.contains(slot)) return slot; } return null; }; const setDropTarget = (slot: Element | null) => { if (!logoDrag || logoDrag.targetSlot === slot) return; logoDrag.targetSlot?.removeAttribute("data-logo-drop-target"); logoDrag.targetSlot = slot; slot?.setAttribute("data-logo-drop-target", "1"); }; const createLogoGhost = (label: string) => { const logo = HONEYCOMB_LOGOS[label]; const ghost = document.createElement("div"); const image = document.createElement("img"); ghost.setAttribute("aria-hidden", "true"); Object.assign(ghost.style, { position: "fixed", left: "0px", top: "0px", width: `${W * CELL_SIZE}px`, height: `${H * CELL_SIZE}px`, display: "grid", placeItems: "center", clipPath: HEX_CLIP, background: visual.activeFill, backdropFilter: visual.backdropFilter ?? "none", WebkitBackdropFilter: visual.backdropFilter ?? "none", boxShadow: "0 14px 36px rgba(62,44,10,0.26), 0 0 0 2px rgba(255,255,255,0.9)", pointerEvents: "none", userSelect: "none", zIndex: "2147483647", willChange: "transform, opacity", }); image.src = logo.src; image.alt = ""; image.draggable = false; Object.assign(image.style, { width: `${48 * (logo.scale ?? 1)}%`, maxHeight: "64%", objectFit: "contain", borderRadius: logo.cornerRadius ?? "0", pointerEvents: "none", userSelect: "none", }); ghost.appendChild(image); document.body.appendChild(ghost); dragGhosts.add(ghost); return ghost; }; const updateLogoDrag = (event: PointerEvent) => { const state = logoDrag; if (!state || event.pointerId !== state.pointerId) return; const distance = Math.hypot(event.clientX - state.startX, event.clientY - state.startY); if (!state.dragging && distance < 7) return; event.preventDefault(); if (!state.dragging) { state.dragging = true; state.ghost = createLogoGhost(state.source.logoLabel!); document.body.style.cursor = "grabbing"; document.body.style.userSelect = "none"; releaseSog(); gsap.set(state.ghost, { x: event.clientX, y: event.clientY, xPercent: -50, yPercent: -50, scale: reduce ? 1 : 0.88, autoAlpha: reduce ? 1 : 0, }); if (!reduce) { gsap.to(state.ghost, { scale: 1.04, autoAlpha: 1, duration: 0.18, ease: "back.out(2)", overwrite: "auto", }); } if (state.source.logoEl) { gsap.to(state.source.logoEl, { autoAlpha: 0.28, scale: 0.86, duration: reduce ? 0 : 0.14, ease: "power2.out", overwrite: "auto", }); } } if (state.ghost) gsap.set(state.ghost, { x: event.clientX, y: event.clientY }); const candidate = findLogoSlot(event.clientX, event.clientY); const candidateId = Number(candidate?.getAttribute("data-logo-slot")); setDropTarget(candidateId && candidateId !== state.source.debugId ? candidate : null); }; const finishLogoDrag = (event: PointerEvent, cancelled: boolean) => { const state = logoDrag; if (!state || event.pointerId !== state.pointerId) return; window.removeEventListener("pointermove", state.moveHandler); window.removeEventListener("pointerup", state.endHandler); window.removeEventListener("pointercancel", state.cancelHandler); const targetId = Number(state.targetSlot?.getAttribute("data-logo-slot")); state.targetSlot?.removeAttribute("data-logo-drop-target"); document.body.style.cursor = state.previousCursor; document.body.style.userSelect = state.previousUserSelect; logoDrag = null; if (!state.dragging) return; event.preventDefault(); suppressClickEl = state.source.visEl; suppressClickUntil = performance.now() + 400; if (state.source.logoEl) { gsap.to(state.source.logoEl, { autoAlpha: 1, scale: 1, duration: reduce ? 0 : 0.2, ease: "power2.out", overwrite: "auto", }); } const commitDrop = () => { state.ghost?.remove(); if (state.ghost) dragGhosts.delete(state.ghost); if (cancelled || !targetId || targetId === state.source.debugId) return; commitLogoPlacements((current) => { const sourceLogo = current[state.source.debugId]; if (!sourceLogo) return { ...current }; const targetLogo = current[targetId]; const next = { ...current }; if (targetLogo) next[state.source.debugId] = targetLogo; else delete next[state.source.debugId]; next[targetId] = sourceLogo; return next; }); const targetNode = combNodes.find((node) => node.debugId === targetId); if (targetNode && !targetNode.solid) setNodeSolid(targetNode, true); }; if (state.ghost && !reduce) { gsap.to(state.ghost, { scale: 0.86, autoAlpha: 0, duration: 0.12, ease: "power2.in", overwrite: "auto", onComplete: commitDrop, }); } else { commitDrop(); } }; combNodes.forEach((n) => { // The landing-page comb is a fixed composition. Dragging, placing and // click-to-toggle are reserved for the explicit grid-lab editor. if (!editorMode) { n.visEl.style.cursor = "default"; return; } const selectedTool = placementTool; n.visEl.style.cursor = selectedTool === "__erase__" ? "not-allowed" : selectedTool && HONEYCOMB_LOGOS[selectedTool] ? "copy" : n.logoLabel && n.solid ? "grab" : editorMode || n.kind !== "tool" ? "pointer" : "default"; if (n.logoLabel && n.logoEl) { n.visEl.style.touchAction = "none"; const onPointerDown = contextSafe!((event: PointerEvent) => { if (logoDrag || placementTool || !n.solid || !event.isPrimary || event.button !== 0) return; const moveHandler = contextSafe!((moveEvent: PointerEvent) => updateLogoDrag(moveEvent)); const endHandler = contextSafe!((endEvent: PointerEvent) => finishLogoDrag(endEvent, false)); const cancelHandler = contextSafe!((cancelEvent: PointerEvent) => finishLogoDrag(cancelEvent, true)); logoDrag = { source: n, pointerId: event.pointerId, startX: event.clientX, startY: event.clientY, dragging: false, ghost: null, targetSlot: null, previousCursor: document.body.style.cursor, previousUserSelect: document.body.style.userSelect, moveHandler, endHandler, cancelHandler, }; window.addEventListener("pointermove", moveHandler, { passive: false }); window.addEventListener("pointerup", endHandler); window.addEventListener("pointercancel", cancelHandler); }); n.visEl.addEventListener("pointerdown", onPointerDown as EventListener); cleanups.push(() => n.visEl.removeEventListener("pointerdown", onPointerDown as EventListener)); } const onClick = (event: Event) => { if (suppressClickEl === n.visEl && performance.now() < suppressClickUntil) { event.preventDefault(); event.stopPropagation(); return; } const tool = placementTool; if (editorMode && tool === "__erase__") { commitLogoPlacements((current) => { const next = { ...current }; delete next[n.debugId]; return next; }); return; } if (editorMode && tool && HONEYCOMB_LOGOS[tool]) { commitLogoPlacements((current) => { const next = { ...current }; Object.entries(next).forEach(([cellId, label]) => { if (label === tool) delete next[Number(cellId)]; }); next[n.debugId] = tool; return next; }); if (!n.solid) setNodeSolid(n, true); return; } toggleNode(n); }; n.visEl.addEventListener("click", onClick); cleanups.push(() => n.visEl.removeEventListener("click", onClick)); }); cleanups.push(() => { if (logoDrag) { window.removeEventListener("pointermove", logoDrag.moveHandler); window.removeEventListener("pointerup", logoDrag.endHandler); window.removeEventListener("pointercancel", logoDrag.cancelHandler); logoDrag.targetSlot?.removeAttribute("data-logo-drop-target"); document.body.style.cursor = logoDrag.previousCursor; document.body.style.userSelect = logoDrag.previousUserSelect; logoDrag = null; } dragGhosts.forEach((ghost) => ghost.remove()); dragGhosts.clear(); }); // ── hub hover: the whole network "powers on" ───────────────────────── const hub = centerEl[0] as HTMLElement | undefined; if (hub) { const hubFace = hub.querySelector(".hex-face") as HTMLElement; const toolFaces = cellEls.map((c) => c.querySelector(".hex-face") as HTMLElement); const flare = q("[data-glow-flare]"); const hubEnter = contextSafe!(() => { hub.style.zIndex = "40"; // logo pop gsap.to(hubFace, { scale: reduce ? 1.05 : HUB_HOVER_SCALE, duration: 0.5, ease: "back.out(3)", overwrite: "auto" }); // the dark interior plate grows in lockstep with the G gsap.to(q("[data-gcover]"), { scale: reduce ? 1.05 : HUB_HOVER_SCALE, svgOrigin: `${center.x} ${center.y}`, duration: 0.5, ease: "back.out(3)", overwrite: "auto", }); if (reduce) return; // EVERY comb — ring 1, ring 2, whole field — drifts outward with // the exact same physics (strongest tier). Strand roots follow // their cells automatically via applySog. applySog(center.x, center.y, PHY.hub); // glow flares out gsap.to(flare, { scale: 1.5, opacity: 1, duration: 0.5, ease: "power2.out", overwrite: "auto" }); // strands brighten; their tips ride the growing G separately gsap.to(activeBaseLines, { attr: { "fill-opacity": 0.9 }, duration: 0.3, overwrite: "auto" }); gsap.to(sState, { bx: (i: number) => strandHover[i].bx, by: (i: number) => strandHover[i].by, duration: 0.5, ease: "back.out(3)", overwrite: "auto", onUpdate: redrawStrands, }); // a wave ripples outward through the tool cells gsap.to(toolFaces, { scale: 1.07, duration: 0.26, ease: "power2.out", stagger: { each: 0.05, from: "start" }, yoyo: true, repeat: 1, overwrite: "auto", }); }); const hubLeave = contextSafe!(() => { gsap.to(hubFace, { scale: 1, duration: 0.5, ease: "power3.out", overwrite: "auto", onComplete: () => { hub.style.zIndex = "20"; } }); gsap.to(q("[data-gcover]"), { scale: 1, duration: 0.5, ease: "power3.out", overwrite: "auto" }); releaseSog(); gsap.to(flare, { scale: 1, opacity: 0, duration: 0.6, ease: "power2.out", overwrite: "auto" }); gsap.to(activeBaseLines, { attr: { "fill-opacity": 0.7 }, duration: 0.5, overwrite: "auto" }); gsap.to(sState, { bx: (i: number) => strandRest[i].b.x, by: (i: number) => strandRest[i].b.y, duration: 0.5, ease: "power3.out", overwrite: "auto", onUpdate: redrawStrands, }); }); const hubTap = contextSafe!((e: Event) => { if ((e as PointerEvent).pointerType !== "touch") return; hubEnter(); gsap.delayedCall(1.1, hubLeave); }); hub.addEventListener("mouseenter", hubEnter); hub.addEventListener("mouseleave", hubLeave); hub.addEventListener("pointerdown", hubTap); cleanups.push(() => { hub.removeEventListener("mouseenter", hubEnter); hub.removeEventListener("mouseleave", hubLeave); hub.removeEventListener("pointerdown", hubTap); }); } const rootEl = root.current; const activeRevealNodes = [ ...centerEl.map((el) => ({ el, distance: 0 })), ...combNodes .filter((node) => node.solid) .map((node) => ({ el: node.moveEl, distance: Math.hypot(node.x - center.x, node.y - center.y), })), ] .sort((a, b) => a.distance - b.distance) .map(({ el }) => el); const dynamicPaths = dynStrands.map((strand) => strand.el); const setConnectionsFinal = () => { sState.forEach((state, index) => { state.ax = strandRest[index].a.x; state.ay = strandRest[index].a.y; state.bx = strandRest[index].b.x; state.by = strandRest[index].b.y; }); dynStrands.forEach((strand) => { strand.grow = 1; }); redrawStrands(); updateDynStrands(); baseLines.forEach((line, index) => { gsap.set(line, { attr: { "fill-opacity": toolCellIsActive(index) ? 0.7 : 0 } }); }); if (dynamicPaths.length) { gsap.set(dynamicPaths, { attr: { "fill-opacity": 0.7 } }); } }; const collapseConnections = () => { sState.forEach((state) => { state.bx = state.ax; state.by = state.ay; }); dynStrands.forEach((strand) => { strand.grow = 0; }); redrawStrands(); updateDynStrands(); if (baseLines.length) { gsap.set(baseLines, { attr: { "fill-opacity": 0 } }); } if (dynamicPaths.length) { gsap.set(dynamicPaths, { attr: { "fill-opacity": 0 } }); } }; // ── animated bits, gated behind prefers-reduced-motion ─────────────── const mm = gsap.matchMedia(); mm.add("(prefers-reduced-motion: reduce)", () => { if (packets.length) gsap.set(packets, { autoAlpha: 0 }); if (activeRevealNodes.length) { gsap.set(activeRevealNodes, { scale: 1, autoAlpha: 1, transformOrigin: "50% 50%", }); } if (glow.length) gsap.set(glow, { scale: 1, opacity: 0.7 }); setConnectionsFinal(); }); mm.add("(prefers-reduced-motion: no-preference)", () => { if (packets.length) gsap.set(packets, { autoAlpha: 0 }); // parallax (from V5) — the whole comb drifts gently with the pointer const par = q("[data-parallax]")[0]; let cleanupParallax: (() => void) | undefined; if (par && rootEl) { const px = gsap.quickTo(par, "x", { duration: 0.9, ease: "power3.out" }); const py = gsap.quickTo(par, "y", { duration: 0.9, ease: "power3.out" }); const move = (e: PointerEvent) => { const b = rootEl.getBoundingClientRect(); px(((e.clientX - b.left) / b.width - 0.5) * 16); py(((e.clientY - b.top) / b.height - 0.5) * 10); }; const settle = () => { px(0); py(0); }; rootEl.addEventListener("pointermove", move); rootEl.addEventListener("pointerleave", settle); cleanupParallax = () => { rootEl.removeEventListener("pointermove", move); rootEl.removeEventListener("pointerleave", settle); }; } const glowTween = glow.length ? gsap.fromTo( glow, { scale: 1, opacity: 0.65 }, { scale: 1.12, opacity: 0.8, duration: 3.2, ease: "sine.inOut", repeat: -1, yoyo: true, paused: true, } ) : null; // ambient — a glowing data packet travels each line from tool → hub. // The packet group is clipPath'd to exclude the central G hex, so the // dot + glow vanish at the G's edge instead of bleeding into its // transparent cut-out. const packetTimelines: gsap.core.Timeline[] = []; packets.forEach((dot, i) => { if (!toolCellIsActive(i)) { gsap.set(dot, { autoAlpha: 0 }); return; } const from = toolCells[i]; const packetTimeline = gsap.timeline({ repeat: -1, paused: true, delay: i * 0.45 }) .set(dot, { attr: { cx: from.x, cy: from.y } }) .to(dot, { autoAlpha: 1, duration: 0.25 }) .to(dot, { attr: { cx: lineEnds[i].x, cy: lineEnds[i].y }, duration: 1.8, ease: "power1.in" }, 0) .to(dot, { autoAlpha: 0, duration: 0.2 }, "-=0.05"); packetTimelines.push(packetTimeline); }); const startAmbientMotion = () => { glowTween?.play(0); packetTimelines.forEach((timeline) => timeline.restart(true)); }; if (revealOnScroll && rootEl) { if (activeRevealNodes.length) { gsap.set(activeRevealNodes, { scale: 0.16, autoAlpha: 0, transformOrigin: "50% 50%", }); } if (glow.length) gsap.set(glow, { scale: 0.8, autoAlpha: 0 }); collapseConnections(); const introTimeline = gsap.timeline({ scrollTrigger: { trigger: rootEl, start: "top 72%", once: true, }, }); if (activeRevealNodes.length) { introTimeline.to(activeRevealNodes, { scale: 1, autoAlpha: 1, duration: 0.48, stagger: 0.045, ease: "back.out(1.75)", }); } introTimeline.addLabel("connections"); if (activeBaseLines.length) { introTimeline .to(sState, { bx: (index: number) => strandRest[index].b.x, by: (index: number) => strandRest[index].b.y, duration: 0.58, stagger: 0.045, ease: "power2.out", onUpdate: redrawStrands, }, "connections") .to(activeBaseLines, { attr: { "fill-opacity": 0.7 }, duration: 0.42, stagger: 0.045, ease: "power2.out", }, "connections"); } if (glow.length) { introTimeline.to( glow, { scale: 1, autoAlpha: 0.65, duration: 0.45, ease: "power2.out" }, 0 ); } if (dynStrands.length) { introTimeline .to(dynStrands, { grow: 1, duration: 0.55, stagger: 0.025, ease: "power2.out", onUpdate: updateDynStrands, }, "connections+=0.04") .to(dynamicPaths, { attr: { "fill-opacity": 0.7 }, duration: 0.38, stagger: 0.025, ease: "power2.out", }, "connections+=0.04"); } introTimeline.call(startAmbientMotion); } else { if (activeRevealNodes.length) { gsap.set(activeRevealNodes, { scale: 1, autoAlpha: 1, transformOrigin: "50% 50%", }); } if (glow.length) gsap.set(glow, { scale: 1, opacity: 0.65 }); setConnectionsFinal(); startAmbientMotion(); } // NOTE: no ambient drift on ring 2 anymore — it kept the deco combs // permanently a few px off their true position, which read as "not // returning home" and made ring 2 behave differently from the field. return () => { cleanupParallax?.(); if (activeRevealNodes.length) { gsap.set(activeRevealNodes, { clearProps: "transform,opacity,visibility" }); } }; }); return () => { mm.revert(); cleanups.forEach((fn) => fn()); }; }, { scope: root, dependencies: [logoPlacements, activeStateKey, layerStateKey, appearance, placementTool, editorMode, physics, revealOnScroll], revertOnUpdate: true, } ); return ( ); }