/* Torta: a pastel party. Sprinkles on the page, balloons, a two-tier cake with the age as number
   candles that can be blown out (and lit again), the message on a frosted card and the photos as
   glossy stickers. */

:root {
  --cream: #fff0f5;
  --berry: #4a1838;
  --pink: #ff6fa3;
  --pink-soft: #ffc2d8;
  --mint: #5fd3b5;
  --lilac: #a58bff;
  --butter: #ffcf4a;
  --sky: #63b9ff;
  --round: "Baloo", "Arial Rounded MT Bold", system-ui, sans-serif;
  --text: "Nunito", system-ui, sans-serif;
  --lb-bg: rgba(74, 24, 56, .95);
  --lb-font: var(--round);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--cream); }

body {
  margin: 0;
  color: var(--berry);
  font: 400 1.0625rem/1.6 var(--text);
  overflow-wrap: anywhere;
  hyphens: auto;
  -webkit-font-smoothing: antialiased;
  background: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%27160%27 height=%27160%27 opacity=%27.55%27%3E%3Crect x=%270%27 y=%2767%27 width=%2712%27 height=%274%27 rx=%272%27 fill=%27%23ff7aa8%27 transform=%27rotate(56 0 67)%27/%3E%3Crect x=%277%27 y=%27129%27 width=%2712%27 height=%274%27 rx=%272%27 fill=%27%235fd3b5%27 transform=%27rotate(74 7 129)%27/%3E%3Crect x=%2778%27 y=%2770%27 width=%2712%27 height=%274%27 rx=%272%27 fill=%27%23a58bff%27 transform=%27rotate(85 78 70)%27/%3E%3Crect x=%2742%27 y=%2733%27 width=%2712%27 height=%274%27 rx=%272%27 fill=%27%23ffcf4a%27 transform=%27rotate(128 42 33)%27/%3E%3Crect x=%2721%27 y=%2757%27 width=%2712%27 height=%274%27 rx=%272%27 fill=%27%2363b9ff%27 transform=%27rotate(106 21 57)%27/%3E%3Crect x=%27124%27 y=%2757%27 width=%2712%27 height=%274%27 rx=%272%27 fill=%27%23ff7aa8%27 transform=%27rotate(15 124 57)%27/%3E%3Crect x=%2733%27 y=%27110%27 width=%2712%27 height=%274%27 rx=%272%27 fill=%27%235fd3b5%27 transform=%27rotate(107 33 110)%27/%3E%3Crect x=%2783%27 y=%2772%27 width=%2712%27 height=%274%27 rx=%272%27 fill=%27%23a58bff%27 transform=%27rotate(42 83 72)%27/%3E%3Crect x=%2746%27 y=%27119%27 width=%2712%27 height=%274%27 rx=%272%27 fill=%27%23ffcf4a%27 transform=%27rotate(2 46 119)%27/%3E%3Crect x=%2729%27 y=%2786%27 width=%2712%27 height=%274%27 rx=%272%27 fill=%27%2363b9ff%27 transform=%27rotate(128 29 86)%27/%3E%3Crect x=%272%27 y=%2758%27 width=%2712%27 height=%274%27 rx=%272%27 fill=%27%23ff7aa8%27 transform=%27rotate(160 2 58)%27/%3E%3Crect x=%2778%27 y=%2715%27 width=%2712%27 height=%274%27 rx=%272%27 fill=%27%235fd3b5%27 transform=%27rotate(110 78 15)%27/%3E%3Crect x=%27144%27 y=%2748%27 width=%2712%27 height=%274%27 rx=%272%27 fill=%27%23a58bff%27 transform=%27rotate(162 144 48)%27/%3E%3Crect x=%273%27 y=%27108%27 width=%2712%27 height=%274%27 rx=%272%27 fill=%27%23ffcf4a%27 transform=%27rotate(145 3 108)%27/%3E%3C/svg%3E") var(--cream);
}

[hidden] { display: none !important; }

button { font: inherit; color: inherit; }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  isolation: isolate;
  overflow-x: clip;
  padding: clamp(36px, 8vw, 80px) 16px clamp(32px, 6vw, 56px);
  display: grid;
  justify-items: center;
  text-align: center;
  background: radial-gradient(70% 55% at 50% 62%, rgba(255, 255, 255, .9), rgba(255, 255, 255, 0) 70%);
}

.balloons { position: absolute; inset: 0; z-index: -1; pointer-events: none; }

.balloon {
  position: absolute;
  width: clamp(54px, 13vw, 96px);
  aspect-ratio: 5 / 6;
  border-radius: 50% 50% 48% 52% / 56% 56% 44% 44%;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .75) 0 8%, transparent 26%), var(--c);
  box-shadow: inset -8px -10px 18px rgba(0, 0, 0, .1);
}

.balloon::before { content: ""; position: absolute; left: 50%; bottom: -6px; width: 10px; height: 8px; translate: -50% 0; background: var(--c); clip-path: polygon(50% 0, 100% 100%, 0 100%); }

.balloon::after { content: ""; position: absolute; left: 50%; top: 100%; width: 1.5px; height: 120px; background: linear-gradient(rgba(74, 24, 56, .35), transparent); }

.b1 { --c: var(--pink); left: 2%; top: 40%; rotate: -8deg; }
.b2 { --c: var(--lilac); right: 3%; top: 1%; rotate: 9deg; width: clamp(48px, 11vw, 84px); }
.b3 { --c: var(--mint); left: 7%; top: 1%; rotate: 6deg; width: clamp(34px, 8vw, 64px); }
.b4 { --c: var(--butter); right: 7%; top: 44%; rotate: -5deg; width: clamp(44px, 10vw, 76px); }

.kicker {
  margin: 0;
  font: 700 clamp(1.3rem, 5.4vw, 2rem)/1.1 var(--round);
  color: var(--pink);
}

.name {
  width: 100%;
  margin: 4px 0 0;
  max-width: min(100%, 980px);
  font: 800 15vw/.98 var(--round);
  letter-spacing: -.02em;
  color: var(--berry);
  text-shadow: 3px 3px 0 var(--pink-soft), 6px 6px 0 rgba(255, 111, 163, .25);
  hyphens: manual;
  text-wrap: balance;
}

.date {
  margin: 12px 0 0;
  padding: 4px 14px 2px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 0 var(--pink-soft);
  font: 700 .95rem/1.4 var(--round);
  color: var(--berry);
}

/* ---------- The cake ---------- */

.scene {
  position: relative;
  width: min(92%, 420px);
  margin-top: clamp(76px, 18vw, 116px);
}

.cake { display: block; width: 100%; height: auto; overflow: visible; }

.candles {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 77%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2%;
  pointer-events: none;
}

.candle { position: relative; display: grid; justify-items: center; }

.candles:not(:has(.digit)) { gap: 22px; }

/* A number candle: the digit itself, striped like candy. */
.digit {
  display: block;
  font: 800 clamp(6rem, 30vw, 8.6rem)/.8 var(--round);
  letter-spacing: -.02em;
  background: repeating-linear-gradient(-50deg, #ff8fb8 0 9px, #fff 9px 16px, #ffd166 16px 25px, #fff 25px 32px);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 2.5px var(--berry);
  padding: 0 .02em;
}

.candles.three .digit { font-size: clamp(4.8rem, 22vw, 6.6rem); }

/* A plain candle when there is no age. */
.stick {
  width: 16px;
  height: clamp(64px, 18vw, 90px);
  border: 2.5px solid var(--berry);
  border-radius: 5px 5px 2px 2px;
  background: repeating-linear-gradient(-45deg, var(--c, #ff8fb8) 0 7px, #fff 7px 13px);
}

.wick { width: 3px; height: 12px; border-radius: 2px; background: var(--berry); }

.flame {
  position: absolute;
  bottom: calc(100% - 3px);
  left: 50%;
  width: 22px;
  height: 34px;
  translate: -50% 0;
  border-radius: 50% 50% 45% 45% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 78%, #fff 0 18%, #ffe27a 32%, #ffab3d 62%, #ff6a3d 82%, transparent 84%);
  box-shadow: 0 0 22px 8px rgba(255, 190, 80, .45), 0 0 60px 20px rgba(255, 170, 60, .18);
  transform-origin: 50% 90%;
  transition: transform .35s ease, opacity .35s ease;
}

.smoke {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  width: 14px;
  height: 14px;
  translate: -50% 0;
  border-radius: 50%;
  background: rgba(120, 100, 110, .35);
  filter: blur(3px);
  opacity: 0;
}

.out .flame { transform: scale(0, .2); opacity: 0; }

.blow {
  margin-top: clamp(26px, 5vw, 40px);
  padding: .7em 1.6em .62em;
  border: 0;
  border-radius: 999px;
  background: var(--berry);
  color: #fff;
  font: 800 clamp(1.1rem, 4.4vw, 1.35rem)/1.1 var(--round);
  box-shadow: 0 6px 0 #2b0b20, 0 14px 30px -10px rgba(74, 24, 56, .6);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}

.blow:active { transform: translateY(5px); box-shadow: 0 1px 0 #2b0b20, 0 6px 16px -8px rgba(74, 24, 56, .6); }

.blow:focus-visible { outline: 3px solid var(--sky); outline-offset: 4px; }

.wish {
  min-height: 1.6em;
  margin: 18px 0 0;
  font: 700 clamp(1.15rem, 4.6vw, 1.5rem)/1.3 var(--round);
  color: var(--pink);
}

/* ---------- Message card ---------- */

main { width: min(1040px, 100% - 32px); margin: 0 auto; }

.card {
  position: relative;
  width: min(700px, 100%);
  margin: clamp(30px, 6vw, 56px) auto 0;
  padding: clamp(46px, 9vw, 70px) clamp(22px, 6vw, 56px) clamp(32px, 7vw, 54px);
  border-radius: 34px;
  background: #fff;
  box-shadow: 0 10px 0 var(--pink-soft), 0 30px 60px -30px rgba(74, 24, 56, .35);
}

/* Frosting dripping over the card's top edge. */
.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40px;
  border-radius: 34px 34px 0 0;
  background:
    radial-gradient(circle at 50% 0, var(--pink) 15px, transparent 15.5px) 0 12px / 46px 30px repeat-x,
    linear-gradient(var(--pink), var(--pink)) 0 0 / 100% 14px no-repeat;
}

.card-title {
  margin: 0 0 18px;
  font: 800 clamp(1.7rem, 6.4vw, 2.4rem)/1.1 var(--round);
  color: var(--berry);
  text-align: center;
}

.text p {
  margin: 0 0 1em;
  white-space: pre-line;
  font: 500 clamp(1.1rem, 3.6vw, 1.25rem)/1.7 var(--text);
  text-wrap: pretty;
}

.text p:last-child { margin-bottom: 0; }

.text .salute { font: 800 clamp(1.4rem, 5vw, 1.75rem)/1.2 var(--round); color: var(--pink); }

.from { margin: 26px 0 0; text-align: right; }

.from span { display: block; font: 600 .95rem/1.3 var(--text); color: #9a6a85; }

.from b { font: 800 clamp(1.35rem, 5vw, 1.7rem)/1.2 var(--round); color: var(--pink); }

/* ---------- Photo stickers ---------- */

.album { margin-top: clamp(60px, 11vw, 110px); }

.album-title {
  width: fit-content;
  margin: 0 auto clamp(24px, 5vw, 40px);
  padding: .2em .8em .1em;
  border-radius: 999px;
  background: var(--mint);
  color: #fff;
  font: 800 clamp(1.5rem, 6vw, 2.2rem)/1.2 var(--round);
  box-shadow: 0 5px 0 #3fae92;
  rotate: -2deg;
}

.stickers { columns: 2; column-gap: clamp(14px, 3.5vw, 26px); padding: 0 4px; }

@media (min-width: 760px) {
  .stickers { columns: 3; }
}

.sticker {
  break-inside: avoid;
  margin: 0 0 clamp(16px, 4vw, 28px);
  padding: 7px;
  border-radius: 26px;
  background: #fff;
  box-shadow: 6px 7px 0 var(--c, var(--pink));
  rotate: var(--tilt, 0deg);
  transition: rotate .3s cubic-bezier(.3, 1.6, .5, 1), scale .3s cubic-bezier(.3, 1.6, .5, 1);
}

.sticker:hover { rotate: 0deg; scale: 1.03; }

.sticker .photo {
  display: block;
  width: 100%;
  aspect-ratio: var(--ratio, 1);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 20px;
  overflow: hidden;
  background: #ffe3ee;
  cursor: zoom-in;
}

.sticker .photo img { display: block; width: 100%; height: 100%; object-fit: cover; }

.sticker .photo:focus-visible { outline: 3px solid var(--sky); outline-offset: 4px; }

/* ---------- Finale ---------- */

.finale {
  width: min(700px, 100% - 32px);
  margin: clamp(60px, 11vw, 110px) auto 0;
  padding-bottom: clamp(44px, 8vw, 84px);
  text-align: center;
}

.hurra {
  margin: 0;
  font: 800 clamp(2.6rem, 12vw, 5rem)/1 var(--round);
  color: var(--pink);
  text-shadow: 3px 3px 0 #fff, 6px 6px 0 var(--pink-soft);
}

.hurra-sub { margin: 10px 0 0; font: 700 1.15rem/1.4 var(--round); color: var(--berry); }

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

/* ---------- Motion ---------- */

.reveal .rv { transition: opacity .7s ease, transform .7s cubic-bezier(.3, 1.4, .5, 1); }

.reveal .rv:not(.in) { opacity: 0; transform: translateY(26px) scale(.97); }

@media (prefers-reduced-motion: no-preference) {
  .flame { animation: flicker 1.6s ease-in-out infinite alternate; }
  .candle:nth-child(2) .flame { animation-delay: -.6s; }
  .candle:nth-child(3) .flame { animation-delay: -1.1s; }
  .out .flame { animation: none; }
  .out .smoke { animation: smoke 1.6s ease-out forwards; }
  .balloon { animation: bob 5s ease-in-out infinite alternate; }
  .b2 { animation-delay: -1.5s; }
  .b3 { animation-delay: -3s; }
  .b4 { animation-delay: -2.2s; }
  .scene { animation: plop .9s .2s cubic-bezier(.3, 1.5, .5, 1) both; }
  .name { animation: plop .8s cubic-bezier(.3, 1.5, .5, 1) both; }
}

@keyframes flicker {
  0% { transform: rotate(-3deg) scale(1, 1); }
  35% { transform: rotate(2deg) scale(.94, 1.06); }
  70% { transform: rotate(-1deg) scale(1.04, .95); }
  100% { transform: rotate(3deg) scale(.97, 1.04); }
}

@keyframes smoke {
  0% { opacity: .9; transform: translateY(0) scale(.6); }
  100% { opacity: 0; transform: translateY(-70px) translateX(8px) scale(2.4); }
}

@keyframes bob { to { transform: translateY(-14px); } }

@keyframes plop { from { opacity: 0; transform: scale(.85) translateY(20px); } }

.stickers.one { columns: 1; width: min(100%, 420px); margin: 0 auto; }
