:root {
  --wine: #2a1218;
  --wine-deep: #16090d;
  --rose: #c45b66;
  --blush: #e8a0a8;
  --gold: #e4c48a;
  --gold-deep: #c9a15a;
  --cream: #f6efe4;
  --ink: #3a2428;
  --box: #9b2f3d;
  --box-dark: #7a2230;
  --envelope: #f3e6d2;
  --envelope-dark: #e2cfb3;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: "Manrope", sans-serif;
  color: var(--cream);
  background:
    radial-gradient(circle at 20% 10%, rgba(196, 91, 102, 0.22), transparent 36%),
    radial-gradient(circle at 80% 90%, rgba(228, 196, 138, 0.14), transparent 32%),
    linear-gradient(160deg, var(--wine-deep), var(--wine) 55%, #3a1820);
  overflow-x: hidden;
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
  z-index: 0;
}

.glow-a {
  width: 280px;
  height: 280px;
  background: rgba(228, 196, 138, 0.16);
  top: -80px;
  right: -40px;
}

.glow-b {
  width: 360px;
  height: 360px;
  background: rgba(196, 91, 102, 0.18);
  bottom: -120px;
  left: -80px;
}

.petals {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(246, 239, 228, 0.18) 1px, transparent 1.5px),
    radial-gradient(circle, rgba(228, 196, 138, 0.16) 1px, transparent 1.5px);
  background-size: 90px 90px, 140px 140px;
  background-position: 0 0, 40px 60px;
  opacity: 0.45;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px 48px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.gate {
  width: min(520px, 100%);
  text-align: center;
  animation: rise 0.8s ease both;
}

.eyebrow {
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--gold);
  margin-bottom: 14px;
}

h1,
.letter-title {
  font-family: "Cormorant Garamond", serif;
  font-weight: 600;
}

h1 {
  font-size: clamp(2.6rem, 8vw, 4.4rem);
  line-height: 0.95;
  margin-bottom: 16px;
}

.lede {
  color: rgba(246, 239, 228, 0.78);
  line-height: 1.6;
  margin-bottom: 32px;
}

.password-form {
  display: grid;
  gap: 12px;
}

.password-form input,
.password-form button {
  width: 100%;
  min-height: 56px;
  border-radius: 999px;
  border: 0;
  font: inherit;
}

.password-form input {
  background: rgba(246, 239, 228, 0.08);
  color: var(--cream);
  padding: 0 22px;
  border: 1px solid rgba(228, 196, 138, 0.28);
  outline: none;
  text-align: center;
}

.password-form input::placeholder {
  color: rgba(246, 239, 228, 0.45);
}

.password-form input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(228, 196, 138, 0.14);
}

.password-form button {
  background: linear-gradient(180deg, #f0d7a4, var(--gold-deep));
  color: #4a2d18;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.password-form button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.error {
  color: #ffb3b8;
  min-height: 1.4em;
  font-size: 0.95rem;
}

.gate.shake .password-form {
  animation: shake 0.42s ease;
}

.preview-gift {
  width: 210px;
  height: 210px;
  margin: 28px auto 0;
  position: relative;
  display: grid;
  place-items: end center;
  transform: scale(0.78);
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.22));
}

.reveal {
  width: min(920px, 100%);
  min-height: 80vh;
  display: grid;
  place-items: center;
}

.stage {
  position: relative;
  width: min(640px, 96vw);
  height: min(88vh, 820px);
  display: grid;
  place-items: center;
  perspective: 900px;
}

.gift,
.envelope {
  position: absolute;
  transform-origin: center;
}

.gift {
  width: 210px;
  height: 210px;
  display: grid;
  place-items: end center;
  transition: opacity 0.5s ease, transform 0.8s ease;
}

.gift-box {
  width: 180px;
  height: 130px;
  background: linear-gradient(160deg, #c24454, var(--box) 48%, var(--box-dark));
  border-radius: 8px 8px 14px 14px;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  position: relative;
  overflow: hidden;
}

.gift-lid {
  position: absolute;
  top: 28px;
  left: 3px;
  width: 204px;
  height: 52px;
  background: linear-gradient(180deg, #d85b68, #9a2d3a);
  border-radius: 8px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  z-index: 3;
  transform-origin: center bottom;
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.ribbon-v,
.ribbon-h {
  position: absolute;
  background: linear-gradient(180deg, #f4dba0, var(--gold-deep));
}

.ribbon-v {
  width: 28px;
  inset: 0 auto 0 50%;
  transform: translateX(-50%);
}

.ribbon-h {
  height: 28px;
  inset: 42% 0 auto;
}

.bow {
  position: absolute;
  left: 50%;
  top: -22px;
  width: 86px;
  height: 52px;
  transform: translateX(-50%);
}

.bow-left,
.bow-right {
  position: absolute;
  top: 8px;
  width: 38px;
  height: 28px;
  background: radial-gradient(circle at 30% 30%, #fff3c8, var(--gold-deep));
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}

.bow-left {
  left: 0;
  transform: rotate(-28deg);
}

.bow-right {
  right: 0;
  transform: rotate(28deg);
}

.bow-knot {
  position: absolute;
  left: 50%;
  top: 14px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f6e3b0;
  transform: translateX(-50%);
  box-shadow: 0 4px 0 #b8893d;
}

.stage.opening .gift {
  animation: gift-wiggle 0.55s ease;
}

.stage.opened .gift-lid {
  transform: translateY(-92px) rotate(-12deg);
}

.stage.opened .gift {
  opacity: 0.18;
  transform: translateY(70px) scale(0.86);
}

.envelope {
  width: min(380px, 88vw);
  height: 230px;
  opacity: 0;
  transform: translateY(40px) scale(0.7);
  transform-style: preserve-3d;
  transition:
    opacity 0.55s ease,
    transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 4;
}

.stage.opened .envelope {
  opacity: 1;
  transform: translateY(46px) scale(1);
}

.stage.revealed .envelope {
  transform: translateY(78px) scale(1);
}

.envelope-back,
.envelope-flap,
.envelope-pocket,
.letter {
  position: absolute;
}

.envelope-back {
  inset: 0;
  background: linear-gradient(180deg, #f8eddb, var(--envelope-dark));
  border-radius: 8px 8px 16px 16px;
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.28);
}

.envelope-pocket {
  inset: 0;
  z-index: 5;
  background:
    linear-gradient(140deg, #f6e7cf 0 46%, transparent 46%),
    linear-gradient(-140deg, #edd6b6 0 46%, transparent 46%),
    linear-gradient(180deg, transparent 42%, #e4c9a6 42%);
  clip-path: polygon(0 42%, 50% 100%, 100% 42%, 100% 100%, 0 100%);
}

.envelope-flap {
  left: 0;
  right: 0;
  top: 0;
  height: 118px;
  background: linear-gradient(180deg, #fff6e8, #e7d3b4);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  z-index: 6;
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.12));
  backface-visibility: hidden;
}

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

.letter {
  left: -80px;
  right: -80px;
  top: 14px;
  height: min(72vh, 560px);
  background: var(--cream);
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 10px 10px;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.18);
  transform: translateY(84px);
  opacity: 0;
  z-index: 3;
  transition:
    transform 0.85s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.5s ease;
}

.stage.revealed .letter {
  transform: translateY(calc(-1 * min(56vh, 430px)));
  opacity: 1;
  z-index: 7;
}

.letter-title {
  text-align: center;
  font-size: 1.55rem;
  margin-bottom: 8px;
  color: #6a2d36;
}

.photo-frame {
  height: calc(100% - 40px);
  border-radius: 12px;
  overflow: hidden;
  background: #ead9c4;
  display: grid;
  place-items: center;
  position: relative;
}

.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.photo-frame img.is-loaded {
  display: block;
  cursor: zoom-in;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  background: rgba(14, 6, 9, 0.94);
  cursor: zoom-out;
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  width: min(96vw, 1400px);
  height: min(92vh, 900px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(246, 239, 228, 0.12);
  color: var(--cream);
  font-size: 1.1rem;
  cursor: pointer;
}

.lightbox-close:hover {
  background: rgba(246, 239, 228, 0.22);
}

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 6;
}

.confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  animation: fall linear forwards;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  75% {
    transform: translateX(8px);
  }
}

@keyframes gift-wiggle {
  0%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(-6deg);
  }
  75% {
    transform: rotate(6deg);
  }
}

@keyframes fall {
  to {
    transform: translateY(110vh) rotate(360deg);
    opacity: 0.2;
  }
}

@media (max-width: 640px) {
  .stage {
    height: 640px;
  }

  .envelope {
    width: min(300px, 88vw);
  }

  .letter {
    left: 6px;
    right: 6px;
    height: min(64vh, 460px);
  }

  .stage.revealed .letter {
    transform: translateY(-210px);
  }
}
