/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  /* Pink-Blue palette for Galina */
  --pink-50: #fdf2f8;
  --pink-100: #fce7f3;
  --pink-200: #fbcfe8;
  --pink-300: #f9a8d4;
  --pink-400: #f472b6;
  --pink-500: #ec4899;
  --pink-600: #db2777;

  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-300: #93c5fd;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;

  --purple-300: #d8b4fe;
  --purple-400: #c084fc;
  --purple-500: #a855f7;

  --cream: #fff9f5;
  --cream-dark: #fef3ec;

  --text-primary: #4a1942;
  --text-secondary: #7c3a6d;
  --text-light: #b06ea3;

  /* Gradients */
  --gradient-sky: linear-gradient(135deg, #fce4ec 0%, #e8d5f5 25%, #d4e4fc 50%, #fce4ec 75%, #f8d0e8 100%);
  --gradient-letter: linear-gradient(180deg, #fffaf6 0%, #fff5f0 50%, #fff0f5 100%);
  --gradient-accent: linear-gradient(135deg, var(--pink-400), var(--purple-400), var(--blue-400));

  /* Typography */
  --font-display: 'Marck Script', cursive;
  --font-serif: 'Cormorant Garamond', serif;
  --font-sans: 'Inter', sans-serif;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Shadows */
  --shadow-soft: 0 4px 20px rgba(236, 72, 153, 0.1);
  --shadow-medium: 0 8px 40px rgba(236, 72, 153, 0.15);
  --shadow-glow-pink: 0 0 30px rgba(244, 114, 182, 0.3);
  --shadow-glow-blue: 0 0 30px rgba(96, 165, 250, 0.3);

  /* Transitions */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.2s var(--ease-smooth);
  --transition-medium: 0.4s var(--ease-smooth);
  --transition-slow: 0.8s var(--ease-smooth);
}

/* ============================================
   RESET & BASE
   ============================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-serif);
  color: var(--text-primary);
  background: var(--gradient-sky);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  cursor: default;
  position: relative;
}

/* ============================================
   BACKGROUND STARS
   ============================================ */
.stars-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.star-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: white;
  animation: twinkle var(--duration) var(--delay) infinite ease-in-out;
  opacity: 0;
}

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

/* ============================================
   FLOATING CATS
   ============================================ */
.floating-cats {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.cat {
  position: absolute;
  font-size: 1.8rem;
  opacity: 0.12;
  animation: floatCat var(--duration, 20s) var(--delay, 0s) infinite ease-in-out;
  filter: grayscale(0.3);
}

.cat-1 { --duration: 25s; --delay: 0s; left: 5%; top: 15%; }
.cat-2 { --duration: 30s; --delay: 3s; left: 85%; top: 25%; }
.cat-3 { --duration: 22s; --delay: 7s; left: 15%; top: 70%; }
.cat-4 { --duration: 28s; --delay: 5s; left: 75%; top: 75%; }
.cat-5 { --duration: 35s; --delay: 10s; left: 50%; top: 10%; }

@keyframes floatCat {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  25% { transform: translateY(-30px) rotate(5deg) scale(1.05); }
  50% { transform: translateY(-15px) rotate(-3deg) scale(0.95); }
  75% { transform: translateY(-40px) rotate(4deg) scale(1.02); }
}

/* ============================================
   CLICK EFFECTS
   ============================================ */
.click-effects {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.click-particle {
  position: absolute;
  pointer-events: none;
  animation: particleFloat var(--float-duration, 2s) var(--ease-smooth) forwards;
  font-size: var(--size, 1.5rem);
  filter: drop-shadow(0 0 6px rgba(244, 114, 182, 0.5));
}

.click-text {
  position: absolute;
  pointer-events: none;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--pink-500);
  white-space: nowrap;
  text-shadow: 0 0 10px rgba(244, 114, 182, 0.4);
  animation: textFloat 2.5s var(--ease-smooth) forwards;
}

@keyframes particleFloat {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.3) rotate(0deg);
  }
  30% {
    opacity: 1;
    transform: translate(var(--tx, 30px), var(--ty, -50px)) scale(1.2) rotate(var(--rot, 45deg));
  }
  100% {
    opacity: 0;
    transform: translate(calc(var(--tx, 30px) * 1.5), calc(var(--ty, -50px) * 2)) scale(0.5) rotate(calc(var(--rot, 45deg) * 2));
  }
}

@keyframes textFloat {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.5);
  }
  15% {
    opacity: 1;
    transform: translateY(-10px) scale(1);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-80px) scale(0.8);
  }
}

/* ============================================
   SCENES
   ============================================ */
.scene {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 10;
}

.hidden {
  display: none !important;
}

/* ============================================
   ENVELOPE SCENE
   ============================================ */
.scene-envelope {
  flex-direction: column;
  gap: var(--space-xl);
}

.envelope-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}

.envelope-hint {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--text-secondary);
  animation: hintPulse 2s infinite ease-in-out;
  text-shadow: 0 0 20px rgba(244, 114, 182, 0.3);
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.6; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-5px); }
}

/* Envelope */
.envelope {
  width: 320px;
  height: 220px;
  position: relative;
  cursor: pointer;
  transition: transform 0.3s var(--ease-spring);
  perspective: 800px;
}

.envelope:hover {
  transform: scale(1.05) translateY(-5px);
}

.envelope:active {
  transform: scale(0.98);
}

.envelope-body {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--pink-100) 0%, var(--blue-100) 100%);
  border-radius: 0 0 12px 12px;
  position: relative;
  box-shadow: var(--shadow-medium), var(--shadow-glow-pink);
  overflow: hidden;
}

.envelope-body::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 2px dashed var(--pink-200);
  border-radius: 0 0 10px 10px;
  pointer-events: none;
}

.envelope-letter {
  position: absolute;
  top: 10%;
  left: 10%;
  right: 10%;
  height: 60%;
  background: var(--cream);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: transform 0.6s var(--ease-spring);
}

.letter-preview {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text-light);
}

.envelope-flap {
  width: 100%;
  height: 55%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  transform-origin: top center;
  transition: transform 0.8s var(--ease-spring);
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  background: linear-gradient(180deg, var(--pink-200), var(--blue-200));
}

.envelope-flap::after {
  content: '';
  position: absolute;
  inset: 3px;
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  border: 2px dashed var(--pink-300);
  opacity: 0.5;
}

.envelope-front {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  pointer-events: none;
}

.envelope-heart {
  font-size: 3rem;
  animation: heartBeat 1.5s infinite ease-in-out;
  filter: drop-shadow(0 4px 12px rgba(236, 72, 153, 0.4));
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.15); }
  30% { transform: scale(1); }
  45% { transform: scale(1.1); }
  60% { transform: scale(1); }
}

.envelope-to {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--text-primary);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.envelope-from {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--text-secondary);
}

/* Envelope opening animation */
.envelope.opening .envelope-flap {
  transform: rotateX(180deg);
}

.envelope.opening .envelope-letter {
  transform: translateY(-120%) scale(1.1);
}

.envelope.opening .envelope-front {
  opacity: 0;
  transition: opacity 0.3s;
}

/* ============================================
   LETTER SCENE
   ============================================ */
.scene-letter {
  padding: var(--space-xl) var(--space-md);
  align-items: flex-start;
  padding-top: var(--space-3xl);
  animation: fadeInUp 1s var(--ease-smooth);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.letter-container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: var(--space-lg);
}

.letter-paper {
  background: var(--gradient-letter);
  border-radius: 16px;
  padding: var(--space-2xl) var(--space-2xl) var(--space-xl);
  box-shadow:
    var(--shadow-medium),
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 0 60px rgba(244, 114, 182, 0.08);
  position: relative;
  overflow: hidden;
}

/* Paper texture overlay */
.letter-paper::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      transparent,
      transparent 31px,
      rgba(236, 72, 153, 0.04) 31px,
      rgba(236, 72, 153, 0.04) 32px
    );
  pointer-events: none;
  border-radius: 16px;
}

/* Decorative margin line */
.letter-paper::after {
  content: '';
  position: absolute;
  top: 0;
  left: 60px;
  width: 2px;
  height: 100%;
  background: rgba(236, 72, 153, 0.08);
  pointer-events: none;
}

.letter-decoration-top,
.letter-decoration-bottom {
  text-align: center;
  font-size: 1rem;
  color: var(--pink-300);
  letter-spacing: 0.5em;
  padding: var(--space-sm) 0;
  opacity: 0.6;
}

.letter-title {
  font-family: var(--font-display);
  font-size: 2.4rem;
  color: var(--pink-500);
  text-align: center;
  margin: var(--space-lg) 0 var(--space-2xl);
  text-shadow: 0 2px 10px rgba(236, 72, 153, 0.2);
  line-height: 1.3;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.letter-body {
  position: relative;
  z-index: 1;
}

.letter-body p {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 2;
  color: var(--text-primary);
  margin-bottom: var(--space-lg);
  text-indent: 1.5em;
  opacity: 0;
  animation: letterLineIn 0.8s var(--ease-smooth) forwards;
}

.letter-body p:nth-child(1) { animation-delay: 0.2s; }
.letter-body p:nth-child(2) { animation-delay: 0.5s; }
.letter-body p:nth-child(3) { animation-delay: 0.8s; }
.letter-body p:nth-child(4) { animation-delay: 1.1s; }
.letter-body p:nth-child(5) { animation-delay: 1.4s; }
.letter-body p:nth-child(6) { animation-delay: 1.7s; }
.letter-body p:nth-child(7) { animation-delay: 2.0s; }
.letter-body p:nth-child(8) { animation-delay: 2.3s; }
.letter-body p:nth-child(9) { animation-delay: 2.6s; }

@keyframes letterLineIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.letter-highlight {
  text-align: center;
  font-size: 1.3rem !important;
  font-weight: 600;
  color: var(--pink-600) !important;
  text-indent: 0 !important;
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.08), rgba(96, 165, 250, 0.08));
  border-radius: 12px;
  border-left: 3px solid var(--pink-300);
  border-right: 3px solid var(--blue-300);
}

/* Poem / Distance paragraph */
.letter-poem {
  text-indent: 0 !important;
  text-align: center;
  font-style: italic;
  line-height: 2.2 !important;
  padding: var(--space-lg) var(--space-md);
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.05), rgba(168, 85, 247, 0.05), rgba(96, 165, 250, 0.05));
  border-radius: 12px;
  border-left: 3px solid var(--pink-200);
  border-right: 3px solid var(--blue-200);
  position: relative;
}

.poem-emphasis {
  display: block;
  margin-top: var(--space-sm);
  font-weight: 600;
  font-style: normal;
  color: var(--pink-600);
  font-size: 1.1em;
}

.letter-sign {
  text-align: right;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--text-secondary);
  margin-top: var(--space-2xl);
  text-indent: 0 !important;
  line-height: 1.8;
}

.letter-sign-name {
  font-family: var(--font-display);
  font-size: 1.6rem;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.letter-sign-heart {
  display: inline-block;
  font-size: 2rem;
  color: var(--pink-400);
  animation: heartBeat 1.5s infinite ease-in-out;
}

/* Footer */
.letter-footer {
  margin-top: var(--space-2xl);
  text-align: center;
  opacity: 0;
  animation: letterLineIn 0.8s 2.5s var(--ease-smooth) forwards;
}

.letter-cats {
  font-size: 1.8rem;
  letter-spacing: 0.3em;
  margin-bottom: var(--space-md);
}

.letter-cats span {
  display: inline-block;
  animation: catBounce 2s infinite ease-in-out;
}

.letter-cats span:nth-child(1) { animation-delay: 0s; }
.letter-cats span:nth-child(2) { animation-delay: 0.3s; }
.letter-cats span:nth-child(3) { animation-delay: 0.6s; }

@keyframes catBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.letter-ps {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 300;
  letter-spacing: 0.02em;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .envelope {
    width: 280px;
    height: 190px;
  }

  .envelope-to {
    font-size: 1.3rem;
  }

  .letter-container {
    padding: var(--space-md) var(--space-sm);
  }

  .letter-paper {
    padding: var(--space-xl) var(--space-lg) var(--space-lg);
    border-radius: 12px;
  }

  .letter-paper::after {
    left: 30px;
  }

  .letter-title {
    font-size: 1.8rem;
  }

  .letter-body p {
    font-size: 1.05rem;
    line-height: 1.9;
  }

  .letter-highlight {
    font-size: 1.1rem !important;
    padding: var(--space-sm) var(--space-md);
  }

  .cat {
    font-size: 1.4rem;
    opacity: 0.08;
  }
}

@media (max-width: 400px) {
  .envelope {
    width: 250px;
    height: 170px;
  }

  .letter-paper {
    padding: var(--space-lg) var(--space-md);
  }

  .letter-title {
    font-size: 1.5rem;
  }

  .letter-body p {
    font-size: 1rem;
    line-height: 1.8;
  }
}

/* ============================================
   SELECTION STYLE
   ============================================ */
::selection {
  background: var(--pink-200);
  color: var(--text-primary);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--pink-50);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--pink-300), var(--blue-300));
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(var(--pink-400), var(--blue-400));
}
