:root {
  --bg-left: #ff9fae;
  --bg-right: #ffd1c7;
  --ink: #2e1823;
  --ink-soft: rgba(46, 24, 35, 0.76);
  --rose-red: #eb0014;
  --rose-deep: #ff2f43;
  --rose-bright: #ff5f7f;
  --rose-mid: #ff6b88;
  --rose-soft: #ff89a4;
  --rose-light: #ffb2c2;
  --rose-lighter: #ffd8e3;
  --paper: #fffdfc;
  --paper-edge: #ffe9ee;
  --line: rgba(46, 24, 35, 0.08);
  --button: #ff655d;
  --shadow: 0 28px 60px rgba(160, 63, 83, 0.24);
  --shadow-soft: 0 18px 34px rgba(160, 63, 83, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  overflow-x: hidden;
  background: linear-gradient(135deg, var(--bg-left), var(--bg-right));
  color: var(--ink);
  font-family: "Manrope", sans-serif;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  filter: blur(50px);
  opacity: 0.65;
}

body::before {
  top: 8%;
  left: 5%;
  width: 18rem;
  height: 18rem;
  background: rgba(255, 255, 255, 0.28);
}

body::after {
  right: 6%;
  bottom: 10%;
  width: 14rem;
  height: 14rem;
  background: rgba(255, 94, 127, 0.22);
}

.particle-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

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

.intro-copy {
  max-width: 52rem;
  text-align: center;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(46, 24, 35, 0.62);
}

h1 {
  margin: 18px 0 0;
  font-size: clamp(2.45rem, 5vw, 3.95rem);
  line-height: 0.98;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.subtitle {
  margin: 14px auto 0;
  max-width: 38rem;
  font-size: clamp(1rem, 2vw, 1.1rem);
  line-height: 1.7;
  color: var(--ink-soft);
}

.envelope-scene {
  display: grid;
  justify-items: center;
  width: 100%;
  margin-top: 26px;
}

.letter-stage {
  position: relative;
  width: min(92vw, 520px);
  height: min(75vh, 640px);
  min-height: 520px;
  perspective: 1800px;
}

.letter {
  position: absolute;
  left: 50%;
  bottom: 126px;
  width: min(82%, 420px);
  height: min(58vh, 420px);
  min-height: 360px;
  padding: 34px 24px 20px;
  border-radius: 28px 28px 22px 22px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), var(--paper-edge)),
    var(--paper);
  box-shadow: 0 20px 48px rgba(126, 52, 72, 0.18);
  overflow: auto;
  opacity: 0;
  transform: translate(-50%, 240px);
  transform-origin: bottom center;
  transition:
    transform 900ms cubic-bezier(0.2, 0.95, 0.25, 1),
    box-shadow 500ms ease,
    opacity 240ms ease;
  pointer-events: none;
  z-index: 2;
}

.letter::-webkit-scrollbar {
  width: 7px;
}

.letter::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 101, 93, 0.32);
}

.envelope-scene.is-open .letter {
  opacity: 1;
  transform: translate(-50%, -34px);
  box-shadow: 0 34px 70px rgba(126, 52, 72, 0.24);
  pointer-events: auto;
}

.letter-heart,
.burst-heart {
  width: 50px;
  height: 50px;
  background: var(--rose-red);
  transform: rotate(-45deg);
}

.letter-heart,
.burst-heart,
.letter-heart::before,
.letter-heart::after,
.burst-heart::before,
.burst-heart::after {
  position: absolute;
}

.letter-heart::before,
.letter-heart::after,
.burst-heart::before,
.burst-heart::after {
  content: "";
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: inherit;
}

.letter-heart::before,
.burst-heart::before {
  top: -50%;
  left: 0;
}

.letter-heart::after,
.burst-heart::after {
  top: 0;
  left: 50%;
}

.letter-heart {
  top: 30px;
  left: 50%;
  width: 54px;
  height: 54px;
  transform: translateX(-50%) rotate(-45deg);
  box-shadow: 0 12px 18px rgba(235, 0, 20, 0.18);
}

.letter-kicker {
  margin: 80px 0 0;
  text-align: center;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(46, 24, 35, 0.5);
}

h2 {
  margin: 12px 0 0;
  text-align: center;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2.15rem, 5vw, 3rem);
  line-height: 1;
  font-weight: 700;
}

.letter-body {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.letter-body p {
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.6;
  color: rgba(46, 24, 35, 0.82);
}

.letter-final {
  font-weight: 700;
  color: #c63250;
}

.letter-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.letter-photo {
  position: relative;
  margin: 0;
  aspect-ratio: 3 / 4;
  padding: 6px;
  border: 1px solid rgba(255, 163, 183, 0.4);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #fff1f4);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.letter-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.signature {
  margin: 18px 0 0;
  text-align: center;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.45rem;
  font-weight: 700;
}

.envelope {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(100%, 520px);
  aspect-ratio: 10 / 6.7;
  transform: translateX(-50%);
  filter: drop-shadow(0 22px 32px rgba(127, 56, 77, 0.22));
}

.envelope-shadow {
  position: absolute;
  inset: auto 8% -7%;
  height: 18%;
  border-radius: 50%;
  background: rgba(151, 64, 83, 0.25);
  filter: blur(22px);
}

.envelope-back,
.envelope-flap,
.envelope-left,
.envelope-right,
.envelope-bottom {
  position: absolute;
  inset: 0;
}

.envelope-back {
  background: linear-gradient(180deg, #ff3240, #ff566b);
  border-radius: 0 0 28px 28px;
  z-index: 1;
}

.envelope-flap {
  height: 58%;
  background: linear-gradient(180deg, #ff2636, #ff4a61);
  clip-path: polygon(0 0, 50% 82%, 100% 0);
  transform-origin: center top;
  transform: rotateX(0deg);
  transition: transform 900ms cubic-bezier(0.2, 0.95, 0.25, 1);
  z-index: 5;
  backface-visibility: hidden;
}

.envelope-scene.is-open .envelope-flap {
  transform: rotateX(180deg);
  z-index: 1;
}

.envelope-left {
  background: linear-gradient(180deg, #ff6f8c, #ff6a88);
  clip-path: polygon(0 0, 52% 50%, 0 100%);
  z-index: 6;
}

.envelope-right {
  background: linear-gradient(180deg, #ff6a88, #ff5f80);
  clip-path: polygon(100% 0, 48% 50%, 100% 100%);
  z-index: 6;
}

.envelope-bottom {
  background: linear-gradient(180deg, #ff8aa2, #ff7d98);
  clip-path: polygon(0 100%, 50% 50%, 100% 100%);
  z-index: 7;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin-top: 48px;
}

.action-button {
  min-width: 172px;
  padding: 18px 28px;
  border: 2px solid rgba(255, 101, 93, 0.9);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--button);
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    transform 220ms ease,
    background 220ms ease,
    color 220ms ease,
    box-shadow 220ms ease,
    opacity 220ms ease;
}

.action-button:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.26);
  box-shadow: 0 16px 28px rgba(160, 63, 83, 0.16);
}

.action-button:active {
  transform: translateY(0);
}

.action-button.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.status-note {
  margin: 14px 0 0;
  font-size: 0.96rem;
  color: rgba(46, 24, 35, 0.62);
  text-align: center;
}

.burst-heart {
  bottom: 22vh;
  width: 18px;
  height: 18px;
  border-radius: 5px 0 0 0;
  opacity: 0;
  animation: burstUp linear forwards;
}

@keyframes burstUp {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(-45deg) scale(0.55);
  }

  15% {
    opacity: 0.95;
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--drift-x), -48vh, 0) rotate(-45deg) scale(1.15);
  }
}

@media (max-width: 900px) {
  .experience {
    padding-top: 32px;
  }

  .letter-stage {
    min-height: 560px;
  }

  .letter {
    height: min(54vh, 410px);
  }
}

@media (max-width: 640px) {
  .experience {
    align-content: start;
    padding: 24px 12px 18px;
  }

  .intro-copy {
    max-width: 22rem;
  }

  h1 {
    font-size: clamp(2.1rem, 10.5vw, 2.9rem);
    line-height: 1;
  }

  .subtitle {
    font-size: 0.96rem;
  }

  .envelope-scene {
    margin-top: 18px;
  }

  .letter-stage {
    width: min(100%, 460px);
    height: auto;
    min-height: 500px;
  }

  .letter {
    bottom: 112px;
    width: min(86%, 360px);
    min-height: 334px;
    height: min(49vh, 372px);
    padding: 30px 18px 18px;
    border-radius: 24px 24px 18px 18px;
    transform: translate(-50%, 220px);
  }

  .envelope-scene.is-open .letter {
    transform: translate(-50%, -20px);
  }

  .letter-kicker {
    margin-top: 80px;
    font-size: 0.66rem;
  }

  h2 {
    font-size: 2.15rem;
  }

  .letter-body p {
    font-size: 0.9rem;
    line-height: 1.55;
  }

  .letter-gallery {
    gap: 8px;
  }

  .letter-photo {
    padding: 5px;
    border-radius: 14px;
  }

  .letter-photo img {
    border-radius: 10px;
  }

  .envelope {
    width: min(100%, 420px);
  }

  .controls {
    width: 100%;
    gap: 12px;
    margin-top: 30px;
  }

  .action-button {
    min-width: 0;
    flex: 1 1 0;
    padding: 16px 20px;
    font-size: 0.92rem;
  }
}

@media (max-width: 420px) {
  .experience {
    padding-inline: 10px;
  }

  .letter-stage {
    min-height: 470px;
  }

  .letter {
    width: 88%;
    min-height: 320px;
    height: min(46vh, 350px);
    padding-inline: 16px;
  }

  .letter-heart {
    width: 48px;
    height: 48px;
  }

  .controls {
    flex-direction: column;
  }

  .action-button {
    width: 100%;
  }

  .status-note {
    max-width: 18rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
