# Hidden text under a flashlight

> A dark basement: the beam of a flashlight follows the pointer, a finger or the arrow keys and reveals the writing on the wall.

- Category: [Text & scroll](https://library.aimran.es/components/text-scroll)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-tx-flashlight
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

The page is pitch black until a warm circle of light passes over it. A copy of the text sits under a radial mask that follows the pointer, so the wall and the words appear only inside the beam, and the light wanders on its own when nobody moves it. It suits mystery teasers, escape rooms, games, museums and hidden offers.

Write the headline in the text field, edit the paragraph in the HTML and set the light color with the main color and the darkness with the secondary one. A slider changes the beam radius. The real text is always in the page for screen readers.

## Code

### HTML

```html
<div class="uvq14-fl" tabindex="0" role="group" aria-label="Flashlight: move the light with the mouse, your finger or the arrow keys"><div class="tx"><p class="kc">Basement 2 · Archive</p><h3>What you're looking for is here</h3><p>The boxes from 1987 are still on the back shelf. Nobody has switched the light on since.</p></div><div class="lit" aria-hidden="true" translate="no"></div></div>
```

### CSS

```css
.uvq14-fl {
  --c1: #fbbf24;
  --c2: #0b0d10;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --rr: 85px;
  /* radio de la luz */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq14-fl {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 21em;
  height: 14em;
  border-radius: 1.2em;
  overflow: hidden;
  color: #fff;
  background: var(--c2);
  cursor: none;
  touch-action: none;
  outline: 0;
  --x: 50%;
  --y: 50%;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08),0 1.4em 2.4em -1.4em rgba(0,0,0,.6);
}

.uvq14-fl:focus-visible {
  box-shadow: 0 0 0 3px var(--c1);
}

.uvq14-fl .tx,.uvq14-fl .lit {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  padding: 1.6em 1.6em;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.uvq14-fl .tx {
  color: rgba(255,255,255,.075);
}

.uvq14-fl .lit {
  color: #2a2216;
  background: radial-gradient(circle var(--rr) at var(--x) var(--y),color-mix(in srgb,var(--c1) 55%,#fff8e6),color-mix(in srgb,var(--c1) 70%,#7a5a20) 70%,#3a2c14),repeating-linear-gradient(0deg,rgba(0,0,0,.08) 0 1px,transparent 1px 1.6em),repeating-linear-gradient(90deg,rgba(0,0,0,.06) 0 1px,transparent 1px 3.2em);
  -webkit-mask: radial-gradient(circle var(--rr) at var(--x) var(--y),#000 55%,transparent 100%);
  mask: radial-gradient(circle var(--rr) at var(--x) var(--y),#000 55%,transparent 100%);
  pointer-events: none;
}

.uvq14-fl .kc {
  margin: 0;
  font: 700 .66em/1 ui-monospace,"SF Mono","JetBrains Mono",Menlo,Consolas,monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.uvq14-fl h3 {
  margin: .45em 0 .4em;
  font-size: 1.8em;
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -.03em;
}

.uvq14-fl .tx p:last-child,.uvq14-fl .lit p:last-child {
  margin: 0;
  font-size: .85em;
  line-height: 1.55;
}
```

### JavaScript

```js
document.querySelectorAll(".uvq14-fl").forEach(el => {
  const tx=el.querySelector(".tx"),lit=el.querySelector(".lit");const rm=matchMedia("(prefers-reduced-motion: reduce)").matches;let x=0,y=0,raf=0,idle=true,tm=0,t0=performance.now();
const copy=()=>{lit.innerHTML=tx.innerHTML};copy();
const put=()=>{el.style.setProperty("--x",x.toFixed(1)+"px");el.style.setProperty("--y",y.toFixed(1)+"px")};
const wander=()=>{const t=(performance.now()-t0)/1000,W=el.offsetWidth,H=el.offsetHeight;x=W/2+Math.sin(t*.7)*W*.32;y=H/2+Math.sin(t*1.1+1)*H*.28;put();raf=idle?requestAnimationFrame(wander):0};
const wake=()=>{idle=false;cancelAnimationFrame(raf);raf=0;clearTimeout(tm);tm=setTimeout(()=>{if(document.activeElement!==el&&!rm){idle=true;wander()}},2600)};
el.addEventListener("pointermove",e=>{const r=el.getBoundingClientRect(),s=r.width/el.offsetWidth||1;x=(e.clientX-r.left)/s;y=(e.clientY-r.top)/s;wake();put()});
el.addEventListener("pointerdown",e=>{const r=el.getBoundingClientRect(),s=r.width/el.offsetWidth||1;x=(e.clientX-r.left)/s;y=(e.clientY-r.top)/s;wake();put()});
el.addEventListener("keydown",e=>{const m={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(!m)return;e.preventDefault();const d=e.shiftKey?48:18;x=Math.max(0,Math.min(el.offsetWidth,x+m[0]*d));y=Math.max(0,Math.min(el.offsetHeight,y+m[1]*d));wake();put()});
el.addEventListener("focus",wake);
const mo=new MutationObserver(copy);mo.observe(tx,{childList:true,characterData:true,subtree:true});
x=el.offsetWidth/2;y=el.offsetHeight/2;put();if(!rm)wander();
return()=>{mo.disconnect();cancelAnimationFrame(raf);clearTimeout(tm)}
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq14-fl {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 21em;
  height: 14em;
  border-radius: 1.2em;
  overflow: hidden;
  color: #fff;
  background: var(--c2);
  cursor: none;
  touch-action: none;
  outline: 0;
  --x: 50%;
  --y: 50%;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08),0 1.4em 2.4em -1.4em rgba(0,0,0,.6);
}

.uvq14-fl:focus-visible {
  box-shadow: 0 0 0 3px var(--c1);
}

.uvq14-fl .tx,.uvq14-fl .lit {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  padding: 1.6em 1.6em;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.uvq14-fl .tx {
  color: rgba(255,255,255,.075);
}

.uvq14-fl .lit {
  color: #2a2216;
  background: radial-gradient(circle var(--rr) at var(--x) var(--y),color-mix(in srgb,var(--c1) 55%,#fff8e6),color-mix(in srgb,var(--c1) 70%,#7a5a20) 70%,#3a2c14),repeating-linear-gradient(0deg,rgba(0,0,0,.08) 0 1px,transparent 1px 1.6em),repeating-linear-gradient(90deg,rgba(0,0,0,.06) 0 1px,transparent 1px 3.2em);
  -webkit-mask: radial-gradient(circle var(--rr) at var(--x) var(--y),#000 55%,transparent 100%);
  mask: radial-gradient(circle var(--rr) at var(--x) var(--y),#000 55%,transparent 100%);
  pointer-events: none;
}

.uvq14-fl .kc {
  margin: 0;
  font: 700 .66em/1 ui-monospace,"SF Mono","JetBrains Mono",Menlo,Consolas,monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.uvq14-fl h3 {
  margin: .45em 0 .4em;
  font-size: 1.8em;
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -.03em;
}

.uvq14-fl .tx p:last-child,.uvq14-fl .lit p:last-child {
  margin: 0;
  font-size: .85em;
  line-height: 1.55;
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const tx=el.querySelector(".tx"),lit=el.querySelector(".lit");const rm=matchMedia("(prefers-reduced-motion: reduce)").matches;let x=0,y=0,raf=0,idle=true,tm=0,t0=performance.now();
const copy=()=>{lit.innerHTML=tx.innerHTML};copy();
const put=()=>{el.style.setProperty("--x",x.toFixed(1)+"px");el.style.setProperty("--y",y.toFixed(1)+"px")};
const wander=()=>{const t=(performance.now()-t0)/1000,W=el.offsetWidth,H=el.offsetHeight;x=W/2+Math.sin(t*.7)*W*.32;y=H/2+Math.sin(t*1.1+1)*H*.28;put();raf=idle?requestAnimationFrame(wander):0};
const wake=()=>{idle=false;cancelAnimationFrame(raf);raf=0;clearTimeout(tm);tm=setTimeout(()=>{if(document.activeElement!==el&&!rm){idle=true;wander()}},2600)};
el.addEventListener("pointermove",e=>{const r=el.getBoundingClientRect(),s=r.width/el.offsetWidth||1;x=(e.clientX-r.left)/s;y=(e.clientY-r.top)/s;wake();put()});
el.addEventListener("pointerdown",e=>{const r=el.getBoundingClientRect(),s=r.width/el.offsetWidth||1;x=(e.clientX-r.left)/s;y=(e.clientY-r.top)/s;wake();put()});
el.addEventListener("keydown",e=>{const m={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(!m)return;e.preventDefault();const d=e.shiftKey?48:18;x=Math.max(0,Math.min(el.offsetWidth,x+m[0]*d));y=Math.max(0,Math.min(el.offsetHeight,y+m[1]*d));wake();put()});
el.addEventListener("focus",wake);
const mo=new MutationObserver(copy);mo.observe(tx,{childList:true,characterData:true,subtree:true});
x=el.offsetWidth/2;y=el.offsetHeight/2;put();if(!rm)wander();
return()=>{mo.disconnect();cancelAnimationFrame(raf);clearTimeout(tm)}
}

export default function TxFlashlight() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#fbbf24",
          "--c2": "#0b0d10",
          "--s": "16px",
          "--k": "1",
          "--rr": "85px",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq14-fl" tabIndex={0} role="group" aria-label="Flashlight: move the light with the mouse, your finger or the arrow keys"><div className="tx"><p className="kc">Basement 2 · Archive</p><h3>What you're looking for is here</h3><p>The boxes from 1987 are still on the back shelf. Nobody has switched the light on since.</p></div><div className="lit" aria-hidden="true" translate="no"></div></div>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Hidden text under a flashlight” block (Text & scroll) from AIMRAN Library to my project.

## What it is
A dark basement: the beam of a flashlight follows the pointer, a finger or the arrow keys and reveals the writing on the wall.

## Chosen settings
- Main color: #fbbf24
- Secondary color: #0b0d10
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Light radius: 85px (from 50 to 140px)
- Text: "Lo que buscas está aquí"

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq14-fl {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 21em;
  height: 14em;
  border-radius: 1.2em;
  overflow: hidden;
  color: #fff;
  background: var(--c2);
  cursor: none;
  touch-action: none;
  outline: 0;
  --x: 50%;
  --y: 50%;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08),0 1.4em 2.4em -1.4em rgba(0,0,0,.6);
}

.uvq14-fl:focus-visible {
  box-shadow: 0 0 0 3px var(--c1);
}

.uvq14-fl .tx,.uvq14-fl .lit {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  padding: 1.6em 1.6em;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.uvq14-fl .tx {
  color: rgba(255,255,255,.075);
}

.uvq14-fl .lit {
  color: #2a2216;
  background: radial-gradient(circle var(--rr) at var(--x) var(--y),color-mix(in srgb,var(--c1) 55%,#fff8e6),color-mix(in srgb,var(--c1) 70%,#7a5a20) 70%,#3a2c14),repeating-linear-gradient(0deg,rgba(0,0,0,.08) 0 1px,transparent 1px 1.6em),repeating-linear-gradient(90deg,rgba(0,0,0,.06) 0 1px,transparent 1px 3.2em);
  -webkit-mask: radial-gradient(circle var(--rr) at var(--x) var(--y),#000 55%,transparent 100%);
  mask: radial-gradient(circle var(--rr) at var(--x) var(--y),#000 55%,transparent 100%);
  pointer-events: none;
}

.uvq14-fl .kc {
  margin: 0;
  font: 700 .66em/1 ui-monospace,"SF Mono","JetBrains Mono",Menlo,Consolas,monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.uvq14-fl h3 {
  margin: .45em 0 .4em;
  font-size: 1.8em;
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -.03em;
}

.uvq14-fl .tx p:last-child,.uvq14-fl .lit p:last-child {
  margin: 0;
  font-size: .85em;
  line-height: 1.55;
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const tx=el.querySelector(".tx"),lit=el.querySelector(".lit");const rm=matchMedia("(prefers-reduced-motion: reduce)").matches;let x=0,y=0,raf=0,idle=true,tm=0,t0=performance.now();
const copy=()=>{lit.innerHTML=tx.innerHTML};copy();
const put=()=>{el.style.setProperty("--x",x.toFixed(1)+"px");el.style.setProperty("--y",y.toFixed(1)+"px")};
const wander=()=>{const t=(performance.now()-t0)/1000,W=el.offsetWidth,H=el.offsetHeight;x=W/2+Math.sin(t*.7)*W*.32;y=H/2+Math.sin(t*1.1+1)*H*.28;put();raf=idle?requestAnimationFrame(wander):0};
const wake=()=>{idle=false;cancelAnimationFrame(raf);raf=0;clearTimeout(tm);tm=setTimeout(()=>{if(document.activeElement!==el&&!rm){idle=true;wander()}},2600)};
el.addEventListener("pointermove",e=>{const r=el.getBoundingClientRect(),s=r.width/el.offsetWidth||1;x=(e.clientX-r.left)/s;y=(e.clientY-r.top)/s;wake();put()});
el.addEventListener("pointerdown",e=>{const r=el.getBoundingClientRect(),s=r.width/el.offsetWidth||1;x=(e.clientX-r.left)/s;y=(e.clientY-r.top)/s;wake();put()});
el.addEventListener("keydown",e=>{const m={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(!m)return;e.preventDefault();const d=e.shiftKey?48:18;x=Math.max(0,Math.min(el.offsetWidth,x+m[0]*d));y=Math.max(0,Math.min(el.offsetHeight,y+m[1]*d));wake();put()});
el.addEventListener("focus",wake);
const mo=new MutationObserver(copy);mo.observe(tx,{childList:true,characterData:true,subtree:true});
x=el.offsetWidth/2;y=el.offsetHeight/2;put();if(!rm)wander();
return()=>{mo.disconnect();cancelAnimationFrame(raf);clearTimeout(tm)}
}

export default function TxFlashlight() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#fbbf24",
          "--c2": "#0b0d10",
          "--s": "16px",
          "--k": "1",
          "--rr": "85px",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq14-fl" tabIndex={0} role="group" aria-label="Flashlight: move the light with the mouse, your finger or the arrow keys"><div className="tx"><p className="kc">Basement 2 · Archive</p><h3>What you're looking for is here</h3><p>The boxes from 1987 are still on the back shelf. Nobody has switched the light on since.</p></div><div className="lit" aria-hidden="true" translate="no"></div></div>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
