:root {
  --pink: #fbcfe8;
  --rose: #be185d;
  --light-rose: #f8bbd9;
  --ink: #3d2b2b;
  --shadow: rgba(0,0,0,0.15);
}

body {
  /* margin:0; */
  font-family:'Georgia', serif;
  background: linear-gradient(135deg,#fdf2f8,#fce7f3,#fbcfe8);
  display:flex;
  flex-direction:column;
  min-height:100vh;
  color:var(--ink);
  overflow-x:hidden;
  position:relative;
}

/* Background decorative hearts */
.background-heart {
  position: fixed;
  pointer-events: none;
  user-select: none;
  font-size: 30px;
  color: #f472b6;
  opacity: 0.08;
  animation: drift 40s linear infinite;
}
@keyframes drift {
  0% {transform: translateY(0) rotate(0deg);}
  100% {transform: translateY(-100vh) rotate(360deg);}
}

header, footer {
  position: fixed;
  left:0; width:100%;
  text-align:center;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(10px);
  color: var(--rose);
  font-weight: bold;
  z-index:10;
  font-family:'Georgia', serif;
}
header { top:0; padding:10px 0; font-size:22px; border-bottom:1px solid #f8bbd9; }
footer { bottom:0; padding:6px 0; font-size:12px; border-top:1px solid #f8bbd9; }

main {
  flex:1;
  display:flex;
  justify-content:center;
  align-items:flex-start;
  gap:40px;
  flex-wrap:wrap;
  padding:120px 20px 80px 20px;
}

/* Form Card */
.form-container {
  background: rgba(255,255,255,0.95);
  padding: 36px 28px;
  border-radius: 20px;
  box-shadow: 0 10px 40px var(--shadow);
  max-width:420px;
  width:100%;
  display:flex;
  flex-direction:column;
  gap:10px;
  position:relative;
}
.form-container h1 {
  font-size:26px;
  margin:0 0 10px 0;
  color:var(--rose);
}
.form-container .tagline {
  font-size:14px;
  color:#be185d;
  margin-bottom:18px;
}
input,textarea {
  width:100%;
  padding:10px;
  border:1px solid #f8bbd9;
  border-radius:8px;
  font-family:'Georgia', serif;
  font-size:14px;
}
textarea{height:110px; resize:none;}
button {
  background: linear-gradient(90deg,var(--rose),#f472b6);
  color:white;
  border:none;
  padding:12px 16px;
  border-radius:10px;
  cursor:pointer;
  font-size:15px;
  transition: transform 0.2s;
}
button:hover{transform:scale(1.05);}
#copied{color:var(--rose); display:none; margin-top:8px; font-size:14px; text-align:center;}

/* Letter Preview Card */
.letter-preview {
  max-width:540px;
  width:100%;
  position:relative;
  background: rgba(255,255,255,0.95);
  padding:24px;
  border-radius:20px;
  box-shadow:0 10px 40px var(--shadow);
  display:flex;
  flex-direction:column;
  gap:16px;
}

.letter-preview .instruction{
  text-align:center;
  font-weight:bold;
  color:var(--rose);
}

.envelope-container {position:relative;width:100%;aspect-ratio:3/2;margin:0 auto;}
.envelope {
  position: relative;
  width: 100%;
  height: 100%;
  cursor:pointer;
  overflow:hidden;
  border-radius:12px;
  box-shadow:0 10px 30px var(--shadow);
  background: linear-gradient(135deg, var(--light-rose), var(--rose));
  outline:1px solid rgba(255,255,255,.35);
}
 .envelope-liner{
    position:absolute;inset:0 0 50% 0; /* top half */
    background:
      repeating-linear-gradient(45deg, rgba(255,255,255,.25) 0 8px, rgba(255,255,255,.12) 8px 16px),
      linear-gradient(135deg,#ffd6ea,#e28ab6);
    clip-path:polygon(0 0,100% 0,50% 100%);
    z-index:1;
  }
.envelope-flap {
  position:absolute;top:0;left:0;width:100%;padding-top:50%;
  background: var(--rose);
  clip-path: polygon(0 0,50% 100%,100% 0);
  transform-origin: top center;
  transition: transform 1.4s ease-in-out;
  z-index:3;
  box-shadow:0 2px 0 rgba(255,255,255,.35) inset;
}
.envelope-bottom-flap{
  position:absolute;
  bottom:0;
  left:0;
  width:100%;
  height:46%;
  background:linear-gradient(135deg,#c53a79,#92134b);
  clip-path:polygon(0 100%,50% 0,100% 100%);
  z-index:1; /* behind the paper */
  box-shadow:0 -2px 0 rgba(0,0,0,.12) inset;
}

.envelope.opening .envelope-flap{transform:rotateX(180deg);}
.letter-content {
  position: absolute;
  top: 20%;
  left: 6%;
  right: 6%;
  bottom: 6%;
  padding: 28px 26px 24px 26px;
  border-radius: 10px;
  overflow: auto;
  z-index: 5;
  color: var(--ink);

  /* --- Paper stack: persistent textured layers even when scrolled --- */
  background-color: #fff;
  background-image:
    /* Layer 1: Horizontal Grid */
    repeating-linear-gradient(90deg, rgba(0,0,0,.02) 0 2px, transparent 2px 4px),
    /* Layer 2: Vertical Grid */
    repeating-linear-gradient(0deg, rgba(0,0,0,.01) 0 2px, transparent 2px 4px),
    /* All other existing background layers */
    linear-gradient(180deg, rgba(255,255,255,.98), rgba(255,255,255,.96)),
    repeating-linear-gradient(180deg, rgba(190,24,93,.08) 0 1px, transparent 1px 28px),
    radial-gradient(1200px 600px at 30% 20%, rgba(0,0,0,.03) 0 45%, transparent 46%),
    radial-gradient(900px 450px at 75% 80%, rgba(0,0,0,.025) 0 45%, transparent 46%);
  background-attachment: local, local, local, local;
  background-blend-mode: normal;

  box-shadow:
    inset 0 0 0 1px #f3c3d8,
    inset 0 20px 40px rgba(190, 24, 93, .06),
    0 10px 30px rgba(0, 0, 0, .18);
  transform: scale(.9) translateY(50px);
  opacity: 0;
  transition: transform 1.2s ease-out, opacity 1.2s ease-out;
  scroll-behavior: smooth;
}

/* Keep edge and watermark fixed relative to content */
/* .letter-content::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .03) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .02) 0 2px, transparent 2px 4px);
  mix-blend-mode: multiply;
  opacity: .35;
  background-attachment: local;
} */

.letter-content::after {
  content: "♥";
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%) rotate(-10deg);
  font-size: 180px;
  line-height: 1;
  color: #be185d;
  opacity: .04;
  pointer-events: none;
  background-attachment: local;
}

.envelope.opening .letter-content {
  transform: scale(1) translateY(0);
  opacity: 1;
  z-index: 4;
}


.header{text-align:center;border-bottom:2px solid #f8bbd9;padding-bottom:12px;margin-bottom:18px;}
.title{color: var(--rose); font-size:24px; margin-bottom:6px;}
.content {
  font-family: 'Great Vibes', 'Alex Brush', 'Allura', cursive;
  line-height: 1.8;
  font-size: 18px;
  word-break: break-word;
}
.signature{text-align:right;margin-top:22px;font-style:italic;color:var(--rose);}
.signature-from{margin-top:22px;font-style:italic;color:var(--rose);}
.signature-black{text-align:left;margin-top:22px;font-style:italic;}

.heart{position:fixed;bottom:-20px;color:#f472b6;font-size:14px;pointer-events:none;user-select:none;animation:floatUp 4s linear forwards;}
@keyframes floatUp{0%{transform:translateY(0) scale(1);opacity:1}100%{transform:translateY(-100vh) scale(0.8);opacity:0}}

.sparkle{position:absolute;width:12px;height:12px;background:#f59e0b;border-radius:50%;animation:sparkle 2s infinite;}
  @keyframes sparkle{0%,100%{opacity:0;transform:scale(0)}50%{opacity:1;transform:scale(1)}}

/* Mobile adjustments */
@media(max-width:920px){
  main{
    /* flex-direction:column; */
    align-items:center;gap:20px;padding:100px 20px 80px 20px;}
  .letter-preview, .form-container{max-width:92vw;}
  .envelope-container{aspect-ratio:4/3;}
}
@media(max-width:520px){
  .form-container h1{font-size:20px;}
  .content{font-size:16px;}
  .form-container{padding:20px;}
  main{padding:80px 10px 60px 10px;}
  /* .letter-content{top:22%;left:5%;right:5%;padding:20px;} */
}

