Patterns Medium
Spotlight Reveal
Mouse-driven spotlight that reveals colorful hidden content through a dark overlay using CSS masks.
css-maskmouse-tracking
Targets: JS HTML
Code
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--accent: #86e8ff;
--neon-purple: #ae52ff;
--neon-pink: #ff40d6;
}
body {
background: #030510;
color: #f0f4fb;
font-family: 'Inter', 'SF Pro Display', system-ui, sans-serif;
overflow: hidden;
height: 100vh;
cursor: none;
}
@media (hover: none) {
body { cursor: auto; }
}
/* ── Stage ── */
.stage {
position: relative;
width: 100vw;
height: 100vh;
overflow: hidden;
}
/* ── Hidden layer (colorful content underneath) ── */
.hidden-layer {
position: absolute;
inset: 0;
z-index: 1;
background: linear-gradient(135deg, #0a0520 0%, #150a30 50%, #0d1a2a 100%);
}
.hidden-content {
position: relative;
width: 100%;
height: 100%;
}
.color-block {
position: absolute;
border-radius: 16px;
}
.block-1 {
width: 200px; height: 200px;
background: linear-gradient(135deg, #86e8ff, #3d9eff);
top: 10%; left: 8%;
transform: rotate(-12deg);
}
.block-2 {
width: 150px; height: 260px;
background: linear-gradient(135deg, #ae52ff, #7c2aff);
top: 15%; right: 12%;
transform: rotate(8deg);
}
.block-3 {
width: 280px; height: 140px;
background: linear-gradient(135deg, #ff40d6, #ff6b9d);
bottom: 20%; left: 15%;
transform: rotate(5deg);
}
.block-4 {
width: 120px; height: 120px;
background: linear-gradient(135deg, #ffcc66, #ff9f43);
top: 55%; left: 50%;
border-radius: 50%;
}
.block-5 {
width: 180px; height: 100px;
background: linear-gradient(135deg, #50c878, #27ae60);
bottom: 10%; right: 20%;
transform: rotate(-6deg);
}
.block-6 {
width: 100px; height: 200px;
background: linear-gradient(135deg, #ff6b6b, #ee5a24);
top: 5%; left: 45%;
transform: rotate(15deg);
}
.orb {
position: absolute;
border-radius: 50%;
filter: blur(40px);
}
.orb-1 {
width: 300px; height: 300px;
background: rgba(134, 232, 255, 0.2);
top: 30%; left: 30%;
}
.orb-2 {
width: 250px; height: 250px;
background: rgba(174, 82, 255, 0.15);
bottom: 15%; right: 25%;
}
.orb-3 {
width: 200px; height: 200px;
background: rgba(255, 64, 214, 0.12);
top: 60%; left: 10%;
}
.hidden-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
z-index: 5;
}
.hidden-text h2 {
font-size: 3rem;
font-weight: 700;
letter-spacing: -0.03em;
margin-bottom: 0.5rem;
background: linear-gradient(135deg, #86e8ff, #ae52ff);
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.hidden-text p {
font-size: 1rem;
color: rgba(255, 255, 255, 0.7);
}
/* ── Cover layer (dark overlay with spotlight mask) ── */
.cover-layer {
position: absolute;
inset: 0;
z-index: 10;
background: #030510;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
/* The mask is set via JS on mousemove */
-webkit-mask-image: radial-gradient(circle 0px at 50% 50%, transparent 0%, black 100%);
mask-image: radial-gradient(circle 0px at 50% 50%, transparent 0%, black 100%);
-webkit-mask-composite: source-over;
pointer-events: none;
}
.cover-content {
padding: 2rem;
pointer-events: auto;
}
.eyebrow {
display: inline-block;
font-size: 0.7rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.18em;
color: var(--accent);
margin-bottom: 1rem;
}
h1 {
font-size: clamp(2.5rem, 7vw, 5rem);
font-weight: 700;
letter-spacing: -0.03em;
}
.subtitle {
font-size: clamp(0.9rem, 2vw, 1.05rem);
color: #8a95a8;
max-width: 460px;
margin: 0.75rem auto 0;
line-height: 1.6;
}
.hint {
margin-top: 2rem;
font-size: 0.8rem;
color: rgba(134, 232, 255, 0.5);
text-transform: uppercase;
letter-spacing: 0.1em;
}
/* ── Trail ── */
.trail {
position: fixed;
inset: 0;
z-index: 5;
pointer-events: none;
}
.trail-dot {
position: absolute;
width: 8px;
height: 8px;
border-radius: 50%;
background: rgba(134, 232, 255, 0.4);
transform: translate(-50%, -50%);
will-change: transform, opacity;
}
/* ── Back button ── */
.btn-back {
position: fixed;
bottom: 2rem;
left: 50%;
transform: translateX(-50%);
z-index: 20;
display: inline-block;
padding: 0.7rem 2rem;
border-radius: 999px;
border: 1px solid rgba(134, 232, 255, 0.3);
color: var(--accent);
text-decoration: none;
font: 600 0.85rem/1 'Inter', system-ui, sans-serif;
transition: all 0.25s ease;
background: rgba(3, 5, 16, 0.8);
backdrop-filter: blur(8px);
}
.btn-back:hover {
background: rgba(134, 232, 255, 0.08);
border-color: var(--accent);
}
/* ── Reduced motion ── */
.reduced-motion .cover-layer {
-webkit-mask-image: none;
mask-image: none;
background: rgba(3, 5, 16, 0.5);
}
.reduced-motion body { cursor: auto; }Spotlight Reveal
Mouse-driven spotlight that reveals colorful hidden content through a dark overlay using CSS masks.
Source
- Repository:
libs-genclaude - Original demo id:
17-spotlight-reveal
Notes
Mouse-driven spotlight that reveals colorful hidden content through a dark overlay using CSS masks.