# Trash can that crumples paper

> The document crumples into a paper ball that arcs through the air; the bin lid flips open, swallows it and shuts.

- Category: [Microinteractions](https://library.aimran.es/components/microinteractions)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-mi27-trash-crumple
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

Deleting a draft is easier to trust when you can see where it went. Here the document squashes and twists into a paper ball, which flies in an arc toward the bin; the lid flips open just in time, snaps shut with a bounce and a counter appears on the can. Undo brings the page back and unfolds it.

The main color is the metal of the bin and the secondary one the delete button and the counter. Every motion is done with the Web Animations API, so it adapts to the real distance between the document and the bin. With reduced motion the result appears without the throw.

## Code

### HTML

```html
<div class="uvq15-trs"><div class="ar"><div class="dc"><b>Letter draft</b><i></i><i></i><i></i><i class="s"></i><i></i><i class="s"></i></div><span class="bl" aria-hidden="true"></span><div class="bn" aria-hidden="true"><span class="ld"></span><span class="cn"><span class="ct">0</span></span></div></div><button type="button" class="go"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6M9 6V4h6v2"/></svg><span>Move to trash</span></button><button type="button" class="un" hidden><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 14 4 9l5-5"/><path d="M4 9h11a5 5 0 0 1 0 10h-3"/></svg><span>Undo</span></button><p class="sr" aria-live="polite"></p></div>
```

### CSS

```css
.uvq15-trs {
  --c1: #475569;
  --c2: #ef4444;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq15-trs {
  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;
  border-radius: 1.3em;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent),0 1.4em 2.6em -1.8em rgba(0,0,0,.35);
  display: grid;
  justify-items: center;
  gap: 1.1em;
  width: 17em;
  padding: 1.2em;
}

.uvq15-trs .ar {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  width: 100%;
  height: 8.6em;
}

.uvq15-trs .dc {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: start;
  gap: .45em;
  width: 6.4em;
  height: 8.2em;
  box-sizing: border-box;
  padding: .8em .7em;
  border-radius: .4em;
  background: #fff;
  color: #1e293b;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06),0 .8em 1.4em -.8em rgba(0,0,0,.45);
}

.uvq15-trs .dc b {
  font-size: .62em;
  margin-bottom: .2em;
}

.uvq15-trs .dc i {
  height: .28em;
  border-radius: 1em;
  background: #cbd5e1;
}

.uvq15-trs .dc i.s {
  width: 60%;
}

.uvq15-trs.gone .dc {
  visibility: hidden;
}

.uvq15-trs .bl {
  position: absolute;
  left: 3.2em;
  top: 4.1em;
  z-index: 1;
  width: 2.8em;
  height: 2.8em;
  margin: -1.4em 0 0 -1.4em;
  border-radius: 46% 54% 50% 50%/52% 46% 54% 48%;
  background: conic-gradient(from 20deg,rgba(0,0,0,.08),transparent 12%,rgba(0,0,0,.12) 20%,transparent 30%,rgba(0,0,0,.1) 45%,transparent 55%,rgba(0,0,0,.14) 70%,transparent 82%,rgba(0,0,0,.08)),radial-gradient(circle at 35% 30%,#fff,#e2e8f0 55%,#94a3b8);
  box-shadow: 0 .3em .5em -.2em rgba(0,0,0,.35);
  opacity: 0;
  pointer-events: none;
}

.uvq15-trs .bn {
  position: relative;
  z-index: 2;
  width: 4.4em;
  height: 5.6em;
  margin-right: .3em;
}

.uvq15-trs .cn {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4.8em;
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(90deg,transparent 0 .55em,rgba(0,0,0,.18) .55em .7em),linear-gradient(90deg,color-mix(in srgb,var(--c1) 70%,#fff),var(--c1) 45%,color-mix(in srgb,var(--c1) 70%,#000));
  clip-path: polygon(0 0,100% 0,88% 100%,12% 100%);
  border-radius: 0 0 .5em .5em;
}

.uvq15-trs .ct {
  display: grid;
  place-items: center;
  min-width: 1.5em;
  height: 1.5em;
  padding: 0 .3em;
  box-sizing: border-box;
  border-radius: 1em;
  font-size: .75em;
  font-weight: 800;
  color: #fff;
  background: var(--c2);
  transform: scale(0);
  transition: transform calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq15-trs.has .ct {
  transform: none;
}

.uvq15-trs .ld {
  position: absolute;
  left: -.25em;
  right: -.25em;
  top: .1em;
  height: .55em;
  border-radius: .3em .3em .1em .1em;
  background: linear-gradient(color-mix(in srgb,var(--c1) 65%,#fff),var(--c1));
  transform-origin: 100% 100%;
}

.uvq15-trs .ld::before {
  content: "";
  position: absolute;
  left: 35%;
  right: 35%;
  top: -.35em;
  height: .45em;
  border-radius: .3em .3em 0 0;
  border: .15em solid var(--c1);
  border-bottom: 0;
}

.uvq15-trs .go,.uvq15-trs .un {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  gap: .45em;
  padding: .75em 1.2em;
  border-radius: .8em;
  font-weight: 700;
  transition: transform .15s cubic-bezier(.25,.1,.25,1),background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-trs .go {
  color: #fff;
  background: var(--c2);
}

.uvq15-trs .un {
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq15-trs .go:hover {
  filter: brightness(1.08);
}

.uvq15-trs .go:active,.uvq15-trs .un:active {
  transform: scale(.96);
}

.uvq15-trs .go:focus-visible,.uvq15-trs .un:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq15-trs .go svg,.uvq15-trs .un svg {
  width: 1.15em;
  height: 1.15em;
}

.uvq15-trs [hidden] {
  display: none;
}

.uvq15-trs .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
```

### JavaScript

```js
document.querySelectorAll(".uvq15-trs").forEach(el => {
  const k=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1,rm=matchMedia("(prefers-reduced-motion:reduce)").matches;const dc=el.querySelector(".dc"),bl=el.querySelector(".bl"),bn=el.querySelector(".bn"),ld=el.querySelector(".ld"),ct=el.querySelector(".ct"),go=el.querySelector(".go"),un=el.querySelector(".un"),sr=el.querySelector(".sr");let n=0,busy=false;
const ez="cubic-bezier(.22,1,.36,1)",cancel=x=>x.getAnimations().forEach(a=>a.cancel());
const lid=()=>{if(!rm)ld.animate([{transform:"none"},{transform:"rotate(40deg)",offset:.25},{transform:"rotate(40deg)",offset:.68},{transform:"rotate(-6deg)",offset:.82},{transform:"none"}],{duration:950/k,easing:"ease-out"})};
const wob=()=>{if(!rm)bn.animate([{transform:"none"},{transform:"rotate(4deg)"},{transform:"rotate(-3deg)"},{transform:"none"}],{duration:420/k,easing:"ease-out"})};
const fin=()=>{bl.style.opacity="0";cancel(dc);el.classList.add("gone","has");n++;ct.textContent=String(n);wob();go.hidden=true;un.hidden=false;un.focus();busy=false;sr.textContent="Document moved to trash"};
go.addEventListener("click",()=>{if(busy)return;busy=true;if(rm){fin();return}
const sc=el.getBoundingClientRect().width/el.offsetWidth||1,a=bl.getBoundingClientRect(),b=bn.getBoundingClientRect(),dx=(b.left+b.width/2-a.left-a.width/2)/sc,dy=(b.top+b.height*.45-a.top-a.height/2)/sc;
dc.animate([{transform:"none",borderRadius:".4em",opacity:1},{transform:"scale(.85,.72) rotate(-6deg) skewX(8deg)",borderRadius:"30% 18% 36% 22%",offset:.35},{transform:"scale(.42) rotate(-24deg)",borderRadius:"46%",opacity:1,offset:.82},{transform:"scale(.36) rotate(-30deg)",borderRadius:"50%",opacity:0}],{duration:520/k,easing:"ease-in",fill:"forwards"}).onfinish=()=>{
bl.style.opacity="1";const fr=[];for(let i=0;i<=16;i++){const t=i/16;fr.push({transform:"translate("+dx*t+"px,"+(dy*t-70*4*t*(1-t))+"px) rotate("+t*420+"deg) scale("+(1-.3*t)+")",opacity:t>.9?0:1})}
lid();bl.animate(fr,{duration:640/k,easing:"cubic-bezier(.45,0,.6,1)"}).onfinish=fin}});
un.addEventListener("click",()=>{if(busy)return;n--;ct.textContent=String(n);el.classList.remove("gone");el.classList.toggle("has",n>0);un.hidden=true;go.hidden=false;go.focus();sr.textContent="Document restored";lid();
if(!rm)dc.animate([{transform:"translate(8em,-1em) scale(.35) rotate(40deg)",borderRadius:"50%",opacity:0},{transform:"scale(.5) rotate(-10deg)",borderRadius:"40%",opacity:1,offset:.4},{transform:"scale(1.04) rotate(2deg)",borderRadius:".4em",offset:.75},{transform:"none",borderRadius:".4em",opacity:1}],{duration:700/k,easing:ez})})
});
```

### 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 = `
.uvq15-trs {
  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;
  border-radius: 1.3em;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent),0 1.4em 2.6em -1.8em rgba(0,0,0,.35);
  display: grid;
  justify-items: center;
  gap: 1.1em;
  width: 17em;
  padding: 1.2em;
}

.uvq15-trs .ar {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  width: 100%;
  height: 8.6em;
}

.uvq15-trs .dc {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: start;
  gap: .45em;
  width: 6.4em;
  height: 8.2em;
  box-sizing: border-box;
  padding: .8em .7em;
  border-radius: .4em;
  background: #fff;
  color: #1e293b;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06),0 .8em 1.4em -.8em rgba(0,0,0,.45);
}

.uvq15-trs .dc b {
  font-size: .62em;
  margin-bottom: .2em;
}

.uvq15-trs .dc i {
  height: .28em;
  border-radius: 1em;
  background: #cbd5e1;
}

.uvq15-trs .dc i.s {
  width: 60%;
}

.uvq15-trs.gone .dc {
  visibility: hidden;
}

.uvq15-trs .bl {
  position: absolute;
  left: 3.2em;
  top: 4.1em;
  z-index: 1;
  width: 2.8em;
  height: 2.8em;
  margin: -1.4em 0 0 -1.4em;
  border-radius: 46% 54% 50% 50%/52% 46% 54% 48%;
  background: conic-gradient(from 20deg,rgba(0,0,0,.08),transparent 12%,rgba(0,0,0,.12) 20%,transparent 30%,rgba(0,0,0,.1) 45%,transparent 55%,rgba(0,0,0,.14) 70%,transparent 82%,rgba(0,0,0,.08)),radial-gradient(circle at 35% 30%,#fff,#e2e8f0 55%,#94a3b8);
  box-shadow: 0 .3em .5em -.2em rgba(0,0,0,.35);
  opacity: 0;
  pointer-events: none;
}

.uvq15-trs .bn {
  position: relative;
  z-index: 2;
  width: 4.4em;
  height: 5.6em;
  margin-right: .3em;
}

.uvq15-trs .cn {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4.8em;
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(90deg,transparent 0 .55em,rgba(0,0,0,.18) .55em .7em),linear-gradient(90deg,color-mix(in srgb,var(--c1) 70%,#fff),var(--c1) 45%,color-mix(in srgb,var(--c1) 70%,#000));
  clip-path: polygon(0 0,100% 0,88% 100%,12% 100%);
  border-radius: 0 0 .5em .5em;
}

.uvq15-trs .ct {
  display: grid;
  place-items: center;
  min-width: 1.5em;
  height: 1.5em;
  padding: 0 .3em;
  box-sizing: border-box;
  border-radius: 1em;
  font-size: .75em;
  font-weight: 800;
  color: #fff;
  background: var(--c2);
  transform: scale(0);
  transition: transform calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq15-trs.has .ct {
  transform: none;
}

.uvq15-trs .ld {
  position: absolute;
  left: -.25em;
  right: -.25em;
  top: .1em;
  height: .55em;
  border-radius: .3em .3em .1em .1em;
  background: linear-gradient(color-mix(in srgb,var(--c1) 65%,#fff),var(--c1));
  transform-origin: 100% 100%;
}

.uvq15-trs .ld::before {
  content: "";
  position: absolute;
  left: 35%;
  right: 35%;
  top: -.35em;
  height: .45em;
  border-radius: .3em .3em 0 0;
  border: .15em solid var(--c1);
  border-bottom: 0;
}

.uvq15-trs .go,.uvq15-trs .un {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  gap: .45em;
  padding: .75em 1.2em;
  border-radius: .8em;
  font-weight: 700;
  transition: transform .15s cubic-bezier(.25,.1,.25,1),background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-trs .go {
  color: #fff;
  background: var(--c2);
}

.uvq15-trs .un {
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq15-trs .go:hover {
  filter: brightness(1.08);
}

.uvq15-trs .go:active,.uvq15-trs .un:active {
  transform: scale(.96);
}

.uvq15-trs .go:focus-visible,.uvq15-trs .un:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq15-trs .go svg,.uvq15-trs .un svg {
  width: 1.15em;
  height: 1.15em;
}

.uvq15-trs [hidden] {
  display: none;
}

.uvq15-trs .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
`;

// 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 k=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1,rm=matchMedia("(prefers-reduced-motion:reduce)").matches;const dc=el.querySelector(".dc"),bl=el.querySelector(".bl"),bn=el.querySelector(".bn"),ld=el.querySelector(".ld"),ct=el.querySelector(".ct"),go=el.querySelector(".go"),un=el.querySelector(".un"),sr=el.querySelector(".sr");let n=0,busy=false;
const ez="cubic-bezier(.22,1,.36,1)",cancel=x=>x.getAnimations().forEach(a=>a.cancel());
const lid=()=>{if(!rm)ld.animate([{transform:"none"},{transform:"rotate(40deg)",offset:.25},{transform:"rotate(40deg)",offset:.68},{transform:"rotate(-6deg)",offset:.82},{transform:"none"}],{duration:950/k,easing:"ease-out"})};
const wob=()=>{if(!rm)bn.animate([{transform:"none"},{transform:"rotate(4deg)"},{transform:"rotate(-3deg)"},{transform:"none"}],{duration:420/k,easing:"ease-out"})};
const fin=()=>{bl.style.opacity="0";cancel(dc);el.classList.add("gone","has");n++;ct.textContent=String(n);wob();go.hidden=true;un.hidden=false;un.focus();busy=false;sr.textContent="Document moved to trash"};
go.addEventListener("click",()=>{if(busy)return;busy=true;if(rm){fin();return}
const sc=el.getBoundingClientRect().width/el.offsetWidth||1,a=bl.getBoundingClientRect(),b=bn.getBoundingClientRect(),dx=(b.left+b.width/2-a.left-a.width/2)/sc,dy=(b.top+b.height*.45-a.top-a.height/2)/sc;
dc.animate([{transform:"none",borderRadius:".4em",opacity:1},{transform:"scale(.85,.72) rotate(-6deg) skewX(8deg)",borderRadius:"30% 18% 36% 22%",offset:.35},{transform:"scale(.42) rotate(-24deg)",borderRadius:"46%",opacity:1,offset:.82},{transform:"scale(.36) rotate(-30deg)",borderRadius:"50%",opacity:0}],{duration:520/k,easing:"ease-in",fill:"forwards"}).onfinish=()=>{
bl.style.opacity="1";const fr=[];for(let i=0;i<=16;i++){const t=i/16;fr.push({transform:"translate("+dx*t+"px,"+(dy*t-70*4*t*(1-t))+"px) rotate("+t*420+"deg) scale("+(1-.3*t)+")",opacity:t>.9?0:1})}
lid();bl.animate(fr,{duration:640/k,easing:"cubic-bezier(.45,0,.6,1)"}).onfinish=fin}});
un.addEventListener("click",()=>{if(busy)return;n--;ct.textContent=String(n);el.classList.remove("gone");el.classList.toggle("has",n>0);un.hidden=true;go.hidden=false;go.focus();sr.textContent="Document restored";lid();
if(!rm)dc.animate([{transform:"translate(8em,-1em) scale(.35) rotate(40deg)",borderRadius:"50%",opacity:0},{transform:"scale(.5) rotate(-10deg)",borderRadius:"40%",opacity:1,offset:.4},{transform:"scale(1.04) rotate(2deg)",borderRadius:".4em",offset:.75},{transform:"none",borderRadius:".4em",opacity:1}],{duration:700/k,easing:ez})})
}

export default function Mi27TrashCrumple() {
  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": "#475569",
          "--c2": "#ef4444",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq15-trs"><div className="ar"><div className="dc"><b>Letter draft</b><i></i><i></i><i></i><i className="s"></i><i></i><i className="s"></i></div><span className="bl" aria-hidden="true"></span><div className="bn" aria-hidden="true"><span className="ld"></span><span className="cn"><span className="ct">0</span></span></div></div><button type="button" className="go"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M3 6h18M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6M9 6V4h6v2" /></svg><span>Move to trash</span></button><button type="button" className="un" hidden={true}><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M9 14 4 9l5-5" /><path d="M4 9h11a5 5 0 0 1 0 10h-3" /></svg><span>Undo</span></button><p className="sr" aria-live="polite"></p></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 “Trash can that crumples paper” block (Microinteractions) from AIMRAN Library to my project.

## What it is
The document crumples into a paper ball that arcs through the air; the bin lid flips open, swallows it and shuts.

## Chosen settings
- Main color: #475569
- Secondary color: #ef4444
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Tirar a la papelera"

## 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 = `
.uvq15-trs {
  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;
  border-radius: 1.3em;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent),0 1.4em 2.6em -1.8em rgba(0,0,0,.35);
  display: grid;
  justify-items: center;
  gap: 1.1em;
  width: 17em;
  padding: 1.2em;
}

.uvq15-trs .ar {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  width: 100%;
  height: 8.6em;
}

.uvq15-trs .dc {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: start;
  gap: .45em;
  width: 6.4em;
  height: 8.2em;
  box-sizing: border-box;
  padding: .8em .7em;
  border-radius: .4em;
  background: #fff;
  color: #1e293b;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06),0 .8em 1.4em -.8em rgba(0,0,0,.45);
}

.uvq15-trs .dc b {
  font-size: .62em;
  margin-bottom: .2em;
}

.uvq15-trs .dc i {
  height: .28em;
  border-radius: 1em;
  background: #cbd5e1;
}

.uvq15-trs .dc i.s {
  width: 60%;
}

.uvq15-trs.gone .dc {
  visibility: hidden;
}

.uvq15-trs .bl {
  position: absolute;
  left: 3.2em;
  top: 4.1em;
  z-index: 1;
  width: 2.8em;
  height: 2.8em;
  margin: -1.4em 0 0 -1.4em;
  border-radius: 46% 54% 50% 50%/52% 46% 54% 48%;
  background: conic-gradient(from 20deg,rgba(0,0,0,.08),transparent 12%,rgba(0,0,0,.12) 20%,transparent 30%,rgba(0,0,0,.1) 45%,transparent 55%,rgba(0,0,0,.14) 70%,transparent 82%,rgba(0,0,0,.08)),radial-gradient(circle at 35% 30%,#fff,#e2e8f0 55%,#94a3b8);
  box-shadow: 0 .3em .5em -.2em rgba(0,0,0,.35);
  opacity: 0;
  pointer-events: none;
}

.uvq15-trs .bn {
  position: relative;
  z-index: 2;
  width: 4.4em;
  height: 5.6em;
  margin-right: .3em;
}

.uvq15-trs .cn {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4.8em;
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(90deg,transparent 0 .55em,rgba(0,0,0,.18) .55em .7em),linear-gradient(90deg,color-mix(in srgb,var(--c1) 70%,#fff),var(--c1) 45%,color-mix(in srgb,var(--c1) 70%,#000));
  clip-path: polygon(0 0,100% 0,88% 100%,12% 100%);
  border-radius: 0 0 .5em .5em;
}

.uvq15-trs .ct {
  display: grid;
  place-items: center;
  min-width: 1.5em;
  height: 1.5em;
  padding: 0 .3em;
  box-sizing: border-box;
  border-radius: 1em;
  font-size: .75em;
  font-weight: 800;
  color: #fff;
  background: var(--c2);
  transform: scale(0);
  transition: transform calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq15-trs.has .ct {
  transform: none;
}

.uvq15-trs .ld {
  position: absolute;
  left: -.25em;
  right: -.25em;
  top: .1em;
  height: .55em;
  border-radius: .3em .3em .1em .1em;
  background: linear-gradient(color-mix(in srgb,var(--c1) 65%,#fff),var(--c1));
  transform-origin: 100% 100%;
}

.uvq15-trs .ld::before {
  content: "";
  position: absolute;
  left: 35%;
  right: 35%;
  top: -.35em;
  height: .45em;
  border-radius: .3em .3em 0 0;
  border: .15em solid var(--c1);
  border-bottom: 0;
}

.uvq15-trs .go,.uvq15-trs .un {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  gap: .45em;
  padding: .75em 1.2em;
  border-radius: .8em;
  font-weight: 700;
  transition: transform .15s cubic-bezier(.25,.1,.25,1),background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-trs .go {
  color: #fff;
  background: var(--c2);
}

.uvq15-trs .un {
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq15-trs .go:hover {
  filter: brightness(1.08);
}

.uvq15-trs .go:active,.uvq15-trs .un:active {
  transform: scale(.96);
}

.uvq15-trs .go:focus-visible,.uvq15-trs .un:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq15-trs .go svg,.uvq15-trs .un svg {
  width: 1.15em;
  height: 1.15em;
}

.uvq15-trs [hidden] {
  display: none;
}

.uvq15-trs .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
`;

// 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 k=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1,rm=matchMedia("(prefers-reduced-motion:reduce)").matches;const dc=el.querySelector(".dc"),bl=el.querySelector(".bl"),bn=el.querySelector(".bn"),ld=el.querySelector(".ld"),ct=el.querySelector(".ct"),go=el.querySelector(".go"),un=el.querySelector(".un"),sr=el.querySelector(".sr");let n=0,busy=false;
const ez="cubic-bezier(.22,1,.36,1)",cancel=x=>x.getAnimations().forEach(a=>a.cancel());
const lid=()=>{if(!rm)ld.animate([{transform:"none"},{transform:"rotate(40deg)",offset:.25},{transform:"rotate(40deg)",offset:.68},{transform:"rotate(-6deg)",offset:.82},{transform:"none"}],{duration:950/k,easing:"ease-out"})};
const wob=()=>{if(!rm)bn.animate([{transform:"none"},{transform:"rotate(4deg)"},{transform:"rotate(-3deg)"},{transform:"none"}],{duration:420/k,easing:"ease-out"})};
const fin=()=>{bl.style.opacity="0";cancel(dc);el.classList.add("gone","has");n++;ct.textContent=String(n);wob();go.hidden=true;un.hidden=false;un.focus();busy=false;sr.textContent="Document moved to trash"};
go.addEventListener("click",()=>{if(busy)return;busy=true;if(rm){fin();return}
const sc=el.getBoundingClientRect().width/el.offsetWidth||1,a=bl.getBoundingClientRect(),b=bn.getBoundingClientRect(),dx=(b.left+b.width/2-a.left-a.width/2)/sc,dy=(b.top+b.height*.45-a.top-a.height/2)/sc;
dc.animate([{transform:"none",borderRadius:".4em",opacity:1},{transform:"scale(.85,.72) rotate(-6deg) skewX(8deg)",borderRadius:"30% 18% 36% 22%",offset:.35},{transform:"scale(.42) rotate(-24deg)",borderRadius:"46%",opacity:1,offset:.82},{transform:"scale(.36) rotate(-30deg)",borderRadius:"50%",opacity:0}],{duration:520/k,easing:"ease-in",fill:"forwards"}).onfinish=()=>{
bl.style.opacity="1";const fr=[];for(let i=0;i<=16;i++){const t=i/16;fr.push({transform:"translate("+dx*t+"px,"+(dy*t-70*4*t*(1-t))+"px) rotate("+t*420+"deg) scale("+(1-.3*t)+")",opacity:t>.9?0:1})}
lid();bl.animate(fr,{duration:640/k,easing:"cubic-bezier(.45,0,.6,1)"}).onfinish=fin}});
un.addEventListener("click",()=>{if(busy)return;n--;ct.textContent=String(n);el.classList.remove("gone");el.classList.toggle("has",n>0);un.hidden=true;go.hidden=false;go.focus();sr.textContent="Document restored";lid();
if(!rm)dc.animate([{transform:"translate(8em,-1em) scale(.35) rotate(40deg)",borderRadius:"50%",opacity:0},{transform:"scale(.5) rotate(-10deg)",borderRadius:"40%",opacity:1,offset:.4},{transform:"scale(1.04) rotate(2deg)",borderRadius:".4em",offset:.75},{transform:"none",borderRadius:".4em",opacity:1}],{duration:700/k,easing:ez})})
}

export default function Mi27TrashCrumple() {
  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": "#475569",
          "--c2": "#ef4444",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq15-trs"><div className="ar"><div className="dc"><b>Letter draft</b><i></i><i></i><i></i><i className="s"></i><i></i><i className="s"></i></div><span className="bl" aria-hidden="true"></span><div className="bn" aria-hidden="true"><span className="ld"></span><span className="cn"><span className="ct">0</span></span></div></div><button type="button" className="go"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M3 6h18M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6M9 6V4h6v2" /></svg><span>Move to trash</span></button><button type="button" className="un" hidden={true}><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M9 14 4 9l5-5" /><path d="M4 9h11a5 5 0 0 1 0 10h-3" /></svg><span>Undo</span></button><p className="sr" aria-live="polite"></p></div>
      </div>
    </>
  );
}
```

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