/* Base Styles */
@font-face {
  font-family: 'BanglaHandwriting';
  src: url('https://text-to-handwriting-maker.vercel.app/fonts/Bangla_Font.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

.letter-title, .letter-content p {
  font-family: 'BanglaHandwriting', sans-serif;
}
.letter-content p {
  font-size: 22px !important;
}
h1.letter-title {
  font-size: 50px;
}
:root {
  --primary-color: #f48fb1;
  --secondary-color: #fce4ec;
  --accent-color: #ec407a;
  --text-color: #424242;
  --shadow-color: rgba(0, 0, 0, 0.1);
}

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

body {
  margin: 0;
  background-color: var(--secondary-color);
  font-family: 'BanglaHandwriting', sans-serif;
  color: var(--text-color);
  overflow-x: hidden;
}

h1, p {
  font-family: 'BanglaHandwriting', sans-serif;
}

p {
  line-height: 1.8;
  margin-bottom: 30px;
  font-size: 1rem;
  text-align: justify;
}

h1 {
  font-weight: 300;
  color: var(--accent-color);
}

.container {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 2s ease;
}

/* Background floating hearts */
.background-elements {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 1;
}

.floating-heart {
  position: absolute;
  color: rgba(244, 143, 177, 0.3);
  animation: float 15s infinite ease-in-out;
  z-index: 2;
  transition: transform 0.5s ease, opacity 0.5s ease, box-shadow 0.5s ease;
}

.message.openNor .floating-heart {
  animation: float 15s infinite ease-in-out, pulse 3s infinite alternate;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.3;
    box-shadow: 0 0 10px rgba(236, 64, 122, 0.4);
  }
  100% {
    transform: scale(1.2);
    opacity: 0.5;
    box-shadow: 0 0 15px rgba(236, 64, 122, 0.6);
  }
}

.heart1 {
  top: 15%;
  left: 10%;
  font-size: 24px;
  animation-delay: 0s;
}

.heart2 {
  top: 40%;
  right: 15%;
  font-size: 18px;
  animation-delay: 5s;
}

.heart3 {
  bottom: 20%;
  left: 20%;
  font-size: 30px;
  animation-delay: 2s;
}

@keyframes float {
  0% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-20px) rotate(5deg); }
  50% { transform: translateY(0) rotate(0deg); }
  75% { transform: translateY(20px) rotate(-5deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

.heart {
  position: absolute;
  left: 50%;
  top: 50%;
  text-align: center;
  transform: translate(-50%, -50%);
  transition: transform 0.5s, top 0.5s;
  z-index: 10;
  cursor: pointer;
  filter: drop-shadow(0 0 10px rgba(236, 64, 122, 0.5));
}

.heart > img {
  width: 60px;
  height: auto;
  transition: all 0.3s ease;
  filter: drop-shadow(0 0 5px rgba(236, 64, 122, 0.3));
  position: relative;
  z-index: 11;
}

.heart > img:hover {
  filter: drop-shadow(0 0 10px rgba(236, 64, 122, 0.7));
  transform: scale(1.1);
  z-index: 11;
}

.heart-glow {
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(236, 64, 122, 0.3) 0%, rgba(252, 228, 236, 0) 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9;
  animation: heart-pulse 2s infinite ease-in-out;
}

@keyframes heart-pulse {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
  50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.3; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
}

.message {
  padding: 30px;
  background-color: #fff;
  width: 90%;
  max-width: 800px;
  max-height: 80%;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  overflow-y: auto;
  animation-name: openmsg;
  animation-duration: 2s;
  animation-timing-function: linear;
  animation-play-state: paused;
  animation-fill-mode: forwards;
  box-shadow: 0 15px 30px var(--shadow-color);
  border-radius: 15px;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) #f5f5f5;
  transition: box-shadow 0.5s ease, opacity 0.5s ease, transform 0.5s ease;
  will-change: transform, opacity, max-height, padding;
}

.message.openNor {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.message::-webkit-scrollbar {
  width: 8px;
}

.message::-webkit-scrollbar-track {
  background: #f5f5f5;
  border-radius: 10px;
}

.message::-webkit-scrollbar-thumb {
  background-color: var(--primary-color);
  border-radius: 10px;
}

/* Message header styling */
.message-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 30px;
  position: relative;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.8s ease, transform 0.8s ease;
  z-index: 7;
}

.letter-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 20px;
  text-align: center;
  position: relative;
  color: var(--accent-color);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  cursor: default;
}

.message.openNor .letter-title:hover {
  transform: scale(1.05);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.15);
}

.message-decoration {
  flex: 1;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--accent-color), transparent);
  max-width: 100px;
  position: relative;
  margin: 0 10px;
  box-shadow: 0 0 5px rgba(236, 64, 122, 0.3);
  transition: all 0.5s ease;
}

.message.openNor .message-decoration {
  height: 3px;
  max-width: 120px;
  background: linear-gradient(to right, transparent, var(--accent-color) 30%, var(--accent-color) 70%, transparent);
  box-shadow: 0 0 8px rgba(236, 64, 122, 0.5);
}

/* Decorative elements for message header */
.decoration-dot {
  display: block;
  width: 6px;
  height: 6px;
  background-color: var(--accent-color);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.7;
  box-shadow: 0 0 5px rgba(236, 64, 122, 0.3);
  transition: all 0.5s ease;
}

.message.openNor .decoration-dot {
  transform: translateY(-50%) scale(1.2);
  opacity: 1;
  box-shadow: 0 0 8px rgba(236, 64, 122, 0.5);
}

.message-decoration:first-child .decoration-dot {
  right: 0;
}

.message-decoration:last-child .decoration-dot {
  left: 0;
}

.title-underline {
  display: block;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, rgba(236, 64, 122, 0), rgba(236, 64, 122, 0.7), rgba(236, 64, 122, 0));
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  transition: width 1s ease;
}

.message.openNor .title-underline {
  width: 80%;
}

/* Letter content styling */
.letter-content {
  padding: 0 10px;
  position: relative;
  z-index: 6;
}

.letter-content p {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Add a subtle paper texture to the message */
.message::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5eXlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAFVklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiBhJRCgh1FYhiLAmdvX0CzTOpNE77ME0Zty/nWWzchDtiqrmQDeuv3powQ5ta2eN0FY0InkqDD73lT9c9lEzwUNqgFHs9VQce3TVClFCQrSTfOiYkVJQBmpbq2L6iZavPnAPcoU0dSw0SUTqz/GtrGuXfbyyBniKykOWQWGqwwMA7QiYAxi+IlPdqo+hYHnUt5ZPfnsHJyNiDtnpJyayNBkF6cWoYGAMY92U2hXHF/C1M8uP/ZtYdiuj26UdAdQQSXQErwSOMzt/XWRWAz5GuSBIkwG1H3FabJ2OsUOUhGC6tK4EMtJO0ttC6IBD3kM0ve0tJwMdSfjZo+EEISaeTr9P3wYrGjXqyC1krcKdhMpxEnt5JetoulscpyzhXN5FRpuPHvbeQaKxF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qFVijqWaJhwtD8MNlSBeWNNWTa5Z5kPZw5+LbVT99wqTdx29lMUH4OIG/D86ruKEauBjvH5xy6um/Sfj7ei6UUVk4AIl3MyD4MSSTOFgSwsH/QJWaQ5as7ZcmgBZkzjjU1UrQ74ci1gWBCSGHtuV1H2mhSnO3Wp/3fEV5a+4wz//6qy8JxjZsmxxy5+4w9CDNJY09T072iKG0EnOS0arEYgXqYnXcYHwjTtUNAcMelOd4xpkoqiTYICWFq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==');
  opacity: 0.05;
  pointer-events: none;
  z-index: 4;
  border-radius: 15px;
}

/* Letter footer styling */
.letter-footer {
  display: flex;
  justify-content: center;
  margin-top: 40px;
}

.signature {
  font-size: 3rem;
  color: var(--accent-color);
  text-align: center;
}

.heart > img:hover {
  animation-name: beat;
  animation-duration: 2s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-play-state: running;
}

@keyframes beat {
  0% { width: 60px; transform: scale(1); }
  25% { width: 70px; transform: scale(1.1); }
  50% { width: 55px; transform: scale(0.95); }
  75% { width: 70px; transform: scale(1.1); }
  100% { width: 60px; transform: scale(1); }
}

@keyframes openmsg {
  0% {
    max-height: 0;
    padding: 0px 30px;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  100% {
    max-height: 85%;
    padding: 30px;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes heartMove {
  0% { top: 50%; transform: translate(-50%, -50%); }
  100% {
    top: 90%;
    transform: translate(-50%, 0);
  }
}

.openNor {
  animation-direction: normal;
  animation-play-state: running;
}

.closeNor {
  animation-direction: reverse;
  animation-play-state: running;
}

.no-anim {
  animation: none;
}

.closed {
  max-height: 0;
  padding: 0px 20px;
  z-index: 1;
  overflow: hidden;
}

.closed .message-header,
.closed .letter-content,
.closed .letter-footer {
  opacity: 0;
  transform: translateY(-20px);
}

.openHer {
  animation-name: heartMove;
  animation-duration: 2s;
  animation-timing-function: linear;
  animation-play-state: running;
  animation-fill-mode: forwards;
}

.closeHer {
  animation-name: heartMove;
  animation-duration: 2s;
  animation-timing-function: linear;
  animation-play-state: running;
  animation-direction: reverse;
  animation-fill-mode: backwards;
}

.beating > img {
  animation-name: beat;
  animation-duration: 2s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-play-state: running;
}

.openedHer {
  top: 90%;
  transform: translate(-50%, 0);
}

/* Initial heart state */
.heart:not(.openedHer):not(.openHer):not(.closeHer) {
  top: 50%;
  transform: translate(-50%, -50%);
}

/* Responsive Media Queries */
@media screen and (max-width: 768px) {
  .message {
    width: 95%;
    padding: 25px 20px;
  }
  
  .letter-title {
    font-size: 2rem;
  }
  
  p {
    font-size: 0.95rem;
    margin-bottom: 25px;
  }
  
  .heart > img {
    width: 50px;
  }
  
  .heart-glow {
    width: 70px;
    height: 70px;
  }
  
  .signature {
    font-size: 2.5rem;
  }
}

@media screen and (max-width: 480px) {
  .message {
    width: 95%;
    padding: 20px 15px;
  }
  
  .letter-title {
    font-size: 1.8rem;
    margin: 0 10px;
  }
  
  .message-decoration {
    max-width: 60px;
  }
  
  p {
    font-size: 0.9rem;
    margin-bottom: 20px;
    line-height: 1.6;
  }
  
  .heart > img {
    width: 45px;
  }
  
  .heart-glow {
    width: 60px;
    height: 60px;
  }
  
  .signature {
    font-size: 2rem;
  }
  
  @keyframes beat {
    0% { width: 45px; transform: scale(1); }
    25% { width: 55px; transform: scale(1.1); }
    50% { width: 40px; transform: scale(0.95); }
    75% { width: 55px; transform: scale(1.1); }
    100% { width: 45px; transform: scale(1); }
  }
}

/* Optimization: Combine similar selectors and remove redundant rules */
.message-header, .letter-content p, .signature {
  will-change: opacity, transform;
}

.heart > img, .heart-glow {
  will-change: transform, filter, opacity;
}

