/* ════════════════════════════════
   LETTER — 플로팅 편지 버튼 & 모달
   ════════════════════════════════ */

/* ── 플로팅 버튼 ── */
#letterBtn {
  position: fixed;
  bottom: 28px;
  right: 24px;
  z-index: 9999;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 210, 200, 0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2px solid rgba(255, 150, 130, 0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 24px rgba(255, 100, 80, 0.22),
    0 0 0 0 rgba(255, 130, 110, 0.4);
  user-select: none;
  animation: letterHeartbeat 1.6s ease-in-out infinite;
}

/* 두근두근 심장 박동 */
@keyframes letterHeartbeat {
  0%   { transform: scale(1);    box-shadow: 0 4px 24px rgba(255,100,80,0.22), 0 0 0 0   rgba(255,130,110,0.45); }
  14%  { transform: scale(1.13); box-shadow: 0 6px 28px rgba(255,100,80,0.32), 0 0 0 8px rgba(255,130,110,0.15); }
  28%  { transform: scale(1);    box-shadow: 0 4px 24px rgba(255,100,80,0.22), 0 0 0 10px rgba(255,130,110,0); }
  42%  { transform: scale(1.08); box-shadow: 0 5px 26px rgba(255,100,80,0.28), 0 0 0 0   rgba(255,130,110,0.3); }
  56%  { transform: scale(1);    box-shadow: 0 4px 24px rgba(255,100,80,0.22), 0 0 0 6px rgba(255,130,110,0); }
  100% { transform: scale(1);    box-shadow: 0 4px 24px rgba(255,100,80,0.22), 0 0 0 0   rgba(255,130,110,0); }
}

#letterBtn:hover {
  animation: none;
  transform: scale(1.12);
  box-shadow: 0 8px 32px rgba(255, 100, 80, 0.38);
}

#letterBtn:active {
  animation: none;
  transform: scale(0.92);
}

.letter-envelope {
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(255,100,80,0.35));
}

/* 읽지 않은 알림 점 */
.letter-dot {
  position: absolute;
  top: 11px;
  right: 11px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ff5566;
  border: 2px solid #fff;
  animation: dotPulse 1.8s ease-in-out infinite;
}

#letterBtn.unread .letter-dot { display: block; }

@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.3); opacity: 0.7; }
}

/* ── 모달 오버레이 ── */
#letterModal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#letterModal.open {
  opacity: 1;
  pointer-events: all;
}

.lm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 8, 16, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ── 편지지 ── */
.lm-paper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  max-height: 88dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fffdf8;
  border-radius: 28px 28px 0 0;
  padding: 32px 28px 48px;

  /* 편지지 줄 배경 */
  background-image:
    linear-gradient(rgba(244, 160, 176, 0.12) 1px, transparent 1px);
  background-size: 100% 2.4em;
  background-position: 0 72px;

  transform: translateY(100%);
  transition: transform 0.42s cubic-bezier(0.32, 0.72, 0, 1);

  box-shadow: 0 -8px 48px rgba(60, 20, 40, 0.18);
}

#letterModal.open .lm-paper {
  transform: translateY(0);
}

/* 닫기 */
.lm-close {
  position: absolute;
  top: 18px;
  right: 20px;
  background: rgba(60,20,40,0.07);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.lm-close:hover { background: rgba(60,20,40,0.12); }

/* 상단 */
.lm-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px dashed rgba(244,160,176,0.4);
}

.lm-stamp {
  font-size: 32px;
  filter: drop-shadow(0 2px 8px rgba(244,160,176,0.4));
}

.lm-to {
  font-family: 'Noto Serif KR', serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--rose-dk);
  letter-spacing: 0.05em;
}

/* 본문 */
.lm-body {
  font-family: 'Noto Serif KR', serif;
  font-size: 14.5px;
  color: #4a3040;
  line-height: 2.4em;
  font-weight: 300;
}

.lm-body p {
  margin-bottom: 1.6em;
}

.lm-body p:last-child {
  margin-bottom: 0;
}

/* 하단 서명 */
.lm-bottom {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px dashed rgba(244,160,176,0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lm-sig {
  font-family: 'Playfair Display', serif;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  font-style: italic;
}

.lm-sig em {
  color: var(--rose-dk);
  font-style: italic;
}

.lm-hearts {
  font-size: 22px;
  animation: heartBeat 1.4s ease-in-out infinite;
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  14%       { transform: scale(1.25); }
  28%       { transform: scale(1); }
  42%       { transform: scale(1.15); }
  56%       { transform: scale(1); }
}
