/* ===== WELCOME LETTER POPUP ===== */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Pacifico&display=swap');

/* ---- Overlay backdrop ---- */
#welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 1;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#welcome-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* Now displayed on mobile */


/* ---- Floating hearts background ---- */
.letter-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99998;
  overflow: hidden;
  transition: opacity 0.5s ease;
}

/* Hearts now displayed on mobile */

.letter-hearts.hidden {
  opacity: 0;
}


.letter-hearts span {
  position: absolute;
  bottom: -60px;
  font-size: 1.4rem;
  opacity: 0;
  animation: floatUp linear infinite;
}

.letter-hearts span:nth-child(1)  { left: 5%;  animation-duration: 6s;  animation-delay: 0.2s; font-size: 1.1rem; }
.letter-hearts span:nth-child(2)  { left: 15%; animation-duration: 8s;  animation-delay: 1.1s; font-size: 1.6rem; }
.letter-hearts span:nth-child(3)  { left: 25%; animation-duration: 7s;  animation-delay: 0.5s; font-size: 1.0rem; }
.letter-hearts span:nth-child(4)  { left: 38%; animation-duration: 5s;  animation-delay: 2.0s; font-size: 1.3rem; }
.letter-hearts span:nth-child(5)  { left: 50%; animation-duration: 9s;  animation-delay: 0.8s; font-size: 1.5rem; }
.letter-hearts span:nth-child(6)  { left: 62%; animation-duration: 6.5s;animation-delay: 1.5s; font-size: 1.2rem; }
.letter-hearts span:nth-child(7)  { left: 72%; animation-duration: 7.5s;animation-delay: 0.3s; font-size: 1.0rem; }
.letter-hearts span:nth-child(8)  { left: 82%; animation-duration: 8s;  animation-delay: 1.8s; font-size: 1.4rem; }
.letter-hearts span:nth-child(9)  { left: 90%; animation-duration: 5.5s;animation-delay: 0.6s; font-size: 1.1rem; }
.letter-hearts span:nth-child(10) { left: 47%; animation-duration: 7s;  animation-delay: 2.5s; font-size: 1.3rem; }

@keyframes floatUp {
  0%   { transform: translateY(0) rotate(0deg);   opacity: 0; }
  10%  { opacity: 0.9; }
  90%  { opacity: 0.5; }
  100% { transform: translateY(-110vh) rotate(25deg); opacity: 0; }
}

/* ---- Letter card ---- */
#welcome-letter {
  position: relative;
  background: linear-gradient(145deg, #fff0f8 0%, #fff5fb 40%, #fce4f5 100%);
  border: 3px dashed #f7a8d0;
  border-radius: 28px;
  max-width: 460px;
  width: 100%;
  padding: 0;
  box-shadow:
    0 20px 60px rgba(247, 100, 180, 0.25),
    0 4px 24px rgba(0,0,0,0.12),
    inset 0 1px 0 rgba(255,255,255,0.9);
  animation: letterPop 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  font-family: 'Nunito', sans-serif;
  overflow: hidden;
}

@keyframes letterPop {
  0%   { transform: scale(0.4) rotate(-8deg); opacity: 0; }
  60%  { transform: scale(1.06) rotate(1deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ---- Header strip ---- */
.letter-header {
  background: linear-gradient(90deg, #ff85c1, #ff6eb0, #f97fc0);
  padding: 14px 22px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 24px 24px 0 0;
  position: relative;
  overflow: hidden;
}

.letter-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  animation: sheen 3s infinite;
}

@keyframes sheen {
  0%   { transform: skewX(-20deg) translateX(-120%); }
  100% { transform: skewX(-20deg) translateX(220%); }
}

.letter-brand {
  font-family: 'Pacifico', cursive;
  color: #fff;
  font-size: 1.05rem;
  text-shadow: 0 2px 6px rgba(0,0,0,0.2);
  letter-spacing: 0.5px;
}

.letter-brand .wave-emoji {
  display: inline-block;
  animation: wave 1.4s ease-in-out infinite;
  transform-origin: 70% 70%;
}

@keyframes wave {
  0%,100% { transform: rotate(0deg); }
  30%      { transform: rotate(20deg); }
  60%      { transform: rotate(-10deg); }
  80%      { transform: rotate(15deg); }
}

.letter-dots {
  display: flex;
  gap: 6px;
}

.letter-dots span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  display: block;
}

.letter-dots span:nth-child(1) { background: #ff5c5c; }
.letter-dots span:nth-child(2) { background: #ffbd2e; }
.letter-dots span:nth-child(3) { background: #28c840; }

/* ---- Body ---- */
.letter-body {
  padding: 28px 30px 24px;
  text-align: center;
  position: relative;
}

/* Decorative confetti dots */
.letter-body::before {
  content: '✿ ✿';
  position: absolute;
  top: 10px;
  left: 22px;
  font-size: 0.75rem;
  color: #fbb6ce;
  opacity: 0.6;
}

.letter-body::after {
  content: '✿ ✿';
  position: absolute;
  top: 10px;
  right: 22px;
  font-size: 0.75rem;
  color: #fbb6ce;
  opacity: 0.6;
}

/* Big emoji icon */
.letter-icon {
  font-size: 3.2rem;
  display: block;
  margin-bottom: 10px;
  animation: iconBounce 2s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(247,100,180,0.35));
}

@keyframes iconBounce {
  0%,100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-8px) scale(1.08); }
}

/* Quote text */
.letter-quote {
  font-family: 'Pacifico', cursive;
  font-size: 1.18rem;
  color: #bd1d6e; /* Darker pink for better contrast (WCAG) */
  line-height: 1.6;
  margin: 0 0 12px;
  text-shadow: 0 1px 3px rgba(214,51,132,0.15);
}

/* Sub text */
.letter-sub {
  font-size: 0.9rem;
  color: #7a4d61; /* Darker for accessibility */
  line-height: 1.7;
  margin: 0 0 22px;
  padding: 10px 14px;
  background: rgba(255,179,215,0.2);
  border-radius: 14px;
  border-left: 3px solid #f7a8d0;
  text-align: left;
}

/* Author sig */
.letter-author {
  font-size: 0.82rem;
  color: #a04070;
  font-style: italic;
  margin-bottom: 20px;
}

/* ---- Progress bar ---- */
.letter-progress-wrap {
  background: rgba(247,168,208,0.25);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 18px;
}

.letter-progress-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff85c1, #f06292);
  border-radius: 99px;
  animation: shrinkBar 30s linear forwards;
  transform-origin: left;
}

@keyframes shrinkBar {
  from { width: 100%; }
  to   { width: 0%; }
}

/* ---- Action buttons ---- */
.letter-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-close-letter {
  background: linear-gradient(135deg, #ff85c1, #f06292);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 10px 28px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(240,98,146,0.4);
  transition: all 0.25s ease;
  letter-spacing: 0.3px;
}

.btn-close-letter:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 8px 24px rgba(240,98,146,0.55);
  background: linear-gradient(135deg, #f06292, #ec407a);
}

.btn-close-letter:active {
  transform: scale(0.97);
}

.btn-next-quote {
  background: transparent;
  color: #d63384;
  border: 2px solid #f7a8d0;
  border-radius: 50px;
  padding: 9px 20px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-next-quote:hover {
  background: rgba(247,168,208,0.2);
  border-color: #d63384;
  transform: translateY(-2px);
}

/* ---- Sticker corner decorations ---- */
.letter-sticker {
  position: absolute;
  font-size: 1.6rem;
  pointer-events: none;
  animation: stickerWiggle 3s ease-in-out infinite;
}

.letter-sticker-tl { top: -18px; left: -12px; transform: rotate(-20deg); animation-delay: 0s; }
.letter-sticker-tr { top: -18px; right: -12px; transform: rotate(20deg); animation-delay: 0.8s; }
.letter-sticker-bl { bottom: -16px; left: -10px; transform: rotate(15deg); animation-delay: 1.4s; }
.letter-sticker-br { bottom: -16px; right: -10px; transform: rotate(-15deg); animation-delay: 0.4s; }

@keyframes stickerWiggle {
  0%,100% { transform: rotate(var(--r, -20deg)) scale(1); }
  50%      { transform: rotate(var(--r, -20deg)) scale(1.18); }
}

/* ---- Footer strip ---- */
.letter-footer {
  background: linear-gradient(90deg, #fce4f5, #ffdcf0);
  padding: 10px 22px;
  border-radius: 0 0 24px 24px;
  text-align: center;
  font-size: 0.78rem;
  color: #a04070;
  letter-spacing: 0.5px;
}

/* ---- Reactions Bar ---- */
.letter-reactions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 15px 0 20px;
  flex-wrap: wrap;
}

.reaction-btn {
  background: white;
  border: 1px solid #f9daeb;
  border-radius: 12px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 3px 10px rgba(247, 168, 208, 0.15);
  position: relative;
  overflow: visible;
  min-width: 50px;
}

.reaction-burst {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 4;
}

.reaction-burst span {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 13px;
  animation: reactionBurst 0.62s ease-out forwards;
  animation-delay: var(--delay, 0ms);
}

@keyframes reactionBurst {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(var(--angle)) translateX(0) scale(0.8);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--angle)) translateX(var(--distance)) scale(0.35);
  }
}

.reaction-btn:hover {
  transform: translateY(-4px) scale(1.05);
  border-color: #ff85c1;
  box-shadow: 0 6px 15px rgba(247, 168, 208, 0.3);
}

.reaction-btn:active {
  transform: scale(0.95);
}

.reaction-icon {
  font-size: 1.4rem;
}

.reaction-count {
  font-size: 0.75rem;
  font-weight: 800;
  color: #bd1d6e;
  transition: color 0.2s ease;
}

/* Active state for reactions */
.reaction-btn.active {
  background: #ff85c1;
  border-color: #f06292;
  box-shadow: 0 4px 15px rgba(240, 98, 146, 0.4);
  transform: translateY(-2px);
}

.reaction-btn.active .reaction-count {
  color: #ffffff;
}

.reaction-btn.active .reaction-icon {
  filter: drop-shadow(0 0 5px rgba(255,255,255,0.8));
}

/* Floating emoji animation */
@keyframes floatReaction {
  0% { transform: translateY(0) scale(1) rotate(0); opacity: 1; }
  100% { transform: translateY(-100px) scale(1.5) rotate(15deg); opacity: 0; }
}

.floating-reaction {
  position: absolute;
  top: 0;
  pointer-events: none;
  font-size: 1.5rem;
  z-index: 10;
  animation: floatReaction 1s ease-out forwards;
}

/* ---- Responsive & UX Improvements ---- */
@media (max-width: 480px) {
  #welcome-overlay {
    padding: 15px; /* Less padding to allow larger card */
  }

  #welcome-letter {
    border-radius: 20px;
    border-width: 2px;
    width: 95%; /* Occupy more width on very small screens */
  }

  .letter-header {
    padding: 10px 18px 8px;
  }

  .letter-brand {
    font-size: 0.95rem;
  }

  .letter-body {
    padding: 20px 18px 16px;
  }

  .letter-icon {
    font-size: 2.8rem;
    margin-bottom: 8px;
  }

  .letter-quote {
    font-size: 1rem;
    margin-bottom: 10px;
  }

  .letter-sub {
    font-size: 0.85rem;
    padding: 8px 12px;
    margin-bottom: 18px;
    line-height: 1.6;
  }

  .letter-author {
    font-size: 0.78rem;
    margin-bottom: 16px;
  }

  .letter-actions {
    flex-direction: column; /* Stack buttons vertically for better tap targets */
    gap: 10px;
    width: 100%;
  }

  .btn-close-letter, .btn-next-quote {
    width: 100%;
    padding: 12px 20px; /* Larger tap target */
    font-size: 0.95rem;
  }

  /* Shrink stickers on mobile so they don't crowd the content */
  .letter-sticker {
    font-size: 1.2rem;
  }
  .letter-sticker-tl { top: -14px; left: -8px; }
  .letter-sticker-tr { top: -14px; right: -8px; }
  .letter-sticker-bl { bottom: -12px; left: -6px; }
  .letter-sticker-br { bottom: -12px; right: -6px; }

  .letter-reactions {
    gap: 6px;
    margin: 12px 0 16px;
  }

  .reaction-btn {
    min-width: 46px;
    padding: 6px 9px;
  }

  .reaction-icon {
    font-size: 1.2rem;
  }

  .letter-footer {
    font-size: 0.72rem;
    padding: 8px 15px;
  }
}

@media (max-width: 360px) {
  #welcome-overlay {
    padding: 10px;
  }

  .letter-body {
    padding: 16px 14px 14px;
  }

  .letter-sub {
    max-height: 132px;
    overflow-y: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .letter-hearts,
  .reaction-burst,
  .floating-reaction {
    display: none !important;
  }
}

/* Touch device specific adjustments */
@media (hover: none) {
  .btn-close-letter:hover, .btn-next-quote:hover {
    transform: none; /* Disable hover scale on touch devices as it can feel sticky */
  }
  .btn-close-letter:active, .btn-next-quote:active {
    transform: scale(0.96);
    background: rgba(240, 98, 146, 0.9);
  }
}
