/* ============================================
   Personagram.ai — CSS Animations Library
   Viewer frame animations + delight effects
   ============================================ */

/* ============================================
   Confetti
   ============================================ */

.css-anim-confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ============================================
   Fireworks
   ============================================ */

.css-anim-fireworks {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.firework-burst {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: firework-particle ease-out forwards;
}

@keyframes firework-particle {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--fx), var(--fy)) scale(0); opacity: 0; }
}

/* ============================================
   Sparkles
   ============================================ */

.css-anim-sparkles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.sparkle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #fff;
  border-radius: 50%;
  animation: sparkle-twinkle ease-in-out infinite;
  box-shadow: 0 0 6px 2px rgba(255, 209, 102, 0.5);
}

@keyframes sparkle-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.5); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ============================================
   Hearts
   ============================================ */

.css-anim-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.heart {
  position: absolute;
  bottom: -40px;
  font-size: 24px;
  animation: heart-float ease-out forwards;
}

@keyframes heart-float {
  0% { transform: translateY(0) rotate(0deg) scale(0.5); opacity: 0; }
  10% { opacity: 1; transform: translateY(-10vh) rotate(-10deg) scale(1); }
  90% { opacity: 0.8; }
  100% { transform: translateY(-110vh) rotate(20deg) scale(0.3); opacity: 0; }
}

/* ============================================
   Balloons
   ============================================ */

.css-anim-balloons {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.balloon {
  position: absolute;
  bottom: -60px;
  font-size: 40px;
  animation: balloon-float ease-out forwards;
}

@keyframes balloon-float {
  0% { transform: translateY(0) rotate(-5deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(-120vh) rotate(10deg); opacity: 0.3; }
}

/* ============================================
   Stars
   ============================================ */

.css-anim-stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.shooting-star {
  position: absolute;
  width: 80px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #ffd166, #fff);
  border-radius: 2px;
  animation: star-streak linear forwards;
}

@keyframes star-streak {
  0% { transform: translateX(-100px) translateY(0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateX(110vw) translateY(60px); opacity: 0; }
}

/* ============================================
   Snow
   ============================================ */

.css-anim-snow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.snowflake {
  position: absolute;
  top: -10px;
  color: #fff;
  font-size: 14px;
  opacity: 0.7;
  animation: snow-drift linear infinite;
}

@keyframes snow-drift {
  0% { transform: translateY(-10px) translateX(0) rotate(0deg); }
  50% { transform: translateY(50vh) translateX(30px) rotate(180deg); }
  100% { transform: translateY(110vh) translateX(-20px) rotate(360deg); }
}

/* ============================================
   Frame Overlay Text Animations
   ============================================ */

.overlay-text {
  opacity: 0;
}

.overlay-text.animate-fade-in-up {
  animation: frame-fade-in-up 0.8s ease forwards;
}

.overlay-text.animate-fade-in {
  animation: frame-fade-in 0.6s ease forwards;
}

@keyframes frame-fade-in-up {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes frame-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================
   Viewer Specific Styles
   ============================================ */

.viewer-frame {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--navy);
}

.frame-background {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 1;
}

.frame-background::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 40%, rgba(0,0,0,0.5) 100%);
}

.avatar-pip {
  position: absolute;
  z-index: 10;
  border: 3px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  object-fit: cover;
}

.avatar-pip.bottom-right {
  bottom: 100px;
  right: 20px;
  width: 30vw;
  max-width: 180px;
  height: auto;
  aspect-ratio: 9/16;
  border-radius: 50%;
}

.avatar-pip.full-screen {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 65%;
  max-width: 500px;
  height: auto;
  border-radius: var(--radius-lg);
}

.frame-overlay-text {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  padding: 0 24px;
}

.frame-overlay-text h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 4rem);
  color: #fff;
  text-shadow: 0 2px 20px rgba(0,0,0,0.5);
  margin-bottom: 12px;
}

.frame-overlay-text h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  color: #fff;
  text-shadow: 0 2px 16px rgba(0,0,0,0.5);
  margin-bottom: 10px;
}

.frame-overlay-text h3 {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  color: rgba(255,255,255,0.9);
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
  margin-bottom: 8px;
}

.frame-overlay-text p {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 8px rgba(0,0,0,0.4);
  max-width: 600px;
  margin: 0 auto 8px;
}

/* Choice buttons */
.choices-container {
  position: absolute;
  z-index: 30;
  bottom: 120px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
}

.choice-btn {
  width: 85%;
  max-width: 400px;
  min-height: 52px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--navy);
  border: none;
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  opacity: 0;
  animation: choice-appear 0.4s ease forwards;
}

.choice-btn:nth-child(1) { animation-delay: 0ms; }
.choice-btn:nth-child(2) { animation-delay: 100ms; }
.choice-btn:nth-child(3) { animation-delay: 200ms; }
.choice-btn:nth-child(4) { animation-delay: 300ms; }

.choice-btn:active { transform: scale(0.96); }

@keyframes choice-appear {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Viewer navigation */
.viewer-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: rgba(10, 14, 26, 0.6);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255,255,255,0.05);
}

.viewer-nav-btn {
  padding: 10px 24px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.viewer-nav-btn:hover { background: rgba(255, 255, 255, 0.25); }

.viewer-nav-btn.primary {
  background: var(--gradient-coral);
  box-shadow: 0 4px 16px rgba(255, 77, 109, 0.3);
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 4px 16px rgba(255, 77, 109, 0.3); }
  50% { box-shadow: 0 4px 24px rgba(255, 77, 109, 0.5); }
}

.viewer-dots {
  display: flex;
  gap: 6px;
}

.viewer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

.viewer-dot.active {
  background: var(--coral);
  box-shadow: 0 0 8px rgba(255, 77, 109, 0.5);
}

.viewer-dot.visited { background: rgba(255, 255, 255, 0.5); }

/* Mute toggle */
.mute-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 60;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Loading screen */
.viewer-loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  gap: 24px;
  padding: 32px;
  text-align: center;
}

.viewer-loading-blob {
  width: 80px;
  height: 80px;
  background: var(--gradient-coral);
  border-radius: 50%;
  animation: blob-morph 3s ease-in-out infinite;
}

@keyframes blob-morph {
  0%, 100% { border-radius: 50%; transform: scale(1); }
  25% { border-radius: 40% 60% 50% 50%; transform: scale(1.05); }
  50% { border-radius: 50% 40% 60% 50%; transform: scale(0.95); }
  75% { border-radius: 60% 50% 40% 60%; transform: scale(1.02); }
}

.viewer-loading h3 {
  font-family: var(--font-display);
  color: var(--cream);
}

.viewer-loading p {
  color: var(--cream-dim);
  font-size: 0.9rem;
  animation: loading-fade 2s ease-in-out infinite;
}

@keyframes loading-fade {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* End screen */
.viewer-end {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  gap: 20px;
  padding: 32px;
  text-align: center;
  animation: fade-in 0.5s ease;
}

/* ============================================
   Gradient mesh background
   ============================================ */

.gradient-mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.gradient-mesh::before {
  content: '';
  position: absolute;
  width: 120%;
  height: 120%;
  top: -10%;
  left: -10%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(255, 77, 109, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(255, 209, 102, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(100, 60, 180, 0.1) 0%, transparent 50%);
  animation: mesh-shift 20s ease-in-out infinite;
}

@keyframes mesh-shift {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(2%, -2%) rotate(1deg); }
  66% { transform: translate(-1%, 1%) rotate(-0.5deg); }
}
