/* 
  Romantic 8/3 page – global styles
  Mobile‑first; tablet/desktop tweaks in media queries.
*/

:root {
  --pink-light: #ffd2e5;
  --pink: #ff8fb1;
  --pink-deep: #ff4f8b;
  --purple-soft: #c5a8ff;
  --bg-dark: #1a0121;
  --white-soft: rgba(255, 255, 255, 0.92);
  --glass-bg: rgba(255, 255, 255, 0.15);
  --glass-border: rgba(255, 255, 255, 0.7);
  --danger: #ff4d6a;
  --success: #73ffb1;
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.25);
  --transition-fast: 0.25s ease-out;
  --transition-med: 0.6s ease-in-out;
  --card-width-mobile: 280px;
  --card-height-mobile: 440px;
  /* Chiều rộng chuẩn cho hero / thiệp / album
     - Trên mobile: full width (100%)
     - Từ breakpoint nhất định trở lên: giới hạn lại trong media query bên dưới */
  --content-width: 100%;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  /* Font tổng thể thơ, mềm */
  font-family: "Cormorant Garamond", "Times New Roman", serif;
  color: #fff;
  background: var(--pink-light);
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  background: radial-gradient(circle at top left, #ffe4f2, #fbd3e9);
}

/* SPA phases */
.phase {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-med);
}

.phase--active {
  opacity: 1;
  pointer-events: auto;
}

/* ===================== */
/* Phase 1: Loading      */
/* ===================== */

#loading-screen {
  background: radial-gradient(circle at top left, #ffe4f2, #ff9aa2);
}

.loading-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

.heart-loader {
  position: relative;
  width: 90px;
  height: 80px;
  background: var(--pink-deep);
  transform: rotate(-45deg) scale(1);
  transform-origin: center;
  border-radius: 50% 50% 0 0;
  animation: heartbeat 1.1s infinite;
  box-shadow: 0 18px 45px rgba(255, 79, 139, 0.7);
}

.heart-loader::before,
.heart-loader::after {
  content: "";
  position: absolute;
  width: 90px;
  height: 80px;
  background: var(--pink-deep);
  border-radius: 50% 50% 0 0;
}

.heart-loader::before {
  top: -45px;
  left: 0;
}

.heart-loader::after {
  left: 45px;
  top: 0;
}

.loading-text {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fffdfd;
}

/* ===================== */
/* Phase 2: Passcode     */
/* ===================== */

#passcode-screen {
  background: linear-gradient(135deg, #ff9aa2, #ffb6c1, #ffd1ff);
}

.passcode-glass {
  width: 90%;
  max-width: 360px;
  padding: 1.8rem 1.5rem;
  border-radius: 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: 0 25px 60px rgba(255, 112, 163, 0.7);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  text-align: center;
}

.passcode-title {
  margin: 0 0 1.4rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.passcode-form {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  align-items: center;
}

.passcode-inputs {
  display: flex;
  gap: 0.6rem;
}

.code-input {
  width: 46px;
  height: 52px;
  text-align: center;
  font-size: 1.5rem;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  outline: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  transition: border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    background-color var(--transition-fast),
    transform 0.15s ease-out;
}

.code-input:focus {
  border-color: var(--success);
  box-shadow: 0 0 0 1px rgba(115, 255, 177, 0.6);
  transform: translateY(-2px);
}

.code-input.error {
  border-color: var(--danger);
}

.btn-unlock {
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--pink-deep), var(--purple-soft));
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(150, 24, 95, 0.7);
  transform: translateY(0);
  transition: transform 0.15s ease-out, box-shadow 0.15s ease-out,
    filter 0.2s ease-out;
}

.btn-unlock:active {
  transform: translateY(2px) scale(0.98);
  box-shadow: 0 10px 20px rgba(150, 24, 95, 0.4);
  filter: brightness(0.98);
}

.hint-text {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  opacity: 0.8;
}

.passcode-form.shake {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

#passcode-hearts-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.passcode-heart {
  position: absolute;
  font-size: 1.4rem;
  animation: floatUp 1.8s ease-out forwards;
}

/* ===================== */
/* Phase 3: Main Page    */
/* ===================== */

#main-page {
  background: linear-gradient(120deg, #ffb6c1, #ff9aa2, #f6d1f8, #c7b1ff);
  background-size: 300% 300%;
  animation: bgGradient 18s ease infinite;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  min-height: 100vh;
}

#petal-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.petal {
  position: absolute;
  top: -10%;
  font-size: 1.1rem;
  opacity: 0.9;
  will-change: transform, opacity;
  animation-name: fallPetal;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.main-content {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 100vh;
  padding: 2.2rem 1.4rem 2.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2rem;
  text-align: center;
}

/* Hero */
.home-hero {
  width: 100%;
  margin: 0 auto;
  padding: 1.2rem 1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 18px 40px rgba(175, 70, 135, 0.45);
}

.home-badge {
  display: inline-block;
  padding: 0.2rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: #5b2243;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}

.home-heading {
  margin: 0 0 0.4rem;
  font-size: 1.8rem;
  font-weight: 600;
  font-family: "Great Vibes", "Cormorant Garamond", serif;
  letter-spacing: 0.03em;
}

.home-subheading {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.6;
  opacity: 0.9;
}

.home-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.8rem;
  margin-top: 0.6rem;
  width: 100%;
}

/* Card */
.card-scene {
  perspective: 1200px;
  display: flex;
  justify-content: center;
  width: 100%; /* cho khung thiệp co giãn full theo chiều rộng cột */
}

.card {
  width: 100%;              /* luôn bám theo chiều rộng cột */
  min-height: 320px;        /* chiều cao tối thiểu đẹp khi chưa mở thiệp */
  height: auto;             /* sau khi mở, JS sẽ set lại chiều cao đúng bằng nội dung */
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transform: rotateY(0deg);
  transition: transform 0.9s cubic-bezier(0.22, 0.61, 0.36, 1);
  cursor: pointer;
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.card-front {
  background: linear-gradient(145deg, #ff9aa2, #ff4f8b);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: #fff;
  position: relative;
}

.card-front::before,
.card-front::after {
  content: "";
  position: absolute;
  width: 140%;
  height: 140%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.35), transparent);
  opacity: 0.35;
  filter: blur(10px);
}

.card-front::before {
  top: -40%;
  left: -20%;
}

.card-front::after {
  bottom: -40%;
  right: -20%;
}

.envelope-front {
  position: relative;
  padding: 1.4rem 1.2rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.envelope-title {
  display: block;
  font-weight: 700;
  font-size: 1.2rem;
}

.envelope-subtitle {
  display: block;
  font-size: 0.95rem;
  opacity: 0.9;
}

.card-back {
  background: radial-gradient(circle at top left, #fff7fb, #ffe4f2);
  color: #5b2243;
  transform: rotateY(180deg);
}

.message-inner {
  padding: 1.6rem 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.8rem;
  width: 100%;      /* chiếm trọn chiều ngang của mặt sau thiệp */
  max-width: 100%;  /* không bị giới hạn bởi giá trị cố định nào */
}

.message-title {
  margin: 0;
  font-size: 1.6rem;
  color: #b3005c;
  font-family: "Great Vibes", "Cormorant Garamond", serif;
}

.message-text {
  margin: 0;
  line-height: 1.5;
  font-size: 0.98rem;
}

.card.is-open {
  transform: rotateY(180deg);
}

/* Photo slider – single image */
.photo-slider {
  width: 100%;
  margin: 1.2rem auto 0;
  position: relative;
  border-radius: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
  overflow: visible;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.photo-slider.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.photo-stage {
  position: relative;
  width: 100%;
  /* Không ẩn bớt nội dung bên trong để ảnh không bị cắt ở hai bên */
  overflow: visible;
  display: flex;
  justify-content: center; /* luôn căn giữa khung ảnh theo trục ngang */
  touch-action: pan-y; /* cho phép cuộn dọc bình thường trên iOS */
}

.photo-slide {
  position: relative;
  width: 100%;
  max-width: 345px; /* khung ảnh chuẩn, giống chiều rộng thiệp trên mobile */
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: #fffdf7;
  border-radius: 14px;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.35);
  padding: 0.6rem 0.8rem 1rem;
  opacity: 0;
  transform: translateX(16px) scale(0.96);
  transition: opacity 0.5s ease, transform 0.5s ease;
  margin-bottom: 0.9rem;
}

.photo-slide.active {
  display: flex;
  opacity: 1;
  transform: translateX(0) scale(1);
}

.photo-slide img {
  max-width: 100%;
  width: auto;
  height: auto; /* luôn giữ tỉ lệ gốc, không cắt */
  border-radius: 6px;
  display: block;
  object-fit: contain;
  margin: 0 auto !important; /* căn giữa tuyệt đối ảnh trong khung */
  border: 3px solid #ffffff;
}

.photo-slide figcaption {
  margin-top: 0.55rem;
  font-size: 0.9rem;
  color: #444;
  text-align: center;
  font-family: "Cormorant Garamond", "Times New Roman", serif;
}

.photo-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.9rem;
  margin-top: 0.4rem;
}

.photo-nav-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--pink-deep), var(--purple-soft));
  color: #fff;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(150, 24, 95, 0.6);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

.photo-nav-btn:active {
  transform: translateY(1px) scale(0.97);
  box-shadow: 0 6px 14px rgba(150, 24, 95, 0.4);
}

.photo-nav-btn[disabled] {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

.photo-dots {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
}

.photo-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transition: transform 0.2s ease, background 0.2s ease;
}

.photo-dot.is-active {
  transform: scale(1.4);
  background: #ffffff;
}

.album-hearts {
  position: absolute;
  inset: -10px;
  pointer-events: none;
  overflow: visible;
}

.album-heart {
  position: absolute;
  font-size: 1.6rem;
  animation: floatUp 1.9s ease-out forwards;
}

.album-end-message {
  margin-top: 1.1rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #fff9fb;
  text-align: center;
  max-width: 520px;
}

.is-hidden {
  display: none;
}

.album-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1rem;
  padding: 0.6rem 1.6rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--pink-deep), var(--purple-soft));
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-decoration: none;
  box-shadow: 0 12px 26px rgba(150, 24, 95, 0.7);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

.album-cta-btn.is-hidden {
  display: none !important; /* luôn ẩn cho đến khi JS bỏ class is-hidden */
}

.album-cta-btn:active {
  transform: translateY(1px) scale(0.97);
  box-shadow: 0 8px 18px rgba(150, 24, 95, 0.45);
}

/* Footer */
.home-footer {
  margin-top: 1rem;
  text-align: center;
}

.home-footer p {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.9;
}

/* ===================== */
/* Animations            */
/* ===================== */

@keyframes heartbeat {
  0%,
  100% {
    transform: rotate(-45deg) scale(0.95);
  }
  25% {
    transform: rotate(-45deg) scale(1.05);
  }
  45% {
    transform: rotate(-45deg) scale(0.98);
  }
  60% {
    transform: rotate(-45deg) scale(1.08);
  }
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes floatUp {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-120px) scale(1.4);
    opacity: 0;
  }
}

@keyframes bgGradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes fallPetal {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  100% {
    transform: translate3d(0, 115vh, 0) rotate(260deg);
    opacity: 0;
  }
}

@keyframes floatSoft {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  100% {
    transform: translateY(-10px) rotate(3deg);
  }
}

/* Text fade‑up animation */
@keyframes fadeUpSoft {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.home-badge,
.home-heading,
.home-subheading,
.passcode-title,
.hint-text,
.loading-text,
.message-title,
.message-text,
.photo-slide figcaption,
.home-footer p {
  animation: fadeUpSoft 0.8s ease both;
}

.home-heading {
  animation-delay: 0.05s;
}

.home-subheading {
  animation-delay: 0.12s;
}

.message-title {
  animation-delay: 0.05s;
}

.message-text {
  animation-delay: 0.15s;
}

.photo-slide figcaption {
  animation-delay: 0.1s;
}

/* ===================== */
/* MEDIA QUERIES         */
/* ===================== */

@media (min-width: 768px) {
  .passcode-glass {
    max-width: 420px;
    padding: 2.2rem 2rem;
  }

  .passcode-title {
    font-size: 1.5rem;
  }

  .code-input {
    width: 52px;
    height: 58px;
    font-size: 1.7rem;
  }

  .main-content {
    padding: 2.4rem 2.6rem 3rem;
  }

  .home-layout {
    gap: 2.2rem;
  }

  .card {
    width: 100%;        /* vẫn bám theo content width */
    height: auto;       /* chiều cao vẫn linh hoạt theo nội dung */
  }
}

@media (min-width: 1024px) {
  .main-content {
    width: 100%;
    margin: 0 auto;
  }

  .home-layout {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 2.4rem;
  }

  .card-scene {
    flex-shrink: 0;
  }

  .photo-slider {
    flex: 0 0 auto;
    width: 100%;
    margin: 1.4rem auto 0;
  }
}

