@font-face {
  font-family: "Manrope";
  src: url("./fonts/Manrope-variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
}
:root {
  --paper: #f6f0e4;
  --ink: #3d3937;
  --muted: #77716c;
  --kraft: #c9a47a;
  --red: #903b45;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Manrope", "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--red); outline-offset: 5px; }
[hidden] { display: none !important; }
.opening {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 45%, #f9f5eb 0%, #eee7da 70%, #e4d8c7 100%);
  transition: opacity .55s ease, transform .55s ease;
}
.opening.leaving { opacity: 0; transform: translateY(-15px); pointer-events: none; }
.scene-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .28;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.13'/%3E%3C/svg%3E");
}
.scene-topline {
  position: absolute;
  z-index: 2;
  top: clamp(24px, 5vh, 54px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  margin: 0;
  color: #80695b;
  font-family: "Manrope", "Segoe UI", sans-serif;
  font-size: clamp(.92rem, 1.4vw, 1.1rem);
  letter-spacing: .16em;
}
.envelope-wrap {
  width: min(900px, 96vw);
  position: relative;
  z-index: 2;
  text-align: center;
  margin-top: 2.5rem;
}
.envelope {
  display: block;
  position: relative;
  border: 0;
  padding: 0;
  margin: 0 auto;
  width: min(850px, 94vw);
  aspect-ratio: 3 / 2;
  background: transparent;
  cursor: pointer;
  perspective: 1300px;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 13px 15px rgba(83, 58, 37, .12));
}
.envelope[disabled] { cursor: default; }
.flip-card {
  display: block;
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
}
.face {
  position: absolute;
  inset: 0;
  display: block;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face img, .open-frame {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}
.front img { clip-path: inset(12.4% 4.5% 12% 4.5% round 2px); }
.back { transform: rotateY(180deg); }
.back img {
  transform: scale(1.11);
  clip-path: inset(14.5% 10.2% 13.7% 10.2% round 2px);
}
.front-from,
.front-to,
.front-stamp {
  position: absolute;
  display: block;
  pointer-events: none;
  font-family: "Manrope", "Segoe UI", sans-serif;
}
.front-from {
  top: 18%;
  left: 8.5%;
  color: #4a4039;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: .015em;
  text-align: left;
  white-space: nowrap;
  transform: rotate(-2deg);
}
.front-to {
  top: 44%;
  left: 26%;
  color: #4a4039;
  font-size: 18px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  transform: rotate(-1deg);
}.front-stamp {
  top: 17.4%;
  left: 81.4%;
  width: 11.2%;
  height: 18.5%;
  display: grid;
  place-items: center;
  color: #8f4f48;
  font-size: clamp(7px, 1.35vw, 14px);
  font-weight: 700;
  line-height: 1.24;
  text-align: center;
  transform: rotate(-2deg);
}
.envelope.flipping .flip-card { animation: flip-over 1s steps(1, end) forwards; }
.envelope.show-back .flip-card { transform: rotateY(180deg); }
@keyframes flip-over {
  0% { transform: rotateY(0deg) rotate(-1deg) translateY(0); }
  20% { transform: rotateY(35deg) rotate(1deg) translateY(-3px); }
  40% { transform: rotateY(73deg) rotate(-1deg) translateY(-8px); }
  60% { transform: rotateY(108deg) rotate(1deg) translateY(-5px); }
  80% { transform: rotateY(148deg) rotate(-.5deg) translateY(-2px); }
  100% { transform: rotateY(180deg) rotate(0) translateY(0); }
}
.open-frame {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(1.1);
  clip-path: polygon(50% 4%, 89.5% 26%, 89.5% 92%, 10.5% 92%, 10.5% 26%);
}
.envelope.opening-one .flip-card,
.envelope.opening-two .flip-card { opacity: 0; }
.envelope.opening-one .open-one,
.envelope.opening-two .open-two { opacity: 1; }
.envelope.opening-one { transform: translate(-2px, 2px) rotate(-.6deg); }
.envelope.opening-two { transform: translate(2px, -2px) rotate(.35deg); }
.scene-prompt {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  margin: -2.2rem 0 0;
  color: #7a675a;
}
.scene-arrow { width: 68px; height: 48px; flex: none; }
.scene-instruction {
  margin: 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  font-size: clamp(1rem, 2vw, 1.2rem);
}
.scene-sticker {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  filter: drop-shadow(2px 5px 2px rgba(57, 46, 34, .1));
}
.scene-flower { width: clamp(80px, 12vw, 145px); left: clamp(-18px, 5vw, 100px); top: 21%; transform: rotate(-17deg); }
.scene-star { width: clamp(55px, 7vw, 90px); right: 9%; top: 24%; transform: rotate(13deg); }
.scene-heart { width: clamp(55px, 7vw, 80px); right: 12%; bottom: 10%; transform: rotate(-12deg); }

.letter-page {
  position: relative;
  min-height: 100svh;
  padding: clamp(32px, 5vw, 76px) clamp(24px, 5vw, 64px) 120px;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(141, 119, 92, .035) .7px, transparent .7px);
  background-size: 8px 8px;
  animation: letter-arrive .65s steps(5, end) both;
}
@keyframes letter-arrive {
  from { opacity: 0; transform: translateY(25px); }
  to { opacity: 1; transform: translateY(0); }
}
.letter-inner {
  max-width: 1050px;
  margin: 0 auto;
}
.letter-inner::after { content: ""; display: block; clear: both; }
.letter-main { min-width: 0; }
.audio-player {
  width: min(100%, 590px);
  min-height: 48px;
  padding: 5px 14px 5px 8px;
  display: flex;
  align-items: center;
  gap: 13px;
  background: #e8e8e6;
  color: #333332;
}
.audio-toggle {
  flex: 0 0 32px;
  width: 32px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.play-icon {
  display: block;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid currentColor;
}
.audio-toggle.is-playing .play-icon {
  width: 11px;
  height: 14px;
  border: 0;
  border-left: 4px solid currentColor;
  border-right: 4px solid currentColor;
}
.audio-time { font-size: .81rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.audio-progress {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 60px;
  height: 17px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.audio-progress::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(to right, #343434 0 var(--progress, 0%), #fafafa var(--progress, 0%) 100%);
}
.audio-progress::-moz-range-track { height: 4px; background: #fafafa; }
.audio-progress::-moz-range-progress { height: 4px; background: #343434; }
.audio-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border: 0;
  border-radius: 50%;
  background: #343434;
  margin-top: -3px;
}
.audio-progress::-moz-range-thumb { width: 10px; height: 10px; border: 0; border-radius: 50%; background: #343434; }
.letter-text {
  width: 100%;
  margin: 30px 0 0;
  white-space: normal;
  overflow-wrap: break-word;
  color: #514e4d;
  font-family: "Manrope", "Segoe UI", sans-serif;
  font-size: clamp(1.04rem, 1.2vw, 1.18rem);
  font-weight: 400;
  line-height: 1.83;
  letter-spacing: .005em;
}
.letter-note,
.letter-meta p,
.letter-section p { margin: 0; }
.letter-note { margin-bottom: 2.5em; }
.letter-meta p + p { margin-top: .65em; }
.letter-meta { margin-bottom: 2.5em; }
.letter-section + .letter-section { margin-top: 2em; }
.letter-section p + p { margin-top: .95em; }
.letter-note,
.letter-meta p,
.letter-section p { max-width: 650px; }
.memory-gallery {
  margin: 2.25em 0 2.5em;
  padding: 0;
  max-width: none;
}
.memory-gallery--first,
.memory-gallery--second {
  clear: both;
  display: grid;
  width: calc(100vw - 40px);
  margin-left: calc(50% - 50vw + 20px);
  gap: 12px;
}
.memory-gallery--first {
  aspect-ratio: 2.15;
  grid-template-columns: 1.05fr .9fr 1fr;
  grid-template-rows: repeat(2, minmax(0, 1fr));
}
.memory-gallery--second {
  aspect-ratio: 2.27;
  grid-template-columns: 1fr .62fr 1.25fr;
  grid-template-rows: 1.77fr 1fr;
}
.memory-item {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: cover;
  background: #dcd5c9;
}
.memory-first-left { grid-column: 1; grid-row: 1 / 3; }
.memory-first-middle { grid-column: 2; grid-row: 1; }
.memory-first-top { grid-column: 3; grid-row: 1; }
.memory-first-bottom { grid-column: 2 / 4; grid-row: 2; }
.memory-second-left { grid-column: 1; grid-row: 1 / 3; }
.memory-second-top { grid-column: 2 / 4; grid-row: 1; }
.memory-second-middle { grid-column: 2; grid-row: 2; }
.memory-second-right { grid-column: 3; grid-row: 2; object-position: 50% 52%; }
.memory-gallery--final {
  clear: both;
  width: calc(100vw - 40px);
  aspect-ratio: 2.1;
  margin: 3.25rem 0 0 calc(50% - 50vw + 20px);
}
.memory-final-video { object-position: center; }
.collage {
  position: relative;
  float: right;
  width: 300px;
  min-height: 680px;
  margin-left: clamp(24px, 4vw, 70px);
  padding-top: 110px;
}
.portrait-stack {
  position: relative;
  width: min(100%, 290px);
  margin-left: auto;
  transform: rotate(3deg);
  animation: sticker-pop .6s steps(4, end) .2s both;
}
.portrait { display: block; width: 100%; height: auto; filter: drop-shadow(7px 10px 0 rgba(112, 91, 72, .12)); }
.sticker { position: absolute; display: block; height: auto; filter: drop-shadow(3px 5px 1px rgba(100, 77, 54, .12)); }
.hat { width: 38%; left: 49%; top: -18%; transform: translateX(-50%) rotate(-11deg); transform-origin: center 90%; }
.cake { width: 36%; left: -12%; bottom: 2%; transform: rotate(-12deg); }
.sparkle { width: 22%; right: -10%; top: 26%; transform: rotate(20deg); }
.lily { width: 42%; left: -11%; top: 530px; transform: rotate(-13deg); }
.bow { width: 30%; right: 5%; top: 575px; transform: rotate(14deg); }
@keyframes sticker-pop {
  from { opacity: 0; transform: rotate(-4deg) scale(.8); }
  to { opacity: 1; transform: rotate(3deg) scale(1); }
}
.mobile-portrait { display: none; }
.letter-end { display: flex; align-items: end; gap: 14px; margin: 68px 0 0; }
.letter-end img { object-fit: contain; width: 66px; height: 66px; }
.letter-end img:nth-child(2) { width: 105px; height: 115px; transform: rotate(9deg); }
.letter-end img:nth-child(3) { width: 55px; height: 55px; transform: rotate(-14deg); }

@media (max-width: 760px) {
  .envelope-wrap { margin-top: 1rem; }
  .scene-flower { top: 15%; left: -18px; width: 85px; }
  .scene-star { top: 15%; right: 2%; width: 60px; }
  .scene-heart { bottom: 12%; right: 6%; width: 60px; }
  .scene-prompt { margin-top: -1.5rem; }
  .scene-arrow { width: 48px; height: 36px; }
  .letter-page { padding: 30px 24px 85px; }
  .letter-inner { display: block; max-width: 620px; }
  .letter-text { font-size: 1.02rem; line-height: 1.78; }
  .collage { display: none; }
  .memory-gallery--first,
  .memory-gallery--second { gap: 8px; aspect-ratio: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .memory-gallery--first { grid-template-rows: 125px 125px 170px; }
  .memory-first-left { grid-column: 1; grid-row: 1 / 3; }
  .memory-first-middle { grid-column: 2; grid-row: 1; }
  .memory-first-top { grid-column: 2; grid-row: 2; }
  .memory-first-bottom { grid-column: 1 / 3; grid-row: 3; }
  .memory-gallery--second { grid-template-rows: 180px 120px 120px; }
  .memory-second-top { grid-column: 1 / 3; grid-row: 1; }
  .memory-second-left { grid-column: 1; grid-row: 2 / 4; }
  .memory-second-middle { grid-column: 2; grid-row: 2; }
  .memory-second-right { grid-column: 2; grid-row: 3; }

  .mobile-portrait {
    display: block;
    position: relative;
    width: min(220px, 60vw);
    margin: 34px auto 12px;
    transform: rotate(3deg);
  }
  .mobile-portrait .portrait { width: 100%; }
  .mobile-portrait .hat { width: 38%; left: 49%; top: -18%; }
  .mobile-portrait .cake { width: 38%; left: -14%; bottom: 0; }
}
@media (max-width: 420px) {
  .audio-player { gap: 8px; padding-right: 9px; }
  .audio-time { font-size: .72rem; }
  .letter-page { padding-left: 20px; padding-right: 20px; }
  .scene-prompt { margin-top: -1.25rem; }
  .memory-gallery--first { grid-template-rows: 100px 100px 145px; }
  .memory-gallery--second { grid-template-rows: 150px 110px 110px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

