@import url("https://fonts.googleapis.com/css2?family=Dancing+Script:wght@400;700&display=swap");

:root {
  --color-primary: #ffb3d9;
  --color-secondary: #c9a0dc;
  --color-accent: #b4e4ff;
  --color-bg: #fff8f3;
  --color-bg-alt: #fff0f5;
  --font-base: "Quicksand", "Nunito", -apple-system, sans-serif;
  --seal-color: #ffb3d9;
  --ink-color: #4a4a4a;
}

body {
  font-family: var(--font-base);
  min-height: 100vh;
  overflow-x: hidden;
  background: transparent !important;
  animation: none !important;
}

#messages-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

#lock-screen {
  background: linear-gradient(135deg, #ffe5f0 0%, #fff0f5 100%);
}

#main-content {
  padding-top: 80px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.messages-hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
  position: relative;
}

.messages-hero h1 {
  font-size: 3.5rem;
  color: #ff1493;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(255, 255, 255, 0.9), 0 4px 12px rgba(255, 105, 180, 0.4);
  margin-bottom: 0.5rem;
}

.messages-hero p {
  font-size: 1.2rem;
  color: #8b4a6b;
  background: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 0.4rem 1.2rem;
  border-radius: 20px;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.messages-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.messages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2.5rem;
}

.messages-filters {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 1rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.75rem 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 600;
  color: #8b4a6b;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  box-shadow: 0 4px 15px rgba(255, 179, 217, 0.1);
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.7);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 20px rgba(255, 107, 157, 0.3);
  border-color: #ffb3d9;
}

.filter-btn.active {
  background: linear-gradient(135deg, rgba(255, 179, 217, 0.9), rgba(255, 105, 180, 0.9));
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(255, 105, 180, 0.4);
}

.messages-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: #8b4a6b;
  opacity: 0.8;
  background: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(5px);
  border-radius: 16px;
  max-width: 400px;
  margin: 0 auto;
}

.messages-empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.envelope-card {
  perspective: 1000px;
  cursor: pointer;
  position: relative;
}

.envelope-wrapper {
  position: relative;
  width: 100%;
  height: 250px;
  transition: transform 0.3s ease;
}

.envelope-wrapper:hover {
  transform: translateY(-8px);
}

.envelope {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #fff5f6 0%, #ffe4e8 100%);
  border: 1px solid rgba(255, 182, 193, 0.6);
  box-shadow: 0 4px 15px rgba(166, 100, 120, 0.15), inset 0 0 20px rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  overflow: hidden;
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, #ffeef2 0%, #ffd6e0 100%);
  border-bottom: 1px solid rgba(255, 182, 193, 0.8);
  transform-origin: top center;
  transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 3;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 4px 6px rgba(166, 100, 120, 0.1));
}

.envelope-card.open .envelope-flap {
  transform: rotateX(180deg);
}

.envelope-category {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  padding: 0.4rem 1rem;
  background: linear-gradient(135deg, #ffb3d9, #ff69b4);
  color: white;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  z-index: 1;
  box-shadow: 0 2px 8px rgba(255, 105, 180, 0.3);
}

.envelope-preview {
  position: absolute;
  bottom: 3.5rem;
  left: 1rem;
  right: 1rem;
  text-align: center;
  color: #8b4a6b;
  font-size: 0.9rem;
  z-index: 1;
  font-style: italic;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}

.wax-seal {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 65px;
  height: 65px;
  background: radial-gradient(circle at 30% 30%, rgb(255, 145, 175) 0%, var(--seal-color) 40%, rgb(200, 80, 120) 85%, rgb(160, 60, 100) 100%);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), inset 0 0 0 2px rgba(160, 60, 100, 0.3), inset 0 2px 5px rgba(255, 255, 255, 0.3), inset 0 -3px 6px rgba(0, 0, 0, 0.15);
  border-radius: 45% 55% 48% 52% / 50% 45% 55% 50%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.5' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.08'/%3E%3C/svg%3E"), radial-gradient(circle at 30% 30%, rgb(255, 145, 175) 0%, var(--seal-color) 40%, rgb(200, 80, 120) 85%, rgb(160, 60, 100) 100%);
  background-blend-mode: soft-light;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
  filter: drop-shadow(0 -1px 1px rgba(0, 0, 0, 0.2));
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.envelope-card:hover .wax-seal {
  transform: translate(-50%, -50%) scale(1.1);
  filter: brightness(1.05) drop-shadow(0 -1px 1px rgba(0, 0, 0, 0.2));
}

.envelope-card.open .wax-seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0);
}

.letter {
  position: absolute;
  top: 15%;
  left: 8%;
  right: 8%;
  bottom: 8%;
  background: linear-gradient(135deg, #fffcf9 0%, #fff5f0 100%);
  border-radius: 2px;
  padding: 1.5rem;
  box-shadow: inset 0 0 40px rgba(139, 90, 43, 0.05), 0 4px 12px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transform: translateY(100%);
  transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 2;
  border: 1px solid rgba(139, 90, 43, 0.1);
  scroll-behavior: smooth;
}

.letter::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: radial-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
  z-index: 1;
}

.envelope-card.open .letter {
  opacity: 1;
  transform: translateY(0);
}

.letter-header {
  text-align: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 2px dashed rgba(255, 107, 157, 0.3);
}

.letter-title {
  font-family: "Dancing Script", cursive;
  font-size: 1.5rem;
  color: #ff69b4;
  margin-bottom: 0.3rem;
}

.letter-date {
  font-size: 0.85rem;
  color: #999;
  font-style: italic;
}

.letter-body {
  font-family: "Dancing Script", cursive;
  font-size: 1.15rem;
  color: var(--ink-color);
  line-height: 1.8;
  text-align: justify;
}

.letter-signature {
  text-align: right;
  margin-top: 1.5rem;
  font-family: "Dancing Script", cursive;
  font-size: 1.3rem;
  color: #ff69b4;
}

.pen-cursor {
  display: inline-block;
  margin-left: 5px;
  font-size: 1.4rem;
  vertical-align: middle;
  filter: drop-shadow(2px 4px 4px rgba(0, 0, 0, 0.2));
}

.close-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #ffb3d9, #ff69b4);
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 10;
  opacity: 0;
  transform: scale(0) rotate(-180deg);
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  box-shadow: 0 4px 12px rgba(255, 105, 180, 0.4);
  color: white;
}

.envelope-card.open .close-btn {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.close-btn:hover {
  transform: scale(1.15) rotate(90deg);
  box-shadow: 0 6px 16px rgba(255, 105, 180, 0.6);
  background: linear-gradient(135deg, #ff69b4, #ff1493);
}

.typing-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 2rem 0;
  width: 100%;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background-color: var(--color-primary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}
.typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.wobble-love {
  display: inline-block;
  transform-origin: bottom center;
  animation: loveWobble 2s ease-in-out infinite;
  cursor: default;
}

.wobble-love:hover {
  animation-duration: 1s;
  filter: drop-shadow(0 0 5px rgba(255, 105, 180, 0.6));
}

@keyframes loveWobble {
  0% {
    transform: rotate(-8deg) scale(1);
  }
  50% {
    transform: rotate(8deg) scale(1.1);
  }
  100% {
    transform: rotate(-8deg) scale(1);
  }
}

@media (max-width: 768px) {
  .messages-hero h1 {
    font-size: 2.5rem;
  }
  .messages-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .envelope-wrapper {
    height: 280px;
  }
  .letter {
    padding: 1rem;
    top: 12%;
  }
}

@media (max-width: 480px) {
  .messages-hero h1 {
    font-size: 2rem;
  }
  .messages-hero p {
    font-size: 1rem;
  }
  .envelope-wrapper {
    height: 260px;
  }
  .letter {
    top: 10%;
  }
  .wax-seal {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }
  .close-btn {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
  }
}