@font-face {
  font-family: Passions;
  src: url("assets/passions.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: Garamond;
  src: url("assets/garamond.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

@font-face {
  font-family: Garamond;
  src: url("assets/garamond-italic.woff2") format("woff2");
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #54333b;
  --rose-ink: #773c4d;
  --serif: Garamond, Georgia, "Times New Roman", serif;
  --calligraphy: Passions, "Apple Chancery", "Segoe Script", cursive;
}

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

body {
  margin: 0;
  min-inline-size: 0;
  background: #53323a;
  color: var(--ink);
  font-family: var(--serif);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

p, h1 { margin: 0; }
svg { display: block; }
.library { position: absolute; inline-size: 0; block-size: 0; overflow: hidden; }

.garden, .atmosphere, .rain {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.garden {
  background-color: #68434a;
  background-image: radial-gradient(ellipse at 50% 38%, transparent 23%, #351c26a6 100%), url("assets/jardin.webp");
  background-position: center;
  background-size: cover;
  animation: garden-in 1.35s ease-out both;
}

.garden-light {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 32%, #ffedc6 0%, #ffd6a66b 35%, transparent 72%);
  opacity: 0;
}

.garden.is-lit .garden-light { animation: illuminate 2.25s ease-out both; }
.atmosphere { z-index: 1; }
.rain { z-index: 2; }

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  position: relative;
  z-index: 3;
  min-block-size: 100vh;
  min-block-size: 100svh;
  padding: 48px 22px;
  padding-top: max(48px, calc(env(safe-area-inset-top) + 19px));
  padding-right: max(22px, calc(env(safe-area-inset-right) + 16px));
  padding-bottom: max(48px, calc(env(safe-area-inset-bottom) + 19px));
  padding-left: max(22px, calc(env(safe-area-inset-left) + 16px));
  pointer-events: none;
}

.stage > .card, .stage > .interlude { grid-area: 1 / 1; }
.stage:not([data-scene="letter"]) .letter,
.stage[data-scene="letter"] .invitation { display: none; }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  inline-size: 100%;
  max-inline-size: 468px;
  padding: 38px 31px 47px;
  border: 1px solid #d2a778;
  border-radius: 49% 49% 13px 13px / 10% 10% 13px 13px;
  background:
    radial-gradient(ellipse at 50% 39%, #fffcf5 5%, transparent 64%),
    radial-gradient(ellipse at 0 100%, #edc3c3a6, transparent 48%),
    radial-gradient(ellipse at 100% 100%, #edc3c3a6, transparent 48%),
    linear-gradient(151deg, #fbefdf 0%, #fff9ee 50%, #f7e2d5 100%);
  box-shadow: 0 32px 83px #32182373, 0 7px 24px #431f2a52, inset 0 0 27px #bf8b7233, 0 0 0 1px #fff1ce55;
  text-align: center;
  pointer-events: auto;
  isolation: isolate;
}

.card::before, .card::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
  border-radius: inherit;
}

.card::before {
  inset: 8px;
  border: 1px solid #b78655b0;
  box-shadow: 0 0 0 1px #fff9e6aa;
}

.card::after { inset: 12px; border: 1px solid #dabc8f8c; }
.card-ornaments { position: absolute; z-index: -1; inset: 0; pointer-events: none; }

.sprig {
  position: absolute;
  inline-size: clamp(91px, 27%, 126px);
  block-size: auto;
  aspect-ratio: 160 / 109;
  overflow: visible;
}

.sprig-nw { left: 11px; top: 24px; }
.sprig-ne { right: 11px; top: 24px; transform: scaleX(-1); }
.sprig-sw { left: 11px; bottom: 11px; transform: scaleY(-1); }
.sprig-se { right: 11px; bottom: 11px; transform: scale(-1); }

.medallion { inline-size: 111px; block-size: 111px; flex: none; }

.garden-name {
  margin-block: 8px 16px;
  color: #765033;
  font-size: .77rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: .19em;
  text-transform: uppercase;
}

.script {
  font-family: var(--calligraphy);
  font-weight: 400;
  color: var(--rose-ink);
}

.script span { display: block; }
.invitation-title { font-size: clamp(3.85rem, 15.8vw, 5.1rem); line-height: .66; }
.invitation-title span:last-child { line-height: .83; }
.divider { inline-size: 142px; block-size: 22px; flex: none; }
.invitation .divider { margin-block: 10px 19px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  max-inline-size: 100%;
  min-block-size: 51px;
  border-radius: 100px;
  font: 600 1.12rem/1.12 var(--serif);
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 170ms ease-out, box-shadow 200ms ease-out, background-color 200ms ease-out;
}

.button:focus-visible { outline: 2px solid #632d48; outline-offset: 4px; }
.button:active { transform: translateY(1px) scale(.98); }
.button-icon { inline-size: 17px; block-size: 17px; flex: none; fill: currentColor; }

.button-primary {
  position: relative;
  padding: 13px 23px;
  border: 1px solid #a66f4e;
  color: #fff7e8;
  background: linear-gradient(150deg, #99536b, #743749 75%, #642d42);
  box-shadow: inset 0 0 0 2px #f4c9b76b, inset 0 9px 17px #eabbac30, 0 5px 13px #7e3c4d41;
  text-shadow: 0 1px 1px #4e2439;
}

.button-primary .button-icon { color: #f5c8ac; }
.button-primary.is-pulsing { animation: button-pulse 310ms ease-out both; }

.letter { padding-top: 31px; padding-bottom: 39px; }
.letter .medallion { inline-size: 87px; block-size: 75px; }
.letter .garden-name { margin-block: 6px 12px; }

.letter-title {
  position: relative;
  max-inline-size: 100%;
  font-size: clamp(3.25rem, 14.5vw, 4.38rem);
  line-height: .72;
}

.letter-title:focus { outline: none; }

@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  .letter-title span {
    background: linear-gradient(173deg, #815035 2%, #8e4856 40%, #79394b 65%, #946146 85%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}

.title-star {
  position: absolute;
  inline-size: 13px;
  block-size: 13px;
  fill: #b67b3e;
  opacity: .42;
  animation: sparkle 6.7s ease-in-out infinite both;
  pointer-events: none;
}

.title-star-first { inline-size: 10px; block-size: 10px; top: 17%; right: 10%; animation-delay: -3.7s; }
.title-star-second { inline-size: 10px; block-size: 10px; bottom: 15%; left: 6%; animation-delay: -1.2s; }
.letter .divider { margin-block: 13px 10px; inline-size: 124px; }

.declaration {
  max-inline-size: 32ch;
  font-size: clamp(1.13rem, 5vw, 1.39rem);
  line-height: 1.37;
  text-wrap: pretty;
}

.signature {
  margin-block: 13px 18px;
  color: #763c4e;
  font-family: var(--serif);
  font-size: clamp(1.17rem, 5.15vw, 1.5rem);
  font-style: italic;
  line-height: 1.19;
  text-wrap: balance;
}

.button-replay {
  min-block-size: 46px;
  padding: 10px 17px;
  border: 1px solid #b78b68;
  background: #fff5edeb;
  color: #713749;
  box-shadow: 0 3px 9px #9c626726;
}

.button-replay .button-icon { color: #a95b70; }

@media (hover: hover) {
  .button-primary:hover { box-shadow: inset 0 0 0 2px #ffdcbd9c, inset 0 12px 20px #eabbac44, 0 7px 16px #7e3c4d60; }
  .button-replay:hover { background: #fbe7df; box-shadow: 0 4px 12px #9c62673d; }
}

.interlude {
  position: relative;
  max-inline-size: 100%;
  padding: 20px 8px;
  color: #fff2d4;
  text-align: center;
  animation: interlude-in 515ms ease-in-out both;
  isolation: isolate;
}

.interlude[aria-hidden="true"] {
  visibility: hidden;
  animation: interlude-out 320ms ease-out both;
}

.interlude::before {
  content: "";
  position: absolute;
  inset: -45px -18px;
  z-index: -1;
  background: radial-gradient(ellipse, #47222fdf 10%, #5f3244b5 38%, #6c3c5100 73%);
}

.interlude .script {
  color: inherit;
  font-size: clamp(3rem, 16vw, 7.2rem);
  line-height: .75;
  text-shadow: 0 2px 12px #512739, 0 1px 1px #421f2d;
}

.interlude .divider { margin: 13px auto 0; }
.interlude-star { margin: 0 auto 18px; inline-size: 23px; block-size: 23px; fill: #ffe6b2; }

.invitation { animation: paper-in 820ms 90ms cubic-bezier(.2,.7,.25,1) both; }
.invitation.is-unsealing { animation: unseal 250ms ease-in both; }
.stage.is-revealing .letter { animation: paper-in 760ms cubic-bezier(.2,.7,.25,1) both; }
.stage.is-revealing .letter .declaration, .stage.is-revealing .letter .signature {
  animation: text-in 730ms 130ms ease-out both;
}

.stage.is-celebrating:not(.is-revealing) .letter { animation: paper-glow 740ms ease-out; }

.ambient, .particle { position: absolute; display: block; }
.ambient svg, .particle svg { inline-size: 100%; block-size: 100%; }

.ambient {
  left: var(--left);
  top: var(--top);
  inline-size: var(--size);
  block-size: var(--size);
  color: #fff0b8;
  fill: currentColor;
  opacity: 0;
  animation: drift var(--time) var(--delay) ease-in-out infinite both;
}

.ambient.star { animation-name: sparkle; }
.ambient.heart { fill: url(#heart-pearl); }
.ambient.dust {
  border-radius: 100%;
  background: #ffdda4;
  box-shadow: 0 0 5px 1px #ffe0a46e;
  animation-name: sparkle;
}

.particle {
  left: var(--left);
  top: 0;
  inline-size: var(--size);
  block-size: var(--size);
  opacity: 0;
  animation: fall var(--time) var(--delay) cubic-bezier(.26,.07,.81,.93) both;
}

.particle.rose { fill: url(#heart-rose); }
.particle.pearl { fill: url(#heart-pearl); }
.particle.champagne { fill: url(#heart-champagne); }
.particle.star { fill: #ffe8a6; }
.particle.dust { background: #ffe7ae; border-radius: 50%; }

@keyframes garden-in { from { opacity: .14; } to { opacity: 1; } }
@keyframes paper-in {
  from { opacity: 0; transform: translateY(13px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes unseal {
  0%, 53% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: translateY(-3px) scale(1.008); }
}
@keyframes interlude-in {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes interlude-out {
  from { visibility: visible; opacity: 1; transform: translateY(0); }
  to { visibility: hidden; opacity: 0; transform: translateY(-4px); }
}
@keyframes text-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes button-pulse {
  0%, 100% { transform: scale(1); }
  46% { transform: scale(1.045); box-shadow: 0 0 21px 6px #f2c58bb0, inset 0 0 0 2px #ffe3bd9e; }
}
@keyframes paper-glow {
  38% { box-shadow: 0 28px 80px #32182373, 0 0 26px #ffe1aeae, inset 0 0 25px #bf8b7259; }
}
@keyframes illuminate { 0%, 100% { opacity: 0; } 24% { opacity: .56; } 62% { opacity: .16; } }
@keyframes sparkle {
  0%, 13%, 100% { opacity: 0; transform: scale(.55); }
  29% { opacity: .91; transform: scale(1); }
  47% { opacity: .28; transform: scale(.66); }
  67% { opacity: .53; transform: scale(.79); }
  79% { opacity: .11; }
}
@keyframes drift {
  0%, 100% { opacity: 0; transform: translate3d(0, 16px, 0) rotate(-12deg); }
  30% { opacity: .43; }
  75% { opacity: .23; }
  99% { transform: translate3d(14px, -40px, 0) rotate(17deg); }
}
@keyframes fall {
  0% { opacity: 0; transform: translate3d(0, var(--start), 0) rotate(var(--tilt)) scale(.72); }
  13% { opacity: var(--alpha); }
  43% { transform: translate3d(var(--sway), var(--middle), 0) rotate(var(--turn)) scale(1); }
  76% { opacity: var(--alpha); }
  100% { opacity: 0; transform: translate3d(var(--end), var(--distance), 0) rotate(var(--tilt)) scale(.86); }
}

@media (max-aspect-ratio: 4/5) {
  .garden {
    background-image: radial-gradient(ellipse at 50% 35%, transparent 28%, #351c2677 100%), url("assets/jardin-mobile.webp");
    background-position: 50% 47%;
  }
}

@media (max-width: 520px) {
  .stage {
    padding-top: max(28px, calc(env(safe-area-inset-top) + 12px));
    padding-right: max(18px, calc(env(safe-area-inset-right) + 12px));
    padding-bottom: max(28px, calc(env(safe-area-inset-bottom) + 12px));
    padding-left: max(18px, calc(env(safe-area-inset-left) + 12px));
  }

  .card { max-inline-size: 389px; padding-inline: clamp(21px, 6.5vw, 31px); }
  .card::before { inset: 6px; }
  .card::after { inset: 10px; }
  .sprig-nw, .sprig-ne { top: 22px; }
  .sprig-nw, .sprig-sw { left: 8px; }
  .sprig-ne, .sprig-se { right: 8px; }
  .sprig-sw, .sprig-se { bottom: 8px; }
  .invitation { padding-block: 33px 43px; }
  .invitation .medallion { inline-size: 96px; block-size: 96px; }
  .garden-name { margin-block: 6px 14px; font-size: .72rem; letter-spacing: .15em; }
  .letter { padding-block: 26px 39px; }
  .letter .medallion { inline-size: 73px; block-size: 63px; }
  .letter .sprig { inline-size: clamp(79px, 25%, 104px); }
  .letter-title { font-size: clamp(2.67rem, 14vw, 4.2rem); }
  .button-replay { font-size: 1.04rem; }
}

@media (max-width: 355px) {
  .stage { padding-inline: 12px; }
  .card { padding-inline: 17px; }
  .invitation-title { font-size: 3.68rem; }
  .letter { padding-bottom: 46px; }
  .letter .sprig-sw, .letter .sprig-se { inline-size: 71px; }
  .letter-title { font-size: 2.8rem; }
  .signature { font-size: 1.12rem; }
  .button { gap: 7px; }
}

@media (max-height: 620px) {
  .stage { padding-block: max(19px, env(safe-area-inset-top)) max(19px, env(safe-area-inset-bottom)); }
  .letter { padding-block: 22px 43px; }
  .letter .garden-name { margin-block: 4px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .atmosphere, .rain { display: none; }
  .title-star { opacity: .46; }
  .is-celebrating .letter { box-shadow: 0 28px 80px #32182373, 0 0 26px #ffe1aebe, inset 0 0 23px #bf8b7259; }
  .is-celebrating .title-star { opacity: 1; }
}

@media (forced-colors: active) {
  .letter-title span { -webkit-text-fill-color: currentColor; }
  .garden, .atmosphere, .rain { display: none; }
}
