@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@400..700&family=Nunito:wght@400;700&display=swap');

:root {
  --bg-pink: #ffb3c6;
  --bg-heart: #ff8fa3;
  --envelope-red: #d9534f;
  --envelope-light: #f5a3a2;
  --envelope-dark: #c9302c;
  --text-color: #5a2a2a;
}

body {
  margin: 0;
  padding: 0;
  /* Pink Background with Hearts Pattern (CSS only, no image needed) */
  background-color: var(--bg-pink);
  background-image: radial-gradient(var(--bg-heart) 15%, transparent 16%),
                    radial-gradient(var(--bg-heart) 15%, transparent 16%);
  background-size: 60px 60px;
  background-position: 0 0, 30px 30px;
  font-family: 'Nunito', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
}

/* =========================
   UI Components (Buttons, etc)
   ========================= */
.btn {
  background: white;
  color: var(--envelope-red);
  border: 2px solid var(--envelope-red);
  padding: 10px 20px;
  border-radius: 30px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.btn:hover {
  background: var(--envelope-red);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(217, 83, 79, 0.4);
}
.btn-primary {
  background: var(--envelope-red);
  color: white;
}

/* =========================
   The Animated Envelope
   (Adapted from your upload)
   ========================= */
.envlope-wrapper {
  height: 380px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  margin-top: 50px;
}

#envelope {
  position: relative;
  width: 300px; /* Slightly wider for better text fit */
  height: 200px;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  background-color: var(--envelope-red);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.front {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 3;
}

.flap {
  border-left: 150px solid transparent;
  border-right: 150px solid transparent;
  border-bottom: 82px solid transparent;
  border-top: 98px solid var(--envelope-red);
  transform-origin: top;
  pointer-events: none;
}

.pocket {
  border-left: 150px solid var(--envelope-light);
  border-right: 150px solid var(--envelope-light);
  border-bottom: 100px solid var(--envelope-dark);
  border-top: 100px solid transparent;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
}

.letter {
  position: relative;
  background-color: #fff;
  width: 90%;
  margin: 0 auto;
  height: 90%;
  top: 5%;
  border-radius: 6px;
  box-shadow: 0 2px 26px rgba(0, 0, 0, 0.12);
  font-family: 'Dancing Script', cursive;
  padding: 15px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--text-color);
  overflow: hidden; /* Hide overflow until opened */
}

/* Specific styling for the letter text */
.letter-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  width: 100%;
}
.letter h1 { font-size: 24px; margin: 0 0 10px; color: #d6336c; }
.letter p { font-size: 18px; line-height: 1.4; margin: 0; }
.sticker { font-size: 40px; margin-top: 10px; animation: bounce 2s infinite; }

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

/* Envelope Animation States */
.open .flap {
  transform: rotateX(180deg);
  transition: transform 0.4s ease, z-index 0.6s;
  z-index: 1;
}

.close .flap {
  transform: rotateX(0deg);
  transition: transform 0.4s 0.6s ease, z-index 1s;
  z-index: 5;
}

.close .letter {
  transform: translateY(0px);
  transition: transform 0.4s ease, z-index 1s;
  z-index: 1;
}

.open .letter {
  transform: translateY(-120px) scale(1.1); /* Pop up higher and bigger */
  transition: transform 0.4s 0.6s ease, z-index 0.6s;
  z-index: 2;
}

/* Hearts Animation */
.hearts {
  position: absolute;
  top: 90px;
  left: 0;
  right: 0;
  z-index: 2;
}

.heart {
  position: absolute;
  bottom: 0;
  right: 10%;
  pointer-events: none;
  opacity: 0; /* Hidden by default */
}

.heart:before, .heart:after {
  position: absolute;
  content: "";
  left: 50px;
  top: 0;
  width: 50px;
  height: 80px;
  background: #e60073;
  border-radius: 50px 50px 0 0;
  transform: rotate(-45deg);
  transform-origin: 0 100%;
}
.heart:after {
  left: 0;
  transform: rotate(45deg);
  transform-origin: 100% 100%;
}

.open .heart {
  opacity: 1;
  animation: slideUp 4s linear forwards, sideSway 2s ease-in-out infinite alternate;
}
.open .a1 { left: 20%; animation-delay: 0.6s; transform: scale(0.6); }
.open .a2 { left: 55%; animation-delay: 0.8s; transform: scale(1); }
.open .a3 { left: 10%; animation-delay: 1.0s; transform: scale(0.8); }

@keyframes slideUp { 0% { top: 0; } 100% { top: -600px; opacity: 0; } }
@keyframes sideSway { 0% { margin-left: 0px; } 100% { margin-left: 50px; } }

/* =========================
   Create Page Styling
   ========================= */
.create-card {
  background: rgba(255, 255, 255, 0.9);
  padding: 30px;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(160, 50, 50, 0.15);
  max-width: 500px;
  width: 90%;
  text-align: center;
}
.paper-input {
  width: 100%;
  border: 2px solid #ffccd5;
  border-radius: 12px;
  padding: 12px;
  font-family: 'Nunito', sans-serif;
  margin-bottom: 15px;
  outline: none;
}
.paper-input:focus { border-color: var(--envelope-red); }
.letter-editor {
  min-height: 150px;
  border: 2px dashed #ffccd5;
  border-radius: 12px;
  padding: 15px;
  font-family: 'Dancing Script', cursive;
  font-size: 22px;
  background: #fff0f3;
  text-align: left;
}
.letter-editor:focus { border-color: var(--envelope-red); outline: none; background: white; }

/* Control Box below envelope */
.reset {
  text-align: center;
  margin-top: -60px; /* Pull it up closer to envelope */
  position: relative;
  z-index: 10;
}