:root {
  color-scheme: light;
  --paper: #f8f4eb;
  --ink: #352820;
  --red: #a12c28;
  --red-dark: #85221f;
  --butter: #f6e8ca;
  --serif: "Songti SC", "Noto Serif CJK SC", "Noto Serif SC", SimSun, serif;
  --hand: "Kaiti SC", KaiTi, STKaiti, var(--serif);
  --grain: url("assets/grain.png");
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--grain), var(--paper);
  font: 500 1rem/1.65 var(--serif);
}
p, h1, h2 { margin: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 5px; }
.page-width { width: min(92%, 1380px); margin-inline: auto; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
.header-wrap {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--grain), var(--paper);
}
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding-block: 1.25rem 1.35rem;
  border-bottom: 1px solid var(--red);
}
.wordmark {
  text-decoration: none;
  color: var(--red);
  font-size: clamp(1.12rem, 2.45vw, 2.05rem);
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
}
.spark {
  display: inline-block;
  transform: rotate(-18deg);
  margin-left: .16em;
  color: var(--red);
  font-family: Georgia, serif;
}
.masthead-end { display: flex; align-items: center; gap: clamp(.65rem, 2vw, 1.65rem); }
.address { padding-right: clamp(.65rem, 2vw, 1.65rem); border-right: 1px solid var(--red); font-size: clamp(.9rem, 1.7vw, 1.4rem); }
.music {
  display: flex;
  align-items: center;
  gap: .55em;
  min-height: 42px;
  padding: .26em .9em;
  border: 1px solid var(--red);
  border-radius: 8px;
  background: transparent;
  color: var(--red);
  white-space: nowrap;
  font-size: clamp(.84rem, 1.4vw, 1.15rem);
}
.music:hover, .music[aria-pressed="true"] { background: #ae332f0d; }
#music-icon { font-size: .8em; }
.opening {
  display: grid;
  grid-template-columns: minmax(0, 44fr) minmax(0, 56fr);
  align-items: center;
  position: relative;
  min-height: min(64vw, 825px);
  padding-block: clamp(1.5rem, 3vw, 3rem);
}
.opening-copy { z-index: 1; padding-bottom: 1.5rem; }
h1, h2 { font-weight: 720; letter-spacing: .005em; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.85rem, 4.23vw, 4.1rem); line-height: 1.32; }
h2 { font-size: clamp(2rem, 4.2vw, 4rem); line-height: 1.28; }
.script {
  color: var(--red);
  font: italic clamp(1.24rem, 2.9vw, 2.47rem)/1.27 "Snell Roundhand", "Apple Chancery", "Palatino Linotype", Georgia, serif;
}
.opening-script { margin-top: .55em; }
.opening-note { margin: 2.2rem 0 2.5rem; font-size: clamp(1rem, 1.8vw, 1.63rem); line-height: 1.68; }
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 1em;
  background: var(--red);
  color: #fffaf1;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: .64em 1.3em;
  min-height: 48px;
  text-decoration: none;
  font: 650 clamp(1rem, 1.8vw, 1.45rem)/1.4 var(--serif);
  transition: background .2s, box-shadow .2s;
}
.button:hover { background: var(--red-dark); box-shadow: 0 4px 12px #85221f26; }
.open-button { min-width: min(100%, 320px); font-size: clamp(1.15rem, 2.12vw, 1.9rem); }
.opening-caption { margin-top: 1.35rem; font-size: clamp(.85rem, 1.35vw, 1.15rem); letter-spacing: .06em; }
.opening-caption span { padding-inline: .28em; color: var(--red); }
.envelope-scene {
  width: 108%;
  margin-left: -4%;
  border: 0;
  background: transparent;
  color: var(--ink);
  position: relative;
  display: block;
  align-self: center;
  padding: 0;
  isolation: isolate;
}
.hero-photo {
  width: 100%;
  aspect-ratio: 6 / 5;
  object-fit: contain;
  mix-blend-mode: multiply;
  mask-image: linear-gradient(to right, transparent, black 9%, black 91%, transparent), linear-gradient(to bottom, transparent, black 9%, black 91%, transparent);
  mask-composite: intersect;
  transition: transform .35s ease, opacity .34s ease;
}
.envelope-scene:hover .hero-photo { transform: translateY(-5px); }
.envelope-address {
  position: absolute;
  top: 49%;
  right: 14%;
  display: inline-block;
  font: 500 clamp(1.08rem, 2.4vw, 2.4rem)/1.3 var(--hand);
  letter-spacing: .08em;
  border-bottom: 1px solid var(--red);
  padding: 0 .3em .12em;
  transform: rotate(-6deg);
  max-width: 42%;
  overflow-wrap: anywhere;
  transition: opacity .2s;
}
.postmark {
  display: flex;
  align-items: center;
  gap: clamp(.7rem, 2vw, 2.1rem);
  font-size: clamp(1rem, 1.9vw, 1.75rem);
  text-align: center;
  letter-spacing: .105em;
}
.postmark::before, .postmark::after { content: ""; height: 1px; background: var(--red); flex: 1; }
main > .postmark { margin-bottom: clamp(1.5rem, 4vw, 3.25rem); }
.paper-envelope {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1.6;
  perspective: 900px;
  filter: drop-shadow(0 10px 12px #69503337);
}
.paper-envelope span { position: absolute; display: block; }
.paper-back { inset: 0; background: var(--grain), #e8d2ad; border-radius: 3px; }
.paper-front {
  inset: 0;
  background: var(--grain), linear-gradient(154deg, #fff9ed, #efdfc2);
  clip-path: polygon(0 5%, 50% 62%, 100% 5%, 100% 100%, 0 100%);
  z-index: 3;
}
.paper-flap {
  inset: 0 0 35%;
  background: var(--grain), linear-gradient(#f8e9ce, #e2cba4);
  clip-path: polygon(0 0, 100% 0, 51% 100%, 49% 100%);
  transform: rotateX(180deg);
  transform-origin: top center;
}
.hero-open {
  position: absolute;
  width: 76%;
  top: 23%;
  left: 12%;
  transform: rotate(-6deg);
  opacity: 0;
  pointer-events: none;
}
.hero-open .paper-flap { transform: rotateX(0deg); }
.peek-letter {
  background: var(--grain), #fffcf4;
  box-shadow: 0 4px 14px #60493125;
  padding: 7% 8%;
  left: 8%;
  right: 8%;
  bottom: 5%;
  height: 88%;
  z-index: 2;
  text-align: left;
  font: 560 clamp(1rem, 3vw, 2.45rem)/1.45 var(--hand);
}
.peek-letter em { color: var(--red); }
.is-open .hero-photo, .is-open .envelope-address { opacity: 0; }
.is-open .hero-open { animation: appear .42s .06s both; }
.is-open .hero-open .paper-flap { animation: open-flap .46s .12s both; }
.is-open .peek-letter { animation: draw-letter .5s .38s both; }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }
@keyframes open-flap {
  from { z-index: 4; transform: rotateX(0); }
  45% { z-index: 4; }
  46% { z-index: 0; }
  to { z-index: 0; transform: rotateX(180deg); }
}
@keyframes draw-letter { to { transform: translateY(-53%); } }

.letter-section {
  display: grid;
  grid-template-columns: minmax(0, 43fr) minmax(0, 57fr);
  grid-template-rows: 1fr auto;
  align-items: center;
  gap: 1.5rem 6%;
  padding: clamp(2rem, 4vw, 4rem) min(5vw, 4rem);
  animation: appear .55s ease both;
}
.letter-section, .memories { scroll-margin-top: 5.25rem; }
.letter-intro h2 { font-size: clamp(1.85rem, 3.63vw, 3.55rem); }
.letter-intro .script { margin-top: .45em; }
.read-note { margin-top: 2em; font-size: clamp(1rem, 1.6vw, 1.35rem); }
.read-note::before {
  content: "";
  display: block;
  height: 1px;
  background: var(--red);
  width: 2.5rem;
  margin-bottom: 1em;
}
.desk-envelope { width: 58%; margin: 8rem auto .9rem; transform: rotate(-12deg); }
.seal {
  z-index: 4;
  right: 10%;
  bottom: 18%;
  display: grid !important;
  place-items: center;
  width: 20%;
  aspect-ratio: 1;
  border-radius: 43% 52% 45% 48%;
  background: radial-gradient(circle at 37% 32%, #c44a3a, #8c221d 68%);
  color: #e48671;
  border: 3px double #ed846b;
  font-size: clamp(1rem, 2.25vw, 2rem);
  box-shadow: 1px 4px 6px #642e2e55;
}
.letter-sheet {
  grid-row: span 2;
  position: relative;
  padding: clamp(1.75rem, 5.6vw, 5.4rem);
  background: var(--grain), linear-gradient(145deg, #fffaf1 45%, #f8efdf);
  box-shadow: 9px 15px 22px -12px #6d4c394b, 0 2px 4px #74604e20;
  border: 1px solid #fffaf385;
  border-radius: 2px 2.4rem 2px 2px;
  font-size: clamp(1.04rem, 1.75vw, 1.47rem);
  line-height: 1.88;
  transform: rotate(.9deg);
}
.letter-sheet::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 0 100% 0 0;
  background: linear-gradient(40deg, #ebd8b6, #fbf3e4 82%);
  box-shadow: -2px 2px 4px #7c644324;
}
.greeting { font-weight: 740; margin-bottom: 1.22em; }
#letter-body p { white-space: pre-line; margin-bottom: 1.25em; }
.letter-highlight {
  display: inline-block;
  margin-top: .2em;
  color: var(--red);
  font: 540 clamp(1.5rem, 3.25vw, 3.1rem)/1.4 var(--hand);
  border-bottom: 1px solid var(--red);
  transform: rotate(-3deg);
}
.signature { text-align: right; font-size: .83em; margin-top: 2em; }
.memories-link { justify-self: start; }

.memories { padding-block: clamp(3.25rem, 6vw, 6rem) clamp(2.6rem, 5vw, 4rem); }
.memories h2 { padding-inline: min(4vw, 3rem); }
.memories-script { display: flex; gap: .9em; align-items: center; margin: .34em min(4vw, 3rem) .5em; }
.memories-script::after { content: ""; height: 1px; background: var(--red); flex: 1; }
.photo-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 5rem) / 3);
  padding: 2rem 1.25rem 1.4rem;
  gap: 1.25rem;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 1.25rem;
}
.photo-rail::-webkit-scrollbar { display: none; }
.polaroid {
  display: block;
  position: relative;
  padding: 4% 4% 3%;
  border: 1px solid #e5d8c4;
  background: var(--grain), #fffbf1;
  box-shadow: 3px 9px 15px #6b4d3930;
  color: var(--ink);
  transform: rotate(-4deg);
  transition: transform .24s ease;
  scroll-snap-align: start;
  text-align: center;
}
.polaroid:nth-child(3n + 2) { transform: rotate(3deg); }
.polaroid:nth-child(3n) { transform: rotate(-2deg); }
.polaroid:hover, .polaroid:focus-visible { transform: translateY(-5px) rotate(0); z-index: 1; }
.polaroid:nth-child(3n + 2)::before {
  content: "";
  position: absolute;
  top: -.95rem;
  inset-inline-start: 33%;
  width: 34%;
  height: 1.55rem;
  background: var(--grain), #eacb8ac9;
  transform: rotate(-7deg);
}
.polaroid img { width: 100%; aspect-ratio: 0.97; object-fit: cover; }
.polaroid span { display: block; font: 550 clamp(1rem, 2.3vw, 2rem)/1.4 var(--hand); padding: .6em 0 .3em; }
.photo-hint { text-align: center; margin-top: .9rem; font-size: clamp(.9rem, 1.5vw, 1.22rem); }
.photo-controls { display: flex; justify-content: center; gap: .15rem; }
.photo-dot {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
}
.photo-dot::before { content: ""; height: 4px; width: 23px; border-radius: 5px; background: #d9c1a8; }
.photo-dot[aria-current="true"]::before { background: var(--red); }
.lightbox {
  max-width: min(92vw, 860px);
  max-height: 92vh;
  padding: clamp(.8rem, 2.5vw, 1.5rem);
  background: var(--grain), var(--paper);
  border: 0;
  box-shadow: 0 15px 60px #1e110f55;
  color: var(--ink);
  text-align: center;
}
.lightbox::backdrop { background: #35241cce; }
.lightbox img { max-height: 70vh; width: 100%; object-fit: contain; }
.lightbox p { padding-top: .5rem; font: 550 1.35rem/1.4 var(--hand); }
.close-photo {
  position: absolute;
  z-index: 1;
  right: .8rem;
  top: .8rem;
  border: 1px solid var(--red);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  background: var(--paper);
  color: var(--red);
  font-size: 1.65rem;
  line-height: 1;
}

.wish { background: var(--grain), var(--butter); border-top: 1px solid var(--red); }
.wish-inner { position: relative; text-align: center; padding-top: clamp(2.5rem, 6vw, 5.4rem); }
.wish-copy { margin-top: .48rem; font-size: clamp(1rem, 2vw, 1.55rem); }
.cake { position: relative; width: min(88%, 495px); margin: .1rem auto .2rem; aspect-ratio: 3/2; }
.cake img {
  width: 100%;
  height: 100%;
  mask-image: linear-gradient(to right, transparent, black 19%, black 81%, transparent), linear-gradient(to bottom, transparent, black 16%, black 86%, transparent);
  mask-composite: intersect;
}
.flame {
  position: absolute;
  left: var(--flame-x, 50%);
  top: var(--flame-y, 13.5%);
  height: 11%;
  aspect-ratio: .47;
  border-radius: 47% 53% 46% 54% / 70% 68% 32% 30%;
  background: radial-gradient(ellipse at 50% 72%, #fffdea 18%, #ffe5a1 63%, #ffb752 90%);
  filter: drop-shadow(0 0 10px #ffab3c);
  transform: translate(-50%, -94%);
  transform-origin: 50% 90%;
  animation: flicker 1.5s ease-in-out infinite alternate;
  transition: opacity .35s;
}
.candle-out .flame { opacity: 0; }
@keyframes flicker {
  from { transform: translate(-50%, -94%) rotate(-4deg) scaleY(.93); }
  to { transform: translate(-50%, -94%) rotate(6deg) scaleY(1.04); }
}
.wish-button {
  position: relative;
  overflow: hidden;
  min-width: min(100%, 325px);
  border-radius: 99px;
  touch-action: none;
  user-select: none;
}
.wish-button span { position: relative; }
.wish-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #f4ba8a44;
  transform: scaleX(0);
  transform-origin: left;
}
.wish-button.is-holding::before { transform: scaleX(1); transition: transform 1.5s linear; }
.wish-button[aria-disabled="true"] { cursor: default; }
.wish-hint { margin-top: .8rem; font-size: .98rem; }
.wish-hint:empty { display: none; }
.tap-alternative {
  border: 0;
  background: transparent;
  color: var(--red);
  text-decoration: underline;
  text-underline-offset: .25em;
  padding: .5rem;
  min-height: 44px;
}
.wish-card {
  width: min(95%, 570px);
  position: relative;
  z-index: 1;
  margin: 1.4rem auto 0;
  padding: clamp(1.2rem, 3vw, 2rem);
  color: var(--red);
  background: var(--grain), linear-gradient(135deg, #efe2c9 9%, #fff9ec 9%, #fff9ec 91%, #efe2c9 91%);
  box-shadow: 3px 10px 14px #72512928;
  font: 580 clamp(1.41rem, 3.2vw, 2.8rem)/1.36 var(--hand);
  animation: unfold .55s ease both;
  transform-origin: top;
}
@keyframes unfold { from { opacity: 0; transform: rotateX(-70deg) translateY(-10px); } }
.confetti { position: absolute; inset: 33% 0 0; overflow: clip; pointer-events: none; }
.confetti i {
  background: var(--color);
  width: .4rem;
  height: .65rem;
  position: absolute;
  left: 50%;
  top: 44%;
  animation: confetti-flight 1.1s ease-out both;
}
@keyframes confetti-flight {
  70% { opacity: .95; }
  to { transform: translate(var(--x), var(--y)) rotate(var(--angle)); opacity: 0; }
}
.footer { margin-top: clamp(2.7rem, 5vw, 5rem); padding-bottom: 1.8rem; }
.footer .postmark { margin-bottom: .5rem; font-size: clamp(.93rem, 1.5vw, 1.18rem); }
.footer-heart { color: var(--red); }

@media (max-width: 760px) {
  .page-width { width: min(calc(100% - 40px), 550px); }
  .masthead { padding-block: .75rem; }
  .address { display: none; }
  .opening { display: flex; flex-direction: column; align-items: stretch; min-height: auto; padding-block: 1.55rem 1.2rem; }
  .opening-copy { display: contents; }
  h1 { font-size: clamp(1.85rem, 7.7vw, 3.5rem); }
  .opening-script { margin-top: .35em; }
  .envelope-scene { width: 109%; margin: -.15rem 0 -.45rem -4.5%; order: 1; align-self: auto; }
  .envelope-address { font-size: clamp(1.15rem, 4.4vw, 2rem); }
  .opening-note { order: 2; margin: .5rem 0 .8rem; text-align: center; }
  .opening-note span, .opening-note br { display: none; }
  .open-button { order: 3; width: 100%; }
  .open-button span[aria-hidden], .memories-link span[aria-hidden] { display: none; }
  .opening-caption { display: none; }
  main > .postmark { margin-bottom: 1.5rem; }
  .letter-section { display: flex; align-items: stretch; flex-direction: column; padding: 1.8rem 0 0; gap: 1.4rem; }
  .letter-section, .memories { scroll-margin-top: 4.2rem; }
  .letter-intro h2 { font-size: clamp(1.85rem, 7.7vw, 3rem); }
  .letter-sheet { transform: none; }
  .read-note, .desk-envelope { display: none; }
  .memories h2 { padding-inline: 0; }
  .memories-script { margin-inline: 0; }
  .photo-rail {
    width: calc(100% + 20px);
    padding-inline: 12px 20px;
    scroll-padding-inline: 12px;
    grid-auto-columns: 78%;
  }
  .photo-hint { margin-top: .45rem; }
  .cake { width: min(95%, 365px); }
  .wish-prefix { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01s !important; animation-delay: 0s !important; transition-duration: .01s !important; }
  .is-open .hero-open { opacity: 1; }
}

