# E-ink reader page turn

> An e-reader that turns pages with the black flash of electronic ink and leaves a faint ghost of the previous text.

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

## Where to use it

E-readers refresh their screen with a quick black and white flash, and that small glitch is what makes them feel like paper. This block copies it with a stepped CSS animation over a serif page, plus a ghost of the last page that fades out. It works for book launches, long reads, publishers and storytelling sections.

Replace the three pages with your own excerpt and the title in the header. Readers can turn pages with the side buttons, by tapping either half of the screen or with the arrow keys, and each new page is announced politely.

## Code

### HTML

```html
<div class="uvq14-ink"><div class="scr"><p class="hd"><span>The northern lighthouse</span><span>Chapter 3</span></p><div class="pg" aria-live="polite"><p class="gh" aria-hidden="true"></p><p>The fog arrived before the ship. From the tower, Elena counted the bells and wrote the time in her notebook, as she had every night for eleven years.</p><p hidden>Below, the sea beat patiently against the rocks. She lit the lamp, wiped the glass with her sleeve and waited for another light to answer on the horizon.</p><p hidden>Nobody answered. Only the wind, smelling of salt and diesel. Elena went down the spiral staircase counting the steps, one by one, in the dark.</p></div><div class="ft"><span class="br"><i></i></span><span><span class="n">1</span> / 3</span></div><i class="fx" aria-hidden="true"></i></div><div class="ct"><button type="button" class="pv" aria-label="Previous page"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 6l-6 6 6 6"/></svg></button><span class="lg" aria-hidden="true"></span><button type="button" class="nx" aria-label="Next page"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6"/></svg></button></div></div>
```

### CSS

```css
.uvq14-ink {
  --c1: #0f766e;
  --c2: #2b2d31;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq14-ink {
  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;
  width: 17.5em;
  padding: .9em .9em .7em;
  border-radius: 1.5em;
  background: linear-gradient(160deg,color-mix(in srgb,var(--c2) 80%,#fff),var(--c2) 40%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12),0 1.6em 2.6em -1.4em rgba(0,0,0,.55);
}

.uvq14-ink .scr {
  position: relative;
  height: 15.5em;
  padding: 1em 1.15em .8em;
  border-radius: .35em;
  color: #1b1b1b;
  background: #e8e6de;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25),inset 0 .2em .5em rgba(0,0,0,.12);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.uvq14-ink .hd {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  margin: 0 0 .9em;
  font-size: .62em;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .65;
}

.uvq14-ink .pg {
  position: relative;
  flex: 1;
}

.uvq14-ink .pg p {
  margin: 0;
  font: 400 .92em/1.6 "Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  text-align: justify;
  hyphens: auto;
}

.uvq14-ink .pg p:first-of-type+p::first-letter {
  float: left;
  margin: .08em .12em 0 0;
  font-size: 2.6em;
  line-height: .8;
  font-weight: 700;
}

.uvq14-ink .gh {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.uvq14-ink .ft {
  display: flex;
  align-items: center;
  gap: .8em;
  font-size: .62em;
  font-weight: 600;
  opacity: .7;
}

.uvq14-ink .br {
  flex: 1;
  height: .3em;
  border-radius: 1em;
  background: rgba(0,0,0,.12);
  overflow: hidden;
}

.uvq14-ink .br i {
  display: block;
  height: 100%;
  width: calc(var(--q,.333) * 100%);
  background: #1b1b1b;
  transition: width calc(0.3s / var(--k)) steps(3);
}

.uvq14-ink .fx {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
}

.uvq14-ink.flash .fx {
  animation: uvq14-ink-f calc(0.5s / var(--k)) steps(1,end);
}

.uvq14-ink.flash .gh {
  animation: uvq14-ink-g calc(2s / var(--k)) ease-out;
}

.uvq14-ink.nope .scr {
  animation: uvq14-ink-n calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq14-ink .ct {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .6em;
}

.uvq14-ink .ct button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  width: 2.6em;
  height: 1.8em;
  border-radius: .6em;
  color: #d4d4d8;
  background: rgba(255,255,255,.08);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.2s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq14-ink .ct button:hover {
  background: rgba(255,255,255,.16);
}

.uvq14-ink .ct button:active {
  transform: scale(.92);
}

.uvq14-ink .ct button:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq14-ink .ct svg {
  width: 1.1em;
  height: 1.1em;
}

.uvq14-ink .lg {
  width: 2.4em;
  height: .3em;
  border-radius: 1em;
  background: rgba(255,255,255,.14);
}

@keyframes uvq14-ink-f {
  0% {
    opacity: 1;
    background: #111;
  }
  30% {
    opacity: 1;
    background: #e8e6de;
  }
  55% {
    opacity: 1;
    background: #2a2a2a;
  }
  80% {
    opacity: 0;
  }
}

@keyframes uvq14-ink-g {
  from {
    opacity: .13;
  }
  to {
    opacity: 0;
  }
}

@keyframes uvq14-ink-n {
  25% {
    transform: translateX(-.25em);
  }
  75% {
    transform: translateX(.25em);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq14-ink,.uvq14-ink *,.uvq14-ink *::before,.uvq14-ink *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
```

### JavaScript

```js
document.querySelectorAll(".uvq14-ink").forEach(el => {
  const ps=[...el.querySelectorAll(".pg p:not(.gh)")],gh=el.querySelector(".gh"),n=el.querySelector(".n"),scr=el.querySelector(".scr");let i=0;
const flash=c=>{el.classList.remove(c);void el.offsetWidth;el.classList.add(c)};
const go=d=>{const j=i+d;if(j<0||j>=ps.length){flash("nope");return}gh.textContent=ps[i].textContent;ps[i].hidden=true;i=j;ps[i].hidden=false;n.textContent=String(i+1);el.style.setProperty("--q",((i+1)/ps.length).toFixed(3));flash("flash")};
el.querySelector(".pv").addEventListener("click",()=>go(-1));el.querySelector(".nx").addEventListener("click",()=>go(1));
scr.addEventListener("click",e=>{const r=scr.getBoundingClientRect();go(e.clientX-r.left<r.width*.35?-1:1)});
el.addEventListener("keydown",e=>{if(e.key==="ArrowRight"||e.key==="PageDown"){e.preventDefault();go(1)}if(e.key==="ArrowLeft"||e.key==="PageUp"){e.preventDefault();go(-1)}});
el.addEventListener("animationend",e=>{if(e.target===el.querySelector(".fx"))el.classList.remove("flash")})
});
```

### 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-ink {
  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;
  width: 17.5em;
  padding: .9em .9em .7em;
  border-radius: 1.5em;
  background: linear-gradient(160deg,color-mix(in srgb,var(--c2) 80%,#fff),var(--c2) 40%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12),0 1.6em 2.6em -1.4em rgba(0,0,0,.55);
}

.uvq14-ink .scr {
  position: relative;
  height: 15.5em;
  padding: 1em 1.15em .8em;
  border-radius: .35em;
  color: #1b1b1b;
  background: #e8e6de;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25),inset 0 .2em .5em rgba(0,0,0,.12);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.uvq14-ink .hd {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  margin: 0 0 .9em;
  font-size: .62em;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .65;
}

.uvq14-ink .pg {
  position: relative;
  flex: 1;
}

.uvq14-ink .pg p {
  margin: 0;
  font: 400 .92em/1.6 "Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  text-align: justify;
  hyphens: auto;
}

.uvq14-ink .pg p:first-of-type+p::first-letter {
  float: left;
  margin: .08em .12em 0 0;
  font-size: 2.6em;
  line-height: .8;
  font-weight: 700;
}

.uvq14-ink .gh {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.uvq14-ink .ft {
  display: flex;
  align-items: center;
  gap: .8em;
  font-size: .62em;
  font-weight: 600;
  opacity: .7;
}

.uvq14-ink .br {
  flex: 1;
  height: .3em;
  border-radius: 1em;
  background: rgba(0,0,0,.12);
  overflow: hidden;
}

.uvq14-ink .br i {
  display: block;
  height: 100%;
  width: calc(var(--q,.333) * 100%);
  background: #1b1b1b;
  transition: width calc(0.3s / var(--k)) steps(3);
}

.uvq14-ink .fx {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
}

.uvq14-ink.flash .fx {
  animation: uvq14-ink-f calc(0.5s / var(--k)) steps(1,end);
}

.uvq14-ink.flash .gh {
  animation: uvq14-ink-g calc(2s / var(--k)) ease-out;
}

.uvq14-ink.nope .scr {
  animation: uvq14-ink-n calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq14-ink .ct {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .6em;
}

.uvq14-ink .ct button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  width: 2.6em;
  height: 1.8em;
  border-radius: .6em;
  color: #d4d4d8;
  background: rgba(255,255,255,.08);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.2s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq14-ink .ct button:hover {
  background: rgba(255,255,255,.16);
}

.uvq14-ink .ct button:active {
  transform: scale(.92);
}

.uvq14-ink .ct button:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq14-ink .ct svg {
  width: 1.1em;
  height: 1.1em;
}

.uvq14-ink .lg {
  width: 2.4em;
  height: .3em;
  border-radius: 1em;
  background: rgba(255,255,255,.14);
}

@keyframes uvq14-ink-f {
  0% {
    opacity: 1;
    background: #111;
  }
  30% {
    opacity: 1;
    background: #e8e6de;
  }
  55% {
    opacity: 1;
    background: #2a2a2a;
  }
  80% {
    opacity: 0;
  }
}

@keyframes uvq14-ink-g {
  from {
    opacity: .13;
  }
  to {
    opacity: 0;
  }
}

@keyframes uvq14-ink-n {
  25% {
    transform: translateX(-.25em);
  }
  75% {
    transform: translateX(.25em);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq14-ink,.uvq14-ink *,.uvq14-ink *::before,.uvq14-ink *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// 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 ps=[...el.querySelectorAll(".pg p:not(.gh)")],gh=el.querySelector(".gh"),n=el.querySelector(".n"),scr=el.querySelector(".scr");let i=0;
const flash=c=>{el.classList.remove(c);void el.offsetWidth;el.classList.add(c)};
const go=d=>{const j=i+d;if(j<0||j>=ps.length){flash("nope");return}gh.textContent=ps[i].textContent;ps[i].hidden=true;i=j;ps[i].hidden=false;n.textContent=String(i+1);el.style.setProperty("--q",((i+1)/ps.length).toFixed(3));flash("flash")};
el.querySelector(".pv").addEventListener("click",()=>go(-1));el.querySelector(".nx").addEventListener("click",()=>go(1));
scr.addEventListener("click",e=>{const r=scr.getBoundingClientRect();go(e.clientX-r.left<r.width*.35?-1:1)});
el.addEventListener("keydown",e=>{if(e.key==="ArrowRight"||e.key==="PageDown"){e.preventDefault();go(1)}if(e.key==="ArrowLeft"||e.key==="PageUp"){e.preventDefault();go(-1)}});
el.addEventListener("animationend",e=>{if(e.target===el.querySelector(".fx"))el.classList.remove("flash")})
}

export default function TxEinkPage() {
  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": "#0f766e",
          "--c2": "#2b2d31",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq14-ink"><div className="scr"><p className="hd"><span>The northern lighthouse</span><span>Chapter 3</span></p><div className="pg" aria-live="polite"><p className="gh" aria-hidden="true"></p><p>The fog arrived before the ship. From the tower, Elena counted the bells and wrote the time in her notebook, as she had every night for eleven years.</p><p hidden={true}>Below, the sea beat patiently against the rocks. She lit the lamp, wiped the glass with her sleeve and waited for another light to answer on the horizon.</p><p hidden={true}>Nobody answered. Only the wind, smelling of salt and diesel. Elena went down the spiral staircase counting the steps, one by one, in the dark.</p></div><div className="ft"><span className="br"><i></i></span><span><span className="n">1</span> / 3</span></div><i className="fx" aria-hidden="true"></i></div><div className="ct"><button type="button" className="pv" aria-label="Previous page"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M15 6l-6 6 6 6" /></svg></button><span className="lg" aria-hidden="true"></span><button type="button" className="nx" aria-label="Next page"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6" /></svg></button></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 “E-ink reader page turn” block (Text & scroll) from AIMRAN Library to my project.

## What it is
An e-reader that turns pages with the black flash of electronic ink and leaves a faint ghost of the previous text.

## Chosen settings
- Main color: #0f766e
- Secondary color: #2b2d31
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "El faro del norte"

## 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-ink {
  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;
  width: 17.5em;
  padding: .9em .9em .7em;
  border-radius: 1.5em;
  background: linear-gradient(160deg,color-mix(in srgb,var(--c2) 80%,#fff),var(--c2) 40%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12),0 1.6em 2.6em -1.4em rgba(0,0,0,.55);
}

.uvq14-ink .scr {
  position: relative;
  height: 15.5em;
  padding: 1em 1.15em .8em;
  border-radius: .35em;
  color: #1b1b1b;
  background: #e8e6de;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25),inset 0 .2em .5em rgba(0,0,0,.12);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.uvq14-ink .hd {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  margin: 0 0 .9em;
  font-size: .62em;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .65;
}

.uvq14-ink .pg {
  position: relative;
  flex: 1;
}

.uvq14-ink .pg p {
  margin: 0;
  font: 400 .92em/1.6 "Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  text-align: justify;
  hyphens: auto;
}

.uvq14-ink .pg p:first-of-type+p::first-letter {
  float: left;
  margin: .08em .12em 0 0;
  font-size: 2.6em;
  line-height: .8;
  font-weight: 700;
}

.uvq14-ink .gh {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.uvq14-ink .ft {
  display: flex;
  align-items: center;
  gap: .8em;
  font-size: .62em;
  font-weight: 600;
  opacity: .7;
}

.uvq14-ink .br {
  flex: 1;
  height: .3em;
  border-radius: 1em;
  background: rgba(0,0,0,.12);
  overflow: hidden;
}

.uvq14-ink .br i {
  display: block;
  height: 100%;
  width: calc(var(--q,.333) * 100%);
  background: #1b1b1b;
  transition: width calc(0.3s / var(--k)) steps(3);
}

.uvq14-ink .fx {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
}

.uvq14-ink.flash .fx {
  animation: uvq14-ink-f calc(0.5s / var(--k)) steps(1,end);
}

.uvq14-ink.flash .gh {
  animation: uvq14-ink-g calc(2s / var(--k)) ease-out;
}

.uvq14-ink.nope .scr {
  animation: uvq14-ink-n calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq14-ink .ct {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .6em;
}

.uvq14-ink .ct button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  width: 2.6em;
  height: 1.8em;
  border-radius: .6em;
  color: #d4d4d8;
  background: rgba(255,255,255,.08);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.2s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq14-ink .ct button:hover {
  background: rgba(255,255,255,.16);
}

.uvq14-ink .ct button:active {
  transform: scale(.92);
}

.uvq14-ink .ct button:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq14-ink .ct svg {
  width: 1.1em;
  height: 1.1em;
}

.uvq14-ink .lg {
  width: 2.4em;
  height: .3em;
  border-radius: 1em;
  background: rgba(255,255,255,.14);
}

@keyframes uvq14-ink-f {
  0% {
    opacity: 1;
    background: #111;
  }
  30% {
    opacity: 1;
    background: #e8e6de;
  }
  55% {
    opacity: 1;
    background: #2a2a2a;
  }
  80% {
    opacity: 0;
  }
}

@keyframes uvq14-ink-g {
  from {
    opacity: .13;
  }
  to {
    opacity: 0;
  }
}

@keyframes uvq14-ink-n {
  25% {
    transform: translateX(-.25em);
  }
  75% {
    transform: translateX(.25em);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq14-ink,.uvq14-ink *,.uvq14-ink *::before,.uvq14-ink *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// 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 ps=[...el.querySelectorAll(".pg p:not(.gh)")],gh=el.querySelector(".gh"),n=el.querySelector(".n"),scr=el.querySelector(".scr");let i=0;
const flash=c=>{el.classList.remove(c);void el.offsetWidth;el.classList.add(c)};
const go=d=>{const j=i+d;if(j<0||j>=ps.length){flash("nope");return}gh.textContent=ps[i].textContent;ps[i].hidden=true;i=j;ps[i].hidden=false;n.textContent=String(i+1);el.style.setProperty("--q",((i+1)/ps.length).toFixed(3));flash("flash")};
el.querySelector(".pv").addEventListener("click",()=>go(-1));el.querySelector(".nx").addEventListener("click",()=>go(1));
scr.addEventListener("click",e=>{const r=scr.getBoundingClientRect();go(e.clientX-r.left<r.width*.35?-1:1)});
el.addEventListener("keydown",e=>{if(e.key==="ArrowRight"||e.key==="PageDown"){e.preventDefault();go(1)}if(e.key==="ArrowLeft"||e.key==="PageUp"){e.preventDefault();go(-1)}});
el.addEventListener("animationend",e=>{if(e.target===el.querySelector(".fx"))el.classList.remove("flash")})
}

export default function TxEinkPage() {
  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": "#0f766e",
          "--c2": "#2b2d31",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq14-ink"><div className="scr"><p className="hd"><span>The northern lighthouse</span><span>Chapter 3</span></p><div className="pg" aria-live="polite"><p className="gh" aria-hidden="true"></p><p>The fog arrived before the ship. From the tower, Elena counted the bells and wrote the time in her notebook, as she had every night for eleven years.</p><p hidden={true}>Below, the sea beat patiently against the rocks. She lit the lamp, wiped the glass with her sleeve and waited for another light to answer on the horizon.</p><p hidden={true}>Nobody answered. Only the wind, smelling of salt and diesel. Elena went down the spiral staircase counting the steps, one by one, in the dark.</p></div><div className="ft"><span className="br"><i></i></span><span><span className="n">1</span> / 3</span></div><i className="fx" aria-hidden="true"></i></div><div className="ct"><button type="button" className="pv" aria-label="Previous page"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M15 6l-6 6 6 6" /></svg></button><span className="lg" aria-hidden="true"></span><button type="button" className="nx" aria-label="Next page"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6" /></svg></button></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.
````
