Branchwell

AI Resource Pro / website · airesourcepro.com / scripts / covers / base.mjs

Raw 8.6 KB on 6c7ce85c3441baadd17890ab9cc9bf8ed5112901
1// Page shell for the cover images: fonts, the shared look (glass windows, app-icon tiles, chips) and the
2// background (glows, a perspective grid, and a seeded field of the site's outlined-triangle particles).
3// Covers are 1600 x 960 (5:3) and always dark, so they read as product shots in both site themes.
4
5export const W = 1600;
6export const H = 960;
7
8const CSS = /* css */ `
9 * { box-sizing: border-box; margin: 0; padding: 0; }
10 html, body { width: ${W}px; height: ${H}px; overflow: hidden; background: #060a12; color: #eaf4fd; }
11 body { font-family: "Geist", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
12 .stage { position: absolute; inset: 0; overflow: hidden; }
13 .glow { position: absolute; border-radius: 50%; filter: blur(90px); pointer-events: none; }
14 .grid { position: absolute; left: -40%; right: -40%; bottom: -36%; height: 85%;
15 background-image: linear-gradient(rgba(124,196,242,.16) 1px, transparent 1px), linear-gradient(90deg, rgba(124,196,242,.16) 1px, transparent 1px);
16 background-size: 64px 64px; transform: perspective(700px) rotateX(64deg); transform-origin: top;
17 -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 60%, transparent 100%); }
18 canvas#field { position: absolute; inset: 0; }
19 .grain { position: absolute; inset: 0; opacity: .07; mix-blend-mode: overlay; pointer-events: none;
20 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='.9' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }
21 .vignette { position: absolute; inset: 0; background: radial-gradient(120% 90% at 55% 45%, transparent 55%, rgba(3,6,12,.7) 100%); pointer-events: none; }
22
23 .abs { position: absolute; }
24 .mono { font-family: "Geist Mono", ui-monospace, monospace; }
25 .display { font-family: "Funnel Display", "Geist", sans-serif; letter-spacing: -0.03em; }
26
27 /* glass window */
28 .win { position: absolute; border-radius: 26px; overflow: hidden;
29 background: linear-gradient(180deg, rgba(24,36,54,.9), rgba(10,16,26,.94));
30 border: 1px solid rgba(191,227,250,.16);
31 box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 60px 140px -30px rgba(0,0,0,.9), 0 0 120px -30px rgba(70,170,233,.55); }
32 .win::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
33 background: linear-gradient(160deg, rgba(255,255,255,.10), transparent 32%); }
34 .bar { height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 24px; border-bottom: 1px solid rgba(191,227,250,.1); background: rgba(255,255,255,.025); }
35 .bar i { width: 15px; height: 15px; border-radius: 50%; background: rgba(234,244,253,.22); }
36 .bar .t { margin-left: 18px; font: 500 21px "Geist Mono", monospace; color: rgba(234,244,253,.55); }
37 .term { padding: 30px 38px; font: 400 25px/1.75 "Geist Mono", monospace; color: #c9d6e6; white-space: pre; }
38 .term .p { color: #7cc4f2; } .term .b { color: #46aae9; } .term .w { color: #fff; } .term .d { color: rgba(201,214,230,.45); }
39 .term .add { display: block; margin: 0 -38px; padding: 0 38px; background: rgba(70,170,233,.13); color: #bfe3fa; }
40 .term .del { display: block; margin: 0 -38px; padding: 0 38px; background: rgba(234,244,253,.04); color: rgba(201,214,230,.45); text-decoration: line-through; }
41 .caret { display: inline-block; width: 13px; height: 28px; background: #7cc4f2; vertical-align: -5px; box-shadow: 0 0 16px #46aae9; }
42
43 /* app-icon tile holding a product mark */
44 .tile { position: absolute; display: grid; place-items: center; color: #fff;
45 background: radial-gradient(130% 130% at 28% 18%, #9ad3f7 0%, #46aae9 34%, #2a6fd6 70%, #173f93 100%);
46 box-shadow: inset 0 3px 0 rgba(255,255,255,.5), inset 0 -18px 40px rgba(8,26,74,.55), 0 40px 90px -20px rgba(70,170,233,.85), 0 0 0 1px rgba(255,255,255,.15); }
47 .tile::after { content: ""; position: absolute; inset: 0; border-radius: inherit;
48 background: linear-gradient(170deg, rgba(255,255,255,.38), transparent 42%); pointer-events: none; }
49 .tile svg { filter: drop-shadow(0 6px 14px rgba(5,20,60,.45)); position: relative; z-index: 1; }
50 .tile.dark { background: radial-gradient(130% 130% at 28% 18%, #26364d 0%, #121c2b 60%, #0a111c 100%);
51 box-shadow: inset 0 2px 0 rgba(255,255,255,.18), 0 40px 90px -20px rgba(0,0,0,.9), 0 0 0 1px rgba(191,227,250,.22), 0 0 70px -10px rgba(70,170,233,.5); }
52 .reflect { position: absolute; border-radius: 50%; background: rgba(70,170,233,.55); filter: blur(40px); }
53
54 /* glass chips and cards */
55 .chip { position: absolute; display: flex; align-items: center; gap: 12px; padding: 15px 24px; border-radius: 999px;
56 background: rgba(12,20,33,.78); border: 1px solid rgba(191,227,250,.2); font: 500 22px "Geist Mono", monospace; color: #dcecfa;
57 box-shadow: 0 24px 50px -16px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.08); backdrop-filter: blur(12px); }
58 .chip b { width: 11px; height: 11px; border-radius: 50%; background: #46aae9; box-shadow: 0 0 14px #46aae9; }
59 .card { position: absolute; border-radius: 22px; padding: 26px 28px; background: linear-gradient(180deg, rgba(26,38,57,.92), rgba(13,20,32,.95));
60 border: 1px solid rgba(191,227,250,.18); box-shadow: 0 40px 90px -24px rgba(0,0,0,.9), 0 0 70px -24px rgba(70,170,233,.5), inset 0 1px 0 rgba(255,255,255,.08); }
61 .kind { display: inline-block; padding: 6px 14px; border-radius: 999px; background: rgba(70,170,233,.18); color: #7cc4f2; font: 600 17px "Geist Mono", monospace; letter-spacing: .06em; text-transform: uppercase; }
62 .muted { color: rgba(201,214,230,.6); }
63 .blur1 { filter: blur(1.2px); opacity: .8; } .blur2 { filter: blur(2.5px); opacity: .6; }
64`;
65
66// Draws the particle field on a canvas; runs inside the page
67const FIELD = /* js */ `
68(() => {
69 const c = document.getElementById("field"), g = c.getContext("2d"), dpr = 1;
70 c.width = ${W} * dpr; c.height = ${H} * dpr;
71 let h = 2166136261; for (const ch of SEED) h = Math.imul(h ^ ch.charCodeAt(0), 16777619);
72 const r = () => { h ^= h << 13; h ^= h >>> 17; h ^= h << 5; return ((h >>> 0) % 100000) / 100000; };
73 const COLORS = ["#46AAE9", "#7CC4F2", "#BFE3FA", "#FFFFFF", "#3A86E8"];
74 for (let i = 0; i < 420; i++) { g.globalAlpha = .1 + r() * .35; g.fillStyle = "#cfe8fb"; g.fillRect(r() * ${W}, r() * ${H}, 1.4, 1.4); }
75 const tri = (x, y, s, rot, col, a) => {
76 g.save(); g.translate(x, y); g.rotate(rot); g.globalAlpha = a; g.strokeStyle = col; g.lineWidth = Math.max(1.2, s * .16);
77 g.shadowColor = col; g.shadowBlur = s * 1.6; g.beginPath();
78 for (let k = 0; k < 3; k++) { const t = -Math.PI / 2 + k * 2.0944; k ? g.lineTo(Math.cos(t) * s, Math.sin(t) * s) : g.moveTo(Math.cos(t) * s, Math.sin(t) * s); }
79 g.closePath(); g.stroke(); g.restore();
80 };
81 // a flowing ribbon of particles sweeping behind the scene, plus loose ones everywhere
82 const amp = 120 + r() * 80, ph = r() * 6.28, y0 = ${H} * (.45 + r() * .2), tilt = -.25 + r() * .2;
83 for (let i = 0; i < 900; i++) {
84 const t = r(), x = t * ${W} * 1.1 - 60, spread = Math.pow(r(), 2) * 110 * (r() < .5 ? -1 : 1);
85 const y = y0 + Math.sin(t * 5.2 + ph) * amp + (x - ${W} / 2) * tilt + spread;
86 tri(x, y, 2 + Math.pow(r(), 4) * 8, r() * 6.28, COLORS[(r() * 5) | 0], .25 + r() * .6);
87 }
88 for (let i = 0; i < 90; i++) tri(r() * ${W}, r() * ${H}, 2.5 + Math.pow(r(), 3) * 8, r() * 6.28, COLORS[(r() * 5) | 0], .15 + r() * .4);
89})();`;
90
91// plain: no grid or triangle ribbon, for scenes that draw their own particles (the site share image)
92export function page({ seed, body, glows, plain }) {
93 const glowDivs = (glows ?? [
94 { x: 980, y: 300, w: 900, h: 620, c: "rgba(70,170,233,.42)" },
95 { x: 140, y: 620, w: 700, h: 520, c: "rgba(58,134,232,.32)" },
96 { x: 1300, y: -120, w: 520, h: 420, c: "rgba(191,227,250,.18)" },
97 ])
98 .map((gl) => `<div class="glow" style="left:${gl.x - gl.w / 2}px;top:${gl.y - gl.h / 2}px;width:${gl.w}px;height:${gl.h}px;background:${gl.c}"></div>`)
99 .join("");
100 return `<!doctype html><html><head><meta charset="utf-8">
101<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
102<link href="https://fonts.googleapis.com/css2?family=Funnel+Display:wght@300..800&family=Geist:wght@300..700&family=Geist+Mono:wght@400..700&family=Poppins:wght@600&display=block" rel="stylesheet">
103<style>${CSS}</style></head><body><div class="stage">
104${glowDivs}${plain ? "" : `<div class="grid"></div><canvas id="field"></canvas>`}
105${body}
106<div class="vignette"></div><div class="grain"></div></div>
107${plain ? "" : `<script>const SEED = ${JSON.stringify(seed)};${FIELD}</script>`}</body></html>`;
108}