@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/fraunces.woff2") format("woff2");
}

@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/fraunces-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Caveat";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/caveat-700.woff2") format("woff2");
}

:root {
  --frosting: #FBD3DC;
  --frosting-deep: #F6B9C8;
  --cherry: #B3123E;
  --marigold: #F5B728;
  --pool: #1BA6A6;
  --cocoa: #3A1F1B;
  --paper: #FFFDF8;
  --ph: clamp(100px, min(10.2vw, 15.5vh), 178px);
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --hand: "Caveat", "Comic Sans MS", cursive;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  overflow-x: hidden;
  color: var(--cocoa);
  font-family: var(--display);
  background-color: var(--frosting);
  background-image:
    radial-gradient(ellipse 70% 55% at 50% 52%, rgba(255, 253, 248, .55), rgba(255, 253, 248, 0) 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cg fill-opacity='.5'%3E%3Crect x='20' y='30' width='4' height='13' rx='2' fill='%23B3123E' transform='rotate(20 22 36)'/%3E%3Crect x='70' y='15' width='4' height='13' rx='2' fill='%23F5B728' transform='rotate(-40 72 21)'/%3E%3Crect x='120' y='40' width='4' height='13' rx='2' fill='%231BA6A6' transform='rotate(75 122 46)'/%3E%3Crect x='160' y='20' width='4' height='13' rx='2' fill='%23FFFDF8' transform='rotate(-15 162 26)'/%3E%3Crect x='40' y='90' width='4' height='13' rx='2' fill='%23FFFDF8' transform='rotate(60 42 96)'/%3E%3Crect x='95' y='80' width='4' height='13' rx='2' fill='%23B3123E' transform='rotate(-70 97 86)'/%3E%3Crect x='150' y='95' width='4' height='13' rx='2' fill='%23F5B728' transform='rotate(30 152 101)'/%3E%3Crect x='15' y='150' width='4' height='13' rx='2' fill='%231BA6A6' transform='rotate(-30 17 156)'/%3E%3Crect x='70' y='140' width='4' height='13' rx='2' fill='%23F5B728' transform='rotate(10 72 146)'/%3E%3Crect x='125' y='155' width='4' height='13' rx='2' fill='%23FFFDF8' transform='rotate(-55 127 161)'/%3E%3Crect x='165' y='140' width='4' height='13' rx='2' fill='%23B3123E' transform='rotate(85 167 146)'/%3E%3Crect x='100' y='120' width='4' height='13' rx='2' fill='%231BA6A6' transform='rotate(45 102 126)'/%3E%3C/g%3E%3C/svg%3E");
  background-size: auto, 230px 230px;
  background-attachment: fixed, scroll;
}

/* Cherry glaze dripping over the top edge */
.drip {
  position: absolute;
  inset: 0 0 auto 0;
  height: 76px;
  z-index: 2;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='76'%3E%3Cg fill='%23B3123E'%3E%3Cpath d='M0 0H240V16Q225 26 210 16T180 16T150 16T120 16T90 16T60 16T30 16T0 16Z'/%3E%3Crect x='33' y='8' width='14' height='50' rx='7'/%3E%3Crect x='100' y='8' width='10' height='34' rx='5'/%3E%3Crect x='162' y='8' width='16' height='62' rx='8'/%3E%3Crect x='212' y='8' width='9' height='27' rx='4.5'/%3E%3C/g%3E%3Cg fill='%23FFFDF8' fill-opacity='.35'%3E%3Crect x='36' y='26' width='3' height='18' rx='1.5'/%3E%3Crect x='166' y='30' width='3' height='26' rx='1.5'/%3E%3C/g%3E%3C/svg%3E") repeat-x 0 0 / 240px 76px;
  filter: drop-shadow(0 4px 0 rgba(58, 31, 27, .12));
}

/* Layout */
.page {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: clamp(190px, 20vw, 340px) minmax(0, 1fr) clamp(190px, 20vw, 340px);
  gap: 16px;
  max-width: 1720px;
  min-height: 100svh;
  margin: 0 auto;
  padding: 50px 16px 24px;
}

.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

/* Headline */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 8px;
}

.candles {
  position: relative;
  display: inline-flex;
  gap: .08em;
  margin: 0 0 -.12em;
  padding: .5em .25em 0;
  border: 0;
  background: none;
  cursor: pointer;
  font: 900 clamp(54px, 6.2vw, 92px)/1 var(--display);
  font-variation-settings: "SOFT" 100, "WONK" 0, "opsz" 144;
  -webkit-tap-highlight-color: transparent;
}

.candle { position: relative; display: inline-block; }

.candle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: .06em;
  width: .035em;
  height: .13em;
  border-radius: 2px;
  background: var(--cocoa);
  transform: translateX(-50%);
}

.digit {
  display: block;
  color: transparent;
  background: repeating-linear-gradient(-55deg, var(--cherry) 0 .1em, var(--paper) .1em .2em);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-stroke: 2px var(--cherry);
}

.flame {
  position: absolute;
  left: 50%;
  top: -.26em;
  width: .2em;
  height: .32em;
  margin-left: -.1em;
  border-radius: 50% 50% 46% 46% / 62% 62% 38% 38%;
  background: radial-gradient(circle at 50% 74%, #fff 0 16%, #FFE680 30%, var(--marigold) 56%, #EF6A2A 88%);
  box-shadow: 0 0 .28em .1em rgba(245, 183, 40, .55), 0 0 .8em .2em rgba(245, 183, 40, .25);
  transform-origin: 50% 100%;
  animation: flicker .9s ease-in-out infinite alternate;
  transition: opacity .35s ease, transform .35s ease;
}

.candle:nth-child(2) .flame { animation-duration: 1.1s; animation-delay: -.4s; }

.candles.out .flame { opacity: 0; transform: scale(.2) translateY(.1em); animation: none; }

.candles.out .candle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -.2em;
  width: .12em;
  height: .12em;
  border-radius: 50%;
  background: rgba(58, 31, 27, .25);
  animation: smoke 1.6s ease-out forwards;
}

@keyframes flicker {
  0% { transform: scale(1, 1) rotate(-2deg); }
  40% { transform: scale(.94, 1.08) rotate(2deg); }
  100% { transform: scale(1.04, .95) rotate(-1deg); }
}

@keyframes smoke {
  from { opacity: .9; transform: translate(-50%, 0) scale(1); }
  to { opacity: 0; transform: translate(-30%, -1.2em) scale(3.5); }
}

.headline {
  margin: 0;
  font-weight: 900;
  line-height: .9;
}

.hb {
  display: block;
  font: italic 600 clamp(26px, 3.3vw, 50px)/1.1 var(--display);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  color: var(--cocoa);
  animation: rise-in .7s cubic-bezier(.2, .8, .3, 1) .15s both;
}

.name {
  display: block;
  font-size: clamp(64px, 9.4vw, 148px);
  font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 144;
  letter-spacing: -.01em;
  color: var(--cherry);
  text-shadow: .035em .035em 0 var(--marigold), .07em .07em 0 var(--pool);
  padding: 0 .1em .08em 0;
}

.name span {
  display: inline-block;
  animation: drop .8s cubic-bezier(.3, 1.6, .5, 1) both;
  animation-delay: calc(.4s + var(--i) * .07s);
}

@keyframes drop {
  from { opacity: 0; transform: translateY(-.7em) scale(.4) rotate(-14deg); }
  to { opacity: 1; transform: none; }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(.5em); }
  to { opacity: 1; transform: none; }
}

/* Video, framed like a frosted cake tier */
.cake {
  width: clamp(min(100%, 520px), calc((100svh - 520px) * 1.7778 + 40px), min(100%, 1000px));
  margin-top: clamp(16px, 2.4vw, 30px);
  padding: 12px;
}

.frame {
  position: relative;
  padding: 10px;
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 0 12px 0 var(--cherry), 0 26px 40px -8px rgba(58, 31, 27, .35);
}

.frame::before {
  content: "";
  position: absolute;
  inset: -11px;
  border: 10px dotted var(--paper);
  border-radius: 36px;
  pointer-events: none;
}

.frame video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  background: #2A1D1A;
}

.play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: .55em 1.2em;
  border: 0;
  border-radius: 999px;
  background: var(--cherry);
  color: var(--paper);
  font: 700 clamp(18px, 2vw, 24px)/1 var(--display);
  cursor: pointer;
  box-shadow: 0 6px 0 #7E0C2B;
}

.play[hidden] { display: none; }

/* Footer */
.foot {
  margin-top: clamp(26px, 3vw, 40px);
  text-align: center;
}

.love {
  margin: 0;
  font: 700 clamp(34px, 3.6vw, 54px)/1 var(--hand);
  color: var(--cherry);
}

.hint {
  margin: .5em 0 0;
  font: italic 500 clamp(15px, 1.2vw, 18px)/1.4 var(--display);
  color: var(--cocoa);
  opacity: .8;
}

/* Polaroid rails */
.rail {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  min-width: 0;
  padding: 10px 0 20px;
}

.slot {
  --r: 0deg;
  position: relative;
  perspective: 900px;
  animation: bob var(--dur, 6s) ease-in-out var(--delay, 0s) infinite;
}

.rail-left .slot:nth-child(2) { margin-left: 22%; }
.rail-right .slot:nth-child(2) { margin-right: 22%; }
.rail-left .slot:nth-child(3) { margin-right: 12%; }
.rail-right .slot:nth-child(3) { margin-left: 12%; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(var(--r)); }
  50% { transform: translateY(-10px) rotate(calc(var(--r) + 2.5deg)); }
}

.polaroid {
  position: relative;
  padding: calc(var(--ph) * .065) calc(var(--ph) * .065) 0;
  background: var(--paper);
  border-radius: 3px;
  box-shadow: 0 2px 3px rgba(58, 31, 27, .18), 0 14px 26px -6px rgba(58, 31, 27, .32);
  transform-origin: 50% 50%;
  transition: transform .45s cubic-bezier(.5, 0, .3, 1), opacity .45s ease;
}

.slot.out .polaroid { transform: rotateY(90deg) scale(.86); opacity: .4; }

.slot.enter .polaroid { animation: pop .6s cubic-bezier(.3, 1.5, .5, 1) both; }

@keyframes pop {
  from { transform: rotateY(-90deg) scale(.86); }
  to { transform: none; }
}

.polaroid img {
  display: block;
  height: var(--ph);
  width: auto;
  max-width: none;
  background: #E9D9DC;
}

.cap {
  display: block;
  height: calc(var(--ph) * .3);
  font: 700 calc(var(--ph) * .15)/calc(var(--ph) * .3) var(--hand);
  text-align: center;
  color: var(--cocoa);
  white-space: nowrap;
}

.tape {
  position: absolute;
  left: 50%;
  top: calc(var(--ph) * -.07);
  width: calc(var(--ph) * .42);
  height: calc(var(--ph) * .13);
  background: var(--tape, var(--marigold));
  opacity: .82;
  transform: translateX(-50%) rotate(var(--tr, -4deg));
  clip-path: polygon(2% 0, 98% 6%, 100% 50%, 97% 100%, 3% 94%, 0 50%);
}

/* Balloons */
.balloons {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.balloon {
  position: absolute;
  bottom: -160px;
  left: var(--x);
  width: var(--w);
  color: var(--c);
  opacity: .9;
  animation: float-up var(--d) linear forwards;
}

.balloon svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  animation: sway 4.5s ease-in-out infinite alternate;
  transform-origin: 50% 100%;
}

@keyframes float-up {
  to { transform: translateY(calc(-100vh - 220px)); }
}

@keyframes sway {
  from { transform: translateX(-14px) rotate(-5deg); }
  to { transform: translateX(14px) rotate(5deg); }
}

/* Confetti and wish toast */
.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 60;
  pointer-events: none;
}

.wish {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 70;
  margin: 0;
  padding: .3em .9em .35em;
  border-radius: 999px;
  background: var(--cherry);
  color: var(--paper);
  font: 700 clamp(24px, 3vw, 34px)/1.1 var(--hand);
  box-shadow: 0 5px 0 #7E0C2B;
  opacity: 0;
  transform: translate(-50%, 20px);
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
}

.wish.show { opacity: 1; transform: translate(-50%, 0); }
.wish:empty { visibility: hidden; }

:focus-visible {
  outline: 3px solid var(--pool);
  outline-offset: 4px;
  border-radius: 8px;
}

/* Tablet and phone: headline, photos, video, photos */
@media (max-width: 999px) {
  :root { --ph: clamp(66px, 17vw, 128px); }

  .page {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 58px 16px 28px;
  }

  .center { display: contents; }
  .hero { order: 1; }
  .rail-left { order: 2; }
  .cake { order: 3; width: 100%; max-width: 760px; margin-top: 4px; padding: 10px; }
  .rail-right { order: 4; }
  .foot { order: 5; }

  .rail {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: clamp(10px, 4vw, 34px);
    width: 100%;
    min-height: calc(var(--ph) * 1.55);
    padding: 22px 0 14px;
  }

  .rail-right { padding-top: 34px; }

  .rail .slot:nth-child(n) { margin: 0; }
  .rail .slot:nth-child(2) { margin-top: 14px; }

  .frame { padding: 7px; border-radius: 20px; box-shadow: 0 8px 0 var(--cherry), 0 18px 28px -8px rgba(58, 31, 27, .35); }
  .frame::before { inset: -9px; border-width: 8px; border-radius: 28px; }
  .frame video { border-radius: 13px; }
  .name { font-size: clamp(58px, 17vw, 128px); }
}

@media (prefers-reduced-motion: reduce) {
  .slot, .flame, .hb, .name span, .balloon svg { animation: none !important; }
  .slot { transform: rotate(var(--r)); }
  .polaroid { transition: opacity .4s ease; }
  .slot.out .polaroid { transform: none; opacity: 0; }
  .slot.enter .polaroid { animation: none; }
}
