@import url('https://fonts.googleapis.com/css2?family=Charm:wght@400;700&family=Mitr:wght@200;300;400;500&family=Noto+Serif+Thai:wght@300;400;600&display=swap');

/* ==========================================================================
   CSS CUSTOM VARIABLES & RESET
   ========================================================================== */
:root {
  --bg-gradient: linear-gradient(135deg, #fff0f5 0%, #fffdd0 50%, #f9f6f0 100%);
  --text-main: #3d3130;
  --text-muted: #6e5e5d;
  --accent-gold: #c5a880;
  --accent-gold-hover: #b4966e;
  --accent-rose: #d48e9b;
  --accent-rose-hover: #c37d8a;
  --accent-red: #e07a7a;
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.4);
  --glass-shadow: 0 8px 32px 0 rgba(197, 168, 128, 0.15);
  --transition-smooth: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.2s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Mitr', sans-serif;
  color: var(--text-main);
  background: var(--bg-gradient);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.6;
}

/* ==========================================================================
   BACKGROUND & DECORATIVE EFFECTS
   ========================================================================== */
#particles-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ==========================================================================
   GLOBAL APP CONTAINER & CONTROLS
   ========================================================================== */
#app-container {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-height: 600px; /* Stable height for the notebook cover */
  margin: 40px auto;
  padding: 40px 20px; /* Comfortable spacing inside notebook cover */
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  align-items: center;
  z-index: 1;
  perspective: 1500px;
  background: linear-gradient(135deg, #f6e6d6 0%, #dfc9b5 100%); /* Rose-Gold Premium Leather Cover */
  border-radius: 24px;
  box-shadow: 0 30px 60px rgba(197, 168, 128, 0.3), 
              inset 0 0 20px rgba(255, 255, 255, 0.6),
              0 4px 10px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Top Music Controller */
.music-controller {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.music-controller:hover {
  transform: scale(1.1);
  border-color: var(--accent-rose);
}

.music-icon {
  width: 22px;
  height: 22px;
  fill: var(--text-muted);
  transition: var(--transition-fast);
}

.music-controller.playing .music-icon {
  fill: var(--accent-rose);
  animation: spin 6s linear infinite;
}

.music-controller.muted .music-icon-slash {
  display: block;
}

/* Top Progress Indicator */
.progress-bar-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
  z-index: 10;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-rose), var(--accent-gold));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Navigation Overlay */
.nav-controls {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  pointer-events: none;
}

.nav-btn {
  pointer-events: auto;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-main);
  padding: 10px 24px;
  border-radius: 30px;
  font-family: 'Mitr', sans-serif;
  font-size: 0.9rem;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
  opacity: 1;
}

.nav-btn:hover {
  background: white;
  border-color: var(--accent-rose);
  transform: translateY(-2px);
}

.nav-btn:disabled {
  opacity: 0;
  pointer-events: none;
}

.nav-progress-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 300;
  letter-spacing: 1px;
}

/* ==========================================================================
   STORYTELLING STEPS (CARDS & BOOK BINDING)
   ========================================================================== */
.notebook-spine {
  position: absolute;
  left: 6px;
  top: 50px;
  bottom: 50px;
  width: 36px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  z-index: 10; /* Render rings on top */
  pointer-events: none;
  transform: translateZ(50px); /* Bring forward in 3D space to overlay transformed cards */
  transform-style: preserve-3d;
}

.spine-ring {
  width: 36px;
  height: 14px;
  border: 3.5px solid #dfb98a; /* Gold metallic ring border */
  border-right: none; /* Make it C-shaped to hook into the page */
  border-radius: 7px 0 0 7px;
  background: transparent;
  box-shadow: -2px 2px 3px rgba(0, 0, 0, 0.12), inset 1px 1px 1px rgba(255, 255, 255, 0.4);
}

.step-card {
  grid-area: 1 / 1 / 2 / 2;
  width: 100%;
  background: #fdfcf7; /* Premium Warm Ivory Paper */
  background-image: linear-gradient(rgba(197, 168, 128, 0.08) 1px, transparent 1px);
  background-size: 100% 32px; /* Ruled journal lines */
  border: 1px solid rgba(0, 0, 0, 0.05);
  /* Stacked pages shadow effect */
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.04), 
              2px 2px 0 #fff, 
              3px 3px 0 rgba(197, 168, 128, 0.12), 
              5px 5px 0 #fff, 
              6px 6px 0 rgba(197, 168, 128, 0.12);
  border-radius: 6px 18px 18px 6px; /* Book page curved outer corner, flat inner edge */
  padding: 40px 25px 40px 45px; /* Left padding offsets content past the binding rings */
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  transform-origin: left center; /* Set origin to left spine for book page flip */
  transition: transform 0.9s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.9s ease, visibility 0.9s;
  position: relative;
  overflow: hidden;
  min-height: 500px; /* Uniform height for notebook pages */
}

/* Red/Rose margin fold line inside book page */
.step-card::before {
  content: '';
  position: absolute;
  left: 20px; /* Spine rings end exactly on this margin fold line */
  top: 0;
  width: 1px;
  height: 100%;
  background: rgba(212, 142, 155, 0.25);
  z-index: 5;
}

/* Page inner spine fold shadow detail */
.step-card::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 100%;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.05) 0%, rgba(0, 0, 0, 0.01) 80%, transparent 100%);
  z-index: 4;
}

/* Over-leaf Book Page Turn Transitions */
.step-card[data-status="ahead"] {
  transform: rotateY(0deg) scale(0.93) translate(15px, 0);
  opacity: 0;
  visibility: hidden;
  z-index: 1;
}

.step-card[data-status="next-stack"] {
  transform: rotateY(0deg) scale(0.96) translate(8px, 0);
  opacity: 0.9;
  visibility: visible;
  z-index: 2;
}

.step-card[data-status="active"] {
  transform: rotateY(0deg) scale(1) translate(0, 0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 3;
}

.step-card[data-status="behind"] {
  transform: rotateY(-180deg);
  opacity: 0;
  visibility: hidden;
  z-index: 1;
}

/* Typography styles inside cards */
h1, h2 {
  font-family: 'Noto Serif Thai', serif;
  font-weight: 400;
  color: var(--text-main);
  margin-bottom: 20px;
  line-height: 1.4;
  word-break: keep-all;
}

h1.romantic-title {
  font-family: 'Charm', cursive;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent-rose);
  text-shadow: 0 2px 4px rgba(212, 142, 155, 0.1);
}

h2.step-title {
  font-size: 1.6rem;
  position: relative;
  padding-bottom: 12px;
}

h2.step-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 2px;
  background: var(--accent-rose);
  border-radius: 2px;
}

p.story-text {
  font-size: 1rem;
  font-weight: 300;
  color: var(--text-muted);
  margin-bottom: 15px;
  white-space: pre-line;
  word-break: keep-all;
}

.highlight-box {
  margin: 25px 0 15px 0;
  padding: 20px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.4);
  border-left: 4px solid var(--accent-rose);
  font-family: 'Noto Serif Thai', serif;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--text-main);
  box-shadow: 0 4px 15px rgba(197, 168, 128, 0.05);
}

.heart-icon-pulsing {
  font-size: 3rem;
  color: var(--accent-rose);
  margin-bottom: 20px;
  animation: heart-beat 1.5s infinite;
}

.primary-action-btn {
  background: linear-gradient(135deg, var(--accent-rose) 0%, var(--accent-gold) 100%);
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: 30px;
  font-family: 'Mitr', sans-serif;
  font-size: 1rem;
  font-weight: 400;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(212, 142, 155, 0.25);
  transition: var(--transition-smooth);
  margin-top: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.primary-action-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 24px rgba(212, 142, 155, 0.35);
}

/* ==========================================================================
   STEP SPECIFIC STYLING
   ========================================================================== */

/* Step 3: Comparison Columns */
.comparison-container {
  display: flex;
  gap: 15px;
  width: 100%;
  margin: 25px 0;
}

.comparison-col {
  flex: 1;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--glass-border);
  padding: 20px 12px;
  border-radius: 16px;
  text-align: center;
  transition: var(--transition-smooth);
}

.comparison-col:hover {
  background: rgba(255, 255, 255, 0.7);
  transform: translateY(-2px);
}

.comparison-col.arm {
  border-top: 4px solid var(--accent-rose);
}

.comparison-col.cha {
  border-top: 4px solid var(--accent-gold);
}

.comparison-col h3 {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 12px;
}

.comparison-col.arm h3 {
  color: var(--accent-rose);
}

.comparison-col.cha h3 {
  color: var(--accent-gold);
}

.comparison-col ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comparison-col li {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 300;
}

/* Step 4: Staggered Worries Cards */
.worry-cards-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin: 25px 0;
}

.worry-card {
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--glass-border);
  padding: 15px;
  border-radius: 12px;
  text-align: left;
  opacity: 0;
  transform: translateX(-15px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  display: flex;
  align-items: center;
  gap: 12px;
}

.worry-card.show {
  opacity: 1;
  transform: translateX(0);
}

.worry-card-icon {
  font-size: 1.2rem;
  color: var(--accent-red);
}

.worry-card-text {
  font-size: 0.9rem;
  font-weight: 300;
  color: var(--text-muted);
}

.hidden-text {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.8s ease, max-height 0.8s ease;
}

.hidden-text.reveal {
  opacity: 1;
  max-height: 200px;
  margin-top: 15px;
}

/* Step 6: Photo Timeline */
.timeline-scroll-container {
  width: 100%;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 8px;
  margin: 20px 0;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-rose) transparent;
}

.timeline-scroll-container::-webkit-scrollbar {
  width: 4px;
}

.timeline-scroll-container::-webkit-scrollbar-thumb {
  background: var(--accent-rose);
  border-radius: 4px;
}

.timeline-line {
  position: absolute;
  left: 20px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: rgba(197, 168, 128, 0.3);
  z-index: 1;
}

.timeline-item {
  display: flex;
  margin-bottom: 25px;
  position: relative;
  z-index: 2;
  text-align: left;
}

.timeline-node {
  width: 12px;
  height: 12px;
  background: white;
  border: 2px solid var(--accent-rose);
  border-radius: 50%;
  margin-left: 15px;
  margin-right: 15px;
  margin-top: 6px;
  transition: var(--transition-smooth);
}

.timeline-item.active .timeline-node {
  background: var(--accent-rose);
  box-shadow: 0 0 8px var(--accent-rose);
  transform: scale(1.2);
}

.timeline-content {
  flex: 1;
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid var(--glass-border);
  padding: 12px;
  border-radius: 12px;
  transition: var(--transition-smooth);
}

.timeline-item.active .timeline-content {
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 15px rgba(197, 168, 128, 0.1);
  transform: translateX(2px);
}

.timeline-content h4 {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 4px;
}

.timeline-content p {
  font-size: 0.8rem;
  font-weight: 300;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.timeline-photo-placeholder {
  width: 100%;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.timeline-photo-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Step 7: Floating/Split Hearts */
.heart-split-animation {
  width: 100%;
  height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin: 20px 0;
  position: relative;
}

.split-heart {
  font-size: 2.2rem;
  color: var(--accent-rose);
  transition: transform 1.5s ease-in-out;
}

.split-heart.left {
  animation: driftLeft 3s ease-in-out infinite alternate;
}

.split-heart.right {
  animation: driftRight 3s ease-in-out infinite alternate;
}

/* Step 10: Glass Envelope Letter */
.envelope-wrapper {
  perspective: 1000px;
  width: 100%;
  max-width: 320px;
  height: 200px;
  margin: 30px auto;
  cursor: pointer;
  position: relative;
}

.envelope {
  position: absolute;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  border-radius: 0 0 12px 12px;
  transform-style: preserve-3d;
  transition: var(--transition-smooth);
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 160px solid transparent;
  border-right: 160px solid transparent;
  border-top: 100px solid rgba(255, 255, 255, 0.45);
  border-radius: 12px 12px 0 0;
  transform-origin: top;
  transition: transform 0.6s ease;
  z-index: 3;
}

.envelope-paper {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  background: white;
  border-radius: 8px;
  padding: 15px;
  transition: transform 0.6s ease;
  z-index: 2;
  box-shadow: 0 0 10px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transform: translateY(0);
}

.envelope-paper p {
  font-family: 'Noto Serif Thai', serif;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Opened Envelope State */
.envelope-wrapper.open .envelope-flap {
  transform: rotateX(180deg);
  z-index: 1;
}

.envelope-wrapper.open .envelope-paper {
  transform: translateY(-80px);
  z-index: 4;
  height: 280px;
  box-shadow: 0 10px 30px rgba(197, 168, 128, 0.2);
  width: 110%;
  left: -5%;
}

.envelope-paper-scroller {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding-right: 4px;
  display: none;
}

.envelope-wrapper.open .envelope-paper-scroller {
  display: block;
}

.envelope-wrapper.open .envelope-paper p.click-hint {
  display: none;
}

.click-hint {
  font-size: 0.85rem;
  color: var(--accent-rose);
  animation: pulse 1.5s infinite;
}

/* ==========================================================================
   FINAL PROPOSAL SCREEN
   ========================================================================== */
.proposal-photo-frame {
  width: 100%;
  height: auto;
  max-height: 320px;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 20px;
  border: 3px solid white;
  box-shadow: var(--glass-shadow);
  position: relative;
  background: rgba(197, 168, 128, 0.05); /* Soft champagne backdrop */
  display: flex;
  align-items: center;
  justify-content: center;
}

.proposal-photo-frame img,
.proposal-photo-frame video {
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: contain; /* Keep the entire video visible without cropping */
  display: block;
}

.button-group-proposal {
  display: flex;
  gap: 15px;
  width: 100%;
  margin-top: 25px;
}

.proposal-btn {
  flex: 1;
  padding: 14px 20px;
  border-radius: 30px;
  border: none;
  font-family: 'Mitr', sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.proposal-btn.yes {
  background: linear-gradient(135deg, var(--accent-rose) 0%, var(--accent-gold) 100%);
  color: white;
  box-shadow: 0 6px 15px rgba(212, 142, 155, 0.3);
}

.proposal-btn.yes:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(212, 142, 155, 0.4);
}

.proposal-btn.no {
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
}

.proposal-btn.no:hover {
  background: rgba(255, 255, 255, 0.7);
  transform: translateY(-2px);
}

/* Celebration Overlay Styles */
.celebration-message {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 1s ease, max-height 1s ease;
}

.celebration-message.show {
  opacity: 1;
  max-height: 400px;
  margin-top: 20px;
}

/* ==========================================================================
   KEYFRAME ANIMATIONS
   ========================================================================== */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes heart-beat {
  0% { transform: scale(1); }
  14% { transform: scale(1.12); }
  28% { transform: scale(1); }
  42% { transform: scale(1.12); }
  70% { transform: scale(1); }
}

@keyframes pulse {
  0% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
  100% { opacity: 0.6; transform: scale(1); }
}

@keyframes driftLeft {
  0% { transform: translateX(0); }
  100% { transform: translateX(-15px); }
}

@keyframes driftRight {
  0% { transform: translateX(0); }
  100% { transform: translateX(15px); }
}

/* ==========================================================================
   RESPONSIVE OVERRIDES
   ========================================================================== */
@media (max-width: 375px) {
  #app-container {
    padding-top: 70px;
  }
  .step-card {
    padding: 25px 18px;
  }
  h2.step-title {
    font-size: 1.4rem;
  }
  h1.romantic-title {
    font-size: 1.9rem;
  }
  .envelope-wrapper.open .envelope-paper {
    width: 106%;
    left: -3%;
  }
}

/* ==========================================================================
   PASSWORD CARD STYLING
   ========================================================================== */
.password-card {
  width: 100%;
  max-width: 400px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 24px;
  padding: 35px 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  z-index: 100;
}

/* ==========================================================================
   PASSWORD GATE OVERLAY STYLING
   ========================================================================== */
.password-gate-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
  padding: 20px;
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}

.password-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--accent-rose);
  border-radius: 20px;
  padding: 12px 20px;
  font-family: 'Mitr', sans-serif;
  font-size: 1.1rem;
  color: var(--text-main);
  text-align: center;
  outline: none;
  transition: var(--transition-smooth);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.password-input:focus {
  background: white;
  border-color: var(--accent-gold);
  box-shadow: 0 0 10px rgba(197, 168, 128, 0.25);
}

.password-input::placeholder {
  color: #b2a2a0;
  font-size: 0.95rem;
}

/* Shaking animation on input mismatch */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.shake {
  animation: shake 0.5s ease-in-out;
}

