/* ==========================================================================
   CSS REDESIGN: EDITORIAL SOFT VIOLET & POLAROID JOURNAL
   Tối giản, ấm áp, tối ưu cho cả Mobile (iOS/Android) và Desktop
   ========================================================================== */

:root {
  --bg-page: #FAF8FF;
  --bg-paper: #FFFFFF;
  --bg-soft: #F3EEFF;
  --bg-tint: #EAE1FD;

  --line-hairline: #E6DDF7;
  --line-strong: #D0BFF5;

  --text-main: #251F33;
  --text-muted: #5F5572;
  --text-subtle: #9287A6;

  --violet: #7C5CE6;
  --violet-dark: #6344CC;
  --violet-soft: #A78BFA;

  --shadow-paper: 0 8px 28px rgba(45, 31, 84, 0.05);
  --shadow-polaroid: 0 10px 26px rgba(45, 31, 84, 0.08);

  --font-sans: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  --font-serif: 'Lora', Georgia, serif;

  --ease: 0.28s 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-sans);
  line-height: 1.7;
  min-height: 100vh;
  position: relative;
  padding-bottom: 56px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ==================== MÀN HÌNH TRÁI TIM MỞ ĐẦU ==================== */
.envelope-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(250, 248, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  touch-action: manipulation;
  transition: opacity 0.55s var(--ease), visibility 0.55s;
}

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

.envelope-heart-wrap {
  position: relative;
  width: min(94vw, 430px);
  aspect-ratio: 400 / 370;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: heartFloat 4.2s ease-in-out infinite;
  transition: transform 0.55s var(--ease), opacity 0.55s var(--ease);
}

.envelope-overlay.opened .envelope-heart-wrap {
  transform: scale(1.12);
  opacity: 0;
}

@keyframes heartFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.heart-bg-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 18px 36px rgba(124, 92, 230, 0.14));
  animation: heartPulse 2.8s ease-in-out infinite;
  pointer-events: none;
}

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

/* Vòng sóng lan tỏa nhẹ phía sau trái tim */
.heart-ripple {
  position: absolute;
  width: 72%;
  height: 72%;
  border-radius: 50%;
  border: 1px solid rgba(124, 92, 230, 0.22);
  pointer-events: none;
  animation: rippleOut 3.4s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

.heart-ripple.ripple-2 {
  animation-delay: 1.7s;
}

@keyframes rippleOut {
  0% {
    transform: scale(0.82);
    opacity: 0.65;
  }
  100% {
    transform: scale(1.32);
    opacity: 0;
  }
}

/* Các đốm sáng & tim nhỏ bay quanh */
.heart-spark {
  position: absolute;
  color: var(--violet-soft);
  font-size: 0.9rem;
  pointer-events: none;
  opacity: 0;
  animation: sparkDrift 3.6s ease-in-out infinite;
}

.spark-1 { top: 8%; left: 14%; animation-delay: 0s; }
.spark-2 { top: 12%; right: 12%; font-size: 0.85rem; animation-delay: 0.9s; }
.spark-3 { bottom: 20%; left: 10%; font-size: 0.78rem; animation-delay: 1.8s; }
.spark-4 { bottom: 22%; right: 10%; animation-delay: 2.5s; }

@keyframes sparkDrift {
  0%, 100% {
    opacity: 0;
    transform: translateY(6px) scale(0.8);
  }
  50% {
    opacity: 0.85;
    transform: translateY(-6px) scale(1.1);
  }
}

.envelope-heart-content {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 260px;
  padding: 0 10px;
  margin-top: -10px;
}

.envelope-kicker {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--violet);
  margin-bottom: 6px;
}

.envelope-recipient {
  font-family: var(--font-serif);
  font-size: clamp(1.22rem, 4.5vw, 1.48rem);
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 10px;
  line-height: 1.25;
}

.envelope-hint {
  font-size: clamp(0.8rem, 3.2vw, 0.86rem);
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 20px;
}

.btn-open-envelope {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--violet);
  color: #FFFFFF;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(124, 92, 230, 0.25);
  transition: background var(--ease), transform var(--ease), box-shadow var(--ease);
  outline: none;
  touch-action: manipulation;
}

.btn-open-envelope:hover {
  background: var(--violet-dark);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(124, 92, 230, 0.32);
}

.btn-open-envelope .btn-arrow {
  transition: transform var(--ease);
}

.btn-open-envelope:hover .btn-arrow {
  transform: translateX(3px);
}

/* ==================== CANVAS NỀN ==================== */
#petalsCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ==================== TRANG TRÍ HAI BÊN (DESKTOP) ==================== */
.side-decorations {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.side-item {
  position: absolute;
  font-size: 1.5rem;
  opacity: 0.55;
  color: var(--violet-soft);
  filter: drop-shadow(0 4px 10px rgba(124, 92, 230, 0.14));
  animation: sideFloat 5s ease-in-out infinite;
  user-select: none;
}

.side-left.s1  { top: 14%; left: 6%;  font-size: 1.7rem; animation-delay: 0s; }
.side-left.s2  { top: 32%; left: 10%; font-size: 1.5rem; animation-delay: 1.1s; }
.side-left.s3  { top: 52%; left: 5%;  font-size: 1.9rem; animation-delay: 2.2s; }
.side-left.s4  { top: 70%; left: 11%; font-size: 1.45rem; animation-delay: 0.7s; }
.side-left.s5  { top: 86%; left: 7%;  font-size: 1.6rem; animation-delay: 1.8s; }

.side-right.s6  { top: 16%; right: 7%;  font-size: 1.55rem; animation-delay: 0.5s; }
.side-right.s7  { top: 35%; right: 11%; font-size: 1.75rem; animation-delay: 1.6s; }
.side-right.s8  { top: 54%; right: 6%;  font-size: 1.85rem; animation-delay: 2.6s; }
.side-right.s9  { top: 72%; right: 10%; font-size: 1.5rem; animation-delay: 0.9s; }
.side-right.s10 { top: 87%; right: 6%;  font-size: 1.65rem; animation-delay: 2.0s; }

@keyframes sideFloat {
  0%, 100% {
    transform: translateY(0) rotate(-4deg);
  }
  50% {
    transform: translateY(-10px) rotate(4deg);
  }
}

@media (max-width: 860px) {
  .side-decorations {
    display: none;
  }
}

/* ==================== NÚT NHẠC NỀN (GÓC DƯỚI BÊN PHẢI) ==================== */
.music-floating-wrap {
  position: fixed !important;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  right: 16px;
  z-index: 9999;
}

.btn-music-float {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-paper);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-paper);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--violet);
  transition: all var(--ease);
  outline: none;
  touch-action: manipulation;
}

.btn-music-float:hover {
  border-color: var(--violet);
  transform: scale(1.06);
}

.btn-music-float.playing {
  background: var(--violet);
  color: #FFFFFF;
  border-color: var(--violet);
}

.btn-music-float.playing .music-note-icon {
  display: inline-block;
  animation: spinMusic 4s linear infinite;
}

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

/* ==================== BỐ CỤC TRANG CHÍNH ==================== */
.page-wrap {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 52px 22px 20px;
  position: relative;
  z-index: 1;
}

/* ==================== HERO EDITORIAL ==================== */
.hero-header {
  margin-bottom: 40px;
}

.hero-eyebrow {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--violet);
  margin-bottom: 12px;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(1.85rem, 5.5vw, 2.45rem);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-main);
  letter-spacing: -0.015em;
  margin-bottom: 16px;
}

.hero-title em {
  font-style: italic;
  color: var(--violet);
  font-weight: 500;
}

.hero-lead {
  font-size: 0.96rem;
  color: var(--text-muted);
  line-height: 1.75;
  max-width: 52ch;
  text-align: justify;
}

.hairline-divider {
  width: 48px;
  height: 1px;
  background: var(--line-strong);
  margin-top: 28px;
}

/* ==================== NHÃN PHẦN ==================== */
.section-label {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 20px;
}

/* ==================== TIMELINE KỶ NIỆM ==================== */
.memories-section {
  margin-bottom: 48px;
}

.timeline {
  list-style: none;
  position: relative;
  padding-left: 22px;
  border-left: 1px solid var(--line-strong);
}

.timeline-item {
  position: relative;
  padding-bottom: 26px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -27px;
  top: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg-page);
  border: 2px solid var(--violet);
}

.timeline-tag {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--violet);
  margin-bottom: 4px;
}

.timeline-content h3 {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
  line-height: 1.35;
}

.timeline-content p {
  font-size: 0.91rem;
  color: var(--text-muted);
  line-height: 1.65;
  text-align: justify;
}

/* ==================== GÓC ẢNH POLAROID ==================== */
.polaroid-section {
  margin-bottom: 48px;
}

.polaroid-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-items: start;
}

.polaroid-card {
  background: var(--bg-paper);
  padding: 8px 8px 16px;
  border: 1px solid var(--line-hairline);
  border-radius: 3px;
  box-shadow: var(--shadow-polaroid);
  cursor: pointer;
  transition: transform var(--ease), box-shadow var(--ease);
}

.polaroid-card.tilt-left {
  transform: rotate(-1.6deg);
}

.polaroid-card.tilt-right {
  transform: rotate(1.4deg);
}

.polaroid-card.tilt-subtle {
  transform: rotate(-0.8deg);
}

.polaroid-card:hover {
  transform: rotate(0deg) translateY(-4px);
  box-shadow: 0 14px 32px rgba(45, 31, 84, 0.12);
}

.polaroid-frame {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-soft);
  border-radius: 2px;
}

.polaroid-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.polaroid-card figcaption {
  margin-top: 11px;
  padding: 0 4px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

/* ==================== LỜI TỎ TÌNH CHÍNH ==================== */
.confession-section {
  margin-bottom: 44px;
}

.letter-sheet {
  background: var(--bg-paper);
  border: 1px solid var(--line-hairline);
  border-radius: 6px;
  padding: 34px 30px 30px;
  box-shadow: var(--shadow-paper);
  position: relative;
}

.quote-mark {
  display: block;
  font-family: var(--font-serif);
  font-size: 3rem;
  line-height: 0.6;
  color: var(--violet-soft);
  margin-bottom: 12px;
  user-select: none;
}

.confession-greeting {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 12px;
}

.confession-body {
  font-size: 0.96rem;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 14px;
  text-align: justify;
}

.confession-ask {
  font-family: var(--font-serif);
  font-size: 1.06rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.65;
  margin-bottom: 22px;
  text-align: justify;
}

.letter-sign {
  text-align: right;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.98rem;
  color: var(--violet);
  font-weight: 600;
}

/* ==================== CÂU TRẢ LỜI (OPTION A) ==================== */
.response-section {
  background: linear-gradient(180deg, #FFFFFF 0%, #F5EEFF 100%);
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  padding: 30px 22px;
  box-shadow: 0 14px 36px rgba(124, 92, 230, 0.12);
  text-align: center;
  margin-bottom: 36px;
}

.response-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--violet-dark);
  margin-bottom: 12px;
}

.response-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.response-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.btn-response {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--ease);
  touch-action: manipulation;
}

.btn-accept {
  background: var(--violet);
  color: #FFFFFF;
  border: 1px solid var(--violet);
}

.btn-accept:hover {
  background: var(--violet-dark);
  border-color: var(--violet-dark);
  transform: translateY(-1px);
}

.btn-think {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--line-strong);
}

.btn-think:hover {
  background: var(--bg-soft);
  color: var(--violet);
  border-color: var(--violet);
  transform: translateY(-1px);
}

.btn-response.is-selected {
  pointer-events: none;
}

.btn-response.is-dimmed {
  opacity: 0.42;
  pointer-events: none;
}

.response-result {
  margin-top: 18px;
  padding: 14px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--violet-dark);
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.6;
  display: none;
  animation: fadeIn 0.3s ease;
}

.response-result.show {
  display: block;
}

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

/* ==================== HIỆU ỨNG TRÁI TIM BAY (CELEBRATION) ==================== */
.heart-burst-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  overflow: hidden;
}

.burst-heart {
  position: absolute;
  bottom: -24px;
  font-size: 1.25rem;
  opacity: 0;
  animation: burstHeartUp var(--dur, 2.8s) cubic-bezier(0.16, 1, 0.3, 1) forwards;
  user-select: none;
}

@keyframes burstHeartUp {
  0% {
    opacity: 0;
    transform: translateY(0) translateX(0) scale(0.6);
  }
  15% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translateY(-78vh) translateX(var(--drift, 0px)) scale(1.15);
  }
}

/* ==================== CHỤP ẢNH KHOẢNH KHẮC ==================== */
.capture-wrap {
  margin-top: 26px;
  text-align: center;
}

.btn-capture {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-paper);
  color: var(--violet);
  border: 1px solid var(--line-strong);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-paper);
  transition: all var(--ease);
  touch-action: manipulation;
}

.btn-capture:hover {
  background: var(--bg-soft);
  border-color: var(--violet);
  transform: translateY(-1px);
}

.capture-preview-box {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: fadeIn 0.3s ease;
}

.capture-preview-box[hidden] {
  display: none;
}

.preview-polaroid {
  width: min(100%, 260px);
  transform: rotate(-0.8deg);
}

.capture-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.capture-actions[hidden],
.btn-response[hidden],
.btn-capture[hidden] {
  display: none !important;
}

.capture-status {
  font-size: 0.86rem;
  color: var(--violet-dark);
  font-weight: 500;
  min-height: 1.2em;
}

/* ==================== LIGHTBOX XEM CHI TIẾT ẢNH ==================== */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(24, 18, 38, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.22s ease;
}

.lightbox-overlay[hidden] {
  display: none;
}

.lightbox-close {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--ease);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox-content {
  max-width: min(92vw, 560px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 74vh;
  border-radius: 4px;
  object-fit: contain;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.4);
  background: #FFFFFF;
}

.lightbox-caption {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.94rem;
  color: #F3EEFF;
  text-align: center;
}

/* ==================== FOOTER ==================== */
.site-footer {
  text-align: center;
  color: var(--text-subtle);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

/* ==================== RESPONSIVE MOBILE ==================== */
@media (max-width: 540px) {
  .page-wrap {
    padding: 40px 18px 20px;
  }

  .hero-header {
    margin-bottom: 32px;
  }

  .polaroid-grid {
    grid-template-columns: 1fr;
    gap: 18px;
    max-width: 340px;
    margin: 0 auto;
  }

  .polaroid-card.tilt-left {
    transform: rotate(-0.8deg);
  }

  .polaroid-card.tilt-right {
    transform: rotate(0.8deg);
  }

  .polaroid-card.tilt-subtle {
    transform: rotate(-0.4deg);
  }

  .letter-sheet {
    padding: 26px 20px 24px;
  }

  .response-actions {
    flex-direction: column;
  }

  .btn-response {
    width: 100%;
  }

  .envelope-sheet {
    padding: 34px 22px 30px;
  }
}
