/* ============================================================
   Shikha's Birthday — custom animations & components
   (Tailwind handles layout/colors; this file handles the magic)
   ============================================================ */

:root {
  --rose: #e5588f;
  --rose-soft: #ffd9e6;
  --gold: #f6c453;
}

* {
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: #120522;
}

/* ---------- Screen system ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  min-height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.screen.active {
  display: flex;
  opacity: 1;
}
.screen.flex-col {
  display: none; /* overridden by .active */
}
.screen.active.flex-col {
  display: flex;
}

/* ---------- Countdown boxes ---------- */
.cd-box {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 1rem;
  padding: 0.75rem 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  backdrop-filter: blur(6px);
}
.cd-box span {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--rose-soft);
  line-height: 1;
}
.cd-box small {
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 0.35rem;
}

/* ---------- Floating background emojis (flowers/chocolate/animals) ---------- */
.floaty-emojis {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.floaty-emojis span {
  position: absolute;
  bottom: -10%;
  font-size: 1.6rem;
  opacity: 0;
  animation: floatUp linear infinite;
  will-change: transform, opacity;
}
@keyframes floatUp {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.9;
  }
  90% {
    opacity: 0.7;
  }
  100% {
    transform: translateY(-115vh) rotate(240deg);
    opacity: 0;
  }
}

/* ---------- Little animated flourishes ---------- */
.heartbeat {
  animation: heartbeat 1.3s ease-in-out infinite;
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.25); }
  30% { transform: scale(1); }
  45% { transform: scale(1.18); }
}
.wiggle { animation: wiggle 2.5s ease-in-out infinite; }
@keyframes wiggle {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}
.swing { animation: swing 3s ease-in-out infinite; }
@keyframes swing {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}
.float-slow { animation: floatSlow 4s ease-in-out infinite; }
@keyframes floatSlow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

/* ---------- Who-are-you option cards ---------- */
.who-card {
  position: relative;
  padding: 1.1rem 0.5rem;
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  overflow: hidden;
}
.who-card:active {
  transform: scale(0.95);
}
.who-card:hover {
  background: rgba(229, 88, 143, 0.18);
  box-shadow: 0 8px 24px rgba(229, 88, 143, 0.25);
}
.who-card .wc-emoji {
  font-size: 1.9rem;
  display: block;
}
.who-card .wc-name {
  font-family: 'Dancing Script', cursive;
  font-size: 1.55rem;
  color: var(--rose-soft);
  margin-top: 0.15rem;
}

/* ============================================================
   ENVELOPE
   ============================================================ */
.envelope-scene {
  perspective: 1400px;
  padding: 6px;
}
.envelope {
  position: relative;
  width: 300px;
  max-width: 84vw;
  height: 200px;
  cursor: pointer;
  transform-style: preserve-3d;
  animation: envIdle 4.5s ease-in-out infinite;
}
@keyframes envIdle {
  0%, 100% { transform: translateY(0) rotate(-1.2deg); }
  50% { transform: translateY(-9px) rotate(1.2deg); }
}
.envelope.opening {
  animation: none;
  transform: translateY(-4px) scale(1.02);
  transition: transform 0.5s ease;
}
.envelope.flying {
  transition: transform 0.5s ease, opacity 0.5s ease;
  transform: translateY(26px) scale(0.94);
  opacity: 0;
}

/* soft ground shadow */
.envelope::after {
  content: '';
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -22px;
  height: 22px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.45), transparent 72%);
  filter: blur(2px);
  z-index: 0;
}

/* back / body of the envelope */
.env-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #ffb0cd 0%, #ef6f9c 60%, #e5588f 100%);
  border-radius: 14px;
  box-shadow: 0 26px 55px rgba(0, 0, 0, 0.5), inset 0 -10px 24px rgba(0, 0, 0, 0.15);
  z-index: 1;
}

/* the letter that peeks out and slides up */
.env-letter {
  position: absolute;
  left: 7%;
  width: 86%;
  top: 9%;
  height: 82%;
  background: linear-gradient(180deg, #fffaf4, #fff1f5);
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-align: center;
  padding: 0 12%;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
  transition: transform 0.75s cubic-bezier(0.2, 0.85, 0.25, 1) 0.32s,
    box-shadow 0.4s ease 0.32s;
  z-index: 2;
}
.env-letter .env-deco {
  color: #e5588f;
  opacity: 0.6;
  font-size: 0.9rem;
}
.envelope.opening .env-letter {
  transform: translateY(-116%) rotate(-1deg);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.35);
  z-index: 6;
}

/* front pocket (two side flaps + bottom) */
.env-pocket {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #ffa4c4, #ef6f9c);
  border-radius: 14px;
  clip-path: polygon(0 40%, 50% 90%, 100% 40%, 100% 100%, 0 100%);
  z-index: 3;
  box-shadow: inset 0 8px 16px rgba(255, 255, 255, 0.18);
}
/* subtle seam highlight on the pocket V */
.env-pocket::before {
  content: '';
  position: absolute;
  inset: 0;
  clip-path: polygon(0 40%, 50% 90%, 100% 40%, 50% 92%);
  background: rgba(0, 0, 0, 0.06);
}

/* top flap that opens in 3D */
.env-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 58%;
  background: linear-gradient(160deg, #ffbcd5, #f2789f);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transform: rotateX(0deg);
  transition: transform 0.6s cubic-bezier(0.6, 0, 0.3, 1);
  transform-style: preserve-3d;
  backface-visibility: hidden;
  border-radius: 14px 14px 0 0;
  z-index: 5;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}
.envelope.opening .env-flap {
  transform: rotateX(178deg);
  z-index: 1;
  transition: transform 0.6s cubic-bezier(0.6, 0, 0.3, 1), z-index 0s 0.3s;
}

/* wax seal that "breaks" open */
.env-seal {
  position: absolute;
  top: 33%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ff8aa9, #c9184a 78%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.4), inset 0 -3px 6px rgba(0, 0, 0, 0.3),
    inset 0 3px 5px rgba(255, 255, 255, 0.35);
  z-index: 7;
  transition: transform 0.4s ease, opacity 0.4s ease;
}
.env-seal span {
  filter: saturate(1.3);
}
.envelope.opening .env-seal {
  transform: translate(-50%, -50%) scale(1.7) rotate(12deg);
  opacity: 0;
}

.tap-hint {
  animation: tapPulse 1.8s ease-in-out infinite;
}
@keyframes tapPulse {
  0%, 100% { opacity: 0.45; transform: translateY(0); }
  50% { opacity: 0.9; transform: translateY(-3px); }
}

/* ---------- Letter card ---------- */
.letter-card {
  position: relative;
  background: linear-gradient(180deg, #fffdf8 0%, #fff5f4 100%);
  border-radius: 1.5rem;
  padding: 1.9rem 1.5rem 1.7rem;
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.48);
  border: 1px solid rgba(229, 88, 143, 0.18);
  overflow: hidden;
  animation: cardIn 0.85s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
/* faint paper grain / warmth */
.letter-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 0%, rgba(255, 210, 225, 0.5), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(255, 224, 178, 0.35), transparent 50%);
  pointer-events: none;
}
/* dashed inner frame */
.letter-card::before {
  content: '';
  position: absolute;
  inset: 11px;
  border: 1px dashed rgba(229, 88, 143, 0.3);
  border-radius: 1.1rem;
  pointer-events: none;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(42px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.letter-card > * {
  position: relative;
  z-index: 1;
}
.letter-corner {
  position: absolute;
  color: rgba(229, 88, 143, 0.4);
  font-size: 1rem;
  z-index: 2;
}
.letter-corner.tl { top: 8px; left: 12px; }
.letter-corner.tr { top: 8px; right: 12px; }
.letter-corner.bl { bottom: 8px; left: 12px; }
.letter-corner.br { bottom: 8px; right: 12px; }

.letter-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: rgba(229, 88, 143, 0.55);
}
.letter-rule::before,
.letter-rule::after {
  content: '';
  height: 1px;
  width: 32%;
  background: linear-gradient(90deg, transparent, rgba(229, 88, 143, 0.4), transparent);
}

.letter-card p b,
.letter-card p strong {
  color: var(--rose);
  font-weight: 600;
}

/* staggered reveal for letter content */
.letter-anim {
  opacity: 0;
  animation: lineIn 0.55s ease forwards;
}
#wish-body p {
  opacity: 0;
  animation: lineIn 0.55s ease forwards;
}
@keyframes lineIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   NIGHT SKY / MAKE A WISH
   ============================================================ */
.starfield {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  animation: twinkle var(--dur, 3s) ease-in-out infinite;
  opacity: 0.8;
}
@keyframes twinkle {
  0%, 100% { opacity: 0.15; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

.shooting-star {
  position: absolute;
  top: 12%;
  left: -10%;
  width: 120px;
  height: 2px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), #fff);
  border-radius: 999px;
  opacity: 0;
  filter: drop-shadow(0 0 6px #fff);
  z-index: 1;
}
.shooting-star::after {
  content: '';
  position: absolute;
  right: 0;
  top: -2px;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px 2px #fff;
}
.shooting-star.animate {
  animation: shoot 1.6s ease-in forwards;
}
@keyframes shoot {
  0% { transform: translate(0, 0) rotate(18deg); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(120vw, 42vh) rotate(18deg); opacity: 0; }
}

/* garland across top */
.garland {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  font-size: 1.4rem;
  z-index: 1;
  padding-top: 2px;
}
.garland span {
  animation: floatSlow 3.5s ease-in-out infinite;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}
.garland span:nth-child(odd) { animation-delay: 0.5s; }
.garland span:nth-child(3n) { animation-delay: 1s; }

/* ---------- Birthday cake ---------- */
.candle-wrap {
  position: relative;
  width: 200px;
  height: 210px;
  margin: 0 auto;
}

/* plate */
.cake-plate {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 196px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(180deg, #eef0f6, #b9bece);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
}
.cake-plate::before {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 150px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255, 190, 90, 0.28), transparent 70%);
  z-index: -1;
}

/* cake stack */
.cake {
  position: absolute;
  bottom: 13px;
  left: 50%;
  transform: translateX(-50%);
  width: 164px;
  height: 104px;
}

/* sponge / base */
.cake-body {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 72px;
  border-radius: 10px 10px 14px 14px;
  background: linear-gradient(180deg, #ffb2ce 0%, #ef6f9c 60%, #e5588f 100%);
  box-shadow: inset 0 -12px 20px rgba(0, 0, 0, 0.18), 0 10px 20px rgba(0, 0, 0, 0.42);
  overflow: hidden;
  z-index: 1;
}
/* cream filling stripe */
.cake-body::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 30px;
  height: 9px;
  background: rgba(255, 244, 249, 0.75);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* frosting top with drips */
.cake-frost {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 46px;
  border-radius: 12px 12px 8px 8px;
  background: linear-gradient(180deg, #fff7fb, #ffd8e7);
  box-shadow: inset 0 5px 9px rgba(255, 255, 255, 0.65);
  z-index: 2;
}
.cake-frost::after {
  content: '';
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: -9px;
  height: 16px;
  background: radial-gradient(circle at 11px 0, #ffd8e7 9px, transparent 10px) repeat-x;
  background-size: 22px 16px;
}
.cherry {
  position: absolute;
  top: -8px;
  left: 26px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff7a7a, #c1121f 80%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  z-index: 3;
}
.cherry::after {
  content: '';
  position: absolute;
  top: -6px;
  left: 6px;
  width: 6px;
  height: 8px;
  border-left: 2px solid #4c8a3f;
  border-top-left-radius: 6px;
}

/* sprinkles on the sponge */
.sprinkle {
  position: absolute;
  width: 3px;
  height: 9px;
  border-radius: 2px;
  z-index: 2;
}
.sprinkle.s1 { top: 46px; left: 26px; background: #ffe34d; transform: rotate(35deg); }
.sprinkle.s2 { top: 54px; left: 58px; background: #6fd0ff; transform: rotate(-25deg); }
.sprinkle.s3 { top: 48px; left: 92px; background: #b28bff; transform: rotate(50deg); }
.sprinkle.s4 { top: 56px; left: 122px; background: #7CFC9B; transform: rotate(-40deg); }
.sprinkle.s5 { top: 60px; left: 44px; background: #fff; transform: rotate(15deg); }

/* candle on top of the cake */
.cake-candle {
  position: absolute;
  bottom: 104px;
  left: 50%;
  transform: translateX(-50%);
  width: 13px;
  height: 46px;
  border-radius: 3px;
  background: repeating-linear-gradient(45deg, #fff 0 6px, #e5588f 6px 12px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
  z-index: 3;
}
/* little shadow where the candle meets the frosting, so it looks planted */
.cake-candle::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 7px;
  border-radius: 50%;
  background: rgba(120, 20, 60, 0.28);
  filter: blur(1px);
}

/* flame sits on the candle tip */
.flame {
  position: absolute;
  bottom: 146px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 42px;
  transform-origin: bottom center;
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 4;
}
.flame::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: linear-gradient(to top, #ffd93b, #ff8a00 55%, #ff5e3a);
  box-shadow: 0 0 18px 6px rgba(255, 170, 40, 0.7);
  transform-origin: bottom center;
  animation: flameFlicker 0.35s ease-in-out infinite alternate;
}
.flame-glow {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 190, 80, 0.35), transparent 65%);
  animation: glowFlicker 0.5s ease-in-out infinite alternate;
}
/* flame shape flickers in place (no horizontal shift) */
@keyframes flameFlicker {
  0% { transform: scaleY(1) rotate(-2deg); }
  100% { transform: scaleY(1.12) rotate(2deg); }
}
/* glow stays centered while pulsing */
@keyframes glowFlicker {
  0% { transform: translateX(-50%) scale(1); opacity: 0.85; }
  100% { transform: translateX(-50%) scale(1.12); opacity: 1; }
}
.candle-wrap.blown .flame {
  opacity: 0;
  transform: translateX(-50%) translateY(-14px) scale(0.4);
}
.candle-wrap.blown .flame-glow {
  opacity: 0;
}

/* smoke puff after blow */
.smoke {
  position: absolute;
  bottom: 150px;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(220, 220, 220, 0.5);
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}
.smoke.puff {
  animation: smoke 1.6s ease-out forwards;
}
@keyframes smoke {
  0% { opacity: 0.6; transform: translate(-50%, 0) scale(0.6); }
  100% { opacity: 0; transform: translate(-50%, -70px) scale(2.4); }
}

.glow-btn {
  animation: glowPulse 2s ease-in-out infinite;
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 14px rgba(255, 170, 40, 0.4); }
  50% { box-shadow: 0 0 26px rgba(255, 170, 40, 0.8); }
}

/* ---------- Music toggle ---------- */
.music-toggle {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 14px;
  z-index: 50;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(6px);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}
.music-toggle:active { transform: scale(0.9); }

/* ---------- Confetti (per-wish burst) ---------- */
.confetti {
  position: fixed;
  top: -12px;
  width: 9px;
  height: 14px;
  z-index: 60;
  pointer-events: none;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0.9; }
}

/* input shake on wrong password */
.shake {
  animation: shake 0.45s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.1ms !important;
  }
}
