:root {
  --paper: #f8f1e7;
  --paper-deep: #efe3d2;
  --ink: #30251f;
  --muted: #806f63;
  --wine: #8a4b4d;
  --wine-dark: #64383a;
  --pink: #dca2a0;
  --line: rgba(91, 61, 48, .18);
  --shadow: 0 24px 70px rgba(70, 45, 36, .14);
  --serif: "Gowun Batang", "Noto Serif KR", Georgia, serif;
  --hand: "Nanum Pen Script", cursive;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, rgba(255,255,255,.9), transparent 35%),
    radial-gradient(circle at 90% 80%, rgba(233,199,194,.28), transparent 30%),
    var(--paper);
  font-family: var(--serif);
  overflow-x: hidden;
}
body.locked { overflow: hidden; }
button { font: inherit; }
img { display: block; max-width: 100%; }

.paper-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: .14;
  mix-blend-mode: multiply;
  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='.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.13'/%3E%3C/svg%3E");
}

.cover {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  padding: 32px 20px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.95), transparent 33%),
    linear-gradient(145deg, #f9f2e9 0%, #efe2d3 100%);
  transition: opacity 1s ease, visibility 1s ease, transform 1.2s cubic-bezier(.2,.8,.2,1);
  overflow: hidden;
}
.cover.is-open {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-2%);
}
.cover__glow {
  position: absolute;
  width: 440px;
  height: 440px;
  border-radius: 50%;
  filter: blur(20px);
  opacity: .28;
  pointer-events: none;
}
.cover__glow--1 { left: -220px; top: -180px; background: #e8b7b1; }
.cover__glow--2 { right: -240px; bottom: -210px; background: #d4b6a3; }
.eyebrow {
  margin: 0 0 18px;
  font-size: 11px;
  letter-spacing: .32em;
  color: var(--muted);
}
.cover h1 {
  margin: 0;
  font-size: clamp(48px, 9vw, 92px);
  font-weight: 400;
  letter-spacing: -.06em;
}
.cover__subtitle {
  margin: 18px 0 34px;
  line-height: 1.9;
  font-size: clamp(15px, 2vw, 18px);
  color: #69594f;
}
.cover__hint {
  margin: 13px 0 0;
  font-size: 11px;
  color: #97877b;
}

.envelope {
  position: relative;
  width: min(330px, 80vw);
  aspect-ratio: 1.55;
  border: 0;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 24px 26px rgba(85, 54, 43, .18));
  perspective: 900px;
}
.envelope__back,
.envelope__front,
.envelope__flap,
.envelope__letter {
  position: absolute;
  inset: 0;
  border-radius: 5px;
}
.envelope__back { background: #dcbeb0; }
.envelope__letter {
  inset: 8% 8% 10%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 18%;
  background: #fffaf4;
  color: var(--wine-dark);
  font-family: var(--hand);
  font-size: clamp(25px, 6vw, 34px);
  transform: translateY(8%);
  transition: transform .6s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,.07);
}
.envelope__front {
  background:
    linear-gradient(33deg, #e3c8b8 49.4%, transparent 50%) 0 100%/50% 100% no-repeat,
    linear-gradient(-33deg, #ddbcaa 49.4%, transparent 50%) 100% 100%/50% 100% no-repeat;
}
.envelope__flap {
  height: 55%;
  transform-origin: 50% 0;
  background: linear-gradient(155deg, #e6ccbd 49.6%, transparent 50%) left top/50.5% 100% no-repeat,
              linear-gradient(-155deg, #e0c3b2 49.6%, transparent 50%) right top/50.5% 100% no-repeat;
  transition: transform .65s cubic-bezier(.2,.8,.2,1);
  z-index: 3;
}
.envelope__seal {
  position: absolute;
  left: 50%;
  top: 43%;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--wine);
  color: #fff5ef;
  font-size: 25px;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.12), 0 5px 10px rgba(77,37,37,.22);
  transition: opacity .25s ease, transform .5s ease;
}
.envelope:hover .envelope__letter { transform: translateY(2%); }
.envelope:hover .envelope__seal { transform: translate(-50%,-50%) scale(1.07); }
.cover.opening .envelope__flap { transform: rotateX(175deg); }
.cover.opening .envelope__seal { opacity: 0; transform: translate(-50%,-50%) scale(.6); }
.cover.opening .envelope__letter { transform: translateY(-40%); }

.open-label {
  margin-top: 24px;
  border: 0;
  border-bottom: 1px solid rgba(100,56,58,.38);
  padding: 4px 3px 5px;
  background: transparent;
  color: var(--wine-dark);
  font-size: 14px;
  cursor: pointer;
}

.page {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 1.3s ease .25s, transform 1.3s ease .25s;
}
.page.is-visible { opacity: 1; transform: none; }

.music-control {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  top: max(18px, env(safe-area-inset-top));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  border: 1px solid rgba(92,62,51,.15);
  border-radius: 999px;
  background: rgba(248,241,231,.78);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(70,45,36,.08);
}
.music-control button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--wine);
  color: white;
  cursor: pointer;
  transition: transform .2s ease;
}
.music-control button:hover { transform: scale(1.06); }
.music-control span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--muted);
}

.hero-photo {
  min-height: 96svh;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 24px;
  padding: 90px 22px 70px;
}
.hero-photo__frame {
  width: min(760px, 91vw);
  aspect-ratio: 4 / 5;
  max-height: 72svh;
  background: #e8d9cb;
  padding: clamp(10px, 2vw, 16px);
  box-shadow: var(--shadow);
  transform: rotate(-1.2deg);
}
.hero-photo__frame img,
.photo-card img,
.last-photo__image img { width: 100%; height: 100%; object-fit: cover; }
.handwritten {
  margin: 0;
  font-family: var(--hand);
  font-size: clamp(28px, 5vw, 44px);
  color: var(--wine-dark);
  transform: rotate(-2deg);
}

.photo-frame { position: relative; overflow: hidden; }
.photo-frame.is-missing img { display: none; }
.photo-frame.is-missing::after {
  content: attr(data-fallback);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,.65), transparent 28%),
    linear-gradient(135deg, #eadbd0, #d8bdb2);
  color: rgba(92,62,51,.7);
  font-family: var(--hand);
  font-size: clamp(23px, 4vw, 34px);
  text-align: center;
}

.letter {
  width: min(820px, calc(100% - 34px));
  margin: 20px auto 100px;
  padding: clamp(34px, 7vw, 82px) clamp(24px, 7vw, 76px);
  background:
    linear-gradient(rgba(126,98,78,.06) 1px, transparent 1px) 0 0/100% 32px,
    #fffaf3;
  border: 1px solid rgba(98,70,55,.13);
  box-shadow: var(--shadow);
  position: relative;
}
.letter::before {
  content: "";
  position: absolute;
  width: 120px;
  height: 34px;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  background: rgba(221,198,169,.45);
  box-shadow: inset 0 0 1px rgba(90,60,45,.15);
}
.letter__header { margin-bottom: 42px; }
.letter__date {
  font-size: 11px;
  color: #9c897b;
  letter-spacing: .15em;
  text-transform: uppercase;
}
.letter h2 {
  margin: 14px 0 0;
  font-family: var(--hand);
  font-size: clamp(38px, 7vw, 60px);
  font-weight: 400;
  color: var(--wine-dark);
  line-height: 1.1;
}
.letter__body p {
  margin: 0 0 30px;
  font-size: clamp(15px, 2vw, 17.5px);
  line-height: 2.08;
  letter-spacing: -.015em;
  word-break: keep-all;
}
.letter__body strong { color: var(--wine-dark); }
.quote-note {
  margin: 50px 0;
  padding: 26px 28px 22px;
  border-left: 3px solid var(--pink);
  background: rgba(229,202,191,.24);
}
.quote-note span {
  display: block;
  font-family: var(--hand);
  font-size: clamp(28px, 5vw, 38px);
  color: var(--wine-dark);
}
.quote-note p { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

.photo-grid {
  width: min(1080px, calc(100% - 30px));
  margin: 0 auto 110px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  grid-template-rows: auto auto;
  gap: 20px;
}
.photo-card {
  margin: 0;
  min-height: 310px;
  background: #e6d5c8;
  padding: 11px 11px 54px;
  box-shadow: 0 18px 42px rgba(74,49,39,.12);
}
.photo-card--tall { grid-row: 1 / span 2; min-height: 690px; transform: rotate(-1deg); }
.photo-card--wide { aspect-ratio: 1.35; transform: rotate(1.2deg); }
.photo-card:not(.photo-card--tall):not(.photo-card--wide) { aspect-ratio: 1.35; transform: rotate(-.7deg); }
.photo-card figcaption {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 13px;
  font-family: var(--hand);
  font-size: 25px;
  color: #6f4b46;
  text-align: center;
}

.letter--second { margin-bottom: 120px; }
.letter__emphasis {
  margin: 52px 0 !important;
  padding: 24px 0 24px 28px;
  border-left: 2px solid var(--wine);
  font-family: var(--hand);
  font-size: clamp(31px, 5vw, 42px) !important;
  line-height: 1.55 !important;
  color: var(--wine-dark);
}
.closing {
  margin-top: 58px !important;
  font-family: var(--hand);
  font-size: clamp(34px, 6vw, 48px) !important;
  line-height: 1.5 !important;
  color: var(--wine-dark);
}
.signature {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  margin-top: 52px;
  color: #7c665a;
}
.signature span { font-size: 11px; letter-spacing: .12em; }
.signature strong { font-family: var(--hand); font-size: 29px; font-weight: 400; }

.last-photo {
  width: min(820px, calc(100% - 34px));
  margin: 0 auto 120px;
  display: grid;
  grid-template-columns: 1.25fr .75fr;
  align-items: center;
  gap: 34px;
}
.last-photo__image {
  aspect-ratio: 4 / 5;
  padding: 12px;
  background: #ead9cc;
  box-shadow: var(--shadow);
  transform: rotate(1.4deg);
}
.last-photo__text span {
  font-size: 10px;
  letter-spacing: .22em;
  color: var(--muted);
}
.last-photo__text p {
  margin: 10px 0 0;
  font-family: var(--hand);
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.45;
  color: var(--wine-dark);
}
.footer {
  min-height: 42svh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 60px 20px 120px;
  text-align: center;
}
.footer p { margin: 0; font-size: 11px; letter-spacing: .3em; color: var(--muted); }
.footer span { font-family: var(--hand); font-size: 72px; color: var(--wine); }

.section-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 1s ease, transform 1s ease;
}
.section-reveal.is-in { opacity: 1; transform: none; }

.confetti { position: fixed; inset: 0; z-index: 80; pointer-events: none; overflow: hidden; }
.confetti-piece {
  position: absolute;
  top: -30px;
  width: 9px;
  height: 15px;
  border-radius: 2px;
  opacity: .78;
  animation: fall var(--duration) linear var(--delay) forwards;
  background: var(--c);
  transform: rotate(var(--r));
}
@keyframes fall {
  0% { transform: translate3d(0,-30px,0) rotate(0deg); }
  100% { transform: translate3d(var(--drift),105vh,0) rotate(680deg); }
}

@media (max-width: 760px) {
  .desktop-break { display: none; }
  .hero-photo { min-height: 88svh; padding-top: 75px; }
  .hero-photo__frame { aspect-ratio: 4 / 5.3; }
  .letter { margin-bottom: 72px; }
  .letter__body p { line-height: 2; }
  .photo-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 28px;
    width: min(540px, calc(100% - 34px));
  }
  .photo-card--tall { grid-row: auto; min-height: 520px; }
  .photo-card--wide,
  .photo-card:not(.photo-card--tall):not(.photo-card--wide) { min-height: 380px; aspect-ratio: auto; }
  .last-photo { grid-template-columns: 1fr; gap: 28px; }
  .last-photo__text { text-align: center; }
  .music-control span { display: none; }
  .music-control { padding: 5px; }
}

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