/* El sobre de Con un Abrazo (compartido por la invitación, la galería y el editor).
   Sus colores y formas llegan como variables en el atributo style (ver envelopeStyle en render.ts). */
:root {
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .2 0 0 0 0 .16 0 0 0 0 .12 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.envelope { position: relative; width: 100%; aspect-ratio: 380 / 260; perspective: 1400px; cursor: pointer; container-type: inline-size;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)) drop-shadow(0 18px 22px rgba(0,0,0,.45)); transition: transform .8s ease, opacity .6s ease; }
.env3d { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.3,.6,.2,1); }
.envelope.front .env3d { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; transform-style: preserve-3d; }
.face-front { transform: rotateY(180deg); border-radius: 4px; overflow: hidden; background: radial-gradient(ellipse at 30% 20%, var(--env-l), var(--env) 55%, var(--env-d) 130%); }
.ppr { position: absolute; }
/* Textura de papel de algodón real (ambientCG, CC0) multiplicada sobre el color del sobre. */
.ppr::after { content: ""; position: absolute; inset: 0; background: url("/img/papel-algodon.webp") 0 0 / 220px; mix-blend-mode: multiply; opacity: .9; pointer-events: none; }
.b-inside { inset: 0; border-radius: 4px; background: var(--env-d); overflow: hidden; }
.b-inside .liner { position: absolute; inset: 0 6% 30%; border-radius: 0 0 2px 2px; background: var(--liner); }
.b-sides { position: absolute; inset: 0; filter: drop-shadow(0 0 1.5px rgba(0,0,0,.18)); }
.b-left, .b-right { inset: 0; border-radius: 4px; }
.b-left { background: linear-gradient(90deg, var(--env) 0%, var(--env-l) 46%); clip-path: polygon(0 0, 47% 54%, 0 100%); }
.b-right { background: linear-gradient(270deg, var(--env) 0%, var(--env-l) 46%); clip-path: polygon(100% 0, 53% 54%, 100% 100%); }
.b-bottom-wrap { position: absolute; inset: 0; filter: drop-shadow(0 -1.5px 2px rgba(0,0,0,.2)); }
.b-bottom { inset: 0; border-radius: 4px; background: linear-gradient(0deg, var(--env) 0%, var(--env) 35%, var(--env-l) 100%); clip-path: polygon(0 100%, 0 97%, 50% 45%, 100% 97%, 100% 100%); }
.flap { position: absolute; left: 0; right: 0; top: 0; height: var(--flap-h); z-index: 4; transform-origin: top center; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3,.6,.3,1), z-index 0s linear .35s; }
.fo-wrap, .flap-in { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.fo-wrap { filter: drop-shadow(0 2px 2.5px rgba(0,0,0,.25)); }
.flap-out { inset: 0; background: linear-gradient(180deg, var(--env-l) 0%, var(--env) 70%, var(--env-d) 100%); -webkit-mask: var(--mask) 0 0/100% 100% no-repeat; mask: var(--mask) 0 0/100% 100% no-repeat; }
.flap-in { transform: rotateX(180deg); background: linear-gradient(0deg, var(--env-l), var(--env)); -webkit-mask: var(--mask-in) 0 0/100% 100% no-repeat; mask: var(--mask-in) 0 0/100% 100% no-repeat; }
.flap-liner { position: absolute; inset: 0; background: var(--liner); -webkit-mask: var(--mask-liner) 0 0/100% 100% no-repeat; mask: var(--mask-liner) 0 0/100% 100% no-repeat; }
.envelope.open .flap { transform: rotateX(180deg); z-index: 1; }
.seal { position: absolute; z-index: 5; left: 50%; top: var(--seal-top); width: 20.5cqw; height: 20.5cqw; transform: translate(-50%, -50%) rotate(3deg); cursor: pointer; border: 0; padding: 0; background: none;
  filter: drop-shadow(0 2px 2px rgba(30,20,15,.4)); transition: opacity .35s ease, transform .35s ease; }
.seal svg { width: 100%; height: 100%; display: block; overflow: visible; }
button.seal:hover { transform: translate(-50%, -50%) rotate(3deg) scale(1.05); }
.envelope.open .seal { opacity: 0; pointer-events: none; transform: translate(-50%, -30%) scale(.7); }

/* Sello interactivo: entero hasta que se rompe; entonces sus dos mitades se separan y caen. */
button.seal .whole, button.seal .half { position: absolute; inset: 0; }
button.seal .half { display: none; }
button.seal .half.l { clip-path: polygon(-10% -10%, 53% -10%, 47% 20%, 56% 38%, 45% 57%, 54% 76%, 47% 110%, -10% 110%); }
button.seal .half.r { clip-path: polygon(53% -10%, 110% -10%, 110% 110%, 47% 110%, 54% 76%, 45% 57%, 56% 38%, 47% 20%); }
.envelope.open button.seal { opacity: 1; transform: translate(-50%, -50%) rotate(3deg); transition: none; }
.envelope.open button.seal .whole { visibility: hidden; }
.envelope.open button.seal .half { display: block; }
.envelope.open button.seal .half.l { animation: crack-l 1s cubic-bezier(.45,0,.7,.4) forwards; }
.envelope.open button.seal .half.r { animation: crack-r 1s cubic-bezier(.45,0,.7,.4) forwards; }
@keyframes crack-l { 0% { transform: none; opacity: 1; } 18% { transform: translate(-4%, 1%) rotate(-4deg); opacity: 1; } 100% { transform: translate(-26%, 55%) rotate(-24deg); opacity: 0; } }
@keyframes crack-r { 0% { transform: none; opacity: 1; } 18% { transform: translate(4%, 1%) rotate(5deg); opacity: 1; } 100% { transform: translate(24%, 60%) rotate(28deg); opacity: 0; } }
/* La solapa espera a que el sello se rompa antes de abrirse. */
.envelope.open:has(button.seal) .flap { transition-delay: .3s, .65s; }

/* Con el reverso a la vista, el sello "respira" para invitar a tocarlo; y se mueve si tocan el sobre en otro lado. */
button.seal::after { content: ""; position: absolute; inset: 6%; border-radius: 50%; pointer-events: none; opacity: 0; box-shadow: 0 0 0 0 rgba(255,244,225,.55); }
.envelope:not(.front):not(.open) button.seal::after { animation: seal-call 2.8s ease-out 1.2s infinite; }
@keyframes seal-call { 0% { opacity: .9; box-shadow: 0 0 0 0 rgba(255,244,225,.5); } 70%, 100% { opacity: 0; box-shadow: 0 0 0 4.5cqw rgba(255,244,225,0); } }
button.seal.nudge { animation: seal-nudge .5s ease; }
@keyframes seal-nudge { 0%, 100% { transform: translate(-50%, -50%) rotate(3deg); } 25% { transform: translate(-50%, -50%) rotate(-5deg) scale(1.06); } 60% { transform: translate(-50%, -50%) rotate(8deg) scale(1.04); } }
@media (prefers-reduced-motion: reduce) {
  .envelope.open button.seal .half, button.seal::after { display: none; animation: none; }
  button.seal.nudge { animation: none; }
}
/* La tarjeta dentro del sobre: asoma al abrir la solapa y sale hacia arriba (.out). */
.b-sides, .b-bottom-wrap { z-index: 3; }
.letter { position: absolute; z-index: 2; left: 7%; right: 7%; top: 5%; bottom: 4%; background: #FFFEFB; border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform 1.1s cubic-bezier(.25,.7,.2,1); }
.letter::after { content: ""; position: absolute; inset: 0; background: url("/img/papel-liso.webp") 0 0 / 200px; mix-blend-mode: multiply; pointer-events: none; }
.letter-in { display: flex; flex-direction: column; align-items: center; gap: 1.6cqw; padding: 7cqw 6% 0; text-align: center; }
.letter .l-eyebrow { font-family: var(--fb, "Figtree", sans-serif); font-size: 2.5cqw; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: #6B5E64; }
.letter b { font-family: var(--fd, "Bodoni Moda", serif); font-weight: 400; font-size: 7.6cqw; line-height: 1.1; color: var(--ac, #2A2226); }
.envelope.out .letter { transform: translateY(-62%); }
.f-addr { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); padding: 0 8%; text-align: center; font-family: "Pinyon Script", cursive; font-size: 9cqw; line-height: 1.1; color: var(--addr); }

/* Estampilla en el frente del sobre: papel blanco con orilla perforada y el arte de la plantilla. */
.f-stamp { position: absolute; top: 8%; right: 6%; width: 15cqw; aspect-ratio: 4 / 5; padding: 1.1cqw; background: #FDFBF6;
  transform: rotate(2.5deg); box-shadow: 0 .2cqw .5cqw rgba(0,0,0,.18); }
/* Perforaciones: círculos del color del sobre solo en la orilla. */
.f-stamp::before { content: ""; position: absolute; inset: -.45cqw; padding: .9cqw; pointer-events: none;
  background: radial-gradient(circle, var(--env) .42cqw, transparent .46cqw) 0 0 / 1.25cqw 1.25cqw;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); }
.f-stamp-art { display: block; width: 100%; height: 100%; background: #FDFBF6 center / 150% no-repeat; background-blend-mode: multiply;
  box-shadow: inset 0 0 0 .15cqw rgba(60,45,35,.25); }
.f-stamp-art.paint { background-size: cover; background-blend-mode: normal; }
.f-stamp-art.seal { display: grid; place-items: center; background: #F4EEE2; }
.f-stamp-art.seal svg { width: 75%; height: auto; }
