feat(landing): add matrix and particle background variations

This commit is contained in:
Vijay Janapa Reddi
2026-02-26 12:31:08 -05:00
parent e0a71023e4
commit 59cffeef48
4 changed files with 373 additions and 56 deletions

View File

@@ -1,20 +1,57 @@
/* =============================================================================
MLSysBook Landing — Root hub for two volumes. Matches Vol 1 theme.
Supports both Light and Dark mode via data-bs-theme.
============================================================================= */
:root {
--mls-accent: #A51C30;
--mls-accent-hover: #8b1728;
--mls-text: #1a1a1a;
--mls-muted: #5c5c5c;
--mls-border: #e0e0e0;
--mls-bg: #fff;
--mls-card-bg: #fff;
--mls-shadow: 0 2px 8px rgba(0,0,0,0.06);
--mls-shadow-hover: 0 8px 24px rgba(165, 28, 48, 0.12);
--mls-text: #111111;
--mls-text-muted: #555555;
--mls-bg: #ffffff;
--mls-card-bg: rgba(255, 255, 255, 0.95);
--mls-card-border: rgba(0, 0, 0, 0.05);
--mls-card-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
--mls-card-shadow-hover: 0 20px 40px rgba(0, 0, 0, 0.12);
--mls-glass-bg: rgba(255, 255, 255, 0.85);
--mls-glass-border: rgba(255, 255, 255, 0.6);
--mls-terminal-bg: rgba(25, 25, 30, 0.95);
--mls-terminal-border: rgba(255, 255, 255, 0.1);
--mls-terminal-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
--mls-terminal-text: #e6e6e6;
--mls-slider-bg: rgba(255, 255, 255, 0.5);
--mls-slider-track: rgba(0, 0, 0, 0.1);
--mls-slider-thumb: #ffffff;
--mls-link: #444444;
--mls-footer-bg: rgba(255, 255, 255, 0.9);
--mls-vol-sep: rgba(0, 0, 0, 0.08);
}
/* Plain white page background */
[data-bs-theme="dark"] {
--mls-accent: #ff4d6d;
--mls-accent-hover: #ff758f;
--mls-text: #e0e0e0;
--mls-text-muted: #aaaaaa;
--mls-bg: #0a0a0c;
--mls-card-bg: rgba(20, 20, 25, 0.95);
--mls-card-border: rgba(255, 255, 255, 0.1);
--mls-card-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
--mls-card-shadow-hover: 0 20px 40px rgba(0, 0, 0, 0.7);
--mls-glass-bg: rgba(15, 15, 20, 0.85);
--mls-glass-border: rgba(255, 255, 255, 0.1);
--mls-terminal-bg: rgba(10, 10, 12, 0.95);
--mls-terminal-border: rgba(255, 255, 255, 0.1);
--mls-terminal-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
--mls-terminal-text: #e6e6e6;
--mls-slider-bg: rgba(20, 20, 25, 0.8);
--mls-slider-track: rgba(255, 255, 255, 0.1);
--mls-slider-thumb: #222222;
--mls-link: #cccccc;
--mls-footer-bg: rgba(20, 20, 25, 0.9);
--mls-vol-sep: rgba(255, 255, 255, 0.1);
}
/* Page background */
html {
scroll-snap-type: y mandatory;
scroll-behavior: smooth;
@@ -25,7 +62,8 @@ body,
#quarto-content,
main.content,
.column-page {
background: #fff !important;
background: var(--mls-bg) !important;
color: var(--mls-text) !important;
}
/* No Quarto title block; we use .mls-hero only */
@@ -89,13 +127,13 @@ main.content,
}
.mls-landing-left {
background: rgba(255, 255, 255, 0.85);
background: var(--mls-glass-bg);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
padding: 3rem;
border-radius: 24px;
border: 1px solid rgba(255, 255, 255, 0.6);
box-shadow: 0 20px 40px rgba(0,0,0,0.08);
border: 1px solid var(--mls-glass-border);
box-shadow: var(--mls-card-shadow);
}
@media (max-width: 900px) {
@@ -120,7 +158,7 @@ main.content,
.mls-hero-title {
font-size: clamp(2.5rem, 5vw, 4rem);
font-weight: 800;
color: #111;
color: var(--mls-text);
letter-spacing: -0.03em;
margin: 0 0 1.5rem;
line-height: 1.2;
@@ -129,14 +167,15 @@ main.content,
.mls-hero-tagline {
font-size: 1.25rem;
font-weight: 600;
color: #333;
color: var(--mls-text);
opacity: 0.9;
margin: 0 0 1rem;
line-height: 1.4;
}
.mls-hero-intro {
font-size: 1.1rem;
color: #555;
color: var(--mls-text-muted);
margin: 0 0 2.5rem;
line-height: 1.5;
}
@@ -151,7 +190,7 @@ main.content,
}
.mls-links a {
color: #444;
color: var(--mls-link);
text-decoration: none;
font-weight: 600;
}
@@ -175,10 +214,10 @@ main.content,
}
.mls-vol-card {
background: rgba(255, 255, 255, 0.95);
border: 1px solid rgba(0,0,0,0.05);
background: var(--mls-card-bg);
border: 1px solid var(--mls-card-border);
border-radius: 16px;
box-shadow: 0 10px 30px rgba(0,0,0,0.08);
box-shadow: var(--mls-card-shadow);
padding: 1.25rem;
transition: transform 0.3s ease, box-shadow 0.3s ease;
flex: 1;
@@ -188,7 +227,7 @@ main.content,
.mls-vol-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 40px rgba(0,0,0,0.12);
box-shadow: var(--mls-card-shadow-hover);
}
.mls-vol-card-link {
@@ -231,24 +270,24 @@ main.content,
.mls-vol-subtitle {
font-size: 1.1rem;
font-weight: 700;
color: #111;
color: var(--mls-text);
margin: 0 0 1.25rem;
line-height: 1.3;
}
.mls-vol-downloads {
font-size: 0.85rem;
color: var(--mls-muted);
color: var(--mls-text-muted);
margin: auto 0 0 0;
padding-top: 1rem;
border-top: 1px solid rgba(0,0,0,0.08);
border-top: 1px solid var(--mls-vol-sep);
font-weight: 600;
display: flex;
justify-content: space-between;
}
.mls-vol-downloads a {
color: #111;
color: var(--mls-text);
text-decoration: none;
}
@@ -264,13 +303,14 @@ main.content,
margin-top: 4rem;
text-align: center;
font-size: 0.85rem;
color: #666;
color: var(--mls-text-muted);
}
.mls-footer span {
background: rgba(255, 255, 255, 0.9);
padding: 0.2rem 0.5rem;
border-radius: 4px;
background: var(--mls-footer-bg);
padding: 0.5rem 1rem;
border-radius: 6px;
display: inline-block;
}
.mls-scroll-indicator {
@@ -279,7 +319,7 @@ main.content,
left: 50%;
transform: translateX(-50%);
text-align: center;
color: var(--mls-muted);
color: var(--mls-text-muted);
font-size: 0.85rem;
font-weight: 600;
text-transform: uppercase;
@@ -300,10 +340,10 @@ main.content,
/* Feature Sections (TinyTorch, Hardware, Labs) */
.mls-feature-card {
background: rgba(255, 255, 255, 0.95);
border: 1px solid rgba(0,0,0,0.05);
background: var(--mls-card-bg);
border: 1px solid var(--mls-card-border);
border-radius: 12px;
box-shadow: 0 10px 30px rgba(0,0,0,0.08);
box-shadow: var(--mls-card-shadow);
padding: 4rem 2rem;
display: flex;
flex-direction: column;
@@ -336,7 +376,7 @@ main.content,
.mls-feature-title {
font-size: clamp(2rem, 4vw, 2.75rem);
font-weight: 800;
color: #111;
color: var(--mls-text);
margin: 0;
line-height: 1.1;
letter-spacing: -0.02em;
@@ -344,7 +384,7 @@ main.content,
.mls-feature-desc {
font-size: 1.25rem;
color: #555;
color: var(--mls-text-muted);
max-width: 420px;
margin: 0 auto;
line-height: 1.5;
@@ -359,15 +399,16 @@ main.content,
animation: floatTerminal 6s ease-in-out infinite;
}
.css-terminal {
background: rgba(25, 25, 30, 0.95);
background: var(--mls-terminal-bg);
border-radius: 8px;
border: 1px solid rgba(255,255,255,0.1);
box-shadow: 0 20px 40px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.1);
border: 1px solid var(--mls-terminal-border);
box-shadow: var(--mls-terminal-shadow), inset 0 1px 0 rgba(255,255,255,0.1);
overflow: hidden;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
.css-terminal-header {
background: rgba(45, 45, 50, 0.9);
background: rgba(0, 0, 0, 0.2);
padding: 10px 12px;
display: flex;
gap: 8px;
@@ -385,7 +426,7 @@ main.content,
padding: 16px;
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
font-size: 0.75rem;
color: #e6e6e6;
color: var(--mls-terminal-text);
text-align: left;
min-height: 100px;
line-height: 1.4;
@@ -409,7 +450,7 @@ main.content,
display: inline-block;
width: 8px;
height: 16px;
background: #e6e6e6;
background: var(--mls-terminal-text);
animation: blink 1s step-end infinite;
}
.term-shadow {
@@ -423,6 +464,9 @@ main.content,
filter: blur(5px);
animation: shadowTerminal 6s ease-in-out infinite;
}
[data-bs-theme="dark"] .term-shadow {
background: rgba(0,0,0,0.5);
}
@keyframes floatTerminal {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-10px); }
@@ -440,11 +484,11 @@ main.content,
.css-sliders-wrapper {
position: relative;
width: 220px;
background: rgba(255, 255, 255, 0.5);
background: var(--mls-slider-bg);
border-radius: 12px;
padding: 20px;
box-shadow: 0 10px 30px rgba(0,0,0,0.05);
border: 1px solid rgba(0,0,0,0.05);
box-shadow: var(--mls-card-shadow);
border: 1px solid var(--mls-card-border);
margin: 0 auto 2rem auto;
}
.css-slider {
@@ -456,7 +500,7 @@ main.content,
.slider-label {
font-size: 0.75rem;
font-weight: 600;
color: #555;
color: var(--mls-text-muted);
margin-bottom: 5px;
text-align: left;
text-transform: uppercase;
@@ -465,7 +509,7 @@ main.content,
.slider-track {
width: 100%;
height: 6px;
background: rgba(0,0,0,0.1);
background: var(--mls-slider-track);
border-radius: 3px;
position: relative;
}
@@ -480,7 +524,7 @@ main.content,
top: 50%;
width: 14px;
height: 14px;
background: #fff;
background: var(--mls-slider-thumb);
border: 2px solid var(--mls-accent);
border-radius: 50%;
transform: translate(-50%, -50%);

View File

@@ -0,0 +1,121 @@
document.addEventListener('DOMContentLoaded', function(){
var container = document.getElementById('mls-neural-bg');
if (!container) return;
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
container.appendChild(canvas);
var isDark = document.documentElement.getAttribute('data-bs-theme') === 'dark';
// Observe theme changes
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.attributeName === 'data-bs-theme') {
isDark = document.documentElement.getAttribute('data-bs-theme') === 'dark';
}
});
});
observer.observe(document.documentElement, { attributes: true });
var fontSize = 14;
var columns = 0;
var drops = [];
// ML Systems related characters
var chars = "01∑∫∇∂∆∏µσλθωαβγδεζηικλμνξοπρστυφχψωABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-*/=<>[]{}()";
chars = chars.split("");
var lastW = window.innerWidth;
var lastH = window.innerHeight;
function resize() {
var dpr = Math.min(window.devicePixelRatio || 1, 2);
var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
if (w === 0) w = 1000;
if (h === 0) h = 800;
if (Math.abs(w - lastW) > 50 || drops.length === 0) {
var canvasH = h + 200;
canvas.width = w * dpr;
canvas.height = canvasH * dpr;
canvas.style.width = w + 'px';
canvas.style.height = canvasH + 'px';
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.scale(dpr, dpr);
lastW = w;
lastH = h;
columns = Math.floor(w / fontSize);
drops = [];
for(var x = 0; x < columns; x++) {
drops[x] = Math.random() * -100; // Start off screen randomly
}
}
}
function draw() {
var w = canvas.width / Math.min(window.devicePixelRatio || 1, 2);
var h = canvas.height / Math.min(window.devicePixelRatio || 1, 2);
// Translucent background to create trail effect
if (isDark) {
ctx.fillStyle = "rgba(10, 10, 12, 0.05)";
} else {
ctx.fillStyle = "rgba(255, 255, 255, 0.05)";
}
ctx.fillRect(0, 0, w, h);
// Set text color and font
ctx.font = fontSize + "px monospace";
for(var i = 0; i < drops.length; i++) {
var text = chars[Math.floor(Math.random() * chars.length)];
// Color based on theme
if (isDark) {
// Glowing cyan/blue for dark mode
ctx.fillStyle = Math.random() > 0.9 ? "#fff" : "#00e5ff";
ctx.globalAlpha = Math.random() * 0.5 + 0.1;
} else {
// Harvard Crimson for light mode
ctx.fillStyle = Math.random() > 0.9 ? "#111" : "#A51C30";
ctx.globalAlpha = Math.random() * 0.3 + 0.05;
}
ctx.fillText(text, i * fontSize, drops[i] * fontSize);
ctx.globalAlpha = 1;
// Reset drop to top randomly
if(drops[i] * fontSize > h && Math.random() > 0.975) {
drops[i] = 0;
}
drops[i]++;
}
}
var lastTime = 0;
function tick(timestamp) {
requestAnimationFrame(tick);
// Matrix effect looks better slightly slower (~20-25fps)
if (timestamp - lastTime < 40) return;
lastTime = timestamp;
draw();
}
resize();
requestAnimationFrame(tick);
var resizeTimeout;
window.addEventListener('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
if (window.innerWidth !== lastW) {
resize();
}
}, 200);
});
});

View File

@@ -0,0 +1,134 @@
document.addEventListener('DOMContentLoaded', function(){
var container = document.getElementById('mls-neural-bg');
if (!container) return;
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
container.appendChild(canvas);
var isDark = document.documentElement.getAttribute('data-bs-theme') === 'dark';
// Observe theme changes
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.attributeName === 'data-bs-theme') {
isDark = document.documentElement.getAttribute('data-bs-theme') === 'dark';
}
});
});
observer.observe(document.documentElement, { attributes: true });
var particles = [];
var numParticles = 150;
var lastW = window.innerWidth;
var lastH = window.innerHeight;
var time = 0;
function resize() {
var dpr = Math.min(window.devicePixelRatio || 1, 2);
var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
if (w === 0) w = 1000;
if (h === 0) h = 800;
if (Math.abs(w - lastW) > 50 || particles.length === 0) {
var canvasH = h + 200;
canvas.width = w * dpr;
canvas.height = canvasH * dpr;
canvas.style.width = w + 'px';
canvas.style.height = canvasH + 'px';
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.scale(dpr, dpr);
lastW = w;
lastH = h;
initParticles(w, canvasH);
}
}
function initParticles(w, h) {
particles = [];
for(var i = 0; i < numParticles; i++) {
particles.push({
x: Math.random() * w,
y: Math.random() * h,
size: Math.random() * 3 + 1,
speedX: Math.random() * 1 - 0.5,
speedY: Math.random() * 1 - 0.5,
baseAlpha: Math.random() * 0.5 + 0.1,
pulseSpeed: Math.random() * 0.05 + 0.01
});
}
}
function draw() {
var w = canvas.width / Math.min(window.devicePixelRatio || 1, 2);
var h = canvas.height / Math.min(window.devicePixelRatio || 1, 2);
ctx.clearRect(0, 0, w, h);
time += 1;
for(var i = 0; i < particles.length; i++) {
var p = particles[i];
// Move
p.x += p.speedX;
p.y += p.speedY;
// Wrap around edges
if(p.x < 0) p.x = w;
if(p.x > w) p.x = 0;
if(p.y < 0) p.y = h;
if(p.y > h) p.y = 0;
// Pulse alpha
var currentAlpha = p.baseAlpha + Math.sin(time * p.pulseSpeed) * 0.2;
if(currentAlpha < 0) currentAlpha = 0;
if(currentAlpha > 1) currentAlpha = 1;
ctx.beginPath();
ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
if (isDark) {
// Glowing cyan/purple for dark mode
var r = i % 2 === 0 ? 0 : 179;
var g = i % 2 === 0 ? 229 : 136;
var b = 255;
ctx.fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + currentAlpha + ')';
ctx.shadowBlur = 10;
ctx.shadowColor = ctx.fillStyle;
} else {
// Harvard Crimson / Dark Grey for light mode
var r = i % 2 === 0 ? 165 : 100;
var g = i % 2 === 0 ? 28 : 100;
var b = i % 2 === 0 ? 48 : 100;
ctx.fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + currentAlpha + ')';
ctx.shadowBlur = 0;
}
ctx.fill();
}
}
var lastTime = 0;
function tick(timestamp) {
requestAnimationFrame(tick);
if (timestamp - lastTime < 33) return; // ~30fps
lastTime = timestamp;
draw();
}
resize();
requestAnimationFrame(tick);
var resizeTimeout;
window.addEventListener('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
if (window.innerWidth !== lastW) {
resize();
}
}, 200);
});
});

View File

@@ -38,6 +38,9 @@ document.addEventListener('DOMContentLoaded', function(){
var spacing = 4;
var cols = 0, rows = 0;
var lastW = window.innerWidth;
var lastH = window.innerHeight;
function resize() {
var dpr = Math.min(window.devicePixelRatio || 1, 2);
var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
@@ -46,13 +49,22 @@ document.addEventListener('DOMContentLoaded', function(){
if (w === 0) w = 1000;
if (h === 0) h = 800;
canvas.width = w * dpr;
canvas.height = h * dpr;
canvas.style.width = w + 'px';
canvas.style.height = h + 'px';
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.scale(dpr, dpr);
initPixels(w, h);
// Only resize canvas if width changes significantly (ignore height changes from scrollbars/navbars)
if (Math.abs(w - lastW) > 50 || pixels.length === 0) {
// Make canvas slightly larger than screen to account for mobile address bar hiding
var canvasH = h + 200;
canvas.width = w * dpr;
canvas.height = canvasH * dpr;
canvas.style.width = w + 'px';
canvas.style.height = canvasH + 'px';
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.scale(dpr, dpr);
lastW = w;
lastH = h;
initPixels(w, canvasH);
}
}
function initPixels(w, h) {
@@ -78,8 +90,9 @@ document.addEventListener('DOMContentLoaded', function(){
}
function draw() {
var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
// Use the canvas dimensions for clearing, not the window dimensions
var w = canvas.width / Math.min(window.devicePixelRatio || 1, 2);
var h = canvas.height / Math.min(window.devicePixelRatio || 1, 2);
ctx.clearRect(0, 0, w, h);
time += 1.5;
@@ -115,6 +128,11 @@ document.addEventListener('DOMContentLoaded', function(){
var resizeTimeout;
window.addEventListener('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(resize, 200);
resizeTimeout = setTimeout(function() {
// Only trigger resize if width actually changed (ignores mobile scrollbar hide/show)
if (window.innerWidth !== lastW) {
resize();
}
}, 200);
});
});