/* =====================================================================
   EFECTO DE ÉXITO  -  E1 "Sello real"  +  E12 "Carnet de paje"
   Se usa con js/exito.js  ->  RMVExito.mostrar({ nombre, regalos, alCerrar })
   ===================================================================== */
.rmv-exito {
  position: fixed; inset: 0; z-index: 1000000;
  display: none; align-items: center; justify-content: center;
  padding: 14px; box-sizing: border-box; overflow-y: auto;
  /* El formulario de detrás se DIFUMINA y se oscurece poco a poco al abrirse (clase .difuminado) */
  background: rgba(5, 9, 26, 0);
  -webkit-backdrop-filter: blur(0px); backdrop-filter: blur(0px);
  transition: background-color .7s ease, -webkit-backdrop-filter .7s ease, backdrop-filter .7s ease;
  font-family: inherit; color: #f5df25;
}
.rmv-exito.abierto { display: flex; }
.rmv-exito.abierto.difuminado { background: rgba(5, 9, 26, .64); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
/* Navegadores que no saben difuminar: se oscurece más para que no se lea lo de detrás */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .rmv-exito.abierto.difuminado { background: rgba(5, 9, 26, .95); }
}
.rmv-escena { position: relative; width: 100%; max-width: 440px; margin: auto; text-align: center; }
.rmv-oculto { display: none !important; }

/* ---------------------------------------------------------------- E1: la carta */
.rmv-carta {
  position: relative; box-sizing: border-box; width: min(100%, 400px); margin: 0 auto;
  padding: clamp(22px, 5vh, 34px) clamp(18px, 5vw, 30px) clamp(64px, 11vh, 96px);
  background: linear-gradient(160deg, #fffaf0, #f2e4bf);
  color: #24304b; border: 1px solid #d8c99f; border-radius: 8px; text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6), 0 0 0 4px rgba(216, 184, 92, .25);
  opacity: 0; transform: translateY(40px) rotate(-1.2deg) scale(.96);
}
.rmv-carta::before {
  content: ''; position: absolute; inset: 8px; pointer-events: none; border-radius: 4px;
  border: 1px solid rgba(177, 139, 45, .45);
}
.rmv-carta-sup { margin: 0 0 8px; font-family: 'Cinzel', Georgia, serif; font-size: clamp(11px, 3vw, 13px); letter-spacing: .22em; text-transform: uppercase; color: #9a741c; }
.rmv-carta-titulo { margin: 0 0 12px; font-family: Georgia, serif; font-size: clamp(21px, 6vw, 27px); line-height: 1.2; color: #24304b; }
.rmv-carta-texto { margin: 0 0 16px; font-family: Georgia, serif; font-size: clamp(15px, 4.2vw, 18px); line-height: 1.5; color: #3d4966; }
.rmv-carta-firma { margin: 0; text-align: left; font-family: Georgia, serif; font-style: italic; font-size: clamp(14px, 3.8vw, 16px); color: #9a741c; }

/* El sello de cera */
.rmv-sello {
  position: absolute; right: clamp(16px, 7%, 36px); bottom: clamp(12px, 3vh, 24px);
  width: clamp(78px, 24vw, 104px); height: clamp(78px, 24vw, 104px);
  opacity: 0; filter: drop-shadow(0 6px 8px rgba(60, 35, 0, .45));
}
.rmv-sello svg { display: block; width: 100%; height: 100%; }

/* Destello y chispas en el golpe */
.rmv-flash {
  position: absolute; right: clamp(16px, 7%, 36px); bottom: clamp(12px, 3vh, 24px);
  width: clamp(78px, 24vw, 104px); height: clamp(78px, 24vw, 104px);
  border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(255, 252, 215, .95) 0%, rgba(255, 223, 90, .55) 35%, rgba(255, 223, 90, 0) 70%);
}
.rmv-chispas { position: absolute; right: clamp(16px, 7%, 36px); bottom: clamp(12px, 3vh, 24px); width: clamp(78px, 24vw, 104px); height: clamp(78px, 24vw, 104px); pointer-events: none; }
.rmv-chispas i { position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; margin: -3.5px; border-radius: 50%; background: #ffe46a; box-shadow: 0 0 8px #ffd34a; opacity: 0; }
.rmv-chispas i:nth-child(1)  { --dx: -86px; --dy: -52px; }  .rmv-chispas i:nth-child(2)  { --dx: -48px; --dy: -92px; }
.rmv-chispas i:nth-child(3)  { --dx:   6px; --dy: -104px; } .rmv-chispas i:nth-child(4)  { --dx:  58px; --dy: -86px; }
.rmv-chispas i:nth-child(5)  { --dx:  96px; --dy: -40px; }  .rmv-chispas i:nth-child(6)  { --dx: -96px; --dy:  10px; }
.rmv-chispas i:nth-child(7)  { --dx:  92px; --dy:  22px; }  .rmv-chispas i:nth-child(8)  { --dx: -64px; --dy:  58px; }
.rmv-chispas i:nth-child(9)  { --dx:  62px; --dy:  60px; }  .rmv-chispas i:nth-child(10) { --dx:  -8px; --dy:  72px; }

.rmv-sellada {
  margin: 18px 0 0; font-family: 'Cinzel', Georgia, serif; font-weight: 700;
  font-size: clamp(20px, 5.6vw, 26px); letter-spacing: .04em; color: #f5df25;
  text-shadow: 0 0 16px rgba(245, 223, 37, .55); opacity: 0;
}
.rmv-continuar-sello { margin-top: 18px; opacity: 0; }

/* Cronología de E1 (se activa con .fase-sello) */
.fase-sello .rmv-carta { animation: rmvCartaEntra .7s cubic-bezier(.2, .8, .2, 1) forwards, rmvGolpe .38s ease-out 1.02s; }
.fase-sello .rmv-sello { animation: rmvEstampar .7s cubic-bezier(.3, 0, .3, 1) .5s forwards; }
.fase-sello .rmv-flash { animation: rmvFlash .65s ease-out 1.02s forwards; }
.fase-sello .rmv-chispas i { animation: rmvChispa .75s ease-out 1.02s forwards; }
.fase-sello .rmv-sellada { animation: rmvAparece .5s ease-out 1.5s forwards; }
.fase-sello .rmv-continuar-sello { animation: rmvAparece .5s ease-out 2.1s forwards; }
.saliendo .rmv-carta { animation: rmvCartaSale .45s ease-in forwards !important; }
.saliendo .rmv-sellada { animation: rmvCartaSale .3s ease-in forwards !important; }

@keyframes rmvCartaEntra { to { opacity: 1; transform: none; } }
@keyframes rmvCartaSale  { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-30px) scale(.94) rotate(1.5deg); } }
@keyframes rmvGolpe { 0%, 100% { transform: none; } 28% { transform: translateY(6px) scale(.99); } 58% { transform: translateY(-2px); } }
@keyframes rmvEstampar {
  0%   { opacity: 0; transform: translateY(-160px) scale(2.1) rotate(-24deg); }
  45%  { opacity: 1; transform: translateY(-34px) scale(1.5) rotate(-8deg); }
  70%  { opacity: 1; transform: translateY(0) scale(.84) rotate(3deg); }
  86%  { opacity: 1; transform: translateY(0) scale(1.08) rotate(-1deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes rmvFlash  { 0% { opacity: 0; transform: scale(.4); } 25% { opacity: 1; } 100% { opacity: 0; transform: scale(3.2); } }
@keyframes rmvChispa { 0% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.2); } }
@keyframes rmvAparece { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- E12: el carnet */
.rmv-carnet-caja { display: none; }
.fase-carnet .rmv-carnet-caja { display: block; animation: rmvCarnetEntra .8s cubic-bezier(.2, .8, .2, 1); }
@keyframes rmvCarnetEntra { from { opacity: 0; transform: translateY(30px) scale(.9) rotate(-2deg); } to { opacity: 1; transform: none; } }
.rmv-carnet-titulo { margin: 0 0 10px; font-family: 'Cinzel', Georgia, serif; font-size: clamp(21px, 6vw, 28px); color: #f5df25; text-shadow: 0 0 16px rgba(245, 223, 37, .5); }
.rmv-carnet-marco {
  position: relative; display: inline-block; max-width: 100%; border-radius: 22px; overflow: hidden;
  box-shadow: 0 0 0 2px rgba(245, 223, 37, .8), 0 0 34px rgba(245, 223, 37, .45), 0 18px 40px rgba(0, 0, 0, .6);
}
.rmv-carnet-marco canvas { display: block; height: clamp(210px, 50vh, 470px); width: auto; max-width: 100%; aspect-ratio: 4 / 5; }
.rmv-carnet-marco::after {                                  /* brillo que cruza el carnet */
  content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .38), transparent); transform: skewX(-18deg);
  animation: rmvBrillo 3.6s ease-in-out 1s infinite;
}
@keyframes rmvBrillo { 0% { left: -60%; } 45%, 100% { left: 150%; } }

.rmv-botones { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.rmv-btn {
  flex: 1 1 140px; min-height: 48px; padding: 10px 14px; border: 0; border-radius: 14px; cursor: pointer;
  font: inherit; font-size: 16px; font-weight: 700; color: #1a1a1a;
  background: linear-gradient(45deg, #f5df25, #ffd700); transition: transform .2s, filter .2s;
}
.rmv-btn:hover { transform: translateY(-1px); filter: brightness(1.07); }
.rmv-btn-sec { background: transparent; color: #f5df25; border: 2px solid rgba(245, 223, 37, .65); }
.rmv-btn-texto { flex-basis: 100%; min-height: 40px; background: none; border: 0; color: #cfd6ee; text-decoration: underline; font-weight: 400; font-size: 15px; }
.rmv-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.rmv-aviso { min-height: 1.4em; margin: 10px 0 0; font-size: 14px; color: #fff6c8; }

/* Texto para lectores de pantalla */
.rmv-solo-voz { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Si el usuario prefiere menos movimiento: todo aparece ya colocado, sin animaciones */
.rmv-exito.sin-mov { transition: none; }
.rmv-exito.sin-mov .rmv-carta { opacity: 1; transform: none; animation: none !important; }
.rmv-exito.sin-mov .rmv-sello { opacity: 1; animation: none !important; }
.rmv-exito.sin-mov .rmv-sellada, .rmv-exito.sin-mov .rmv-continuar-sello { opacity: 1; animation: none !important; }
.rmv-exito.sin-mov .rmv-flash, .rmv-exito.sin-mov .rmv-chispas { display: none; }
.rmv-exito.sin-mov .rmv-carnet-caja { animation: none !important; }
.rmv-exito.sin-mov .rmv-carnet-marco::after { display: none; }

@media (max-height: 560px) { .rmv-carnet-marco canvas { height: clamp(170px, 44vh, 300px); } .rmv-carnet-titulo { margin-bottom: 6px; } }

/* ---------------------------------------------------------------- Compartir: Instagram / X / Facebook */
.rmv-panel {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 2;
  width: min(100%, 460px); box-sizing: border-box; padding: 16px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: #121735; border: 2px solid #f5df25; border-bottom: 0; border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .65), 0 0 28px rgba(245, 223, 37, .3); text-align: center;
  animation: rmvPanelSube .28s ease-out;
}
@keyframes rmvPanelSube { from { transform: translate(-50%, 40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.rmv-panel-titulo { margin: 0 0 12px; font-family: 'Cinzel', Georgia, serif; font-size: 20px; color: #f5df25; }
.rmv-redes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.rmv-red {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 78px; padding: 8px 4px; border: 2px solid rgba(245, 223, 37, .55); border-radius: 16px; cursor: pointer;
  background: #1c2350; color: #fff; font: inherit; font-size: 15px; font-weight: 700; transition: transform .2s, border-color .2s, background .2s;
}
.rmv-red i { font-size: 28px; line-height: 1; }
.rmv-red:hover { transform: translateY(-2px); border-color: #f5df25; }
.rmv-red:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.rmv-red-ig i { color: #ff5fa8; }
.rmv-red-x i  { color: #fff; }
.rmv-red-fb i { color: #5aa0ff; }
.rmv-mas { width: 100%; flex: none; }
.rmv-panel .rmv-aviso { min-height: 1.3em; margin: 8px 0 0; }
.rmv-panel .rmv-btn-texto { width: 100%; }
.rmv-exito.sin-mov .rmv-panel { animation: none; }

/* ---------------------------------------------------------------- ERROR: el pergamino arrugado */
.rmv-err { display: none; position: relative; width: 100%; max-width: 420px; margin: auto; text-align: center; }
.rmv-exito.modo-error .rmv-escena { display: none; }
.rmv-exito.modo-error .rmv-err { display: grid; }
.rmv-err > * { grid-area: 1 / 1; }
.rmv-err-hoja, .rmv-err-msg {
  box-sizing: border-box; width: min(100%, 400px); margin: 0 auto; align-self: center;
  background: linear-gradient(160deg, #fffaf0, #f2e4bf); color: #24304b;
  border: 1px solid #d8c99f; border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6), 0 0 0 4px rgba(216, 184, 92, .25);
}
/* la hoja "escrita" que se va a arrugar */
.rmv-err-hoja { height: clamp(210px, 38vh, 290px); padding: 26px 26px 0; opacity: 0; transform: translateY(40px) rotate(-1.2deg) scale(.96); transform-origin: 50% 55%; }
.rmv-err-hoja i { display: block; height: 7px; margin: 0 0 17px; border-radius: 4px; background: rgba(36, 48, 75, .22); }
.rmv-err-hoja i:nth-child(1) { width: 55%; margin-bottom: 26px; background: rgba(154, 116, 28, .45); }
.rmv-err-hoja i:nth-child(3) { width: 88%; } .rmv-err-hoja i:nth-child(5) { width: 70%; } .rmv-err-hoja i:nth-child(6) { width: 40%; }
/* la bola de papel */
.rmv-err-bola {
  width: clamp(92px, 26vw, 120px); height: clamp(92px, 26vw, 120px); border-radius: 46% 54% 50% 50% / 52% 46% 54% 48%;
  align-self: center; justify-self: center; opacity: 0; transform: scale(.2);
  background:
    linear-gradient(35deg, transparent 46%, rgba(120, 90, 30, .35) 48%, transparent 51%),
    linear-gradient(-30deg, transparent 40%, rgba(120, 90, 30, .3) 43%, transparent 46%),
    linear-gradient(110deg, transparent 55%, rgba(120, 90, 30, .28) 57%, transparent 60%),
    radial-gradient(circle at 32% 28%, #fffaf0, #e8d5a2 55%, #b89a56);
  box-shadow: 0 14px 22px rgba(0, 0, 0, .55), inset -6px -8px 14px rgba(110, 80, 20, .35);
}
/* el pergamino con el aviso */
.rmv-err-msg { padding: clamp(22px, 5vh, 32px) clamp(18px, 5vw, 28px) clamp(20px, 4vh, 26px); visibility: hidden; opacity: 0; transform: translateY(26px) scale(.97); }
.rmv-err-pista { margin: 0 0 16px; font-family: Georgia, serif; font-style: italic; font-size: clamp(14px, 3.8vw, 16px); color: #9a741c; }

.rmv-exito.err-hoja .rmv-err-hoja { animation: rmvErrEntra .5s ease-out forwards; }
.rmv-exito.err-arruga .rmv-err-hoja { animation: rmvErrArruga .75s cubic-bezier(.5, 0, .8, .4) forwards; }
.rmv-exito.err-arruga .rmv-err-bola { animation: rmvErrBola .75s ease-in forwards; }
.rmv-exito.err-rueda .rmv-err-bola { animation: rmvErrRueda .8s cubic-bezier(.45, 0, .9, .6) forwards; }
.rmv-exito.err-msg .rmv-err-hoja, .rmv-exito.err-msg .rmv-err-bola { display: none; }
.rmv-exito.err-msg .rmv-err-msg { visibility: visible; animation: rmvErrMsg .55s ease-out forwards; }
@keyframes rmvErrEntra { to { opacity: 1; transform: none; } }
@keyframes rmvErrArruga {
  0%   { opacity: 1; transform: none; border-radius: 8px; }
  35%  { opacity: 1; transform: scale(.85, .6) rotate(6deg); border-radius: 18px; }
  100% { opacity: 0; transform: scale(.12) rotate(70deg); border-radius: 50%; }
}
@keyframes rmvErrBola { 0% { opacity: 0; transform: scale(.2) rotate(0); } 55% { opacity: 1; } 100% { opacity: 1; transform: scale(1) rotate(25deg); } }
@keyframes rmvErrRueda { from { opacity: 1; transform: scale(1) rotate(25deg); } to { opacity: 1; transform: translate(120vw, 18vh) rotate(760deg); } }
@keyframes rmvErrMsg { to { opacity: 1; transform: none; } }
.rmv-exito.sin-mov .rmv-err-msg { visibility: visible; opacity: 1; transform: none; animation: none !important; }
.rmv-exito.sin-mov .rmv-err-hoja, .rmv-exito.sin-mov .rmv-err-bola { display: none; }
