/* ============================================================
   ENVELOPE.CSS — Escena del sobre y animacion de apertura
   ============================================================ */

/* ── RESET & BASE ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0c1a;
  --envelope:  #f5ead8;
  --flap:      #e8d5b0;
  --folds:     #ddc89a;
  --seal:      #8b1a1a;
  --gold:      #c9a96e;
  --card-bg:   #fffdf7;
  --card-text: #2c1a0e;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Georgia', serif;
  -webkit-font-smoothing: antialiased;
}

/* ── ESCENA: centrada, simula telefono ─────────────────────── */
#scene {
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Estrellas de fondo */
#scene::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 75% 15%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 45% 70%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 85% 55%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 10% 80%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 60% 45%, rgba(201,169,110,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 55%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(2px 2px at 90% 85%, rgba(201,169,110,0.3) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* Texto "toca para abrir" */
#hint {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(201,169,110,0.7);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  z-index: 10;
  animation: hintPulse 2.5s ease-in-out infinite;
}

/* ── SOBRE (ENVELOPE) ──────────────────────────────────────── */
#envelope-wrap {
  position: relative;
  width: 320px;
  height: 210px;
  z-index: 5;
  cursor: pointer;
  background: #f5e6c8;
  border-radius: 4px;
  animation: floatEnvelope 4s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}

/* ── IMAGEN COMPLETA DEL SOBRE ─────────────────────────── */
#envelope-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: 4px;
  z-index: 1;
  background: transparent;
}

/* ── SOLAPA / FLAP (imagen animada) ─────────────────────── */
#flap-wrap {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 220px;
  z-index: 6;
  perspective: 800px;
  perspective-origin: 50% 0%;
}

#flap {
  position: absolute;
  top: 0; left: 0;
  width: 320px;
  height: 220px;
  object-fit: fill;
  background: transparent;
  transform-origin: top center;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

/* Estado abierto del flap */
#flap.open {
  transform: rotateX(-175deg);
}

/* ── SELLO DE CERA ────────────────────────────────────── */
#seal {
  position: absolute;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  z-index: 8;
  cursor: pointer;
  transition: transform 0.3s ease, opacity 0.4s ease;
  user-select: none;
  /* Sombra elegante alrededor de la imagen */
  box-shadow:
    0 4px 16px rgba(0,0,0,0.5),
    0 0 0 2px rgba(201,169,110,0.4);
  -webkit-tap-highlight-color: transparent;
}

#seal-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Si la imagen no carga o tiene areas transparentes, fondo negro al 25% */
  background: rgba(0, 0, 0, 0.25);
}

#seal:active {
  transform: translateX(-50%) scale(0.92);
}

#seal.hidden {
  opacity: 0;
  transform: translateX(-50%) scale(0.5);
  pointer-events: none;
}

/* ── ANIMACIONES ───────────────────────────────────────────── */
@keyframes floatEnvelope {
  0%, 100% { transform: translateY(0px);   }
  50%       { transform: translateY(-10px); }
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1;   }
}

@keyframes sealShake {
  0%, 100% { transform: translateX(-50%) rotate(0deg);   }
  20%       { transform: translateX(-50%) rotate(-4deg);  }
  40%       { transform: translateX(-50%) rotate(4deg);   }
  60%       { transform: translateX(-50%) rotate(-3deg);  }
  80%       { transform: translateX(-50%) rotate(3deg);   }
}

.seal-shake { animation: sealShake 0.4s ease !important; }
