# Painting zoom viewer with minimap

> A framed painting opens full screen: wheel or pinch to zoom, drag with inertia and a minimap showing the visible area.

- Category: [Overlays](https://library.aimran.es/components/overlays)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-ov-art-zoom
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

Museum sites let you get close to the brushstrokes, and this viewer does the same for any SVG or image. The framed thumbnail opens a dark full screen view, the wheel zooms where the pointer is, two fingers pinch, a drag pans with inertia and a double click jumps in. It fits galleries, maps, plans and product detail.

The main color is the gilded frame and the minimap outline, the second one the viewing room. Swap the symbol for your own artwork, keep its viewBox in the script, and use arrows, plus, minus and zero to move, zoom and reset from the keyboard.

## Code

### HTML

```html
<div class="uvq13-art"><svg class="def" aria-hidden="true" width="0" height="0"><symbol id="uvq13-art-p" viewBox="0 0 400 300"><rect width="400" height="300" fill="#efe6d2"/><rect x="250" y="160" width="134" height="124" fill="#1f2937"/><g fill="#f8f5ec"><rect x="271" y="176" width="9" height="9"/><rect x="289" y="176" width="9" height="9"/><rect x="307" y="176" width="9" height="9"/><rect x="262" y="185" width="9" height="9"/><rect x="280" y="185" width="9" height="9"/><rect x="298" y="185" width="9" height="9"/><rect x="271" y="194" width="9" height="9"/><rect x="289" y="194" width="9" height="9"/><rect x="307" y="194" width="9" height="9"/><rect x="262" y="203" width="9" height="9"/><rect x="280" y="203" width="9" height="9"/><rect x="298" y="203" width="9" height="9"/></g><circle cx="130" cy="125" r="88" fill="#1e3a8a"/><circle cx="130" cy="125" r="56" fill="none" stroke="#f59e0b" stroke-width="10"/><circle cx="130" cy="125" r="20" fill="#dc2626"/><path d="M20 270L380 40" stroke="#111" stroke-width="3"/><path d="M60 292L330 10" stroke="#111" stroke-width="1.2"/><path d="M226 286l60-104 60 104z" fill="#facc15" fill-opacity=".92"/><g fill="#111"><circle cx="234.4" cy="97.0" r="1.9"/><circle cx="334.6" cy="129.1" r="2.4"/><circle cx="285.9" cy="34.5" r="2.7"/><circle cx="325.4" cy="67.5" r="2.5"/><circle cx="287.0" cy="36.5" r="1.4"/><circle cx="337.3" cy="74.2" r="1.9"/><circle cx="259.5" cy="81.8" r="1.1"/><circle cx="245.2" cy="122.1" r="2.8"/><circle cx="259.0" cy="37.3" r="1.5"/><circle cx="306.1" cy="53.4" r="1.3"/><circle cx="265.0" cy="135.3" r="2.8"/><circle cx="263.6" cy="32.2" r="1.3"/><circle cx="285.8" cy="54.8" r="2.4"/><circle cx="313.2" cy="110.3" r="2.0"/><circle cx="356.9" cy="33.8" r="2.0"/><circle cx="282.1" cy="63.6" r="1.3"/><circle cx="349.5" cy="94.7" r="2.1"/><circle cx="286.3" cy="134.6" r="1.1"/><circle cx="266.5" cy="84.1" r="1.0"/><circle cx="314.4" cy="134.1" r="2.3"/><circle cx="341.8" cy="101.5" r="1.8"/><circle cx="334.0" cy="129.6" r="1.2"/><circle cx="303.2" cy="128.7" r="0.9"/><circle cx="305.4" cy="130.7" r="2.0"/><circle cx="328.7" cy="61.9" r="2.4"/><circle cx="296.8" cy="68.3" r="1.7"/><circle cx="320.4" cy="50.5" r="2.8"/><circle cx="249.3" cy="46.0" r="1.7"/><circle cx="372.5" cy="37.3" r="1.3"/><circle cx="293.5" cy="127.1" r="0.9"/><circle cx="334.9" cy="128.6" r="1.7"/><circle cx="292.9" cy="48.6" r="2.4"/><circle cx="275.2" cy="109.6" r="2.6"/><circle cx="232.7" cy="40.7" r="1.6"/><circle cx="258.9" cy="79.7" r="1.9"/><circle cx="343.6" cy="80.4" r="2.8"/><circle cx="281.5" cy="74.1" r="1.7"/><circle cx="350.4" cy="43.6" r="1.8"/><circle cx="317.4" cy="117.6" r="2.5"/><circle cx="269.1" cy="106.9" r="1.4"/><circle cx="297.6" cy="92.9" r="0.8"/><circle cx="347.9" cy="80.6" r="2.4"/><circle cx="249.7" cy="60.9" r="2.1"/><circle cx="329.9" cy="130.3" r="2.2"/><circle cx="341.4" cy="37.8" r="0.7"/><circle cx="369.9" cy="135.3" r="0.7"/></g><g stroke="#b91c1c" stroke-width="1.4"><path d="M36 292l30-60"/><path d="M42 292l30-60"/><path d="M48 292l30-60"/><path d="M54 292l30-60"/><path d="M60 292l30-60"/><path d="M66 292l30-60"/><path d="M72 292l30-60"/><path d="M78 292l30-60"/><path d="M84 292l30-60"/><path d="M90 292l30-60"/><path d="M96 292l30-60"/><path d="M102 292l30-60"/><path d="M108 292l30-60"/><path d="M114 292l30-60"/></g><rect x="18" y="18" width="70" height="26" fill="#dc2626"/><path d="M300 58q6-6 12 0q6-6 12 0" fill="none" stroke="#111" stroke-width="1.2"/><text x="340" y="294" font-size="6" font-family="Georgia,serif" font-style="italic" fill="#3f3f46">M. Ferrer 1923</text></symbol></svg><div class="wall"><button type="button" class="fire" aria-haspopup="dialog" aria-label="Enlarge painting"><svg viewBox="0 0 400 300" aria-hidden="true"><use href="#uvq13-art-p"/></svg></button><p class="pl"><b>Composition in blue</b><small>Oil on canvas · 1923</small></p></div><div class="vw" role="dialog" aria-modal="true" aria-label="Composition in blue"><div class="vp" tabindex="0" role="group" aria-label="Zoomable painting"><div class="cv"><svg viewBox="0 0 400 300" width="400" height="300" aria-hidden="true"><use href="#uvq13-art-p"/></svg></div></div><div class="cap"><b>Composition in blue</b><small>Oil on canvas · 1923</small></div><p class="hn">Drag to move · scroll or pinch to zoom</p><div class="tb"><button type="button" class="zo" aria-label="Zoom out">−</button><output>100 %</output><button type="button" class="zi" aria-label="Zoom in">+</button><button type="button" class="ft">Fit</button></div><div class="mm" aria-hidden="true"><svg viewBox="0 0 400 300"><use href="#uvq13-art-p"/></svg><i class="mr"></i></div><button type="button" class="x" aria-label="Close"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 7l10 10M17 7L7 17"/></svg></button></div></div>
```

### CSS

```css
.uvq13-art {
  --c1: #c9a227;
  --c2: #161412;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq13-art {
  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: 22em;
  height: 18em;
  border-radius: 1.2em;
  overflow: hidden;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 9%,transparent);
  background: radial-gradient(70% 60% at 50% 30%,color-mix(in srgb,var(--fg) 2%,var(--bg)),color-mix(in srgb,var(--fg) 9%,var(--bg)));
}

.uvq13-art .def {
  position: absolute;
  width: 0;
  height: 0;
}

.uvq13-art .wall {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1em;
}

.uvq13-art .fire {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: block;
  width: 11em;
  padding: .55em;
  background: linear-gradient(135deg,color-mix(in srgb,var(--c1) 65%,#fff),var(--c1) 40%,color-mix(in srgb,var(--c1) 60%,#000));
  box-shadow: inset 0 0 0 .15em color-mix(in srgb,var(--c1) 50%,#000),0 1.3em 1.8em -1em rgba(0,0,0,.55);
  cursor: zoom-in;
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq13-art .fire svg {
  display: block;
  width: 100%;
  height: auto;
  box-sizing: border-box;
  border: .35em solid #f8f5ec;
}

.uvq13-art .fire:hover {
  transform: translateY(-.15em);
}

.uvq13-art .fire:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq13-art .pl {
  display: grid;
  margin: 0;
  padding: .35em .8em;
  text-align: center;
  background: color-mix(in srgb,var(--fg) 4%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 9%,transparent);
}

.uvq13-art .pl b {
  font-size: .78em;
}

.uvq13-art .pl small {
  font-size: .62em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq13-art .vw {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  color: #f5f5f4;
  background: var(--c2);
  opacity: 0;
  pointer-events: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-art.open .vw {
  opacity: 1;
  pointer-events: auto;
}

.uvq13-art .vp {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  outline: 0;
  transform: scale(.85);
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq13-art.open .vp {
  transform: none;
}

.uvq13-art .vp:focus-visible {
  box-shadow: inset 0 0 0 2px var(--c1);
}

.uvq13-art .vp.dr {
  cursor: grabbing;
}

.uvq13-art .cv {
  position: absolute;
  left: 0;
  top: 0;
  width: 400px;
  height: 300px;
  transform-origin: 0 0;
  box-shadow: 0 1em 3em rgba(0,0,0,.6);
}

.uvq13-art .cv svg {
  display: block;
}

.uvq13-art .cap {
  position: absolute;
  left: .9em;
  top: .8em;
  display: grid;
  font-size: .72em;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}

.uvq13-art .cap small {
  opacity: .7;
}

.uvq13-art .hn {
  position: absolute;
  left: 50%;
  top: 45%;
  margin: 0;
  padding: .5em .9em;
  border-radius: 2em;
  font-size: .68em;
  white-space: nowrap;
  background: rgba(0,0,0,.6);
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-art .vw.qt .hn {
  opacity: 0;
}

.uvq13-art .tb {
  position: absolute;
  left: .8em;
  bottom: .8em;
  display: flex;
  align-items: center;
  gap: .15em;
  padding: .25em;
  border-radius: 2em;
  background: rgba(20,20,20,.78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.uvq13-art .tb button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-width: 2em;
  height: 2em;
  padding: 0 .55em;
  border-radius: 2em;
  font-weight: 700;
  color: #fff;
}

.uvq13-art .tb button:hover {
  background: rgba(255,255,255,.12);
}

.uvq13-art .tb .ft {
  font-size: .72em;
  height: 2.6em;
}

.uvq13-art .tb output {
  min-width: 3.4em;
  text-align: center;
  font: 600 .72em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
}

.uvq13-art .mm {
  position: absolute;
  right: .8em;
  bottom: .8em;
  width: 5em;
  height: 3.75em;
  border-radius: .3em;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,.3),0 .4em 1em rgba(0,0,0,.5);
}

.uvq13-art .mm svg {
  display: block;
  width: 100%;
  height: 100%;
}

.uvq13-art .mr {
  position: absolute;
  box-sizing: border-box;
  border: 1.5px solid var(--c1);
  box-shadow: 0 0 0 99em rgba(0,0,0,.35);
}

.uvq13-art .x {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  right: .7em;
  top: .7em;
  display: grid;
  place-items: center;
  width: 2.1em;
  height: 2.1em;
  border-radius: 50%;
  color: #fff;
  background: rgba(0,0,0,.5);
}

.uvq13-art .x svg {
  width: 1em;
  height: 1em;
}

.uvq13-art .vw button:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

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

### JavaScript

```js
document.querySelectorAll(".uvq13-art").forEach(el => {
  const fire=el.querySelector(".fire"),scr=el.querySelector(".scr"),pnl=el.querySelector(".vw");let tms=[];const later=(f,ms)=>tms.push(setTimeout(f,ms));
const foc=(t,ms)=>later(()=>{const n=typeof t==="string"?el.querySelector(t):t;n&&n.focus({preventScroll:true})},ms||0);
const isOpen=()=>el.classList.contains("open");
const open=u=>{if(isOpen())return;el.classList.add("open");pnl.inert=false;fire&&fire.setAttribute("aria-expanded","true");later(fit,0);vw.classList.remove('qt');later(()=>vw.classList.add('qt'),2800);u&&foc(vp,320)};
const close=()=>{if(!isOpen())return;el.classList.remove("open");pnl.inert=true;fire&&fire.setAttribute("aria-expanded","false");cancelAnimationFrame(raf);fire&&fire.focus({preventScroll:true})};
fire&&fire.addEventListener("click",()=>isOpen()?close():open(true));scr&&scr.addEventListener("click",()=>close());
el.addEventListener("keydown",e=>{if(!isOpen())return;if(e.key==="Escape"){e.preventDefault();e.stopPropagation();close()}else if(e.key==="Tab"){const f=[...pnl.querySelectorAll('button:not([disabled]),input:not([disabled]),textarea,a[href],[tabindex="0"]')].filter(x=>x.getClientRects().length);if(!f.length){e.preventDefault();return}const a=f[0],z=f[f.length-1],ac=document.activeElement;if(e.shiftKey&&(ac===a||!pnl.contains(ac))){e.preventDefault();z.focus()}else if(!e.shiftKey&&(ac===z||!pnl.contains(ac))){e.preventDefault();a.focus()}}});
pnl.inert=true;later(()=>open(false),500);const vw=el.querySelector(".vw"),vp=el.querySelector(".vp"),cv=el.querySelector(".cv"),out=el.querySelector(".tb output"),mr=el.querySelector(".mr");let X=0,Y=0,Z=1,Z0=1,raf=0,drag=null;const ps=new Map();
const sc=()=>el.getBoundingClientRect().width/el.offsetWidth||1;
const clamp=()=>{const W=vp.clientWidth,H=vp.clientHeight,w=400*Z,h=300*Z;X=w<=W?(W-w)/2:Math.min(0,Math.max(W-w,X));Y=h<=H?(H-h)/2:Math.min(0,Math.max(H-h,Y))};
const draw=()=>{clamp();cv.style.transform="translate("+X+"px,"+Y+"px) scale("+Z+")";out.textContent=Math.round(Z/Z0*100)+" %";const W=vp.clientWidth,H=vp.clientHeight;mr.style.left=Math.max(0,-X/Z/4)+"%";mr.style.top=Math.max(0,-Y/Z/3)+"%";mr.style.width=Math.min(100,W/Z/4)+"%";mr.style.height=Math.min(100,H/Z/3)+"%"};
const fit=()=>{const W=vp.clientWidth,H=vp.clientHeight;Z0=Math.min(W/400,H/300)*.84;Z=Z0;draw()};
const zoomAt=(nz,px,py)=>{nz=Math.max(Z0,Math.min(Z0*8,nz));X=px-(px-X)*nz/Z;Y=py-(py-Y)*nz/Z;Z=nz;draw()};
const loc=e=>{const r=vp.getBoundingClientRect(),s=sc();return[(e.clientX-r.left)/s,(e.clientY-r.top)/s]};
const mid=()=>[vp.clientWidth/2,vp.clientHeight/2];
vp.addEventListener("wheel",e=>{if(!isOpen())return;e.preventDefault();vw.classList.add("qt");const p=loc(e);zoomAt(Z*Math.exp(-e.deltaY*.0015),p[0],p[1])},{passive:false});
vp.addEventListener("pointerdown",e=>{cancelAnimationFrame(raf);vp.setPointerCapture(e.pointerId);ps.set(e.pointerId,loc(e));vw.classList.add("qt");if(ps.size===1){drag={vx:0,vy:0,t:performance.now()};vp.classList.add("dr")}else drag=null});
vp.addEventListener("pointermove",e=>{if(!ps.has(e.pointerId))return;const p=loc(e),q=ps.get(e.pointerId);if(ps.size===2){const o=[...ps.entries()].find(x=>x[0]!==e.pointerId)[1],d0=Math.hypot(q[0]-o[0],q[1]-o[1]),d1=Math.hypot(p[0]-o[0],p[1]-o[1]);if(d0>0)zoomAt(Z*d1/d0,(p[0]+o[0])/2,(p[1]+o[1])/2)}else if(drag){const t=performance.now(),dt=Math.max(1,t-drag.t);drag.vx=(p[0]-q[0])/dt;drag.vy=(p[1]-q[1])/dt;drag.t=t;X+=p[0]-q[0];Y+=p[1]-q[1];draw()}ps.set(e.pointerId,p)});
const up=e=>{ps.delete(e.pointerId);vp.classList.remove("dr");if(drag&&!ps.size){let vx=drag.vx*16,vy=drag.vy*16;drag=null;const st=()=>{vx*=.92;vy*=.92;X+=vx;Y+=vy;draw();if(Math.abs(vx)+Math.abs(vy)>.3)raf=requestAnimationFrame(st)};raf=requestAnimationFrame(st)}};
vp.addEventListener("pointerup",up);vp.addEventListener("pointercancel",up);
vp.addEventListener("dblclick",e=>{const p=loc(e);Z>=Z0*7.9?fit():zoomAt(Z*2,p[0],p[1])});
el.querySelector(".zi").addEventListener("click",()=>{const m=mid();zoomAt(Z*1.5,m[0],m[1])});el.querySelector(".zo").addEventListener("click",()=>{const m=mid();zoomAt(Z/1.5,m[0],m[1])});el.querySelector(".ft").addEventListener("click",fit);el.querySelector(".vw .x").addEventListener("click",close);
vp.addEventListener("keydown",e=>{const m={ArrowLeft:[40,0],ArrowRight:[-40,0],ArrowUp:[0,40],ArrowDown:[0,-40]}[e.key],c=mid();if(m){e.preventDefault();X+=m[0];Y+=m[1];draw()}else if(e.key==="+"||e.key==="="){e.preventDefault();zoomAt(Z*1.4,c[0],c[1])}else if(e.key==="-"){e.preventDefault();zoomAt(Z/1.4,c[0],c[1])}else if(e.key==="0"){e.preventDefault();fit()}});
const ro=new ResizeObserver(()=>{if(isOpen())fit()});ro.observe(el);return()=>{tms.forEach(clearTimeout);cancelAnimationFrame(raf);ro.disconnect()}
});
```

### 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 = `
.uvq13-art {
  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: 22em;
  height: 18em;
  border-radius: 1.2em;
  overflow: hidden;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 9%,transparent);
  background: radial-gradient(70% 60% at 50% 30%,color-mix(in srgb,var(--fg) 2%,var(--bg)),color-mix(in srgb,var(--fg) 9%,var(--bg)));
}

.uvq13-art .def {
  position: absolute;
  width: 0;
  height: 0;
}

.uvq13-art .wall {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1em;
}

.uvq13-art .fire {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: block;
  width: 11em;
  padding: .55em;
  background: linear-gradient(135deg,color-mix(in srgb,var(--c1) 65%,#fff),var(--c1) 40%,color-mix(in srgb,var(--c1) 60%,#000));
  box-shadow: inset 0 0 0 .15em color-mix(in srgb,var(--c1) 50%,#000),0 1.3em 1.8em -1em rgba(0,0,0,.55);
  cursor: zoom-in;
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq13-art .fire svg {
  display: block;
  width: 100%;
  height: auto;
  box-sizing: border-box;
  border: .35em solid #f8f5ec;
}

.uvq13-art .fire:hover {
  transform: translateY(-.15em);
}

.uvq13-art .fire:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq13-art .pl {
  display: grid;
  margin: 0;
  padding: .35em .8em;
  text-align: center;
  background: color-mix(in srgb,var(--fg) 4%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 9%,transparent);
}

.uvq13-art .pl b {
  font-size: .78em;
}

.uvq13-art .pl small {
  font-size: .62em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq13-art .vw {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  color: #f5f5f4;
  background: var(--c2);
  opacity: 0;
  pointer-events: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-art.open .vw {
  opacity: 1;
  pointer-events: auto;
}

.uvq13-art .vp {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  outline: 0;
  transform: scale(.85);
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq13-art.open .vp {
  transform: none;
}

.uvq13-art .vp:focus-visible {
  box-shadow: inset 0 0 0 2px var(--c1);
}

.uvq13-art .vp.dr {
  cursor: grabbing;
}

.uvq13-art .cv {
  position: absolute;
  left: 0;
  top: 0;
  width: 400px;
  height: 300px;
  transform-origin: 0 0;
  box-shadow: 0 1em 3em rgba(0,0,0,.6);
}

.uvq13-art .cv svg {
  display: block;
}

.uvq13-art .cap {
  position: absolute;
  left: .9em;
  top: .8em;
  display: grid;
  font-size: .72em;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}

.uvq13-art .cap small {
  opacity: .7;
}

.uvq13-art .hn {
  position: absolute;
  left: 50%;
  top: 45%;
  margin: 0;
  padding: .5em .9em;
  border-radius: 2em;
  font-size: .68em;
  white-space: nowrap;
  background: rgba(0,0,0,.6);
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-art .vw.qt .hn {
  opacity: 0;
}

.uvq13-art .tb {
  position: absolute;
  left: .8em;
  bottom: .8em;
  display: flex;
  align-items: center;
  gap: .15em;
  padding: .25em;
  border-radius: 2em;
  background: rgba(20,20,20,.78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.uvq13-art .tb button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-width: 2em;
  height: 2em;
  padding: 0 .55em;
  border-radius: 2em;
  font-weight: 700;
  color: #fff;
}

.uvq13-art .tb button:hover {
  background: rgba(255,255,255,.12);
}

.uvq13-art .tb .ft {
  font-size: .72em;
  height: 2.6em;
}

.uvq13-art .tb output {
  min-width: 3.4em;
  text-align: center;
  font: 600 .72em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
}

.uvq13-art .mm {
  position: absolute;
  right: .8em;
  bottom: .8em;
  width: 5em;
  height: 3.75em;
  border-radius: .3em;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,.3),0 .4em 1em rgba(0,0,0,.5);
}

.uvq13-art .mm svg {
  display: block;
  width: 100%;
  height: 100%;
}

.uvq13-art .mr {
  position: absolute;
  box-sizing: border-box;
  border: 1.5px solid var(--c1);
  box-shadow: 0 0 0 99em rgba(0,0,0,.35);
}

.uvq13-art .x {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  right: .7em;
  top: .7em;
  display: grid;
  place-items: center;
  width: 2.1em;
  height: 2.1em;
  border-radius: 50%;
  color: #fff;
  background: rgba(0,0,0,.5);
}

.uvq13-art .x svg {
  width: 1em;
  height: 1em;
}

.uvq13-art .vw button:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

@media (prefers-reduced-motion:reduce) {
  .uvq13-art,.uvq13-art *,.uvq13-art *::before,.uvq13-art *::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 fire=el.querySelector(".fire"),scr=el.querySelector(".scr"),pnl=el.querySelector(".vw");let tms=[];const later=(f,ms)=>tms.push(setTimeout(f,ms));
const foc=(t,ms)=>later(()=>{const n=typeof t==="string"?el.querySelector(t):t;n&&n.focus({preventScroll:true})},ms||0);
const isOpen=()=>el.classList.contains("open");
const open=u=>{if(isOpen())return;el.classList.add("open");pnl.inert=false;fire&&fire.setAttribute("aria-expanded","true");later(fit,0);vw.classList.remove('qt');later(()=>vw.classList.add('qt'),2800);u&&foc(vp,320)};
const close=()=>{if(!isOpen())return;el.classList.remove("open");pnl.inert=true;fire&&fire.setAttribute("aria-expanded","false");cancelAnimationFrame(raf);fire&&fire.focus({preventScroll:true})};
fire&&fire.addEventListener("click",()=>isOpen()?close():open(true));scr&&scr.addEventListener("click",()=>close());
el.addEventListener("keydown",e=>{if(!isOpen())return;if(e.key==="Escape"){e.preventDefault();e.stopPropagation();close()}else if(e.key==="Tab"){const f=[...pnl.querySelectorAll('button:not([disabled]),input:not([disabled]),textarea,a[href],[tabindex="0"]')].filter(x=>x.getClientRects().length);if(!f.length){e.preventDefault();return}const a=f[0],z=f[f.length-1],ac=document.activeElement;if(e.shiftKey&&(ac===a||!pnl.contains(ac))){e.preventDefault();z.focus()}else if(!e.shiftKey&&(ac===z||!pnl.contains(ac))){e.preventDefault();a.focus()}}});
pnl.inert=true;later(()=>open(false),500);const vw=el.querySelector(".vw"),vp=el.querySelector(".vp"),cv=el.querySelector(".cv"),out=el.querySelector(".tb output"),mr=el.querySelector(".mr");let X=0,Y=0,Z=1,Z0=1,raf=0,drag=null;const ps=new Map();
const sc=()=>el.getBoundingClientRect().width/el.offsetWidth||1;
const clamp=()=>{const W=vp.clientWidth,H=vp.clientHeight,w=400*Z,h=300*Z;X=w<=W?(W-w)/2:Math.min(0,Math.max(W-w,X));Y=h<=H?(H-h)/2:Math.min(0,Math.max(H-h,Y))};
const draw=()=>{clamp();cv.style.transform="translate("+X+"px,"+Y+"px) scale("+Z+")";out.textContent=Math.round(Z/Z0*100)+" %";const W=vp.clientWidth,H=vp.clientHeight;mr.style.left=Math.max(0,-X/Z/4)+"%";mr.style.top=Math.max(0,-Y/Z/3)+"%";mr.style.width=Math.min(100,W/Z/4)+"%";mr.style.height=Math.min(100,H/Z/3)+"%"};
const fit=()=>{const W=vp.clientWidth,H=vp.clientHeight;Z0=Math.min(W/400,H/300)*.84;Z=Z0;draw()};
const zoomAt=(nz,px,py)=>{nz=Math.max(Z0,Math.min(Z0*8,nz));X=px-(px-X)*nz/Z;Y=py-(py-Y)*nz/Z;Z=nz;draw()};
const loc=e=>{const r=vp.getBoundingClientRect(),s=sc();return[(e.clientX-r.left)/s,(e.clientY-r.top)/s]};
const mid=()=>[vp.clientWidth/2,vp.clientHeight/2];
vp.addEventListener("wheel",e=>{if(!isOpen())return;e.preventDefault();vw.classList.add("qt");const p=loc(e);zoomAt(Z*Math.exp(-e.deltaY*.0015),p[0],p[1])},{passive:false});
vp.addEventListener("pointerdown",e=>{cancelAnimationFrame(raf);vp.setPointerCapture(e.pointerId);ps.set(e.pointerId,loc(e));vw.classList.add("qt");if(ps.size===1){drag={vx:0,vy:0,t:performance.now()};vp.classList.add("dr")}else drag=null});
vp.addEventListener("pointermove",e=>{if(!ps.has(e.pointerId))return;const p=loc(e),q=ps.get(e.pointerId);if(ps.size===2){const o=[...ps.entries()].find(x=>x[0]!==e.pointerId)[1],d0=Math.hypot(q[0]-o[0],q[1]-o[1]),d1=Math.hypot(p[0]-o[0],p[1]-o[1]);if(d0>0)zoomAt(Z*d1/d0,(p[0]+o[0])/2,(p[1]+o[1])/2)}else if(drag){const t=performance.now(),dt=Math.max(1,t-drag.t);drag.vx=(p[0]-q[0])/dt;drag.vy=(p[1]-q[1])/dt;drag.t=t;X+=p[0]-q[0];Y+=p[1]-q[1];draw()}ps.set(e.pointerId,p)});
const up=e=>{ps.delete(e.pointerId);vp.classList.remove("dr");if(drag&&!ps.size){let vx=drag.vx*16,vy=drag.vy*16;drag=null;const st=()=>{vx*=.92;vy*=.92;X+=vx;Y+=vy;draw();if(Math.abs(vx)+Math.abs(vy)>.3)raf=requestAnimationFrame(st)};raf=requestAnimationFrame(st)}};
vp.addEventListener("pointerup",up);vp.addEventListener("pointercancel",up);
vp.addEventListener("dblclick",e=>{const p=loc(e);Z>=Z0*7.9?fit():zoomAt(Z*2,p[0],p[1])});
el.querySelector(".zi").addEventListener("click",()=>{const m=mid();zoomAt(Z*1.5,m[0],m[1])});el.querySelector(".zo").addEventListener("click",()=>{const m=mid();zoomAt(Z/1.5,m[0],m[1])});el.querySelector(".ft").addEventListener("click",fit);el.querySelector(".vw .x").addEventListener("click",close);
vp.addEventListener("keydown",e=>{const m={ArrowLeft:[40,0],ArrowRight:[-40,0],ArrowUp:[0,40],ArrowDown:[0,-40]}[e.key],c=mid();if(m){e.preventDefault();X+=m[0];Y+=m[1];draw()}else if(e.key==="+"||e.key==="="){e.preventDefault();zoomAt(Z*1.4,c[0],c[1])}else if(e.key==="-"){e.preventDefault();zoomAt(Z/1.4,c[0],c[1])}else if(e.key==="0"){e.preventDefault();fit()}});
const ro=new ResizeObserver(()=>{if(isOpen())fit()});ro.observe(el);return()=>{tms.forEach(clearTimeout);cancelAnimationFrame(raf);ro.disconnect()}
}

export default function OvArtZoom() {
  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": "#c9a227",
          "--c2": "#161412",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq13-art"><svg className="def" aria-hidden="true" width="0" height="0"><symbol id="uvq13-art-p" viewBox="0 0 400 300"><rect width="400" height="300" fill="#efe6d2" /><rect x="250" y="160" width="134" height="124" fill="#1f2937" /><g fill="#f8f5ec"><rect x="271" y="176" width="9" height="9" /><rect x="289" y="176" width="9" height="9" /><rect x="307" y="176" width="9" height="9" /><rect x="262" y="185" width="9" height="9" /><rect x="280" y="185" width="9" height="9" /><rect x="298" y="185" width="9" height="9" /><rect x="271" y="194" width="9" height="9" /><rect x="289" y="194" width="9" height="9" /><rect x="307" y="194" width="9" height="9" /><rect x="262" y="203" width="9" height="9" /><rect x="280" y="203" width="9" height="9" /><rect x="298" y="203" width="9" height="9" /></g><circle cx="130" cy="125" r="88" fill="#1e3a8a" /><circle cx="130" cy="125" r="56" fill="none" stroke="#f59e0b" strokeWidth="10" /><circle cx="130" cy="125" r="20" fill="#dc2626" /><path d="M20 270L380 40" stroke="#111" strokeWidth="3" /><path d="M60 292L330 10" stroke="#111" strokeWidth="1.2" /><path d="M226 286l60-104 60 104z" fill="#facc15" fillOpacity=".92" /><g fill="#111"><circle cx="234.4" cy="97.0" r="1.9" /><circle cx="334.6" cy="129.1" r="2.4" /><circle cx="285.9" cy="34.5" r="2.7" /><circle cx="325.4" cy="67.5" r="2.5" /><circle cx="287.0" cy="36.5" r="1.4" /><circle cx="337.3" cy="74.2" r="1.9" /><circle cx="259.5" cy="81.8" r="1.1" /><circle cx="245.2" cy="122.1" r="2.8" /><circle cx="259.0" cy="37.3" r="1.5" /><circle cx="306.1" cy="53.4" r="1.3" /><circle cx="265.0" cy="135.3" r="2.8" /><circle cx="263.6" cy="32.2" r="1.3" /><circle cx="285.8" cy="54.8" r="2.4" /><circle cx="313.2" cy="110.3" r="2.0" /><circle cx="356.9" cy="33.8" r="2.0" /><circle cx="282.1" cy="63.6" r="1.3" /><circle cx="349.5" cy="94.7" r="2.1" /><circle cx="286.3" cy="134.6" r="1.1" /><circle cx="266.5" cy="84.1" r="1.0" /><circle cx="314.4" cy="134.1" r="2.3" /><circle cx="341.8" cy="101.5" r="1.8" /><circle cx="334.0" cy="129.6" r="1.2" /><circle cx="303.2" cy="128.7" r="0.9" /><circle cx="305.4" cy="130.7" r="2.0" /><circle cx="328.7" cy="61.9" r="2.4" /><circle cx="296.8" cy="68.3" r="1.7" /><circle cx="320.4" cy="50.5" r="2.8" /><circle cx="249.3" cy="46.0" r="1.7" /><circle cx="372.5" cy="37.3" r="1.3" /><circle cx="293.5" cy="127.1" r="0.9" /><circle cx="334.9" cy="128.6" r="1.7" /><circle cx="292.9" cy="48.6" r="2.4" /><circle cx="275.2" cy="109.6" r="2.6" /><circle cx="232.7" cy="40.7" r="1.6" /><circle cx="258.9" cy="79.7" r="1.9" /><circle cx="343.6" cy="80.4" r="2.8" /><circle cx="281.5" cy="74.1" r="1.7" /><circle cx="350.4" cy="43.6" r="1.8" /><circle cx="317.4" cy="117.6" r="2.5" /><circle cx="269.1" cy="106.9" r="1.4" /><circle cx="297.6" cy="92.9" r="0.8" /><circle cx="347.9" cy="80.6" r="2.4" /><circle cx="249.7" cy="60.9" r="2.1" /><circle cx="329.9" cy="130.3" r="2.2" /><circle cx="341.4" cy="37.8" r="0.7" /><circle cx="369.9" cy="135.3" r="0.7" /></g><g stroke="#b91c1c" strokeWidth="1.4"><path d="M36 292l30-60" /><path d="M42 292l30-60" /><path d="M48 292l30-60" /><path d="M54 292l30-60" /><path d="M60 292l30-60" /><path d="M66 292l30-60" /><path d="M72 292l30-60" /><path d="M78 292l30-60" /><path d="M84 292l30-60" /><path d="M90 292l30-60" /><path d="M96 292l30-60" /><path d="M102 292l30-60" /><path d="M108 292l30-60" /><path d="M114 292l30-60" /></g><rect x="18" y="18" width="70" height="26" fill="#dc2626" /><path d="M300 58q6-6 12 0q6-6 12 0" fill="none" stroke="#111" strokeWidth="1.2" /><text x="340" y="294" fontSize="6" fontFamily="Georgia,serif" fontStyle="italic" fill="#3f3f46">M. Ferrer 1923</text></symbol></svg><div className="wall"><button type="button" className="fire" aria-haspopup="dialog" aria-label="Enlarge painting"><svg viewBox="0 0 400 300" aria-hidden="true"><use href="#uvq13-art-p" /></svg></button><p className="pl"><b>Composition in blue</b><small>Oil on canvas · 1923</small></p></div><div className="vw" role="dialog" aria-modal="true" aria-label="Composition in blue"><div className="vp" tabIndex={0} role="group" aria-label="Zoomable painting"><div className="cv"><svg viewBox="0 0 400 300" width="400" height="300" aria-hidden="true"><use href="#uvq13-art-p" /></svg></div></div><div className="cap"><b>Composition in blue</b><small>Oil on canvas · 1923</small></div><p className="hn">Drag to move · scroll or pinch to zoom</p><div className="tb"><button type="button" className="zo" aria-label="Zoom out">−</button><output>100 %</output><button type="button" className="zi" aria-label="Zoom in">+</button><button type="button" className="ft">Fit</button></div><div className="mm" aria-hidden="true"><svg viewBox="0 0 400 300"><use href="#uvq13-art-p" /></svg><i className="mr"></i></div><button type="button" className="x" aria-label="Close"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M7 7l10 10M17 7L7 17" /></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 “Painting zoom viewer with minimap” block (Overlays) from AIMRAN Library to my project.

## What it is
A framed painting opens full screen: wheel or pinch to zoom, drag with inertia and a minimap showing the visible area.

## Chosen settings
- Main color: #c9a227
- Secondary color: #161412
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Composición en azul"

## 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 = `
.uvq13-art {
  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: 22em;
  height: 18em;
  border-radius: 1.2em;
  overflow: hidden;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 9%,transparent);
  background: radial-gradient(70% 60% at 50% 30%,color-mix(in srgb,var(--fg) 2%,var(--bg)),color-mix(in srgb,var(--fg) 9%,var(--bg)));
}

.uvq13-art .def {
  position: absolute;
  width: 0;
  height: 0;
}

.uvq13-art .wall {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1em;
}

.uvq13-art .fire {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: block;
  width: 11em;
  padding: .55em;
  background: linear-gradient(135deg,color-mix(in srgb,var(--c1) 65%,#fff),var(--c1) 40%,color-mix(in srgb,var(--c1) 60%,#000));
  box-shadow: inset 0 0 0 .15em color-mix(in srgb,var(--c1) 50%,#000),0 1.3em 1.8em -1em rgba(0,0,0,.55);
  cursor: zoom-in;
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq13-art .fire svg {
  display: block;
  width: 100%;
  height: auto;
  box-sizing: border-box;
  border: .35em solid #f8f5ec;
}

.uvq13-art .fire:hover {
  transform: translateY(-.15em);
}

.uvq13-art .fire:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq13-art .pl {
  display: grid;
  margin: 0;
  padding: .35em .8em;
  text-align: center;
  background: color-mix(in srgb,var(--fg) 4%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 9%,transparent);
}

.uvq13-art .pl b {
  font-size: .78em;
}

.uvq13-art .pl small {
  font-size: .62em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq13-art .vw {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  color: #f5f5f4;
  background: var(--c2);
  opacity: 0;
  pointer-events: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-art.open .vw {
  opacity: 1;
  pointer-events: auto;
}

.uvq13-art .vp {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  outline: 0;
  transform: scale(.85);
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq13-art.open .vp {
  transform: none;
}

.uvq13-art .vp:focus-visible {
  box-shadow: inset 0 0 0 2px var(--c1);
}

.uvq13-art .vp.dr {
  cursor: grabbing;
}

.uvq13-art .cv {
  position: absolute;
  left: 0;
  top: 0;
  width: 400px;
  height: 300px;
  transform-origin: 0 0;
  box-shadow: 0 1em 3em rgba(0,0,0,.6);
}

.uvq13-art .cv svg {
  display: block;
}

.uvq13-art .cap {
  position: absolute;
  left: .9em;
  top: .8em;
  display: grid;
  font-size: .72em;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}

.uvq13-art .cap small {
  opacity: .7;
}

.uvq13-art .hn {
  position: absolute;
  left: 50%;
  top: 45%;
  margin: 0;
  padding: .5em .9em;
  border-radius: 2em;
  font-size: .68em;
  white-space: nowrap;
  background: rgba(0,0,0,.6);
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-art .vw.qt .hn {
  opacity: 0;
}

.uvq13-art .tb {
  position: absolute;
  left: .8em;
  bottom: .8em;
  display: flex;
  align-items: center;
  gap: .15em;
  padding: .25em;
  border-radius: 2em;
  background: rgba(20,20,20,.78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.uvq13-art .tb button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-width: 2em;
  height: 2em;
  padding: 0 .55em;
  border-radius: 2em;
  font-weight: 700;
  color: #fff;
}

.uvq13-art .tb button:hover {
  background: rgba(255,255,255,.12);
}

.uvq13-art .tb .ft {
  font-size: .72em;
  height: 2.6em;
}

.uvq13-art .tb output {
  min-width: 3.4em;
  text-align: center;
  font: 600 .72em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
}

.uvq13-art .mm {
  position: absolute;
  right: .8em;
  bottom: .8em;
  width: 5em;
  height: 3.75em;
  border-radius: .3em;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,.3),0 .4em 1em rgba(0,0,0,.5);
}

.uvq13-art .mm svg {
  display: block;
  width: 100%;
  height: 100%;
}

.uvq13-art .mr {
  position: absolute;
  box-sizing: border-box;
  border: 1.5px solid var(--c1);
  box-shadow: 0 0 0 99em rgba(0,0,0,.35);
}

.uvq13-art .x {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  right: .7em;
  top: .7em;
  display: grid;
  place-items: center;
  width: 2.1em;
  height: 2.1em;
  border-radius: 50%;
  color: #fff;
  background: rgba(0,0,0,.5);
}

.uvq13-art .x svg {
  width: 1em;
  height: 1em;
}

.uvq13-art .vw button:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

@media (prefers-reduced-motion:reduce) {
  .uvq13-art,.uvq13-art *,.uvq13-art *::before,.uvq13-art *::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 fire=el.querySelector(".fire"),scr=el.querySelector(".scr"),pnl=el.querySelector(".vw");let tms=[];const later=(f,ms)=>tms.push(setTimeout(f,ms));
const foc=(t,ms)=>later(()=>{const n=typeof t==="string"?el.querySelector(t):t;n&&n.focus({preventScroll:true})},ms||0);
const isOpen=()=>el.classList.contains("open");
const open=u=>{if(isOpen())return;el.classList.add("open");pnl.inert=false;fire&&fire.setAttribute("aria-expanded","true");later(fit,0);vw.classList.remove('qt');later(()=>vw.classList.add('qt'),2800);u&&foc(vp,320)};
const close=()=>{if(!isOpen())return;el.classList.remove("open");pnl.inert=true;fire&&fire.setAttribute("aria-expanded","false");cancelAnimationFrame(raf);fire&&fire.focus({preventScroll:true})};
fire&&fire.addEventListener("click",()=>isOpen()?close():open(true));scr&&scr.addEventListener("click",()=>close());
el.addEventListener("keydown",e=>{if(!isOpen())return;if(e.key==="Escape"){e.preventDefault();e.stopPropagation();close()}else if(e.key==="Tab"){const f=[...pnl.querySelectorAll('button:not([disabled]),input:not([disabled]),textarea,a[href],[tabindex="0"]')].filter(x=>x.getClientRects().length);if(!f.length){e.preventDefault();return}const a=f[0],z=f[f.length-1],ac=document.activeElement;if(e.shiftKey&&(ac===a||!pnl.contains(ac))){e.preventDefault();z.focus()}else if(!e.shiftKey&&(ac===z||!pnl.contains(ac))){e.preventDefault();a.focus()}}});
pnl.inert=true;later(()=>open(false),500);const vw=el.querySelector(".vw"),vp=el.querySelector(".vp"),cv=el.querySelector(".cv"),out=el.querySelector(".tb output"),mr=el.querySelector(".mr");let X=0,Y=0,Z=1,Z0=1,raf=0,drag=null;const ps=new Map();
const sc=()=>el.getBoundingClientRect().width/el.offsetWidth||1;
const clamp=()=>{const W=vp.clientWidth,H=vp.clientHeight,w=400*Z,h=300*Z;X=w<=W?(W-w)/2:Math.min(0,Math.max(W-w,X));Y=h<=H?(H-h)/2:Math.min(0,Math.max(H-h,Y))};
const draw=()=>{clamp();cv.style.transform="translate("+X+"px,"+Y+"px) scale("+Z+")";out.textContent=Math.round(Z/Z0*100)+" %";const W=vp.clientWidth,H=vp.clientHeight;mr.style.left=Math.max(0,-X/Z/4)+"%";mr.style.top=Math.max(0,-Y/Z/3)+"%";mr.style.width=Math.min(100,W/Z/4)+"%";mr.style.height=Math.min(100,H/Z/3)+"%"};
const fit=()=>{const W=vp.clientWidth,H=vp.clientHeight;Z0=Math.min(W/400,H/300)*.84;Z=Z0;draw()};
const zoomAt=(nz,px,py)=>{nz=Math.max(Z0,Math.min(Z0*8,nz));X=px-(px-X)*nz/Z;Y=py-(py-Y)*nz/Z;Z=nz;draw()};
const loc=e=>{const r=vp.getBoundingClientRect(),s=sc();return[(e.clientX-r.left)/s,(e.clientY-r.top)/s]};
const mid=()=>[vp.clientWidth/2,vp.clientHeight/2];
vp.addEventListener("wheel",e=>{if(!isOpen())return;e.preventDefault();vw.classList.add("qt");const p=loc(e);zoomAt(Z*Math.exp(-e.deltaY*.0015),p[0],p[1])},{passive:false});
vp.addEventListener("pointerdown",e=>{cancelAnimationFrame(raf);vp.setPointerCapture(e.pointerId);ps.set(e.pointerId,loc(e));vw.classList.add("qt");if(ps.size===1){drag={vx:0,vy:0,t:performance.now()};vp.classList.add("dr")}else drag=null});
vp.addEventListener("pointermove",e=>{if(!ps.has(e.pointerId))return;const p=loc(e),q=ps.get(e.pointerId);if(ps.size===2){const o=[...ps.entries()].find(x=>x[0]!==e.pointerId)[1],d0=Math.hypot(q[0]-o[0],q[1]-o[1]),d1=Math.hypot(p[0]-o[0],p[1]-o[1]);if(d0>0)zoomAt(Z*d1/d0,(p[0]+o[0])/2,(p[1]+o[1])/2)}else if(drag){const t=performance.now(),dt=Math.max(1,t-drag.t);drag.vx=(p[0]-q[0])/dt;drag.vy=(p[1]-q[1])/dt;drag.t=t;X+=p[0]-q[0];Y+=p[1]-q[1];draw()}ps.set(e.pointerId,p)});
const up=e=>{ps.delete(e.pointerId);vp.classList.remove("dr");if(drag&&!ps.size){let vx=drag.vx*16,vy=drag.vy*16;drag=null;const st=()=>{vx*=.92;vy*=.92;X+=vx;Y+=vy;draw();if(Math.abs(vx)+Math.abs(vy)>.3)raf=requestAnimationFrame(st)};raf=requestAnimationFrame(st)}};
vp.addEventListener("pointerup",up);vp.addEventListener("pointercancel",up);
vp.addEventListener("dblclick",e=>{const p=loc(e);Z>=Z0*7.9?fit():zoomAt(Z*2,p[0],p[1])});
el.querySelector(".zi").addEventListener("click",()=>{const m=mid();zoomAt(Z*1.5,m[0],m[1])});el.querySelector(".zo").addEventListener("click",()=>{const m=mid();zoomAt(Z/1.5,m[0],m[1])});el.querySelector(".ft").addEventListener("click",fit);el.querySelector(".vw .x").addEventListener("click",close);
vp.addEventListener("keydown",e=>{const m={ArrowLeft:[40,0],ArrowRight:[-40,0],ArrowUp:[0,40],ArrowDown:[0,-40]}[e.key],c=mid();if(m){e.preventDefault();X+=m[0];Y+=m[1];draw()}else if(e.key==="+"||e.key==="="){e.preventDefault();zoomAt(Z*1.4,c[0],c[1])}else if(e.key==="-"){e.preventDefault();zoomAt(Z/1.4,c[0],c[1])}else if(e.key==="0"){e.preventDefault();fit()}});
const ro=new ResizeObserver(()=>{if(isOpen())fit()});ro.observe(el);return()=>{tms.forEach(clearTimeout);cancelAnimationFrame(raf);ro.disconnect()}
}

export default function OvArtZoom() {
  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": "#c9a227",
          "--c2": "#161412",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq13-art"><svg className="def" aria-hidden="true" width="0" height="0"><symbol id="uvq13-art-p" viewBox="0 0 400 300"><rect width="400" height="300" fill="#efe6d2" /><rect x="250" y="160" width="134" height="124" fill="#1f2937" /><g fill="#f8f5ec"><rect x="271" y="176" width="9" height="9" /><rect x="289" y="176" width="9" height="9" /><rect x="307" y="176" width="9" height="9" /><rect x="262" y="185" width="9" height="9" /><rect x="280" y="185" width="9" height="9" /><rect x="298" y="185" width="9" height="9" /><rect x="271" y="194" width="9" height="9" /><rect x="289" y="194" width="9" height="9" /><rect x="307" y="194" width="9" height="9" /><rect x="262" y="203" width="9" height="9" /><rect x="280" y="203" width="9" height="9" /><rect x="298" y="203" width="9" height="9" /></g><circle cx="130" cy="125" r="88" fill="#1e3a8a" /><circle cx="130" cy="125" r="56" fill="none" stroke="#f59e0b" strokeWidth="10" /><circle cx="130" cy="125" r="20" fill="#dc2626" /><path d="M20 270L380 40" stroke="#111" strokeWidth="3" /><path d="M60 292L330 10" stroke="#111" strokeWidth="1.2" /><path d="M226 286l60-104 60 104z" fill="#facc15" fillOpacity=".92" /><g fill="#111"><circle cx="234.4" cy="97.0" r="1.9" /><circle cx="334.6" cy="129.1" r="2.4" /><circle cx="285.9" cy="34.5" r="2.7" /><circle cx="325.4" cy="67.5" r="2.5" /><circle cx="287.0" cy="36.5" r="1.4" /><circle cx="337.3" cy="74.2" r="1.9" /><circle cx="259.5" cy="81.8" r="1.1" /><circle cx="245.2" cy="122.1" r="2.8" /><circle cx="259.0" cy="37.3" r="1.5" /><circle cx="306.1" cy="53.4" r="1.3" /><circle cx="265.0" cy="135.3" r="2.8" /><circle cx="263.6" cy="32.2" r="1.3" /><circle cx="285.8" cy="54.8" r="2.4" /><circle cx="313.2" cy="110.3" r="2.0" /><circle cx="356.9" cy="33.8" r="2.0" /><circle cx="282.1" cy="63.6" r="1.3" /><circle cx="349.5" cy="94.7" r="2.1" /><circle cx="286.3" cy="134.6" r="1.1" /><circle cx="266.5" cy="84.1" r="1.0" /><circle cx="314.4" cy="134.1" r="2.3" /><circle cx="341.8" cy="101.5" r="1.8" /><circle cx="334.0" cy="129.6" r="1.2" /><circle cx="303.2" cy="128.7" r="0.9" /><circle cx="305.4" cy="130.7" r="2.0" /><circle cx="328.7" cy="61.9" r="2.4" /><circle cx="296.8" cy="68.3" r="1.7" /><circle cx="320.4" cy="50.5" r="2.8" /><circle cx="249.3" cy="46.0" r="1.7" /><circle cx="372.5" cy="37.3" r="1.3" /><circle cx="293.5" cy="127.1" r="0.9" /><circle cx="334.9" cy="128.6" r="1.7" /><circle cx="292.9" cy="48.6" r="2.4" /><circle cx="275.2" cy="109.6" r="2.6" /><circle cx="232.7" cy="40.7" r="1.6" /><circle cx="258.9" cy="79.7" r="1.9" /><circle cx="343.6" cy="80.4" r="2.8" /><circle cx="281.5" cy="74.1" r="1.7" /><circle cx="350.4" cy="43.6" r="1.8" /><circle cx="317.4" cy="117.6" r="2.5" /><circle cx="269.1" cy="106.9" r="1.4" /><circle cx="297.6" cy="92.9" r="0.8" /><circle cx="347.9" cy="80.6" r="2.4" /><circle cx="249.7" cy="60.9" r="2.1" /><circle cx="329.9" cy="130.3" r="2.2" /><circle cx="341.4" cy="37.8" r="0.7" /><circle cx="369.9" cy="135.3" r="0.7" /></g><g stroke="#b91c1c" strokeWidth="1.4"><path d="M36 292l30-60" /><path d="M42 292l30-60" /><path d="M48 292l30-60" /><path d="M54 292l30-60" /><path d="M60 292l30-60" /><path d="M66 292l30-60" /><path d="M72 292l30-60" /><path d="M78 292l30-60" /><path d="M84 292l30-60" /><path d="M90 292l30-60" /><path d="M96 292l30-60" /><path d="M102 292l30-60" /><path d="M108 292l30-60" /><path d="M114 292l30-60" /></g><rect x="18" y="18" width="70" height="26" fill="#dc2626" /><path d="M300 58q6-6 12 0q6-6 12 0" fill="none" stroke="#111" strokeWidth="1.2" /><text x="340" y="294" fontSize="6" fontFamily="Georgia,serif" fontStyle="italic" fill="#3f3f46">M. Ferrer 1923</text></symbol></svg><div className="wall"><button type="button" className="fire" aria-haspopup="dialog" aria-label="Enlarge painting"><svg viewBox="0 0 400 300" aria-hidden="true"><use href="#uvq13-art-p" /></svg></button><p className="pl"><b>Composition in blue</b><small>Oil on canvas · 1923</small></p></div><div className="vw" role="dialog" aria-modal="true" aria-label="Composition in blue"><div className="vp" tabIndex={0} role="group" aria-label="Zoomable painting"><div className="cv"><svg viewBox="0 0 400 300" width="400" height="300" aria-hidden="true"><use href="#uvq13-art-p" /></svg></div></div><div className="cap"><b>Composition in blue</b><small>Oil on canvas · 1923</small></div><p className="hn">Drag to move · scroll or pinch to zoom</p><div className="tb"><button type="button" className="zo" aria-label="Zoom out">−</button><output>100 %</output><button type="button" className="zi" aria-label="Zoom in">+</button><button type="button" className="ft">Fit</button></div><div className="mm" aria-hidden="true"><svg viewBox="0 0 400 300"><use href="#uvq13-art-p" /></svg><i className="mr"></i></div><button type="button" className="x" aria-label="Close"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M7 7l10 10M17 7L7 17" /></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.
````
