@font-face {
  font-family: "Instrument Serif";
  src: url("instrument-serif.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Serif";
  src: url("instrument-serif-italic.woff2") format("woff2");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "DM Sans";
  src: url("dm-sans.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --blush: #f5eff8;
  --ink: #34233d;
  --muted: #5f4b66;
  --plum: #613676;
  --plum-deep: #4e2b60;
  --accent: #804591;
  --line: #ded0e2;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--blush);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(ellipse at 8% 16%, #fffaf4 0%, transparent 51%),
    radial-gradient(ellipse at 95% 98%, #e6d8ee 0%, transparent 61%),
    var(--blush);
}

button { font: inherit; }

button:focus-visible {
  outline: 2px solid var(--plum);
  outline-offset: 5px;
}

h1:focus, h2:focus { outline: none; }

.shell {
  width: min(100% - 104px, 1176px);
  margin-inline: auto;
}

.masthead {
  min-height: 88px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.sender {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: .9375rem;
  font-weight: 600;
  color: var(--plum-deep);
}

.sender-seal,
.letter-stamp,
.wish-seal {
  display: grid;
  place-items: center;
  border-radius: 43% 54% 47% 51%;
}

.sender-seal {
  width: 34px;
  height: 34px;
  color: #fff8ed;
  background: radial-gradient(circle at 34% 26%, #ab7cb6, #75428a 65%, #5f3376);
  box-shadow: inset 0 0 0 2px #fff1ff33, 0 3px 5px #43284922;
  rotate: -9deg;
}

.spark {
  display: inline-block;
  width: 15px;
  height: 15px;
  background: currentColor;
  clip-path: polygon(50% 0, 61% 38%, 100% 50%, 61% 62%, 50% 100%, 39% 62%, 0 50%, 39% 38%);
}

.music-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #d8c7da;
  border-radius: 999px;
  background: #fffaf6a3;
  min-height: 44px;
  padding: 7px 13px;
  color: var(--plum-deep);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease;
}

.music-button[aria-pressed="true"] {
  background: #e9d9ef;
  border-color: #c6abd0;
}

.music-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  font: 1.125rem/1 Georgia, serif;
}

.music-button[aria-pressed="false"] .music-icon::after {
  content: "";
  position: absolute;
  width: 19px;
  top: 50%;
  height: 1px;
  background: currentColor;
  rotate: -42deg;
  box-shadow: 0 -1px 0 #fffaf6;
}

main {
  padding-block: clamp(40px, 7.4vh, 84px) 66px;
}

.scene {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(0, 1.18fr);
  gap: clamp(30px, 5.4vw, 84px);
  align-items: center;
}

.scene.is-entering {
  animation: arrive 570ms cubic-bezier(.21, .8, .24, 1) both;
}

@keyframes arrive {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.chapter h1,
.chapter h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(4.5rem, 9.6vw, 8.55rem);
  line-height: .83;
  letter-spacing: -.036em;
  font-weight: 400;
}

.chapter h2 {
  font-size: clamp(4.05rem, 7.65vw, 7rem);
  line-height: .88;
}

.cake-scene h2 { font-size: clamp(3.7rem, 6.45vw, 6.05rem); }

.chapter em {
  display: block;
  margin-block-start: .08em;
  font-weight: 400;
  color: var(--accent);
}

.chapter h1 em { margin-block-start: .14em; }

.subtitle {
  margin: 29px 0 0;
  max-width: 28ch;
  color: var(--muted);
  font-size: clamp(1.03rem, 1.55vw, 1.2rem);
  line-height: 1.57;
  text-wrap: balance;
}

.primary-button {
  display: inline-flex;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 29px;
  padding: 13px 23px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fffaf7;
  background: var(--plum);
  box-shadow: 0 6px 14px #642f7829;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  transition: background 200ms ease, box-shadow 200ms ease, transform 200ms ease;
}

.primary-button:disabled { cursor: wait; }

.primary-button:active { transform: translateY(1px); }

@media (hover: hover) {
  .primary-button:hover {
    background: var(--plum-deep);
    box-shadow: 0 8px 20px #642f7835;
    transform: translateY(-2px);
  }

  .music-button:hover { background: #eddfef; }
}

.envelope-icon {
  position: relative;
  width: 18px;
  height: 13px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  overflow: hidden;
}

.envelope-icon::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  top: -5px;
  left: 2.5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  border-radius: 1px;
  rotate: 45deg;
}

.button-spark { width: 16px; height: 16px; }

.picture {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 1.05;
  margin: 0;
  overflow: hidden;
  border-radius: 9px;
  box-shadow: 0 26px 60px -28px #5a39658c, 0 1px 1px #51335939;
}

.picture::after {
  content: "";
  position: absolute;
  pointer-events: none;
  inset: 12px;
  border: 1px solid #fff7f771;
  border-radius: 4px;
  z-index: 5;
}

.cover-picture { background: #cbb1d0; }

.cover-picture img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 54%;
}

.envelope-reveal {
  position: absolute;
  inset: 37% 20% 26%;
  opacity: 0;
  perspective: 650px;
  transform: rotate(-7deg) scale(.92);
}

.paper-envelope-back,
.paper-envelope-front,
.paper-envelope-flap,
.paper-envelope-card {
  position: absolute;
  inset: 0;
  border-radius: 4px;
}

.paper-envelope-back {
  background: #ae8cba;
  box-shadow: 0 12px 30px #3e214862;
}

.paper-envelope-front {
  background: linear-gradient(155deg, #e1c8e8, #be9ecc 69%, #b799c6);
  clip-path: polygon(0 0, 50% 57%, 100% 0, 100% 100%, 0 100%);
  z-index: 3;
}

.paper-envelope-flap {
  background: linear-gradient(175deg, #c8acd4, #e9d3ed 77%);
  clip-path: polygon(0 0, 100% 0, 50% 70%);
  transform-origin: top;
  z-index: 4;
}

.paper-envelope-card {
  inset: 7% 9% 5%;
  display: grid;
  place-items: start center;
  padding-top: 8%;
  background: #fff8e9;
  box-shadow: inset 0 0 0 1px #cdafcf, 0 4px 15px #4a305353;
  color: #955fa3;
  z-index: 2;
}

.paper-envelope-card .spark { width: 25px; height: 25px; }

.cover-scene.is-opening .cover-picture img {
  transition: filter 350ms ease, transform 960ms ease;
  filter: blur(6px) brightness(.79);
  transform: scale(1.075);
}

.cover-scene.is-opening .envelope-reveal { animation: envelope-appear 260ms ease forwards; }
.cover-scene.is-opening .paper-envelope-flap { animation: unfold 420ms 100ms ease forwards; }
.cover-scene.is-opening .paper-envelope-card { animation: slide-letter 540ms 270ms cubic-bezier(.17, .72, .24, 1) forwards; }

@keyframes envelope-appear {
  to { opacity: 1; transform: rotate(-7deg) scale(1); }
}

@keyframes unfold {
  48% { z-index: 4; }
  49%, 100% { z-index: 1; }
  to { transform: rotateX(173deg); }
}

@keyframes slide-letter {
  to { transform: translateY(-61%) rotate(5deg); }
}

.cake-picture {
  container-type: inline-size;
  background:
    radial-gradient(ellipse at 50% 82%, #946ba2 0%, transparent 55%),
    radial-gradient(ellipse at 48% 42%, #80608f 0%, #563865 55%, #3b264b 100%);
}

.cake-picture::before {
  content: "";
  position: absolute;
  inset: 2% 5% 17%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 41%, #ffd0a44d 2%, #e7a6b829 34%, transparent 70%);
  transition: opacity 700ms ease;
}

.cake-picture.is-blown::before { opacity: .1; }

.cake-picture::after { border-color: #ecdaee55; }

.cake-twinkles {
  position: absolute;
  inset: 0;
  color: #f7dab6;
}

.cake-twinkles i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  height: var(--s);
  opacity: .72;
}

.cake-twinkles i:nth-child(even) { opacity: .44; }

.cake-model { position: absolute; inset: 11% 7% 2%; }

.cake-shadow,
.plate,
.cake-layer,
.cake-top {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.cake-shadow {
  width: 87%;
  height: 15%;
  bottom: 12%;
  border-radius: 50%;
  background: #251736ac;
  filter: blur(13px);
}

.plate {
  width: 87%;
  height: 16%;
  bottom: 16%;
  border-radius: 50%;
  background: linear-gradient(175deg, #a682b7, #ddc9e6 50%, #fff2fc 76%, #ab84be);
  border-bottom: 3px solid #9c7bb2;
  box-shadow: inset 0 -4px 0 #ecdefb9c, 0 7px 11px #412b5699;
}

.cake-layer {
  width: 69%;
  height: 30%;
  bottom: 23%;
  border-radius: 0 0 48% 48% / 0 0 23% 23%;
  overflow: hidden;
  background: linear-gradient(105deg, #cbb1da 0%, #f1ddef 35%, #e8cfea 66%, #bb9ccc 100%);
  box-shadow: 2px 4px 13px #62477675;
}

.icing {
  position: absolute;
  top: 0;
  width: 100%;
  height: 59%;
  border-radius: 0 0 48% 48% / 0 0 43% 43%;
  background: radial-gradient(ellipse at 38% 5%, #fff9e8 10%, #faebdf 50%, #e2bad5 100%);
  box-shadow: 0 2px 2px #9a6f9d2d;
}

.crumbs {
  position: absolute;
  inset: 63% 5% 5%;
  background-image:
    radial-gradient(circle at 25% 30%, #b987c37a 0 1px, transparent 2px),
    radial-gradient(circle at 65% 65%, #ba8dc4a0 0 1px, transparent 2px);
  background-size: 16px 12px, 19px 13px;
  mask-image: radial-gradient(ellipse at 50% 40%, black 5%, transparent 74%);
}

.cake-top {
  width: 69%;
  height: 17%;
  bottom: 44%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 40% 34%, #fffaf1 12%, #fff1e0 59%, #e6c9e4 100%);
  box-shadow: inset 0 1px 2px white, 0 2px 3px #c5a6c43d;
}

.sugar {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 3.2%;
  height: 5.6%;
  border-radius: 999px;
  background: var(--color);
  rotate: var(--rot);
}

.candle {
  position: absolute;
  z-index: 2;
  bottom: 52%;
  left: var(--x);
  width: 3.1%;
  height: var(--h);
  translate: -50%;
  border-radius: 32% 32% 19% 19% / 7% 7% 7% 7%;
  background:
    linear-gradient(90deg, #fff9e288, transparent 48%, #5e386c49),
    repeating-linear-gradient(-29deg, var(--color) 0 7px, #fae6ec 7px 10px);
  box-shadow: 1px 2px 3px #8f649267;
}

.wick {
  position: absolute;
  bottom: 97%;
  left: 47%;
  width: 13%;
  height: 9%;
  border-radius: 100% 20% 35% 0;
  background: #543359;
}

.flame {
  position: absolute;
  left: 50%;
  bottom: 106%;
  width: 5.4cqw;
  height: 8cqw;
  border-radius: 62% 38% 56% 44% / 69% 62% 38% 31%;
  background: radial-gradient(ellipse at 50% 69%, #fffde6 8%, #fff1af 38%, #ffb366 72%, #e57f8f 100%);
  box-shadow: 0 0 3cqw #ffc98ed0, 0 0 7cqw #ffc98866;
  transform-origin: center bottom;
  animation: flicker 1.4s ease-in-out infinite alternate;
}

.candle:nth-last-child(2) .flame { animation-delay: -480ms; }
.candle:last-child .flame { animation-delay: -890ms; }

@keyframes flicker {
  0%, 45%, 100% { transform: translateX(-50%) rotate(-6deg) scale(.91, 1.03); }
  23%, 70% { transform: translateX(-50%) rotate(7deg) scale(1.01, .9); }
}

.cake-picture.is-blown .flame {
  animation: snuff 240ms var(--delay) both ease-out;
}

@keyframes snuff {
  from { opacity: 1; transform: translateX(-50%) scale(1); }
  to { opacity: 0; transform: translateX(-15%) scale(.14, .1) rotate(31deg); }
}

.smoke {
  position: absolute;
  left: 32%;
  bottom: 105%;
  width: 5cqw;
  height: 13cqw;
  border-radius: 50%;
  opacity: 0;
  background: radial-gradient(ellipse at center, #fce5f4a8, transparent 66%);
  pointer-events: none;
}

.cake-picture.is-blown .smoke { animation: smoke 1.24s calc(170ms + var(--delay)) ease-out both; }

@keyframes smoke {
  0% { opacity: 0; transform: translate(-40%, 30%) rotate(-7deg) scale(.36); }
  26% { opacity: .8; }
  100% { opacity: 0; transform: translate(-6%, -58%) rotate(17deg) scale(1.15); }
}

.letter-scene {
  grid-template-areas: "title paper" "next paper";
  grid-auto-rows: 1fr;
  row-gap: 25px;
}

.letter-heading { grid-area: title; align-self: end; }
.letter-actions { grid-area: next; align-self: start; }
.letter-actions .primary-button { margin-top: 0; }

.letter-paper {
  position: relative;
  grid-area: paper;
  padding: clamp(35px, 4.4vw, 65px);
  border: 1px solid #e4d4df;
  border-radius: 6px;
  background:
    radial-gradient(ellipse at 100% 100%, #f0e3ed 0%, transparent 57%),
    radial-gradient(ellipse at 0% 0%, #fffdf7 0%, transparent 66%),
    #fdf8f1;
  box-shadow: 5px 7px 0 -1px #e7d8ea, 5px 7px 0 #d7c5df, 0 22px 52px -18px #6b4d7447;
  font-size: clamp(1.02rem, 1.48vw, 1.11rem);
  line-height: 1.72;
}

.letter-paper::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid #decde1;
  border-radius: 3px;
  pointer-events: none;
}

.letter-paper p { position: relative; margin: 0 0 1.02em; }

.letter-paper .salutation,
.letter-paper .signature {
  font-family: var(--serif);
  font-size: clamp(2.4rem, 4vw, 3.35rem);
  line-height: 1;
  color: var(--plum);
}

.letter-paper .salutation { margin-bottom: .4em; }
.letter-paper .signature { margin: .65em 0 0; font-style: italic; }

.letter-stamp {
  position: absolute;
  right: 9%;
  bottom: 8%;
  width: 39px;
  height: 39px;
  rotate: 11deg;
  border: 1px solid #cbb2cf;
  color: #a678ad;
  background: #f5e9f2;
}

.gift-scene {
  grid-template-areas: "title wishes" "replay wishes";
  grid-template-rows: 1fr auto;
  row-gap: 21px;
}

.gift-heading { grid-area: title; align-self: end; }
.gift-actions { grid-area: replay; align-self: start; }

.gift-board {
  grid-area: wishes;
  display: grid;
  gap: 12px;
  padding: clamp(18px, 3.4vw, 38px);
  border: 1px solid #d6c2df;
  border-radius: 10px;
  background: radial-gradient(at 12% 10%, #f6e9f5, #ead8ef 81%);
  box-shadow: 0 20px 55px -26px #70447b73;
}

.wish-card {
  border: 1px solid #e2d2e3;
  border-radius: 7px;
  background: #fffaf4;
  box-shadow: 0 3px 6px #6d428011;
}

.wish-toggle {
  display: grid;
  grid-template-columns: 38px 1fr 16px;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 72px;
  border: 0;
  border-radius: inherit;
  padding: 10px clamp(12px, 2vw, 20px);
  text-align: left;
  color: var(--plum-deep);
  background: transparent;
  font: 400 clamp(1.55rem, 2.9vw, 2.08rem)/1 var(--serif);
  cursor: pointer;
}

.wish-seal {
  width: 37px;
  height: 37px;
  color: #fff7ee;
  background: radial-gradient(circle at 36% 30%, #cb95cf, #8b589e 70%, #79498e);
  box-shadow: inset 0 0 0 2px #fff3fd45;
  transition: rotate 360ms ease;
}

.wish-toggle-icon {
  position: relative;
  width: 15px;
  height: 15px;
  opacity: .72;
}

.wish-toggle-icon::before,
.wish-toggle-icon::after {
  content: "";
  position: absolute;
  top: 7px;
  left: 2px;
  width: 11px;
  height: 1px;
  background: currentColor;
}

.wish-toggle-icon::after {
  rotate: 90deg;
  transition: rotate 200ms ease;
}

.wish-toggle[aria-expanded="true"] .wish-toggle-icon::after { rotate: 0deg; }
.wish-toggle[aria-expanded="true"] .wish-seal { rotate: 45deg; }

.wish-message {
  margin: 0;
  padding: 0 21px 17px clamp(16px, 6.9vw, 72px);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--muted);
  animation: arrive 300ms ease both;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  border-radius: 2px;
  color: var(--plum-deep);
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.text-button span { font-size: 1.28em; }

#confetti {
  position: fixed;
  inset: 0;
  z-index: 10;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@media (max-width: 900px) {
  .shell { width: calc(100% - 64px); }
}

@media (max-width: 700px) {
  .shell { width: min(calc(100% - 44px), 500px); }
  .masthead { min-height: 70px; }
  main { padding-block: 36px 36px; }
  .scene { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .chapter h1 { font-size: clamp(4.9rem, 19vw, 6.75rem); }
  .chapter h2 { font-size: clamp(3.85rem, 14.6vw, 5.25rem); }
  .cake-scene h2 { font-size: clamp(3.6rem, 12.3vw, 5rem); }
  .subtitle { margin-top: 18px; }
  .primary-button { margin-top: 21px; min-height: 52px; }
  .picture { aspect-ratio: 1.17; }
  .picture::after { inset: 9px; }
  .letter-scene { grid-template-areas: "title" "paper" "next"; grid-auto-rows: auto; }
  .gift-scene { grid-template-areas: "title" "wishes" "replay"; grid-template-rows: auto; }
  .letter-paper { padding: 30px 25px 33px; }
  .letter-paper::before { inset: 9px; }
}

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

  .cake-picture:not(.is-blown) .flame { transform: translateX(-50%); }
}

.video-scene video {
  display: block;
  justify-self: center;
  width: min(100%, 21rem, 32svh);
  height: auto;
  border-radius: 1.4rem;
  background: var(--ink);
  box-shadow: 0 18px 50px #4e2b6038;
}

.video-scene .text-button {
  margin-block-start: .75rem;
}
