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

:root {
  --paper: #f5efe2;
  --paper-edge: #e8dfc9;
  --ink-paper: #2a2018;
  --ink-paper-2: #5c4b3a;
  --accent: #ff4d6d;
  --accent-2: #ff2d55;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #05070f;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
}

/* ============================================================
   SPACE BACKGROUND
============================================================ */
.space {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 25% 20%, #1b1035 0%, transparent 55%),
    radial-gradient(ellipse at 80% 85%, #0b1b3a 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, #0a0a18 0%, #000 100%);
  overflow: hidden;
  z-index: 0;
}

.nebula {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 30% 40%, rgba(120, 60, 200, 0.18) 0%, transparent 45%),
    radial-gradient(circle at 70% 60%, rgba(200, 60, 120, 0.14) 0%, transparent 50%),
    radial-gradient(circle at 50% 80%, rgba(60, 120, 220, 0.12) 0%, transparent 55%);
  filter: blur(40px);
  animation: nebulaDrift 40s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes nebulaDrift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-30px, -20px) scale(1.06); }
}

#stars-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ============================================================
   HEART LAYER
============================================================ */
.hearts-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.float-heart {
  position: absolute;
  bottom: -200px;
  will-change: transform, opacity;
  animation: floatHeart linear infinite;
}

.float-heart .heart-word {
  position: absolute;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
  transform: translate(-50%, -50%);
  text-shadow:
    0 0 6px rgba(255, 77, 109, 0.9),
    0 0 16px rgba(255, 45, 85, 0.6);
}

@keyframes floatHeart {
  0% {
    transform: translate3d(0, 0, 0) rotate(var(--rot, 0deg)) scale(0.85);
    opacity: 0;
  }
  8% { opacity: var(--op, 0.9); }
  92% { opacity: var(--op, 0.9); }
  100% {
    transform: translate3d(0, calc(-100vh - 400px), 0) rotate(var(--rot, 0deg)) scale(1);
    opacity: 0;
  }
}

/* ============================================================
   STAGE 1 — ENVELOPE
============================================================ */
.envelope-stage {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.envelope-stage.fade-out {
  opacity: 0;
  transform: scale(1.35);
  pointer-events: none;
}

.envelope-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
  cursor: pointer;
  user-select: none;
  animation: envelopeEnter 1.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes envelopeEnter {
  from { opacity: 0; transform: translateY(24px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.envelope-to {
  font-family: 'Great Vibes', 'Cormorant Garamond', cursive;
  font-size: clamp(28px, 5vw, 42px);
  color: #ff8fa3;
  letter-spacing: 1px;
  text-shadow:
    0 0 12px rgba(255, 77, 109, 0.6),
    0 0 28px rgba(255, 45, 85, 0.4);
  animation: fadeInSoft 1.6s ease both;
}
@keyframes fadeInSoft {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.envelope {
  position: relative;
  width: min(340px, 78vw);
  aspect-ratio: 1.55 / 1;
  perspective: 1200px;
  animation: envelopeFloat 4s ease-in-out infinite;
}
@keyframes envelopeFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

.envelope-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #2a1a2e, #1a0f24);
  border: 1px solid rgba(255, 77, 109, 0.25);
  border-radius: 10px;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.7),
    0 0 60px rgba(255, 45, 85, 0.2);
}

.envelope-letter-peek {
  position: absolute;
  left: 8%; right: 8%; top: 8%; bottom: 15%;
  background: linear-gradient(180deg, var(--paper), var(--paper-edge));
  border-radius: 6px;
  transform: translateY(20%);
  z-index: 1;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}

.envelope-flap {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 58%;
  background: linear-gradient(180deg, #3a1f42, #251429);
  border: 1px solid rgba(255, 77, 109, 0.3);
  border-radius: 10px 10px 0 0;
  transform-origin: top center;
  transform: rotateX(0deg);
  transition: transform 0.85s cubic-bezier(0.65, 0, 0.35, 1);
  z-index: 3;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.envelope-wrap.opening .envelope-flap {
  transform: rotateX(-180deg);
}

.envelope-front {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #2a1a2e, #1a0f24);
  border: 1px solid rgba(255, 77, 109, 0.25);
  border-radius: 10px;
  z-index: 2;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 55%, 50% 75%, 100% 55%, 100% 100%, 0 100%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 14%;
}

.envelope-seal {
  color: var(--accent-2);
  filter: drop-shadow(0 0 14px rgba(255, 77, 109, 0.9));
  animation: sealPulse 2s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  position: relative;
}
@keyframes sealPulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50%      { transform: scale(1.15); opacity: 1; }
}

.envelope-cta {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 22px;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 1px;
  animation: ctaPulse 2s ease-in-out infinite;
}
@keyframes ctaPulse {
  0%, 100% {
    opacity: 0.75;
    transform: translateY(0);
    text-shadow: 0 0 12px rgba(255, 77, 109, 0.5);
  }
  50% {
    opacity: 1;
    transform: translateY(-4px);
    text-shadow: 0 0 24px rgba(255, 77, 109, 0.9);
  }
}
.envelope-wrap.opening .envelope-cta,
.envelope-wrap.opening .envelope-to {
  opacity: 0;
  transition: opacity 0.4s;
}

/* ============================================================
   STAGE 2 — LETTER PAPER
============================================================ */
.stage {
  position: relative;
  z-index: 3;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px 80px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}
.stage.reveal {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.paper {
  position: relative;
  max-width: 620px;
  width: 100%;
  background: var(--paper);
  border-radius: 4px;
  padding: 60px 52px;
  color: var(--ink-paper);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 30px 80px rgba(0, 0, 0, 0.55),
    0 4px 18px rgba(0, 0, 0, 0.25);
  transform: rotate(-0.4deg);
  overflow: hidden;
  min-height: 560px;
  will-change: transform;
  backface-visibility: hidden;
}

.paper-texture {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 25%, rgba(120, 90, 60, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 75% 65%, rgba(120, 90, 60, 0.04) 1px, transparent 1px),
    radial-gradient(circle at 45% 85%, rgba(120, 90, 60, 0.04) 1px, transparent 1px);
  background-size: 22px 22px, 30px 30px, 18px 18px;
  pointer-events: none;
  opacity: 0.9;
  z-index: 0;
}

.paper::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 35px,
    rgba(120, 90, 60, 0.08) 35px,
    rgba(120, 90, 60, 0.08) 36px
  );
  background-position: 0 60px;
  pointer-events: none;
  z-index: 0;
}

.paper-content {
  position: relative;
  z-index: 1;
}

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: var(--ink-paper-2);
  margin-bottom: 22px;
  text-align: center;
}

.dear {
  font-family: 'Great Vibes', 'Cormorant Garamond', cursive;
  font-size: clamp(30px, 4.5vw, 44px);
  color: var(--accent-2);
  letter-spacing: 0.5px;
  margin-bottom: 18px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1s ease, transform 1s ease;
}
.dear.show { opacity: 1; transform: translateY(0); }

.apology {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(18px, 2.2vw, 22px);
  line-height: 36px;
  color: var(--ink-paper);
  word-break: break-word;
  overflow-wrap: break-word;
  min-height: 430px;
  text-rendering: optimizeLegibility;
}

.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent-2);
  margin-left: 3px;
  vertical-align: middle;
  transform: translateY(-2px);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink {
  0%, 50%   { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.signature {
  margin-top: 30px;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 17px;
  color: var(--ink-paper-2);
  text-align: right;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1.2s ease, transform 1.2s ease;
}
.signature.show { opacity: 1; transform: translateY(0); }

/* ============================================================
   CHOICES (Yes / No)
============================================================ */
.choices {
  max-width: 620px;
  width: 100%;
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.8s ease, transform 0.8s ease;
  pointer-events: none;
}
.choices.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.choices-prompt {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 20px;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  text-shadow: 0 0 16px rgba(255, 77, 109, 0.3);
}

.choices-buttons {
  position: relative;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 60px;
  padding: 10px;
}

.choice-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 15px 34px;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #fff;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.3s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-icon {
  display: inline-block;
  vertical-align: middle;
}

.choice-btn.yes {
  background: linear-gradient(135deg, #ff4d6d, #a30f24);
  box-shadow:
    0 12px 32px rgba(255, 45, 85, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  animation: yesPulse 2.4s ease-in-out infinite;
}
@keyframes yesPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 12px 32px rgba(255, 45, 85, 0.45); }
  50%      { transform: scale(1.04); box-shadow: 0 16px 44px rgba(255, 45, 85, 0.6); }
}
.choice-btn.yes:hover {
  transform: translateY(-2px) scale(1.06);
  box-shadow: 0 20px 52px rgba(255, 45, 85, 0.7);
}
.choice-btn.yes:active { transform: scale(0.98); }

/* The No button — runs away when touched */
.choice-btn.no {
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  position: relative;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  will-change: transform;
}
.choice-btn.no:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.4);
}
.choice-btn.no:active { transform: scale(0.98); }

/* ============================================================
   RESPONSE SCREENS
============================================================ */
.response-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  overflow-y: auto;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 45, 85, 0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 70% 80%, rgba(120, 60, 200, 0.18) 0%, transparent 50%),
    rgba(5, 7, 15, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s ease;
}
.response-screen.show {
  opacity: 1;
  pointer-events: auto;
}

.response-card {
  max-width: 640px;
  width: 100%;
  background: var(--paper);
  color: var(--ink-paper);
  border-radius: 4px;
  padding: 56px 48px;
  position: relative;
  transform: translateY(24px) rotate(-0.3deg);
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    0 4px 18px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  backface-visibility: hidden;
}
.response-screen.show .response-card {
  transform: translateY(0) rotate(-0.3deg);
}

.response-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 35px,
    rgba(120, 90, 60, 0.07) 35px,
    rgba(120, 90, 60, 0.07) 36px
  );
  background-position: 0 56px;
  pointer-events: none;
  z-index: 0;
}
.response-card > * { position: relative; z-index: 1; }

.response-yes { border-top: 3px solid var(--accent-2); }

.response-emoji {
  text-align: center;
  margin-bottom: 18px;
  animation: emojiIn 1.2s cubic-bezier(0.22, 1, 0.36, 1) both;
  display: flex;
  justify-content: center;
}
@keyframes emojiIn {
  from { opacity: 0; transform: scale(0.4) rotate(-15deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}

.response-title {
  font-family: 'Great Vibes', 'Cormorant Garamond', cursive;
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 400;
  margin-bottom: 22px;
  text-align: center;
  letter-spacing: 0.5px;
}
.response-yes .response-title { color: var(--accent-2); }

.response-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(17px, 2.2vw, 20px);
  line-height: 1.75;
  color: var(--ink-paper);
  margin-bottom: 16px;
}

.response-final {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px dashed rgba(120, 90, 60, 0.3);
  font-style: italic;
  text-align: center;
  color: var(--ink-paper-2);
}

.back-btn {
  display: block;
  margin: 32px auto 0;
  padding: 12px 24px;
  background: transparent;
  border: 1.5px solid rgba(120, 90, 60, 0.35);
  border-radius: 999px;
  color: var(--ink-paper-2);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.back-btn:hover {
  background: rgba(120, 90, 60, 0.08);
  border-color: rgba(120, 90, 60, 0.6);
  color: var(--ink-paper);
}

/* ============================================================
   EASTER EGG
============================================================ */
.easter-egg {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 215, 0, 0.15) 0%, transparent 55%),
    rgba(5, 7, 15, 0.97);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}
.easter-egg.show {
  opacity: 1;
  pointer-events: auto;
}

.egg-card {
  max-width: 580px;
  width: 100%;
  background: linear-gradient(135deg, #fff9e6, #f5efe2);
  color: #2a2018;
  border-radius: 4px;
  padding: 52px 44px;
  position: relative;
  border-top: 3px solid #ffd700;
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.7),
    0 0 80px rgba(255, 215, 0, 0.15);
  transform: translateY(24px) rotate(0.3deg);
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.easter-egg.show .egg-card {
  transform: translateY(0) rotate(0.3deg);
}

.egg-heart {
  text-align: center;
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  animation: eggHeartBeat 1.6s ease-in-out infinite;
}
@keyframes eggHeartBeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.15); }
  30% { transform: scale(1); }
  45% { transform: scale(1.1); }
  60% { transform: scale(1); }
}

.egg-title {
  font-family: 'Great Vibes', 'Cormorant Garamond', cursive;
  font-size: clamp(32px, 5vw, 46px);
  color: #b8860b;
  text-align: center;
  margin-bottom: 22px;
  letter-spacing: 0.5px;
}

.egg-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(17px, 2.2vw, 20px);
  line-height: 1.75;
  color: #2a2018;
  margin-bottom: 16px;
}

.egg-final {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(17px, 2.2vw, 20px);
  line-height: 1.75;
  font-style: italic;
  color: #5c4b3a;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px dashed rgba(120, 90, 60, 0.3);
  text-align: center;
}

.egg-close {
  display: block;
  margin: 32px auto 0;
  padding: 12px 28px;
  background: transparent;
  border: 1.5px solid rgba(120, 90, 60, 0.35);
  border-radius: 999px;
  color: #5c4b3a;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}
.egg-close:hover {
  background: rgba(120, 90, 60, 0.08);
  border-color: rgba(120, 90, 60, 0.6);
  color: #2a2018;
}

/* ============================================================
   AUDIO TOGGLE
============================================================ */
.audio-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 45, 85, 0.2);
  border: 1px solid rgba(255, 77, 109, 0.4);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}
.audio-toggle:hover {
  background: rgba(255, 45, 85, 0.35);
  transform: scale(1.08);
}
.audio-toggle.muted {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  opacity: 0.6;
}

.audio-toggle .audio-on  { display: block; }
.audio-toggle .audio-off { display: none; }
.audio-toggle.muted .audio-on  { display: none; }
.audio-toggle.muted .audio-off { display: block; }

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 700px) {
  .stage {
    padding: 40px 14px 60px;
    align-items: flex-start;
  }

  .paper {
    padding: 40px 26px;
    transform: rotate(-0.3deg);
    min-height: 600px;
  }

  .apology {
    font-size: 17px;
    line-height: 34px;
    min-height: 480px;
  }

  .dear { font-size: 34px; }
  .eyebrow { letter-spacing: 4px; font-size: 10px; }
  .signature { font-size: 15px; margin-top: 24px; }

  .choices-prompt { font-size: 17px; }
  .choice-btn { padding: 14px 26px; font-size: 14px; }
  .choices-buttons { gap: 10px; }

  .response-card {
    padding: 40px 26px;
    border-radius: 3px;
  }
  .response-text { font-size: 16.5px; }

  .egg-card { padding: 40px 26px; }
  .egg-text { font-size: 16.5px; }

  .envelope { width: min(280px, 82vw); }
  .envelope-cta { font-size: 19px; }
  .envelope-to { font-size: 30px; }

  .audio-toggle {
    width: 42px; height: 42px;
    font-size: 16px;
    bottom: 16px; right: 16px;
  }
}

@media (max-width: 380px) {
  .paper { padding: 32px 20px; min-height: 620px; }
  .apology { font-size: 16px; line-height: 32px; min-height: 500px; }
  .dear { font-size: 30px; }
  .response-card { padding: 32px 20px; }
  .egg-card { padding: 32px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .nebula,
  .float-heart,
  .float-heart .heart-word,
  .envelope,
  .envelope-seal,
  .envelope-cta,
  .choice-btn.yes,
  .response-emoji,
  .egg-heart {
    animation: none !important;
  }
}