/* Modern RTL Design System & Surprise Web Application Styles */
@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

:root {
  --primary-font: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #311042 100%);
  --card-bg: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.15);
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --accent-color: #ec4899;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--primary-font);
  direction: rtl;
  text-align: right;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  color: var(--text-main);
  background: var(--bg-gradient);
  background-attachment: fixed;
  background-size: cover;
  overflow-x: hidden;
  position: relative;
  transition: background 0.6s ease, color 0.4s ease;
}

/* THEMES */
body.theme-midnight {
  --bg-gradient: linear-gradient(135deg, #090d16 0%, #0f172a 50%, #1a103c 100%);
  --card-bg: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.12);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-color: #a855f7;
}

body.theme-white {
  --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #f1f5f9 100%);
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(203, 213, 225, 0.8);
  --text-main: #0f172a;
  --text-muted: #475569;
  --accent-color: #6366f1;
}

body.theme-colorful {
  --bg-gradient: linear-gradient(135deg, #4f46e5 0%, #ec4899 40%, #f59e0b 100%);
  --card-bg: rgba(255, 255, 255, 0.15);
  --card-border: rgba(255, 255, 255, 0.28);
  --text-main: #ffffff;
  --text-muted: #fef08a;
  --accent-color: #fbbf24;
}

body.theme-sunset {
  --bg-gradient: linear-gradient(135deg, #431407 0%, #831843 50%, #d97706 100%);
  --card-bg: rgba(255, 255, 255, 0.09);
  --card-border: rgba(251, 191, 36, 0.25);
  --text-main: #fffbeb;
  --text-muted: #fde68a;
  --accent-color: #f59e0b;
}

body.theme-cosmic {
  --bg-gradient: linear-gradient(135deg, #050515 0%, #1e1035 50%, #2b0938 100%);
  --card-bg: rgba(255, 255, 255, 0.07);
  --card-border: rgba(168, 85, 247, 0.3);
  --text-main: #faf5ff;
  --text-muted: #d8b4fe;
  --accent-color: #c084fc;
}

body.theme-romantic {
  --bg-gradient: linear-gradient(135deg, #4c0519 0%, #831843 50%, #9d174d 100%);
  --card-bg: rgba(255, 255, 255, 0.1);
  --card-border: rgba(244, 63, 94, 0.3);
  --text-main: #fff1f2;
  --text-muted: #fecdd3;
  --accent-color: #f43f5e;
}

/* Background overlay canvas */
#sticker-rain-canvas, #celebration-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10;
}

#sticker-rain-canvas {
  pointer-events: auto; /* allows interactive clicking on stickers */
  z-index: 15;
}

#celebration-canvas {
  z-index: 25;
}

/* Layout container */
.app-container {
  position: relative;
  z-index: 20;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem 1rem;
}

/* Progress bar & Header */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 0.75rem;
}

.step-indicator {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 9999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.step-dots {
  display: flex;
  gap: 0.25rem;
  margin-right: 0.4rem;
}

.step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--card-border);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.step-dot.active {
  width: 18px;
  border-radius: 4px;
  background: var(--accent-color);
  box-shadow: 0 0 10px var(--accent-color);
}

.step-dot.completed {
  background: #10b981;
}

/* Floating Sound Control */
.music-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 9999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  transition: all 0.25s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.music-toggle-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent-color);
}

.music-disc {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle, #ec4899 30%, #3b82f6 70%);
  display: inline-block;
  animation: spinDisc 3s linear infinite;
  animation-play-state: paused;
}

.music-disc.playing {
  animation-play-state: running;
}

@keyframes spinDisc {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Main Card */
.story-card-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0.75rem 0 1.5rem 0;
  perspective: 1000px;
}

.story-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 1.75rem;
  padding: 1.75rem 1.4rem;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.35), 0 0 20px rgba(255, 255, 255, 0.05) inset;
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-style: preserve-3d;
  animation: cardFadeIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Polaroid image card */
.polaroid-frame {
  background: #ffffff;
  padding: 0.75rem 0.75rem 1.75rem 0.75rem;
  border-radius: 0.75rem;
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.1);
  transform: rotate(-1.5deg);
  margin: 1rem auto 1.5rem auto;
  max-width: 320px;
  position: relative;
  transition: transform 0.3s ease;
}

.polaroid-frame:hover {
  transform: rotate(0deg) scale(1.02);
}

.polaroid-tape {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 24px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(2px);
  border: 1px dashed rgba(0, 0, 0, 0.15);
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.polaroid-img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 0.4rem;
  display: block;
}

.polaroid-caption {
  color: #334155;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  margin-top: 0.75rem;
}

/* Image Preset Visuals */
.media-preset-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1.25rem auto;
  font-size: 4.5rem;
  filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.2));
  animation: floatEmoji 3.5s ease-in-out infinite alternate;
}

@keyframes floatEmoji {
  0% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(2deg); }
  100% { transform: translateY(4px) rotate(-2deg); }
}

/* Typography */
.step-title {
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.45;
  margin-bottom: 0.6rem;
  color: var(--text-main);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.step-subtitle {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
  line-height: 1.5;
}

.step-body {
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text-main);
  white-space: pre-line;
  margin-bottom: 1.5rem;
  font-weight: 400;
}

/* Next Buttons */
.button-container {
  margin-top: auto;
  width: 100%;
}

.btn-step-next {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1rem 1.5rem;
  font-family: var(--primary-font);
  font-size: 1.15rem;
  font-weight: 700;
  border-radius: 1.25rem;
  border: none;
  cursor: pointer;
  outline: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.btn-step-next:active {
  transform: scale(0.97);
}

/* Button Color Schemes */
.btn-style-glow_purple {
  background: linear-gradient(135deg, #9333ea 0%, #c084fc 100%);
  color: #ffffff;
  box-shadow: 0 10px 25px -5px rgba(147, 51, 234, 0.5), 0 0 15px rgba(192, 132, 252, 0.3);
}

.btn-style-rose_pink {
  background: linear-gradient(135deg, #e11d48 0%, #f43f5e 50%, #fb7185 100%);
  color: #ffffff;
  box-shadow: 0 10px 25px -5px rgba(225, 29, 72, 0.5), 0 0 15px rgba(244, 63, 94, 0.3);
}

.btn-style-amber_gold {
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 50%, #fde68a 100%);
  color: #451a03;
  box-shadow: 0 10px 25px -5px rgba(217, 119, 6, 0.5), 0 0 15px rgba(245, 158, 11, 0.3);
}

.btn-style-cyber_blue {
  background: linear-gradient(135deg, #2563eb 0%, #38bdf8 100%);
  color: #ffffff;
  box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.5);
}

.btn-style-rainbow {
  background: linear-gradient(90deg, #ec4899, #8b5cf6, #3b82f6, #10b981, #f59e0b, #ec4899);
  background-size: 300% 300%;
  color: #ffffff;
  animation: rainbowAnim 4s ease infinite;
  box-shadow: 0 10px 25px -5px rgba(236, 72, 153, 0.4);
}

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

.btn-style-clean_white {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
}

/* Button Animations */
.anim-pulse {
  animation: btnPulse 2s infinite;
}

@keyframes btnPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.anim-bounce {
  animation: btnBounce 1.5s infinite;
}

@keyframes btnBounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-7px); }
  60% { transform: translateY(-3px); }
}

.anim-shimmer {
  position: relative;
  overflow: hidden;
}

.anim-shimmer::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(60deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transform: rotate(30deg);
  animation: shimmerMove 3s infinite;
}

@keyframes shimmerMove {
  0% { transform: translate(-100%, -100%) rotate(30deg); }
  100% { transform: translate(100%, 100%) rotate(30deg); }
}

/* INTERACTIVE ELEMENTS */

/* 1. Birthday Cake & Candle */
.cake-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 1.5rem auto;
  cursor: pointer;
  user-select: none;
}

.cake-visual {
  position: relative;
  width: 140px;
  height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.candle-wrapper {
  position: relative;
  width: 12px;
  height: 38px;
  background: repeating-linear-gradient(45deg, #f43f5e, #f43f5e 5px, #ffffff 5px, #ffffff 10px);
  border-radius: 4px 4px 0 0;
  margin-bottom: 2px;
  z-index: 2;
}

.flame {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 24px;
  background: radial-gradient(ellipse at bottom, #fef08a 0%, #f97316 60%, #ef4444 100%);
  border-radius: 50% 50% 35% 35% / 60% 60% 40% 40%;
  box-shadow: 0 0 18px #f59e0b, 0 0 35px #ef4444;
  animation: flicker 0.15s ease-in-out infinite alternate;
  transform-origin: bottom center;
  transition: all 0.3s ease;
}

@keyframes flicker {
  0% { transform: translateX(-50%) scale(1) rotate(-2deg); }
  100% { transform: translateX(-50%) scale(1.08) rotate(3deg); }
}

.flame.blown-out {
  opacity: 0;
  transform: translateX(-50%) scale(0.2);
}

.smoke-puff {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.8s ease-out;
}

.smoke-puff.show {
  opacity: 0.8;
  transform: translateX(-50%) translateY(-25px) scale(1.4);
}

.cake-tier-top {
  width: 90px;
  height: 30px;
  background: linear-gradient(to bottom, #fbcfe8, #f472b6);
  border-radius: 12px 12px 6px 6px;
  border-bottom: 4px solid #db2777;
  position: relative;
  z-index: 1;
}

.cake-tier-bottom {
  width: 130px;
  height: 45px;
  background: linear-gradient(to bottom, #fdf2f8, #f472b6);
  border-radius: 14px 14px 10px 10px;
  border-bottom: 5px solid #be185d;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.cake-instruction {
  margin-top: 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-color);
  background: rgba(255, 255, 255, 0.15);
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  animation: pulseBadge 1.8s infinite;
}

@keyframes pulseBadge {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* 2. Interactive Gift Box */
.gift-box-interactive {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1.5rem auto;
  cursor: pointer;
}

.gift-box-icon {
  font-size: 5rem;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: giftWiggle 2.5s ease-in-out infinite;
}

@keyframes giftWiggle {
  0%, 100% { transform: rotate(0deg); }
  10% { transform: rotate(-8deg); }
  20% { transform: rotate(8deg); }
  30% { transform: rotate(-5deg); }
  40% { transform: rotate(5deg); }
  50% { transform: rotate(0deg); }
}

.gift-box-interactive:hover .gift-box-icon {
  transform: scale(1.15) rotate(5deg);
}

/* Autoplay Prompt Modal */
.audio-prompt-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.3s ease;
}

.audio-prompt-box {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 1.75rem;
  padding: 2rem 1.5rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
  color: #ffffff;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Responsive tweaks */
@media (max-width: 480px) {
  .app-container {
    padding: 1rem 0.85rem;
  }
  .story-card {
    padding: 1.4rem 1.15rem;
    border-radius: 1.5rem;
  }
  .step-title {
    font-size: 1.3rem;
  }
  .step-body {
    font-size: 0.98rem;
    line-height: 1.75;
  }
  .polaroid-img {
    height: 185px;
  }
}
