/* ==========================================================================
   CSS CHO TRANG LỜI CHÚC 20/10
   Tone màu: Hồng pastel & Trắng tinh tế
   Tương thích 100% với iOS Safari (iPhone), Android và Desktop
   ========================================================================== */

:root {
  /* Bảng màu chủ đạo: Hồng & Trắng */
  --bg-page: #FFF8F9;
  --bg-card: #FFFFFF;
  --bg-card-subtle: #FFF0F3;
  --bg-accent-soft: #FDE2E7;

  --border-light: #FCE4E9;
  --border-medium: #F7CAD4;
  --border-active: #E86380;

  --text-main: #2D2327;
  --text-muted: #6B5B63;
  --text-subtle: #9E8A93;

  --pink-primary: #E86380;
  --pink-hover: #D44B69;
  --pink-soft: #F472B6;
  --pink-glow: rgba(232, 99, 128, 0.22);

  --shadow-sm: 0 4px 14px rgba(232, 99, 128, 0.06);
  --shadow-md: 0 10px 30px rgba(232, 99, 128, 0.1);
  --shadow-lg: 0 18px 45px rgba(232, 99, 128, 0.14);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-full: 9999px;

  --font-main: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  --font-display: 'Outfit', 'Be Vietnam Pro', system-ui, sans-serif;

  --transition: 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-main);
  line-height: 1.65;
  min-height: 100vh;
  position: relative;
  padding-bottom: 60px;
  -webkit-font-smoothing: antialiased;
}

/* ==================== MÀN HÌNH BÌA THƯ MỞ ĐẦU (ENVELOPE INTRO) ==================== */
.envelope-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(255, 248, 249, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.5s;
}

.envelope-overlay.opened {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.envelope-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 45px rgba(232, 99, 128, 0.16);
  padding: 36px 24px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  position: relative;
  cursor: pointer;
  transform: translateY(0);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.envelope-overlay.opened .envelope-card {
  transform: translateY(-20px) scale(0.96);
}

.envelope-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--pink-primary);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-medium);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 16px;
}

.envelope-avatar {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFF0F3 0%, #FDE2E7 100%);
  border: 2px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 16px;
  box-shadow: 0 6px 18px rgba(232, 99, 128, 0.18);
  animation: pulseHeart 2s infinite ease-in-out;
}

@keyframes pulseHeart {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.envelope-recipient {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 8px;
}

.envelope-hint {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 22px;
}

.btn-open-envelope {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--pink-primary);
  color: #FFFFFF;
  border: none;
  font-family: var(--font-main);
  font-size: 0.94rem;
  font-weight: 700;
  padding: 12px 30px;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 6px 20px var(--pink-glow);
  transition: all var(--transition);
  outline: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-open-envelope:hover {
  background: var(--pink-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(232, 99, 128, 0.35);
}

/* ==================== HIỆU ỨNG CÁNH HOA BAY ==================== */
#petalsCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ==================== NÚT NHẠC NỀN GÓC MÀN HÌNH (CHUẨN FIXED CHO IOS) ==================== */
.music-floating-wrap {
  position: fixed !important;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 12px;
  z-index: 9999;
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

.btn-music-float {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid var(--border-medium);
  box-shadow: 0 3px 12px rgba(232, 99, 128, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--pink-primary);
  transition: all var(--transition);
  user-select: none;
  outline: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-music-float:hover {
  transform: scale(1.08);
  border-color: var(--pink-primary);
  box-shadow: 0 4px 16px var(--pink-glow);
}

.btn-music-float .music-note-icon {
  display: inline-block;
  line-height: 1;
}

/* Khi đang phát nhạc: nốt nhạc xoay tròn và tỏa sáng */
.btn-music-float.playing {
  background: var(--pink-primary);
  color: #FFFFFF;
  border-color: var(--pink-primary);
  animation: pulseMusicGlow 2s infinite ease-in-out;
}

.btn-music-float.playing .music-note-icon {
  animation: spinMusic 3.5s linear infinite;
}

@keyframes spinMusic {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulseMusicGlow {
  0%, 100% {
    box-shadow: 0 3px 12px rgba(232, 99, 128, 0.3);
  }
  50% {
    box-shadow: 0 4px 18px rgba(232, 99, 128, 0.55);
  }
}

.container {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding-inline: 18px;
  position: relative;
  z-index: 1;
  overflow-x: clip;
}

/* ==================== PHẦN HEADER ==================== */
header {
  padding-top: max(32px, calc(env(safe-area-inset-top, 0px) + 24px));
  padding-bottom: 22px;
  text-align: center;
}

.date-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  color: var(--pink-primary);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  max-width: 88%;
}

.date-badge span {
  font-size: 0.88rem;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 5.2vw, 2.25rem);
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

h1 .pink-text {
  color: var(--pink-primary);
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 40ch;
  margin: 0 auto;
}

/* ==================== THIỆP CHÍNH / BỨC THƯ ==================== */
.letter-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 26px 22px;
  position: relative;
  margin-bottom: 20px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.letter-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.letter-greeting {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--pink-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.letter-intro {
  font-size: 0.94rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 20px;
}

/* ==================== DANH SÁCH LỜI CHÚC (GỌN GÀNG, KHÔNG THỪA KHOẢNG TRỐNG) ==================== */
.wishes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 22px;
}

.wish-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition: all var(--transition);
}

.wish-item:hover {
  background: var(--bg-card);
  border-color: var(--border-medium);
  transform: translateX(2px);
}

/* Icon gọn gàng, vừa vặn, không còn khoảng trắng thừa */
.wish-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  flex-shrink: 0;
  margin-top: 1px;
}

.wish-body {
  min-width: 0;
}

.wish-body h3 {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 3px;
  line-height: 1.35;
}

.wish-body p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ==================== LỜI KẾT TỪ EM ==================== */
.letter-closing {
  border-top: 1px dashed var(--border-medium);
  padding-top: 16px;
  margin-top: 6px;
}

.closing-message {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.65;
  font-style: italic;
  margin-bottom: 12px;
}

.letter-signature {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--pink-primary);
  font-size: 0.92rem;
}

/* ==================== HỘP BỐC ĐIỀU ƯỚC MAY MẮN ==================== */
.interactive-section {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px 18px;
  text-align: center;
  margin-bottom: 28px;
}

.interactive-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.interactive-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.btn-wish {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card-subtle);
  color: var(--pink-primary);
  border: 1px solid var(--border-medium);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-wish:hover {
  background: var(--pink-primary);
  color: #FFFFFF;
  border-color: var(--pink-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--pink-glow);
}

.random-wish-box {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--bg-card-subtle);
  border: 1px dashed var(--pink-primary);
  border-radius: var(--radius-md);
  color: var(--pink-primary);
  font-size: 0.9rem;
  font-weight: 600;
  display: none;
  animation: fadeIn 0.3s ease;
  line-height: 1.5;
}

.random-wish-box.show {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== FOOTER ==================== */
footer {
  text-align: center;
  color: var(--text-subtle);
  font-size: 0.82rem;
  padding-top: 10px;
}

@media (max-width: 480px) {
  .music-floating-wrap {
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    right: 10px;
  }
  .btn-music-float {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }
  .letter-card {
    padding: 22px 16px;
  }
  .wish-item {
    padding: 11px 12px;
    gap: 10px;
  }
  .wish-icon {
    width: 28px;
    height: 28px;
    font-size: 1.05rem;
  }
  .envelope-card {
    padding: 28px 18px;
  }
}
