/* ==========================================================
   letter.css - Modal Letter, parchment style, typewriter, interactive heart
   ========================================================== */

.letter-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}

.letter-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Parchment Letter Card */
.letter-card {
  position: relative;
  width: min(90vw, 430px);
  max-height: 84vh;
  max-height: 84dvh;
  background: #fdfaf3;
  background-image:
    radial-gradient(#e8dec8 1px, transparent 1px),
    linear-gradient(to bottom, #fffdf8 0%, #f7f1e1 100%);
  background-size:
    20px 20px,
    100% 100%;
  color: #3b2a2a;
  border-radius: 20px;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.7),
    0 0 25px rgba(255, 215, 0, 0.35),
    inset 0 0 40px rgba(230, 205, 170, 0.4);
  border: 2px solid #e2cfb4;
  padding: 28px 24px 24px 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.85);
  opacity: 0;
  transition:
    transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.6s ease;
}

.letter-overlay.active .letter-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Close Button (X) */
.letter-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  color: #6d5454;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.2s;
  outline: none;
  z-index: 10;
}

.letter-close-btn:active {
  background: rgba(0, 0, 0, 0.12);
  transform: scale(0.9);
}

/* Decorative Stamp or Header Ribbon */
.letter-header {
  text-align: center;
  margin-bottom: 16px;
  border-bottom: 1px dashed rgba(160, 120, 80, 0.3);
  padding-bottom: 12px;
}

.letter-stamp {
  display: inline-block;
  font-size: 22px;
  margin-bottom: 4px;
}

.letter-title {
  font-size: 20px;
  font-weight: 700;
  color: #7b2938;
  letter-spacing: 0.5px;
  font-family: "Playfair Display", Georgia, serif;
}

/* Typewriter Content Body */
.letter-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px 12px 2px;
  font-size: 15px;
  line-height: 1.75;
  color: #4a3434;
  font-family:
    "Segoe UI",
    -apple-system,
    sans-serif;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}

/* Custom Scrollbar for Letter */
.letter-body::-webkit-scrollbar {
  width: 4px;
}

.letter-body::-webkit-scrollbar-thumb {
  background: rgba(180, 150, 120, 0.5);
  border-radius: 4px;
}

.typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background-color: #7b2938;
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blinkCursor 0.8s infinite;
}

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

/* Letter Footer & Interactive Heart Button */
.letter-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed rgba(160, 120, 80, 0.3);
}

.letter-heart-btn {
  position: relative;
  width: 58px;
  height: 58px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #ff5e7e 0%, #e63956 100%);
  box-shadow:
    0 6px 20px rgba(230, 57, 86, 0.5),
    0 0 15px rgba(255, 105, 180, 0.4);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  transition:
    transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    box-shadow 0.3s ease;
  animation: heartPulseButton 1.8s ease-in-out infinite;
}

.letter-heart-btn svg {
  width: 28px;
  height: 28px;
  fill: #ffffff;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.letter-heart-btn:active {
  transform: scale(0.92);
}

.letter-heart-btn.clicked {
  animation: heartBurstExpand 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.heart-hint-label {
  margin-top: 6px;
  font-size: 12px;
  color: #8c6a6a;
  letter-spacing: 0.5px;
}

@keyframes heartPulseButton {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
    box-shadow:
      0 8px 25px rgba(230, 57, 86, 0.7),
      0 0 25px rgba(255, 130, 170, 0.6);
  }
}

@keyframes heartBurstExpand {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.35);
    box-shadow: 0 0 45px rgba(255, 90, 130, 1);
  }
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}
