/* Design System & Custom Properties */
:root {
  /* Fonts */
  --font-sans: 'Outfit', system-ui, -apple-system, sans-serif;

  /* Day Theme (Pastel pink / lavender) */
  --bg-gradient-1: #ffccd5;
  --bg-gradient-2: #ffcad4;
  --bg-gradient-3: #b5e2fa;
  --card-border: rgba(255, 255, 255, 0.4);
  --text-primary: #3d2016;
  --btn-bg: rgba(255, 255, 255, 0.7);
  --btn-hover: rgba(255, 255, 255, 0.9);
  --pig-frame-border: #ffffff;
  
  /* Transitions */
  --transition-smooth: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-spring: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Dark Theme Variables */
[data-theme="dark"] {
  --bg-gradient-1: #0f0c1b;
  --bg-gradient-2: #24142f;
  --bg-gradient-3: #130a1c;
  --card-border: rgba(255, 112, 150, 0.15);
  --text-primary: #ffd6e0;
  --btn-bg: rgba(255, 255, 255, 0.1);
  --btn-hover: rgba(255, 255, 255, 0.18);
  --pig-frame-border: rgba(255, 112, 150, 0.25);
}

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

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 0;
  position: relative;
  transition: var(--transition-smooth);
}

/* Dynamic Gradient Flow Background */
.bg-gradient-flow {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -2;
  background: linear-gradient(135deg, var(--bg-gradient-1), var(--bg-gradient-2), var(--bg-gradient-3));
  background-size: 300% 300%;
  animation: gradientShift 18s ease infinite;
}

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

/* Background Particles Container */
.bg-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* Theme Toggle Control */
.theme-toggle-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  background: var(--btn-bg);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: var(--transition-spring);
  backdrop-filter: blur(8px);
  z-index: 100;
}

.theme-toggle-btn:hover {
  transform: scale(1.1) rotate(15deg);
  background: var(--btn-hover);
}

.theme-toggle-btn svg {
  width: 20px;
  height: 20px;
}

/* Pig Container */
.pig-container {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1;
  position: relative;
  cursor: pointer;
  user-select: none;
  z-index: 5;
}

/* Realistic Image Wrapper (Circular Frame) */
.pig-image-wrapper {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 8px solid var(--pig-frame-border, #ffffff);
  overflow: hidden;
  position: relative;
  box-shadow: 0 24px 60px rgba(232, 122, 144, 0.28);
  background: rgba(255, 255, 255, 0.3);
  animation: idleBreatheImg 5s ease-in-out infinite;
  transition: var(--transition-smooth);
}

/* Image style */
.pig-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Smiling State (Default) */
.pig-smiling-img {
  opacity: 1;
  z-index: 2;
}

/* Laughing State */
.pig-laughing-img {
  opacity: 0;
  z-index: 1;
}

/* Active Laugh Transitions */
.pig-container.is-laughing .pig-smiling-img {
  opacity: 0;
}

.pig-container.is-laughing .pig-laughing-img {
  opacity: 1;
}

/* Realistic laugh body shaking vibration */
.pig-container.is-laughing .pig-image-wrapper {
  animation: realisticLaughShake var(--laugh-speed, 0.32s) ease-in-out infinite;
}

/* ANIMATIONS */

/* Idle - Breathing Animation for the circular frame */
@keyframes idleBreatheImg {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-5px) scale(1.015);
  }
}

/* Realistic vibration shaking of belly laugh */
@keyframes realisticLaughShake {
  0%, 100% {
    transform: translateY(0) rotate(0deg) scale(1);
  }
  25% {
    transform: translateY(-5px) rotate(-0.5deg) scale(1.01);
  }
  50% {
    transform: translateY(1px) rotate(0.5deg) scale(0.99);
  }
  75% {
    transform: translateY(-3px) rotate(-0.2deg) scale(1.005);
  }
}

/* Confetti Sparkles & Particles Styles */
.confetti-particle {
  position: absolute;
  pointer-events: none;
  z-index: 100;
  will-change: transform, opacity;
  animation: particleFadeFly var(--particle-duration, 1.2s) cubic-bezier(0.1, 0.8, 0.25, 1) forwards;
}

@keyframes particleFadeFly {
  0% {
    transform: translate(-50%, -50%) translate(0, 0) scale(0) rotate(0deg);
    opacity: 1;
  }
  15% {
    transform: translate(-50%, -50%) translate(var(--dx1), var(--dy1)) scale(1.2) rotate(var(--rot1));
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) translate(var(--dx2), var(--dy2)) scale(0.3) rotate(var(--rot2));
    opacity: 0;
  }
}

/* Background floating pig icons (from all sides) */
.bg-float-pig {
  position: absolute;
  pointer-events: none;
  width: var(--size, 32px);
  height: var(--size, 32px);
  border-radius: 50%;
  border: 2px solid var(--pig-frame-border, rgba(255, 255, 255, 0.4));
  background-image: url('pig_laughing.png');
  background-size: cover;
  background-position: center;
  opacity: var(--opacity, 0.3);
  z-index: -1;
  will-change: transform, opacity;
}

/* Animations for each side */
.float-from-bottom {
  bottom: -60px;
  left: var(--start-pos);
  animation: floatUp var(--duration) linear infinite;
  animation-delay: var(--delay);
}

.float-from-top {
  top: -60px;
  left: var(--start-pos);
  animation: floatDown var(--duration) linear infinite;
  animation-delay: var(--delay);
}

.float-from-left {
  left: -60px;
  top: var(--start-pos);
  animation: floatRight var(--duration) linear infinite;
  animation-delay: var(--delay);
}

.float-from-right {
  right: -60px;
  top: var(--start-pos);
  animation: floatLeft var(--duration) linear infinite;
  animation-delay: var(--delay);
}

@keyframes floatUp {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: var(--opacity); }
  90% { opacity: var(--opacity); }
  100% { transform: translateY(-115vh) rotate(360deg); opacity: 0; }
}

@keyframes floatDown {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: var(--opacity); }
  90% { opacity: var(--opacity); }
  100% { transform: translateY(115vh) rotate(-360deg); opacity: 0; }
}

@keyframes floatRight {
  0% { transform: translateX(0) rotate(0deg); opacity: 0; }
  10% { opacity: var(--opacity); }
  90% { opacity: var(--opacity); }
  100% { transform: translateX(115vw) rotate(360deg); opacity: 0; }
}

@keyframes floatLeft {
  0% { transform: translateX(0) rotate(0deg); opacity: 0; }
  10% { opacity: var(--opacity); }
  90% { opacity: var(--opacity); }
  100% { transform: translateX(-115vw) rotate(-360deg); opacity: 0; }
}

/* Birthday Note Popup Styles */
.note-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 320px;
  max-width: calc(100vw - 48px);
  background: var(--btn-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.35s ease;
  transform-origin: bottom right;
}

[data-theme="dark"] .note-popup {
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.note-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  opacity: 0.6;
  cursor: pointer;
  transition: var(--transition-spring);
  padding: 4px;
}

.note-close-btn:hover {
  opacity: 1;
  transform: scale(1.2);
}

.note-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
}

.note-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  opacity: 0.95;
}

.birthday-heading {
  margin-top: 14px;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  color: var(--accent-color);
  letter-spacing: 0.5px;
  animation: shinePulse 2s ease-in-out infinite alternate;
}

@keyframes shinePulse {
  0% { transform: scale(0.98); filter: drop-shadow(0 0 2px rgba(255, 112, 150, 0.1)); }
  100% { transform: scale(1.02); filter: drop-shadow(0 0 8px rgba(255, 112, 150, 0.5)); }
}

/* Collapsed Note Badge Button */
.note-badge-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--btn-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
  transition: var(--transition-spring);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 6px;
}

.note-badge-btn:hover {
  transform: scale(1.05) translateY(-2px);
  background: var(--btn-hover);
  box-shadow: 0 12px 30px rgba(255, 112, 150, 0.15);
}

.note-popup.closed {
  transform: scale(0.5) translate(40px, 40px);
  opacity: 0;
  pointer-events: none;
}

.note-badge-btn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}
