# Exit intent modal

> As the cursor nears the top edge a line lights up, and if it leaves, a modal drops down offering to save the cart.

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

## Where to use it

Exit intent popups often feel like ambushes, so this one shows its trigger. A thin line at the top glows brighter as the pointer gets close, and leaving through that edge drops a warm modal that offers to keep the cart for 48 hours by email, with a plain no thanks. It fits shops, sign ups and booking forms where people hesitate.

The main color is the glowing edge, the badge and the button, the second one the modal paper. It waits a few seconds before it can show again, and on touch screens or keyboards the simulate button opens it the same way.

## Code

### HTML

```html
<div class="uvq13-ext"><div class="ez" aria-hidden="true"><span>Move the cursor out through the top</span></div><header class="nv"><b>Brisa</b><span class="ct"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 8h12l-1 12H7zM9 8V6.5a3 3 0 0 1 6 0V8"/></svg><i>2</i></span></header><div class="gr" aria-hidden="true"><span><i class="p"></i><i></i><i class="s"></i></span><span><i class="p"></i><i></i><i class="s"></i></span><span><i class="p"></i><i></i><i class="s"></i></span></div><button type="button" class="fire" aria-haspopup="dialog">Simulate leaving</button><div class="scr"></div><div class="dl" role="dialog" aria-modal="true" aria-labelledby="uvq13-ext-t"><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 class="v1"><p class="ti" id="uvq13-ext-t">Leaving already?</p><p class="ds">We will keep your cart for 48 hours.</p><div class="its" aria-hidden="true"><i style="--c:#fb923c"></i><i style="--c:#38bdf8"></i></div><form class="fm"><input type="email" placeholder="you@email.com" aria-label="Email" autocomplete="email"><button type="submit">Save it for me</button></form><button type="button" class="no">No, thanks</button></div><div class="v2" aria-live="polite"><span class="ok"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 7l8 6 8-6M4 6.5h16v11H4z"/></svg></span><p class="ti">We have sent it to you</p><p class="ds">Check your email to get back to your cart.</p></div></div></div>
```

### CSS

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

.uvq13-ext {
  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);
}

.uvq13-ext .ez {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 3;
  height: .25em;
  background: linear-gradient(90deg,transparent,var(--c1) 30% 70%,transparent);
  opacity: calc(.2 + var(--near,0) * .8);
  box-shadow: 0 0 calc(var(--near,0) * 1.4em) var(--c1);
  pointer-events: none;
}

.uvq13-ext .ez span {
  position: absolute;
  left: 50%;
  top: .6em;
  padding: .25em .6em;
  border-radius: 2em;
  font-size: .6em;
  font-weight: 700;
  white-space: nowrap;
  color: var(--c1);
  background: var(--bg);
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--c1) 35%,transparent);
  transform: translate(-50%,calc((1 - var(--near,0)) * -.4em));
  opacity: calc(.55 + var(--near,0) * .45);
}

.uvq13-ext .nv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2em 1.2em .8em;
}

.uvq13-ext .nv b {
  font-size: 1.05em;
  font-weight: 900;
  letter-spacing: -.04em;
}

.uvq13-ext .ct {
  position: relative;
  display: grid;
  place-items: center;
  width: 2em;
  height: 2em;
}

.uvq13-ext .ct svg {
  width: 1.3em;
  height: 1.3em;
}

.uvq13-ext .ct i {
  position: absolute;
  right: -.1em;
  top: -.1em;
  display: grid;
  place-items: center;
  min-width: 1.2em;
  height: 1.2em;
  border-radius: 1em;
  font-size: .62em;
  font-style: normal;
  font-weight: 800;
  color: #fff;
  background: var(--c1);
}

.uvq13-ext .gr {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: .6em;
  padding: 0 1.2em;
}

.uvq13-ext .gr span {
  display: grid;
  gap: .4em;
}

.uvq13-ext .gr i {
  height: .5em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq13-ext .gr .p {
  height: 4.2em;
  border-radius: .7em;
  background: color-mix(in srgb,var(--fg) 7%,transparent);
}

.uvq13-ext .gr .s {
  width: 60%;
}

.uvq13-ext .fire {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  left: 50%;
  bottom: 1em;
  padding: .55em 1em;
  border-radius: 2em;
  font-size: .76em;
  font-weight: 700;
  color: var(--bg);
  background: var(--fg);
  transform: translateX(-50%);
}

.uvq13-ext .scr {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(20,10,4,.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-ext.open .scr {
  opacity: 1;
  pointer-events: auto;
}

.uvq13-ext .dl {
  position: absolute;
  left: 50%;
  top: 1em;
  z-index: 5;
  width: 14.6em;
  padding: 1.1em 1.2em 1em;
  box-sizing: border-box;
  border-radius: 1.2em;
  text-align: center;
  color: #2b1607;
  background: var(--c2);
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--c1) 25%,transparent),0 1.6em 3em -1em rgba(0,0,0,.55);
  transform: translate(-50%,-120%);
  transition: transform calc(0.55s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq13-ext.open .dl {
  transform: translate(-50%,0);
}

.uvq13-ext .x {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  right: .6em;
  top: .6em;
  display: grid;
  place-items: center;
  width: 1.8em;
  height: 1.8em;
  border-radius: 50%;
  color: #2b1607;
  background: rgba(0,0,0,.06);
}

.uvq13-ext .x svg {
  width: .9em;
  height: .9em;
}

.uvq13-ext .ti {
  margin: 0;
  font-size: 1.2em;
  font-weight: 850;
  letter-spacing: -.02em;
}

.uvq13-ext .ds {
  margin: .3em 0 .7em;
  font-size: .74em;
  opacity: .75;
}

.uvq13-ext .its {
  display: flex;
  justify-content: center;
  gap: .4em;
  margin-bottom: .8em;
}

.uvq13-ext .its i {
  width: 2.6em;
  height: 2.6em;
  border-radius: .6em;
  background: linear-gradient(160deg,color-mix(in srgb,var(--c) 45%,#fff),var(--c));
  box-shadow: 0 .3em .6em -.3em rgba(0,0,0,.4);
  transform: rotate(-4deg);
}

.uvq13-ext .its i+i {
  transform: rotate(5deg);
}

.uvq13-ext .fm {
  display: flex;
  gap: .3em;
  padding: .25em;
  border-radius: .8em;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08);
}

.uvq13-ext .fm.bad {
  animation: uvq13-ext-s calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
  box-shadow: 0 0 0 2px #dc2626;
}

.uvq13-ext .fm input {
  flex: 1;
  min-width: 0;
  padding: 0 .5em;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  font-size: .78em;
  color: #2b1607;
}

.uvq13-ext .fm button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: .55em .8em;
  border-radius: .6em;
  font-size: .74em;
  font-weight: 700;
  color: #fff;
  background: var(--c1);
}

.uvq13-ext .no {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  margin-top: .6em;
  font-size: .7em;
  font-weight: 650;
  opacity: .65;
  text-decoration: underline;
  text-underline-offset: .2em;
}

.uvq13-ext .v2 {
  display: none;
}

.uvq13-ext .sent .v1 {
  display: none;
}

.uvq13-ext .sent .v2 {
  display: block;
  animation: uvq13-ext-i calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq13-ext .ok {
  display: grid;
  place-items: center;
  width: 2.8em;
  height: 2.8em;
  margin: 0 auto .5em;
  border-radius: 50%;
  color: #fff;
  background: var(--c1);
}

.uvq13-ext .ok svg {
  width: 1.4em;
  height: 1.4em;
}

.uvq13-ext button:focus-visible,.uvq13-ext .fm:focus-within {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

@keyframes uvq13-ext-s {
  20%,60% {
    transform: translateX(-.3em);
  }
  40%,80% {
    transform: translateX(.3em);
  }
}

@keyframes uvq13-ext-i {
  from {
    opacity: 0;
    transform: scale(.92);
  }
}

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

### JavaScript

```js
document.querySelectorAll(".uvq13-ext").forEach(el => {
  const fire=el.querySelector(".fire"),scr=el.querySelector(".scr"),pnl=el.querySelector(".dl");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");dl.classList.remove('sent');u&&foc('.fm input',400)};
const close=()=>{if(!isOpen())return;el.classList.remove("open");pnl.inert=true;fire&&fire.setAttribute("aria-expanded","false");cool=Date.now()+4000;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),900);const dl=el.querySelector(".dl"),fm=el.querySelector(".fm"),inp=fm.querySelector("input");let cool=0;
const sc=()=>el.getBoundingClientRect().width/el.offsetWidth||1;
el.addEventListener("pointermove",e=>{const y=(e.clientY-el.getBoundingClientRect().top)/sc(),f=parseFloat(getComputedStyle(el).fontSize);el.style.setProperty("--near",Math.max(0,1-y/(f*4)).toFixed(2))});
el.addEventListener("pointerleave",e=>{const r=el.getBoundingClientRect();el.style.setProperty("--near","0");if(e.pointerType==="mouse"&&e.clientY<=r.top+4&&!isOpen()&&Date.now()>cool)open(true)});
fm.addEventListener("submit",e=>{e.preventDefault();if(!/.+@.+\..+/.test(inp.value)){fm.classList.remove("bad");void fm.offsetWidth;fm.classList.add("bad");inp.focus();return}fm.classList.remove("bad");dl.classList.add("sent");foc(".dl .x",0);later(close,1900)});
el.querySelector(".no").addEventListener("click",close);el.querySelector(".dl .x").addEventListener("click",close);return()=>tms.forEach(clearTimeout)
});
```

### 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-ext {
  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);
}

.uvq13-ext .ez {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 3;
  height: .25em;
  background: linear-gradient(90deg,transparent,var(--c1) 30% 70%,transparent);
  opacity: calc(.2 + var(--near,0) * .8);
  box-shadow: 0 0 calc(var(--near,0) * 1.4em) var(--c1);
  pointer-events: none;
}

.uvq13-ext .ez span {
  position: absolute;
  left: 50%;
  top: .6em;
  padding: .25em .6em;
  border-radius: 2em;
  font-size: .6em;
  font-weight: 700;
  white-space: nowrap;
  color: var(--c1);
  background: var(--bg);
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--c1) 35%,transparent);
  transform: translate(-50%,calc((1 - var(--near,0)) * -.4em));
  opacity: calc(.55 + var(--near,0) * .45);
}

.uvq13-ext .nv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2em 1.2em .8em;
}

.uvq13-ext .nv b {
  font-size: 1.05em;
  font-weight: 900;
  letter-spacing: -.04em;
}

.uvq13-ext .ct {
  position: relative;
  display: grid;
  place-items: center;
  width: 2em;
  height: 2em;
}

.uvq13-ext .ct svg {
  width: 1.3em;
  height: 1.3em;
}

.uvq13-ext .ct i {
  position: absolute;
  right: -.1em;
  top: -.1em;
  display: grid;
  place-items: center;
  min-width: 1.2em;
  height: 1.2em;
  border-radius: 1em;
  font-size: .62em;
  font-style: normal;
  font-weight: 800;
  color: #fff;
  background: var(--c1);
}

.uvq13-ext .gr {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: .6em;
  padding: 0 1.2em;
}

.uvq13-ext .gr span {
  display: grid;
  gap: .4em;
}

.uvq13-ext .gr i {
  height: .5em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq13-ext .gr .p {
  height: 4.2em;
  border-radius: .7em;
  background: color-mix(in srgb,var(--fg) 7%,transparent);
}

.uvq13-ext .gr .s {
  width: 60%;
}

.uvq13-ext .fire {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  left: 50%;
  bottom: 1em;
  padding: .55em 1em;
  border-radius: 2em;
  font-size: .76em;
  font-weight: 700;
  color: var(--bg);
  background: var(--fg);
  transform: translateX(-50%);
}

.uvq13-ext .scr {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(20,10,4,.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-ext.open .scr {
  opacity: 1;
  pointer-events: auto;
}

.uvq13-ext .dl {
  position: absolute;
  left: 50%;
  top: 1em;
  z-index: 5;
  width: 14.6em;
  padding: 1.1em 1.2em 1em;
  box-sizing: border-box;
  border-radius: 1.2em;
  text-align: center;
  color: #2b1607;
  background: var(--c2);
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--c1) 25%,transparent),0 1.6em 3em -1em rgba(0,0,0,.55);
  transform: translate(-50%,-120%);
  transition: transform calc(0.55s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq13-ext.open .dl {
  transform: translate(-50%,0);
}

.uvq13-ext .x {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  right: .6em;
  top: .6em;
  display: grid;
  place-items: center;
  width: 1.8em;
  height: 1.8em;
  border-radius: 50%;
  color: #2b1607;
  background: rgba(0,0,0,.06);
}

.uvq13-ext .x svg {
  width: .9em;
  height: .9em;
}

.uvq13-ext .ti {
  margin: 0;
  font-size: 1.2em;
  font-weight: 850;
  letter-spacing: -.02em;
}

.uvq13-ext .ds {
  margin: .3em 0 .7em;
  font-size: .74em;
  opacity: .75;
}

.uvq13-ext .its {
  display: flex;
  justify-content: center;
  gap: .4em;
  margin-bottom: .8em;
}

.uvq13-ext .its i {
  width: 2.6em;
  height: 2.6em;
  border-radius: .6em;
  background: linear-gradient(160deg,color-mix(in srgb,var(--c) 45%,#fff),var(--c));
  box-shadow: 0 .3em .6em -.3em rgba(0,0,0,.4);
  transform: rotate(-4deg);
}

.uvq13-ext .its i+i {
  transform: rotate(5deg);
}

.uvq13-ext .fm {
  display: flex;
  gap: .3em;
  padding: .25em;
  border-radius: .8em;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08);
}

.uvq13-ext .fm.bad {
  animation: uvq13-ext-s calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
  box-shadow: 0 0 0 2px #dc2626;
}

.uvq13-ext .fm input {
  flex: 1;
  min-width: 0;
  padding: 0 .5em;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  font-size: .78em;
  color: #2b1607;
}

.uvq13-ext .fm button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: .55em .8em;
  border-radius: .6em;
  font-size: .74em;
  font-weight: 700;
  color: #fff;
  background: var(--c1);
}

.uvq13-ext .no {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  margin-top: .6em;
  font-size: .7em;
  font-weight: 650;
  opacity: .65;
  text-decoration: underline;
  text-underline-offset: .2em;
}

.uvq13-ext .v2 {
  display: none;
}

.uvq13-ext .sent .v1 {
  display: none;
}

.uvq13-ext .sent .v2 {
  display: block;
  animation: uvq13-ext-i calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq13-ext .ok {
  display: grid;
  place-items: center;
  width: 2.8em;
  height: 2.8em;
  margin: 0 auto .5em;
  border-radius: 50%;
  color: #fff;
  background: var(--c1);
}

.uvq13-ext .ok svg {
  width: 1.4em;
  height: 1.4em;
}

.uvq13-ext button:focus-visible,.uvq13-ext .fm:focus-within {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

@keyframes uvq13-ext-s {
  20%,60% {
    transform: translateX(-.3em);
  }
  40%,80% {
    transform: translateX(.3em);
  }
}

@keyframes uvq13-ext-i {
  from {
    opacity: 0;
    transform: scale(.92);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq13-ext,.uvq13-ext *,.uvq13-ext *::before,.uvq13-ext *::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(".dl");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");dl.classList.remove('sent');u&&foc('.fm input',400)};
const close=()=>{if(!isOpen())return;el.classList.remove("open");pnl.inert=true;fire&&fire.setAttribute("aria-expanded","false");cool=Date.now()+4000;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),900);const dl=el.querySelector(".dl"),fm=el.querySelector(".fm"),inp=fm.querySelector("input");let cool=0;
const sc=()=>el.getBoundingClientRect().width/el.offsetWidth||1;
el.addEventListener("pointermove",e=>{const y=(e.clientY-el.getBoundingClientRect().top)/sc(),f=parseFloat(getComputedStyle(el).fontSize);el.style.setProperty("--near",Math.max(0,1-y/(f*4)).toFixed(2))});
el.addEventListener("pointerleave",e=>{const r=el.getBoundingClientRect();el.style.setProperty("--near","0");if(e.pointerType==="mouse"&&e.clientY<=r.top+4&&!isOpen()&&Date.now()>cool)open(true)});
fm.addEventListener("submit",e=>{e.preventDefault();if(!/.+@.+\..+/.test(inp.value)){fm.classList.remove("bad");void fm.offsetWidth;fm.classList.add("bad");inp.focus();return}fm.classList.remove("bad");dl.classList.add("sent");foc(".dl .x",0);later(close,1900)});
el.querySelector(".no").addEventListener("click",close);el.querySelector(".dl .x").addEventListener("click",close);return()=>tms.forEach(clearTimeout)
}

export default function OvExitIntent() {
  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": "#ea580c",
          "--c2": "#fff7ed",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq13-ext"><div className="ez" aria-hidden="true"><span>Move the cursor out through the top</span></div><header className="nv"><b>Brisa</b><span className="ct"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M6 8h12l-1 12H7zM9 8V6.5a3 3 0 0 1 6 0V8" /></svg><i>2</i></span></header><div className="gr" aria-hidden="true"><span><i className="p"></i><i></i><i className="s"></i></span><span><i className="p"></i><i></i><i className="s"></i></span><span><i className="p"></i><i></i><i className="s"></i></span></div><button type="button" className="fire" aria-haspopup="dialog">Simulate leaving</button><div className="scr"></div><div className="dl" role="dialog" aria-modal="true" aria-labelledby="uvq13-ext-t"><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 className="v1"><p className="ti" id="uvq13-ext-t">Leaving already?</p><p className="ds">We will keep your cart for 48 hours.</p><div className="its" aria-hidden="true"><i style={{ "--c": "#fb923c" } as CSSProperties}></i><i style={{ "--c": "#38bdf8" } as CSSProperties}></i></div><form className="fm"><input type="email" placeholder="you@email.com" aria-label="Email" autoComplete="email" /><button type="submit">Save it for me</button></form><button type="button" className="no">No, thanks</button></div><div className="v2" aria-live="polite"><span className="ok"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M4 7l8 6 8-6M4 6.5h16v11H4z" /></svg></span><p className="ti">We have sent it to you</p><p className="ds">Check your email to get back to your cart.</p></div></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 “Exit intent modal” block (Overlays) from AIMRAN Library to my project.

## What it is
As the cursor nears the top edge a line lights up, and if it leaves, a modal drops down offering to save the cart.

## Chosen settings
- Main color: #ea580c
- Secondary color: #fff7ed
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "¿Te vas ya?"

## 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-ext {
  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);
}

.uvq13-ext .ez {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 3;
  height: .25em;
  background: linear-gradient(90deg,transparent,var(--c1) 30% 70%,transparent);
  opacity: calc(.2 + var(--near,0) * .8);
  box-shadow: 0 0 calc(var(--near,0) * 1.4em) var(--c1);
  pointer-events: none;
}

.uvq13-ext .ez span {
  position: absolute;
  left: 50%;
  top: .6em;
  padding: .25em .6em;
  border-radius: 2em;
  font-size: .6em;
  font-weight: 700;
  white-space: nowrap;
  color: var(--c1);
  background: var(--bg);
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--c1) 35%,transparent);
  transform: translate(-50%,calc((1 - var(--near,0)) * -.4em));
  opacity: calc(.55 + var(--near,0) * .45);
}

.uvq13-ext .nv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2em 1.2em .8em;
}

.uvq13-ext .nv b {
  font-size: 1.05em;
  font-weight: 900;
  letter-spacing: -.04em;
}

.uvq13-ext .ct {
  position: relative;
  display: grid;
  place-items: center;
  width: 2em;
  height: 2em;
}

.uvq13-ext .ct svg {
  width: 1.3em;
  height: 1.3em;
}

.uvq13-ext .ct i {
  position: absolute;
  right: -.1em;
  top: -.1em;
  display: grid;
  place-items: center;
  min-width: 1.2em;
  height: 1.2em;
  border-radius: 1em;
  font-size: .62em;
  font-style: normal;
  font-weight: 800;
  color: #fff;
  background: var(--c1);
}

.uvq13-ext .gr {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: .6em;
  padding: 0 1.2em;
}

.uvq13-ext .gr span {
  display: grid;
  gap: .4em;
}

.uvq13-ext .gr i {
  height: .5em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq13-ext .gr .p {
  height: 4.2em;
  border-radius: .7em;
  background: color-mix(in srgb,var(--fg) 7%,transparent);
}

.uvq13-ext .gr .s {
  width: 60%;
}

.uvq13-ext .fire {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  left: 50%;
  bottom: 1em;
  padding: .55em 1em;
  border-radius: 2em;
  font-size: .76em;
  font-weight: 700;
  color: var(--bg);
  background: var(--fg);
  transform: translateX(-50%);
}

.uvq13-ext .scr {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(20,10,4,.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-ext.open .scr {
  opacity: 1;
  pointer-events: auto;
}

.uvq13-ext .dl {
  position: absolute;
  left: 50%;
  top: 1em;
  z-index: 5;
  width: 14.6em;
  padding: 1.1em 1.2em 1em;
  box-sizing: border-box;
  border-radius: 1.2em;
  text-align: center;
  color: #2b1607;
  background: var(--c2);
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--c1) 25%,transparent),0 1.6em 3em -1em rgba(0,0,0,.55);
  transform: translate(-50%,-120%);
  transition: transform calc(0.55s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq13-ext.open .dl {
  transform: translate(-50%,0);
}

.uvq13-ext .x {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  right: .6em;
  top: .6em;
  display: grid;
  place-items: center;
  width: 1.8em;
  height: 1.8em;
  border-radius: 50%;
  color: #2b1607;
  background: rgba(0,0,0,.06);
}

.uvq13-ext .x svg {
  width: .9em;
  height: .9em;
}

.uvq13-ext .ti {
  margin: 0;
  font-size: 1.2em;
  font-weight: 850;
  letter-spacing: -.02em;
}

.uvq13-ext .ds {
  margin: .3em 0 .7em;
  font-size: .74em;
  opacity: .75;
}

.uvq13-ext .its {
  display: flex;
  justify-content: center;
  gap: .4em;
  margin-bottom: .8em;
}

.uvq13-ext .its i {
  width: 2.6em;
  height: 2.6em;
  border-radius: .6em;
  background: linear-gradient(160deg,color-mix(in srgb,var(--c) 45%,#fff),var(--c));
  box-shadow: 0 .3em .6em -.3em rgba(0,0,0,.4);
  transform: rotate(-4deg);
}

.uvq13-ext .its i+i {
  transform: rotate(5deg);
}

.uvq13-ext .fm {
  display: flex;
  gap: .3em;
  padding: .25em;
  border-radius: .8em;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08);
}

.uvq13-ext .fm.bad {
  animation: uvq13-ext-s calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
  box-shadow: 0 0 0 2px #dc2626;
}

.uvq13-ext .fm input {
  flex: 1;
  min-width: 0;
  padding: 0 .5em;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  font-size: .78em;
  color: #2b1607;
}

.uvq13-ext .fm button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: .55em .8em;
  border-radius: .6em;
  font-size: .74em;
  font-weight: 700;
  color: #fff;
  background: var(--c1);
}

.uvq13-ext .no {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  margin-top: .6em;
  font-size: .7em;
  font-weight: 650;
  opacity: .65;
  text-decoration: underline;
  text-underline-offset: .2em;
}

.uvq13-ext .v2 {
  display: none;
}

.uvq13-ext .sent .v1 {
  display: none;
}

.uvq13-ext .sent .v2 {
  display: block;
  animation: uvq13-ext-i calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq13-ext .ok {
  display: grid;
  place-items: center;
  width: 2.8em;
  height: 2.8em;
  margin: 0 auto .5em;
  border-radius: 50%;
  color: #fff;
  background: var(--c1);
}

.uvq13-ext .ok svg {
  width: 1.4em;
  height: 1.4em;
}

.uvq13-ext button:focus-visible,.uvq13-ext .fm:focus-within {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

@keyframes uvq13-ext-s {
  20%,60% {
    transform: translateX(-.3em);
  }
  40%,80% {
    transform: translateX(.3em);
  }
}

@keyframes uvq13-ext-i {
  from {
    opacity: 0;
    transform: scale(.92);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq13-ext,.uvq13-ext *,.uvq13-ext *::before,.uvq13-ext *::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(".dl");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");dl.classList.remove('sent');u&&foc('.fm input',400)};
const close=()=>{if(!isOpen())return;el.classList.remove("open");pnl.inert=true;fire&&fire.setAttribute("aria-expanded","false");cool=Date.now()+4000;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),900);const dl=el.querySelector(".dl"),fm=el.querySelector(".fm"),inp=fm.querySelector("input");let cool=0;
const sc=()=>el.getBoundingClientRect().width/el.offsetWidth||1;
el.addEventListener("pointermove",e=>{const y=(e.clientY-el.getBoundingClientRect().top)/sc(),f=parseFloat(getComputedStyle(el).fontSize);el.style.setProperty("--near",Math.max(0,1-y/(f*4)).toFixed(2))});
el.addEventListener("pointerleave",e=>{const r=el.getBoundingClientRect();el.style.setProperty("--near","0");if(e.pointerType==="mouse"&&e.clientY<=r.top+4&&!isOpen()&&Date.now()>cool)open(true)});
fm.addEventListener("submit",e=>{e.preventDefault();if(!/.+@.+\..+/.test(inp.value)){fm.classList.remove("bad");void fm.offsetWidth;fm.classList.add("bad");inp.focus();return}fm.classList.remove("bad");dl.classList.add("sent");foc(".dl .x",0);later(close,1900)});
el.querySelector(".no").addEventListener("click",close);el.querySelector(".dl .x").addEventListener("click",close);return()=>tms.forEach(clearTimeout)
}

export default function OvExitIntent() {
  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": "#ea580c",
          "--c2": "#fff7ed",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq13-ext"><div className="ez" aria-hidden="true"><span>Move the cursor out through the top</span></div><header className="nv"><b>Brisa</b><span className="ct"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M6 8h12l-1 12H7zM9 8V6.5a3 3 0 0 1 6 0V8" /></svg><i>2</i></span></header><div className="gr" aria-hidden="true"><span><i className="p"></i><i></i><i className="s"></i></span><span><i className="p"></i><i></i><i className="s"></i></span><span><i className="p"></i><i></i><i className="s"></i></span></div><button type="button" className="fire" aria-haspopup="dialog">Simulate leaving</button><div className="scr"></div><div className="dl" role="dialog" aria-modal="true" aria-labelledby="uvq13-ext-t"><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 className="v1"><p className="ti" id="uvq13-ext-t">Leaving already?</p><p className="ds">We will keep your cart for 48 hours.</p><div className="its" aria-hidden="true"><i style={{ "--c": "#fb923c" } as CSSProperties}></i><i style={{ "--c": "#38bdf8" } as CSSProperties}></i></div><form className="fm"><input type="email" placeholder="you@email.com" aria-label="Email" autoComplete="email" /><button type="submit">Save it for me</button></form><button type="button" className="no">No, thanks</button></div><div className="v2" aria-live="polite"><span className="ok"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M4 7l8 6 8-6M4 6.5h16v11H4z" /></svg></span><p className="ti">We have sent it to you</p><p className="ds">Check your email to get back to your cart.</p></div></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.
````
