:root {
  --bg-1: #ffd6e0;
  --bg-2: #ffe8cc;
  --bg-3: #e3d9ff;
  --bg-4: #ffd1f0;
  --ink: #3b1f4a;
  --accent: #ff4f8b;
  --accent-dark: #c9306a;
  --gold: #ffc93c;
  --violet: #7b61ff;
  --teal: #2ec4b6;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-draw: cubic-bezier(.65, 0, .35, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Baloo 2", system-ui, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  overflow: hidden;
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2), var(--bg-4), var(--bg-3));
  background-size: 300% 300%;
  animation: gradient 30s ease-in-out infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

@keyframes gradient {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.defs { position: absolute; }

/* ============================================================
   Line animation — base
   Todo elemento com pathLength="1" + .draw se "desenha" sozinho.
   ============================================================ */
.draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw var(--dur, 1.2s) var(--ease-draw) var(--d, 0s) forwards;
}
@keyframes draw {
  to { stroke-dashoffset: 0; }
}

/* Desenha, segura e apaga — em loop */
@keyframes draw-loop {
  0%   { stroke-dashoffset: 1; }
  40%  { stroke-dashoffset: 0; }
  60%  { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -1; }
}

/* ---------- Bandeirinhas ---------- */
.bunting {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 110px;
  z-index: 2;
  overflow: visible;
}
.bunting-line {
  fill: none;
  stroke: rgba(59, 31, 74, .35);
  stroke-width: 2;
  --dur: 1.4s;
}
.flag-wrap {
  opacity: 0;
  animation: flag-drop .9s var(--ease-out) var(--d) forwards;
}
.flag {
  transform-origin: top center;
  transform-box: fill-box;
  animation: sway 3.2s ease-in-out var(--d) infinite;
}
@keyframes flag-drop {
  from { opacity: 0; transform: translateY(-40px); }
  60%  { opacity: 1; }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes sway {
  0%, 100% { transform: rotate(-5deg); }
  50%      { transform: rotate(5deg); }
}

/* ---------- Serpentinas ---------- */
.streamers {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.streamer {
  position: absolute;
  width: clamp(110px, 16vw, 200px);
  overflow: visible;
}
.streamer path {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw-loop 7s var(--ease-draw) infinite;
}
.s1 { top: 90px;   left: 2vw; }
.s2 { top: 90px;   right: 2vw; }
.s3 { bottom: 40px; left: 3vw; width: clamp(160px, 22vw, 280px); }
.s4 { bottom: 40px; right: 3vw; width: clamp(160px, 22vw, 280px); }
.s1 path { stroke: var(--accent); animation-delay: .8s; }
.s2 path { stroke: var(--violet); animation-delay: 2.4s; }
.s3 path { stroke: var(--teal);   animation-delay: 4s; }
.s4 path { stroke: var(--gold);   animation-delay: 5.6s; }

/* ---------- Estrelinhas ---------- */
.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.star {
  position: absolute;
  width: var(--s, 26px);
  height: var(--s, 26px);
  overflow: visible;
}
.star path {
  fill: none;
  stroke: var(--c, #fff);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw-loop var(--dur, 5s) var(--ease-draw) var(--d, 0s) infinite;
}

/* ---------- Cartão central ---------- */
.hero {
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 2rem 2rem 2.2rem;
  width: calc(100% - 32px);
  max-width: 680px;
  background: rgba(255, 255, 255, .6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 32px;
  box-shadow: 0 30px 80px -20px rgba(59, 31, 74, .35);
  animation: card-in 1.1s var(--ease-out) .15s both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(40px) scale(.94); }
  to   { opacity: 1; transform: none; }
}

/* Bolo line art */
.cake {
  width: 110px;
  height: 100px;
  overflow: visible;
}
.cake-lines path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cake-lines .drip   { stroke: var(--accent); }
.cake-lines .candle { stroke: var(--violet); stroke-width: 4; --dur: .5s; }
.flames path {
  fill: var(--gold);
  stroke: #ff9f1c;
  stroke-width: 1.5;
  transform-origin: center bottom;
  transform-box: fill-box;
  opacity: 0;
  animation:
    flame-in .4s var(--ease-out) 2s forwards,
    flicker .9s ease-in-out 2.4s infinite alternate;
}
.flames path:nth-child(2) { animation-delay: 2.1s, 2.5s; }
.flames path:nth-child(3) { animation-delay: 2.2s, 2.6s; }
@keyframes flame-in {
  from { opacity: 0; transform: scale(0); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes flicker {
  0%   { transform: scale(1, 1)     rotate(-4deg); }
  50%  { transform: scale(.9, 1.12) rotate(3deg); }
  100% { transform: scale(1.05, .95) rotate(-2deg); }
}

/* Título escrito à mão */
.brand {
  margin: .2rem auto .6rem;
  line-height: 0;
}
.brand-svg {
  width: min(100%, 520px);
  height: auto;
  overflow: visible;
}
.brand-svg text {
  font-family: "Pacifico", cursive;
  font-size: 88px;
  fill: url(#brand-grad);
  fill-opacity: 0;
  stroke: url(#brand-grad);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-dasharray: 700;
  stroke-dashoffset: 700;
}
.ready .brand-svg text {
  animation:
    write 2.6s var(--ease-draw) .6s forwards,
    fill-in 1s ease 2.4s forwards;
}
@keyframes write   { to { stroke-dashoffset: 0; } }
@keyframes fill-in { to { fill-opacity: 1; stroke-width: 0; } }

/* Selo */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-weight: 800;
  font-size: clamp(.95rem, 3.2vw, 1.2rem);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #fff;
  background: var(--accent);
  padding: .35rem 1.2rem;
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--accent-dark);
  opacity: 0;
  animation: rise .8s var(--ease-out) 2.6s forwards;
}
.badge::before,
.badge::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: blink 1.4s ease-in-out infinite;
}
.badge::after { animation-delay: .7s; }
@keyframes blink {
  0%, 100% { opacity: .35; }
  50%      { opacity: 1; }
}

/* Mensagem, palavra por palavra */
.message {
  margin-top: 1.2rem;
  font-size: clamp(1.15rem, 4vw, 1.55rem);
  font-weight: 500;
  line-height: 1.45;
}
.message .w {
  display: inline-block;
  opacity: 0;
  animation: rise .7s var(--ease-out) calc(3s + var(--i, 0) * .08s) forwards;
}
.highlight {
  position: relative;
  font-weight: 800;
  color: var(--accent);
}
.squiggle {
  position: absolute;
  left: 0;
  bottom: -8px;
  width: 100%;
  height: 12px;
  overflow: visible;
}
.squiggle path {
  fill: none;
  stroke: var(--gold);
  stroke-width: 4;
  stroke-linecap: round;
  --d: 3.9s;
  --dur: 1s;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* Barra de progresso em linha */
.progress {
  display: block;
  width: min(240px, 70%);
  margin: 1.6rem auto 0;
  overflow: visible;
}
.progress path {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}
.progress .track { stroke: rgba(59, 31, 74, .12); }
.progress .bar {
  stroke: var(--accent);
  stroke-dasharray: .35 1;
  stroke-dashoffset: .35;
  animation: progress 2.2s var(--ease-draw) infinite;
}
@keyframes progress {
  from { stroke-dashoffset: .35; }
  to   { stroke-dashoffset: -1; }
}

.footer {
  position: fixed;
  bottom: 12px;
  z-index: 3;
  font-size: .9rem;
  color: rgba(59, 31, 74, .7);
}

/* ============================================================
   Balões (posição controlada via requestAnimationFrame)
   ============================================================ */
.balloons {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}
.balloon {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
  transform-origin: 50% 44%;
}
.balloon svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.b-body {
  pointer-events: visiblePainted;
  cursor: pointer;
}
.b-fill {
  fill-opacity: 0;
  animation: fill-in-b .8s ease var(--fd, .6s) forwards;
}
@keyframes fill-in-b { to { fill-opacity: 1; } }
.b-line {
  fill: none;
  stroke-width: 2.5;
  --dur: 1.1s;
}
.b-shine {
  fill: none;
  stroke: #fff;
  stroke-width: 5;
  stroke-linecap: round;
  opacity: .75;
  --dur: .6s;
}
.b-string {
  fill: none;
  stroke: rgba(59, 31, 74, .4);
  stroke-width: 1.6;
}
.balloon.popped .b-body {
  animation: b-pop .22s ease-out forwards;
  transform-origin: 50px 60px;
}
.balloon.popped .b-string {
  animation: string-fall .8s ease-in forwards;
}
@keyframes b-pop {
  to { transform: scale(1.5); opacity: 0; }
}
@keyframes string-fall {
  to { transform: translateY(120px); opacity: 0; }
}

/* Estouro: raios em linha disparando para fora */
.burst {
  position: fixed;
  width: 180px;
  height: 180px;
  margin: -90px 0 0 -90px;
  pointer-events: none;
  z-index: 4;
  overflow: visible;
}
.burst .ray {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: .4 1.4;
  stroke-dashoffset: .4;
  animation: ray .6s var(--ease-out) forwards;
}
@keyframes ray { to { stroke-dashoffset: -1; } }
.burst .ring {
  fill: none;
  stroke-width: 2;
  transform-origin: center;
  transform-box: fill-box;
  animation: ring .5s var(--ease-out) forwards;
}
@keyframes ring {
  from { transform: scale(.2); opacity: 1; }
  to   { transform: scale(1.3); opacity: 0; }
}

/* ---------- Confete com giro 3D ---------- */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  perspective: 600px;
}
.confetti i {
  position: absolute;
  top: -30px;
  animation:
    fall var(--duration, 9s) linear var(--delay, 0s) infinite,
    drift var(--sway, 3s) ease-in-out var(--delay, 0s) infinite alternate;
}
.confetti b {
  display: block;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  background: var(--c);
  animation: flip var(--flip, 1.6s) linear infinite;
}
@keyframes fall {
  to { transform: translateY(calc(100vh + 60px)); }
}
@keyframes drift {
  from { translate: -18px 0; }
  to   { translate: 18px 0; }
}
@keyframes flip {
  to { transform: rotate3d(1, .4, .2, 360deg); }
}

/* ---------- Responsivo ---------- */
@media (max-width: 480px) {
  .hero { padding: 1.6rem 1.1rem 1.8rem; border-radius: 24px; }
  .cake { width: 84px; height: 76px; }
  .badge { letter-spacing: .04em; padding: .35rem .9rem; }
  .s3, .s4 { display: none; }
}

/* ---------- Movimento reduzido ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
  }
  .confetti, .streamers, .stars { display: none; }
}
