/* ==========================================================================
   FLORES AMARILLAS - ESTILOS DE CARTA & SOBRE INTERACTIVO
   Animación de sobre 3D, sello de cera y despliegue de carta
   ========================================================================== */

.envelope-container {
  position: relative;
  width: 100%;
  max-width: 580px;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
  z-index: 10;
}

/* ==========================================================================
   SOBRE VINTAGE (ENVELOPE)
   ========================================================================== */
.envelope {
  position: relative;
  width: 320px;
  height: 220px;
  background: #ecd9bc;
  border-radius: 8px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 204, 0, 0.2);
  cursor: pointer;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

.envelope:hover {
  transform: translateY(-5px) scale(1.02);
}

.envelope.hidden-opened {
  transform: translateY(80px) scale(0.8);
  opacity: 0;
  pointer-events: none;
}

/* Fondos y Solapas del Sobre */
.envelope-back {
  position: absolute;
  inset: 0;
  background: #d8c2a3;
  border-radius: 8px;
}

.envelope-paper-preview {
  position: absolute;
  top: 10px;
  left: 15px;
  right: 15px;
  height: 180px;
  background: #fffdf7;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.envelope.open .envelope-paper-preview {
  transform: translateY(-100px);
}

.envelope-left {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 110px 0 110px 160px;
  border-color: transparent transparent transparent #e4ceb0;
  border-radius: 8px 0 0 8px;
  z-index: 2;
}

.envelope-right {
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 110px 160px 110px 0;
  border-color: transparent #e4ceb0 transparent transparent;
  border-radius: 0 8px 8px 0;
  z-index: 2;
}

.envelope-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 160px 130px 160px;
  border-color: transparent transparent #ecd9bc transparent;
  border-radius: 0 0 8px 8px;
  z-index: 3;
}

.envelope-top {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 130px 160px 0 160px;
  border-color: #f1dfc5 transparent transparent transparent;
  transform-origin: top center;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), z-index 0.2s ease 0.3s;
  z-index: 4;
}

.envelope.open .envelope-top {
  transform: rotateX(180deg);
  z-index: 1;
}

/* Sello de Cera Dorado / Ámbar */
.wax-seal {
  position: absolute;
  top: -145px;
  left: -24px;
  width: 48px;
  height: 48px;
  background: radial-gradient(circle, #f59e0b 0%, #d97706 70%, #92400e 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff9e6;
  font-size: 1.3rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.4);
  cursor: pointer;
  animation: sealPulse 2s infinite ease-in-out alternate;
  transition: transform 0.3s ease;
}

.wax-seal:hover {
  transform: scale(1.12);
}

@keyframes sealPulse {
  0% { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), 0 0 8px rgba(245, 158, 11, 0.4); }
  100% { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4), 0 0 16px rgba(255, 215, 0, 0.8); }
}

/* ==========================================================================
   HOJA DE LA CARTA (LETTER SHEET)
   ========================================================================== */
.letter-sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  background: #fffef9;
  background-image: radial-gradient(#e5decf 1px, transparent 1px);
  background-size: 16px 16px;
  padding: 2.5rem 2rem;
  border-radius: 16px;
  border: 1px solid #e8dfcf;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 215, 0, 0.2);
  color: #2b231d;
  opacity: 1;
  transform: scale(1) translateY(0);
  transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 20;
}

.letter-sheet.hidden {
  display: none;
  opacity: 0;
  transform: scale(0.85) translateY(40px);
}

.btn-close-letter {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #d4c5b3;
  background: rgba(255, 255, 255, 0.8);
  color: #5c4b3a;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-close-letter:hover {
  background: #f59e0b;
  color: #ffffff;
  border-color: #f59e0b;
  transform: rotate(90deg);
}

.letter-inner-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  text-align: center;
}

.letter-header-decor {
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  opacity: 0.85;
}

.decor-branch.mirror {
  transform: scaleX(-1);
}

.letter-meta-date {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: #92400e;
  font-weight: 700;
}

.letter-greeting {
  font-family: var(--font-serif);
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  color: #3f2a1d;
  line-height: 1.3;
}

.letter-body-text {
  text-align: justify;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  color: #4a3b32;
  min-height: 120px;
}

#typed-text-paragraph {
  white-space: pre-line;
  font-size: 1.02rem;
}

.letter-footer-sign {
  text-align: right;
  margin-top: 1rem;
  border-top: 1px solid #eedec8;
  padding-top: 1rem;
}

.sign-note {
  font-size: 0.9rem;
  color: #786555;
  font-style: italic;
}

.sign-author {
  font-family: var(--font-script);
  font-size: 2.2rem;
  color: #d97706;
  line-height: 1.2;
  margin-top: 0.2rem;
}

.letter-quote {
  background: #fff8e1;
  border-left: 4px solid #f59e0b;
  padding: 0.8rem 1rem;
  border-radius: 0 8px 8px 0;
  font-family: var(--font-handwriting);
  font-size: 1.15rem;
  color: #78350f;
  text-align: center;
  margin-top: 0.5rem;
}

/* Cursor parpadeante para efecto de máquina de escribir */
.typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background-color: #d97706;
  margin-left: 2px;
  vertical-align: middle;
  animation: blinkCursor 0.8s infinite;
}

@keyframes blinkCursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
