:root {
  --bg-left: #b9dcff;
  --bg-right: #eff8ff;
  --ink: #1f3e5a;
  --ink-soft: rgba(31, 62, 90, 0.76);
  --heart-red: #74afea;
  --heart-bright: #96c7ff;
  --heart-soft: #b5dbff;
  --paper: #fcfeff;
  --paper-edge: #eaf5ff;
  --button: #4d89c8;
  --shadow: 0 28px 60px rgba(78, 120, 168, 0.24);
}

* {
  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;
  pointer-events: none;
  filter: blur(54px);
  opacity: 0.58;
}

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

body::after {
  right: 8%;
  bottom: 10%;
  width: 16rem;
  height: 16rem;
  background: rgba(122, 189, 255, 0.24);
}

.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(31, 62, 90, 0.58);
}

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

.subtitle {
  margin: 14px auto 0;
  max-width: 34rem;
  font-size: clamp(1rem, 2vw, 1.08rem);
  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);
  min-height: 360px;
  max-height: min(58vh, 430px);
  padding: 34px 24px 24px;
  border-radius: 28px 28px 22px 22px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), var(--paper-edge)),
    var(--paper);
  box-shadow: 0 20px 48px rgba(90, 126, 165, 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(77, 137, 200, 0.32);
}

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

.letter-heart,
.burst-heart {
  width: 50px;
  height: 50px;
  background: var(--heart-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(116, 175, 234, 0.22);
}

.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(31, 62, 90, 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: 18px;
}

.letter-body p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.66;
  color: rgba(31, 62, 90, 0.84);
}

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

.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(87, 126, 168, 0.22));
}

.envelope-shadow {
  position: absolute;
  inset: auto 8% -7%;
  height: 18%;
  border-radius: 50%;
  background: rgba(101, 143, 188, 0.24);
  filter: blur(22px);
}

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

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

.envelope-flap {
  height: 58%;
  background: linear-gradient(180deg, #8ac5fb, #6aaee9);
  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, #a8d3ff, #84bbea);
  clip-path: polygon(0 0, 52% 50%, 0 100%);
  z-index: 6;
}

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

.envelope-bottom {
  background: linear-gradient(180deg, #cbe6ff, #a8d3ff);
  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(77, 137, 200, 0.9);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.2);
  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.34);
  box-shadow: 0 16px 28px rgba(78, 120, 168, 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(31, 62, 90, 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 {
    max-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;
    max-height: min(49vh, 390px);
    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.91rem;
    line-height: 1.58;
  }

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

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

  .action-button {
    min-width: 0;
    width: min(100%, 220px);
    padding: 16px 18px;
  }

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