Skip to content

Commit 567ec9f

Browse files
feat: refine CSS styles and enhance JavaScript functionality for matrix background effects, improving visual clarity and responsiveness
1 parent a2f163f commit 567ec9f

2 files changed

Lines changed: 52 additions & 17 deletions

File tree

assets/css/style.css

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
:root {
2+
/* Shared animated hero / header background */
3+
--brand-hero-grad: linear-gradient(145deg, #0c1222 0%, #1e1b4b 42%, #0e7490 100%);
4+
--brand-hero-grad-size: 200% 200%;
25
--bg: #eef2ff;
36
--bg-deep: #0c1222;
47
--surface: rgba(255, 255, 255, 0.72);
@@ -50,8 +53,8 @@ body {
5053
font-size: 1rem;
5154
line-height: 1.6;
5255
color: var(--text);
53-
/* Light base so matrix (multiply + dark glyphs) reads as black rain in open areas */
54-
background: #f1f5f9;
56+
/* Dark base so white matrix rain reads clearly in gutters */
57+
background: #030712;
5558
background-attachment: fixed;
5659
min-height: 100vh;
5760
min-height: 100dvh;
@@ -69,7 +72,7 @@ a:hover {
6972
text-decoration: underline;
7073
}
7174

72-
/* Full-viewport matrix: dark glyphs + multiply = black-ish rain on light page gaps */
75+
/* Full-viewport matrix: white 0/1, screen blend on dark body */
7376
.matrix-canvas--page-bg {
7477
position: fixed;
7578
inset: 0;
@@ -78,8 +81,8 @@ a:hover {
7881
min-height: 100vh;
7982
min-height: 100dvh;
8083
z-index: 0;
81-
opacity: 0.58;
82-
mix-blend-mode: multiply;
84+
opacity: 0.62;
85+
mix-blend-mode: screen;
8386
pointer-events: none;
8487
}
8588

@@ -93,13 +96,29 @@ a:hover {
9396
position: sticky;
9497
top: 0;
9598
z-index: 50;
96-
background: rgba(15, 23, 42, 0.78);
97-
backdrop-filter: blur(18px) saturate(160%);
98-
border-bottom: 1px solid rgba(148, 163, 184, 0.22);
99-
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
99+
isolation: isolate;
100+
background: var(--brand-hero-grad);
101+
background-size: var(--brand-hero-grad-size);
102+
animation: hero-gradient 14s ease infinite;
103+
border-bottom: 1px solid rgba(255, 255, 255, 0.12);
104+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
105+
}
106+
107+
.site-header::before {
108+
content: "";
109+
position: absolute;
110+
inset: 0;
111+
z-index: 0;
112+
background:
113+
radial-gradient(ellipse 80% 50% at 20% 40%, rgba(79, 70, 229, 0.35), transparent 58%),
114+
radial-gradient(ellipse 60% 40% at 80% 60%, rgba(6, 182, 212, 0.28), transparent 52%),
115+
radial-gradient(circle at 50% 100%, rgba(255, 255, 255, 0.06), transparent 42%);
116+
pointer-events: none;
100117
}
101118

102119
.header-inner {
120+
position: relative;
121+
z-index: 1;
103122
max-width: var(--max);
104123
margin: 0 auto;
105124
padding: 0.875rem 1.5rem;
@@ -223,6 +242,8 @@ a:hover {
223242
}
224243

225244
.nav-panel {
245+
position: relative;
246+
z-index: 1;
226247
display: none;
227248
flex-direction: column;
228249
padding: 0 1.5rem 1rem;

assets/js/main.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,25 +287,39 @@
287287
});
288288
}
289289

290+
function headerBandBottom() {
291+
var el = document.querySelector(".site-header");
292+
if (!el) return 0;
293+
var r = el.getBoundingClientRect();
294+
return Math.ceil(r.bottom);
295+
}
296+
297+
function randomBit() {
298+
return Math.random() < 0.5 ? "1" : "0";
299+
}
300+
290301
function step() {
291302
var v = viewportSize();
292303
var w = pageBg ? v.w : canvas.clientWidth || v.w;
293304
var h = pageBg ? v.h : canvas.clientHeight || 420;
294-
/* Fade trails toward “paper” so multiply blend keeps gutters feeling light */
295-
ctx.fillStyle = pageBg ? "rgba(255, 255, 255, 0.14)" : "rgba(3, 7, 18, 0.07)";
305+
var headerBottom = pageBg ? headerBandBottom() : 0;
306+
/* Fade trails toward page base (light) so black digits read on white gutters */
307+
ctx.fillStyle = pageBg ? "rgba(241, 245, 249, 0.16)" : "rgba(3, 7, 18, 0.07)";
296308
ctx.fillRect(0, 0, w, h);
297309

298310
ctx.font =
299311
"bold 15px ui-monospace, SFMono-Regular, Menlo, Consolas, 'Cascadia Code', monospace";
300312
for (var i = 0; i < drops.length; i++) {
301313
var x = i * cell + Math.floor(cell * 0.35);
302314
var y = drops[i];
303-
/* Near-black with a hint of matrix green; reads black on white after multiply */
304-
var l = 0.08 + (i % 5) * 0.018;
305-
var a = pageBg ? 0.82 : 0.92;
306-
ctx.fillStyle = "hsla(135, 35%, " + Math.round(l * 100) + "%, " + a + ")";
307-
var code = 0x30a0 + Math.floor(Math.random() * 96);
308-
ctx.fillText(String.fromCharCode(code), x, y);
315+
var inHeader = pageBg && headerBottom > 0 && y >= 0 && y <= headerBottom;
316+
/* Header band: bright 0/1 for the strip under .site-header. Elsewhere: black on light areas. */
317+
if (inHeader) {
318+
ctx.fillStyle = "rgba(255, 255, 255, 0.96)";
319+
} else {
320+
ctx.fillStyle = "rgba(15, 23, 42, 0.78)";
321+
}
322+
ctx.fillText(randomBit(), x, y);
309323
drops[i] = y + cell * 0.85 + Math.random() * 12;
310324
if (drops[i] > h + 48 && Math.random() > 0.965) {
311325
drops[i] = -Math.random() * (h * 0.35);

0 commit comments

Comments
 (0)