/* =========================================================
   Happy Birthday, Spancer — Candle-burns-the-gift edition
   ========================================================= */

:root {
  --bg-top:  #fff1f5;
  --bg-mid:  #f0e6ff;
  --bg-bot:  #d9ecff;
  --cream:   #ffffff;
  --ink:     #3a1f55;
  --ink-2:   #6b4a8c;
  --pink-1:  #ffd0e0;
  --pink-2:  #ff8eb1;
  --pink-3:  #ec5b8c;
  --mint-1:  #b8edd6;
  --mint-2:  #7adcb1;
  --mint-3:  #2bae84;
  --ember:   #ff5a1c;
  --ember-2: #ffb04a;
  --shadow-card: 0 24px 50px -22px rgba(120, 80, 160, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

body {
  font-family: "Fraunces", "Cormorant Garamond", Georgia, "Songti SC", serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 0%,  #ffd9e7, transparent 55%),
    radial-gradient(ellipse at 85% 12%, #e3d7ff, transparent 50%),
    radial-gradient(ellipse at 70% 95%, #c6e6ff, transparent 60%),
    radial-gradient(ellipse at 15% 90%, #fff1c2, transparent 55%),
    linear-gradient(180deg, var(--bg-top), var(--bg-mid) 55%, var(--bg-bot));
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

.grain {
  position: fixed; inset: -10%; pointer-events: none; z-index: 2;
  opacity: .04;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.7'/></svg>");
  mix-blend-mode: multiply;
}

#stage {
  position: relative;
  z-index: 3;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 24px;
}

.scene {
  width: 100%;
  max-width: 620px;
  text-align: center;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.scene[data-active] { display: flex; }

/* Typography */
.eyebrow {
  font-family: "Caveat", "Kaiti SC", cursive;
  font-size: 22px; color: var(--ink-2); opacity: .8;
}
.eyebrow.shine-eye {
  background: linear-gradient(90deg, var(--pink-3), var(--mint-3), var(--pink-3));
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  animation: shimmer 5s linear infinite;
  font-weight: 700;
}
@keyframes shimmer { to { background-position: 200% 0; } }

.display {
  font-family: "Fraunces", serif;
  font-weight: 800;
  font-size: clamp(56px, 12vw, 110px);
  line-height: 1.0;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.display em {
  font-style: italic;
  font-weight: 800;
  background: linear-gradient(180deg, #6e1b9c 10%, #d12586 55%, #ff7eb6 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  padding: 0 .04em;
}
.display.big { font-size: clamp(68px, 14vw, 128px); }

.kicker {
  font-family: "Caveat", "Kaiti SC", cursive;
  font-size: 20px;
  color: var(--ink-2);
  opacity: .85;
  min-height: 28px;
  transition: opacity .3s ease;
}

/* =====================================================
   GIFT STAGE
   ===================================================== */
.gift-scene {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 12px;
}
.gift-stage {
  position: relative;
  width: min(360px, 88vw);
  height: min(440px, 110vw);
  touch-action: none;
}

.gift-shadow {
  position: absolute;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  width: 78%; height: 28px;
  background: radial-gradient(ellipse at center, rgba(120,60,140,.32), transparent 70%);
  filter: blur(8px);
  z-index: 0;
}

.light-shaft {
  position: absolute;
  left: 50%; bottom: 60px;
  width: 300px; height: 400px;
  transform: translate(-50%, 0) scale(0.4);
  background: radial-gradient(ellipse at 50% 100%, rgba(255,245,200,.85), rgba(255,200,220,.35) 35%, transparent 70%);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  filter: blur(2px);
}

.gift-box {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.gift-body {
  position: absolute;
  left: 50%; bottom: 40px;
  width: 220px; height: 180px;
  transform: translateX(-50%);
  filter: drop-shadow(0 18px 28px rgba(160,60,120,.35));
}
.gift-body svg { width: 100%; height: 100%; display: block; }

.strap {
  position: absolute;
  box-shadow: 0 2px 4px rgba(40,140,100,.25);
}
.strap-v {
  left: 50%; bottom: 40px;
  width: 18px; height: 180px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--mint-1), var(--mint-2), var(--mint-3));
}
.strap-h {
  left: 50%; bottom: 120px;
  width: 220px; height: 14px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, var(--mint-3), var(--mint-2) 20%, var(--mint-1) 50%, var(--mint-2) 80%, var(--mint-3));
}

.gift-lid {
  position: absolute;
  left: 50%; bottom: 212px;
  width: 240px; height: 36px;
  transform: translateX(-50%);
  filter: drop-shadow(0 6px 8px rgba(160,60,120,.35));
}
.gift-lid svg { width: 100%; height: 100%; display: block; }

.gift-bow-static {
  position: absolute;
  left: 50%; bottom: 224px;
  width: 180px; height: 90px;
  transform: translateX(-50%);
  filter: drop-shadow(0 5px 8px rgba(40,140,100,.4));
}
.gift-bow-static svg { width: 100%; height: 100%; display: block; }

.reveal-glow {
  position: absolute;
  left: 50%; top: 50%;
  width: 380px; height: 380px;
  transform: translate(-50%, -50%) scale(.4);
  background: radial-gradient(circle at center, rgba(255,240,200,.85), rgba(255,180,210,.35) 35%, transparent 70%);
  opacity: 0;
  pointer-events: none;
}

/* CAKE — sits hidden behind the box (z-index lower) until box burns away */
.cake-reveal {
  position: absolute;
  left: 50%;
  bottom: 80px;
  width: 86%;
  z-index: 3;       /* BEHIND the box (z-4) — invisible until box gone */
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
}
.cake-reveal svg {
  width: 100%; height: auto;
  filter: drop-shadow(0 16px 28px rgba(180,80,140,.35));
  display: block;
}

/* CANDLE tool */
.candle-tool {
  position: absolute;
  left: calc(50% + 150px);   /* further to the right of the box */
  bottom: 30px;              /* sits lower, like resting on the table */
  width: 46px;
  height: 184px;
  transform: translate(-50%, 0);
  z-index: 20;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 8px 14px rgba(120,80,140,.4));
  will-change: transform;
}
.candle-tool svg { width: 100%; height: 100%; display: block; }
.candle-tool.dragging { cursor: grabbing; }
.candle-tool .candle-flame {
  opacity: 0;
  transform-origin: 30px 60px;
}
.candle-tool.lit .candle-flame {
  opacity: 1;
  animation: bigFlameFlicker .14s ease-in-out infinite alternate;
}
@keyframes bigFlameFlicker {
  from { transform: scale(1, 1)    translateY(0); }
  to   { transform: scale(1.08, .94) translateY(-1px); }
}

/* Warm glow halo behind candle when lit */
.candle-glow {
  position: absolute;
  left: 50%; top: 8%;
  width: 140px; height: 140px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255,200,120,.55), rgba(255,150,80,.18) 40%, transparent 70%);
  opacity: 0;
  pointer-events: none;
  filter: blur(2px);
}
.candle-tool.lit .candle-glow {
  opacity: 1;
  animation: glowPulse 1.4s ease-in-out infinite alternate;
}
@keyframes glowPulse {
  from { transform: translate(-50%, -50%) scale(.9); opacity: .7; }
  to   { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
}

/* SVG fire — sits on top of the box during burn */
.fire-svg {
  position: absolute;
  left: 50%; bottom: 30px;
  width: 300px; height: 400px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 7;
  opacity: 0;
  filter: drop-shadow(0 0 28px rgba(255, 120, 40, 0.7))
          drop-shadow(0 0 60px rgba(255, 200, 60, 0.4));
}
.fire-svg .smoke-layer { opacity: 0.6; }

/* Ember canvas — bright dots above flames */
.fire-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
}

/* Sparkles canvas (used for celebration burst on cake reveal) */
.sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 11;
}

/* Candle flames on cake */
.candle .flame { transform-origin: center bottom; }
.candle.lit .flame {
  animation: flameFlick .22s ease-in-out infinite alternate;
}
@keyframes flameFlick {
  from { transform: scale(1, 1) translateY(0); }
  to   { transform: scale(1.1, .92) translateY(-1px); }
}

/* =====================================================
   SCENE 2 — reveal page
   ===================================================== */
.ghost-btn {
  background: rgba(255,255,255,.6);
  border: 1px solid rgba(120,60,140,.2);
  color: var(--ink);
  padding: 10px 22px;
  border-radius: 999px;
  font-family: "Caveat", cursive;
  font-size: 18px;
  cursor: pointer;
  transition: all .25s ease;
  margin-top: 14px;
  backdrop-filter: blur(8px);
}
.ghost-btn:hover {
  background: rgba(255,255,255,.85);
  border-color: rgba(120,60,140,.5);
  transform: translateY(-2px);
}
.ghost-btn.subtle {
  font-size: 16px;
  opacity: .65;
  margin-top: 24px;
  background: transparent;
  border-color: rgba(120,60,140,.18);
}
.ghost-btn.subtle:hover { opacity: 1; }

.card {
  margin-top: 8px;
  width: 100%;
  max-width: 480px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.95), rgba(255,255,255,.75)),
    radial-gradient(ellipse at top left, rgba(255,200,220,.5), transparent 60%);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: var(--shadow-card);
  position: relative;
  backdrop-filter: blur(10px);
}
.card::before {
  content: "";
  position: absolute;
  top: -1px; left: 50%; transform: translateX(-50%);
  width: 60%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--pink-3), transparent);
  opacity: .5;
}
.card-message {
  font-family: "Fraunces", serif;
  font-weight: 400;
  font-style: italic;
  font-size: clamp(17px, 3.6vw, 21px);
  line-height: 1.65;
  white-space: pre-line;
  text-align: left;
  color: var(--ink);
}
.card-sign {
  margin-top: 18px;
  font-family: "Caveat", cursive;
  font-size: 22px;
  color: var(--pink-3);
  text-align: right;
  opacity: .85;
}

.photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 520px;
  margin-top: 8px;
}
.polaroid {
  background: var(--cream);
  color: var(--ink);
  border-radius: 4px;
  padding: 10px 10px 28px;
  aspect-ratio: 3 / 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 26px -10px rgba(160,80,160,.35);
  font-family: "Caveat", cursive;
  position: relative;
  transition: transform .3s ease;
}
.polaroid:hover { transform: rotate(0) translateY(-4px) scale(1.03); z-index: 1; }
.polaroid[data-empty] .ph-emoji { font-size: 32px; opacity: .4; margin-bottom: 6px; }
.polaroid small {
  font-size: 16px; color: var(--ink); opacity: .5;
  position: absolute; bottom: 8px; left: 0; right: 0; text-align: center;
}
.polaroid img {
  width: 100%; height: calc(100% - 22px);
  object-fit: cover; border-radius: 2px;
}

#confetti {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 60;
}

@media (max-width: 480px) {
  #stage { padding: 24px 16px; }
  .photos { gap: 10px; }
  .card { padding: 24px 20px; }
  .candle-tool { left: calc(50% + 125px); bottom: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
