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

:root {
  --bg-cream: #f5e6d3;
  --brown-warm: #d4a574;
  --brown-dark: #8b5e3c;
  --gold: #c9a96e;
  --text-dark: #2c1810;
  --card-bg: #fdf5e6;
  --font-hand: 'Caveat', cursive;
  --font-serif: 'Noto Serif SC', serif;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-serif);
  color: var(--text-dark);
  background: var(--bg-cream);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(201, 169, 110, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(212, 165, 116, 0.08) 0%, transparent 50%);
}

.section {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 2rem;
}

.hidden {
  display: none !important;
}

/* ===== Envelope ===== */
.envelope {
  position: relative;
  width: 320px;
  height: 220px;
  cursor: pointer;
  perspective: 1000px;
}

.envelope-body {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #e8d5bc, #d4b898);
  border-radius: 4px;
  position: relative;
  box-shadow: 0 8px 32px rgba(44, 24, 16, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(139, 94, 60, 0.2);
}

/* Triangle flap at bottom of envelope */
.envelope-body::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(135deg, #d4b898, #c9a97e);
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  border-radius: 0 0 4px 4px;
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 110px;
  background: linear-gradient(135deg, #d4b898, #c9a97e);
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
  transform-origin: top;
  transform: rotateX(0deg);
  transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
  backface-visibility: hidden;
  z-index: 2;
  border-radius: 4px 4px 0 0;
}

.envelope.open .envelope-flap {
  transform: rotateX(180deg);
}

.envelope-address {
  text-align: center;
  z-index: 1;
  position: relative;
}

.to-label {
  font-family: var(--font-hand);
  font-size: 1.2rem;
  color: var(--brown-dark);
  margin-bottom: 4px;
}

.to-name {
  font-family: var(--font-hand);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: 4px;
}

.envelope-hint {
  margin-top: 2rem;
  font-family: var(--font-hand);
  font-size: 1.2rem;
  color: var(--brown-dark);
  opacity: 0.7;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ===== Letter ===== */
#letter-section {
  background: linear-gradient(135deg, #f5e6d3 0%, #fdf5e6 50%, #f5e6d3 100%);
}

.letter-paper {
  width: 90%;
  max-width: 640px;
  background: var(--card-bg);
  padding: 3rem 2.5rem;
  border-radius: 4px;
  box-shadow:
    0 4px 24px rgba(44, 24, 16, 0.1),
    inset 0 0 60px rgba(201, 169, 110, 0.05);
  position: relative;
  min-height: 300px;
}

/* Paper lines (subtle) */
.letter-paper::before {
  content: '';
  position: absolute;
  top: 0; left: 2rem; right: 2rem; bottom: 0;
  background: repeating-linear-gradient(
    transparent,
    transparent 3.1rem,
    rgba(139, 94, 60, 0.06) 3.1rem,
    rgba(139, 94, 60, 0.06) 3.2rem
  );
  pointer-events: none;
}

.letter-content {
  position: relative;
  z-index: 1;
  font-family: var(--font-hand);
  font-size: 1.6rem;
  line-height: 2;
  color: var(--text-dark);
  min-height: 200px;
  white-space: pre-wrap;
}

.typed-cursor {
  display: inline-block;
  width: 2px;
  height: 1.4em;
  background: var(--brown-dark);
  margin-left: 2px;
  animation: blink 0.8s step-end infinite;
  vertical-align: text-bottom;
}


@keyframes blink {
  50% { opacity: 0; }
}

/* ===== Quote Cards ===== */
#quotes-section {
  background: linear-gradient(180deg, #fdf5e6 0%, #f5e6d3 100%);
  padding: 4rem 1rem;
}

.quotes-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--brown-dark);
  letter-spacing: 6px;
  margin-bottom: 3rem;
  opacity: 0.6;
}

.cards-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  width: 100%;
  max-width: 500px;
}

.quote-card {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  padding: 1.8rem 1.5rem 2.2rem;
  border-radius: 4px;
  box-shadow: 3px 5px 20px rgba(44, 24, 16, 0.12);
  border-bottom: 6px solid var(--brown-warm);
  opacity: 0;
  transform: translateY(40px) rotate(var(--rot, 0deg));
  transition: opacity 0.8s ease, transform 0.8s ease;
  position: relative;
}

.quote-card.visible {
  opacity: 1;
  transform: translateY(0) rotate(var(--rot, 0deg));
}

.quote-card:nth-child(odd) {
  --rot: 2deg;
  align-self: flex-start;
}

.quote-card:nth-child(even) {
  --rot: -2deg;
  align-self: flex-end;
}

.quote-card:nth-child(3n) {
  --rot: 0.5deg;
}

.quote-text {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.9;
  color: var(--text-dark);
  font-style: italic;
}

/* ===== Closing ===== */
#closing-section {
  position: relative;
  min-height: 100vh;
  background: linear-gradient(180deg, #f5e6d3 0%, #e8d5bc 50%, #d4b898 100%);
  overflow: hidden;
}

#particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.final-message {
  position: relative;
  z-index: 1;
  text-align: center;
}

.final-message h1 {
  font-family: var(--font-hand);
  font-size: 3rem;
  color: var(--text-dark);
  letter-spacing: 4px;
  text-shadow: 0 2px 12px rgba(212, 165, 116, 0.3);
}

.final-message.hidden {
  display: none;
}

.final-message.fade-in {
  animation: fadeIn 2s ease forwards;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .envelope {
    width: 260px;
    height: 180px;
  }

  .to-name {
    font-size: 2rem;
  }

  .letter-paper {
    padding: 2rem 1.5rem;
  }

  .letter-content {
    font-size: 1.3rem;
  }

  #quotes-section {
    padding: 3rem 1rem;
  }

  .quote-card {
    max-width: 320px;
    padding: 1.2rem 1rem 1.8rem;
  }

  .quote-text {
    font-size: 0.9rem;
  }

  .quote-card:nth-child(odd),
  .quote-card:nth-child(even) {
    align-self: center;
    --rot: 1deg;
  }

  .final-message h1 {
    font-size: 2rem;
  }
}

@media (max-width: 400px) {
  .envelope {
    width: 220px;
    height: 160px;
  }

  .to-name {
    font-size: 1.6rem;
  }

  .letter-paper {
    padding: 1.5rem 1rem;
  }

  .letter-content {
    font-size: 1.1rem;
  }
}
