/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Crimson Text", serif;
  background: #f7f3e9;
  color: #2d2d2d;
  min-height: 100vh;
  line-height: 1.7;
  position: relative;
}

/* Music controls */
.music-controls {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
}

.music-btn {
  background: rgba(139, 115, 85, 0.9);
  border: 2px solid rgba(139, 115, 85, 0.3);
  border-radius: 25px;
  padding: 10px 15px;
  color: white;
  cursor: pointer;
  font-family: "Libre Baskerville", serif;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.music-btn:hover {
  background: rgba(139, 115, 85, 1);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.music-btn.playing {
  background: rgba(139, 115, 85, 1);
  border-color: #8b7355;
}

.music-icon {
  font-size: 1.1rem;
  animation: musicPulse 2s ease-in-out infinite;
}

.music-btn.playing .music-icon {
  animation: musicPulse 1s ease-in-out infinite;
}

@keyframes musicPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.music-text {
  font-weight: 500;
}

/* Subtle paper texture */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(
      circle at 15% 25%,
      rgba(139, 115, 85, 0.02) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 85% 75%,
      rgba(139, 115, 85, 0.01) 0%,
      transparent 50%
    );
  pointer-events: none;
  z-index: 1;
}

/* Main container - handwritten paper */
.container {
  position: relative;
  z-index: 2;
  max-width: 650px;
  margin: 0 auto;
  padding: 50px 35px;
  background: #fefefe;
  box-shadow: 0 0 0 1px rgba(139, 115, 85, 0.2), 0 15px 35px rgba(0, 0, 0, 0.08),
    inset 0 0 0 1px rgba(255, 255, 255, 0.8);
  margin-top: 30px;
  margin-bottom: 30px;
  border-radius: 2px;
  transform: rotate(-0.3deg);
}

/* Handwritten lines */
.container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: repeating-linear-gradient(
    transparent,
    transparent 24px,
    rgba(139, 115, 85, 0.08) 24px,
    rgba(139, 115, 85, 0.08) 25px
  );
  pointer-events: none;
  z-index: 1;
}

/* Margin line */
.container::after {
  content: "";
  position: absolute;
  top: 0;
  left: 40px;
  width: 1px;
  height: 100%;
  background: rgba(139, 115, 85, 0.12);
  z-index: 1;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 40px;
  padding-bottom: 25px;
  border-bottom: 1px solid rgba(139, 115, 85, 0.3);
  position: relative;
  z-index: 2;
}

.date-stamp {
  font-family: "Libre Baskerville", serif;
  font-size: 0.85rem;
  color: #8b7355;
  margin-bottom: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-style: italic;
  transform: rotate(-0.5deg);
}

.main-title {
  font-family: "Libre Baskerville", serif;
  font-size: 2.2rem;
  color: #2d2d2d;
  margin-bottom: 12px;
  font-weight: 400;
  letter-spacing: 0.5px;
  transform: rotate(0.3deg);
}

.subtitle {
  font-style: italic;
  color: #8b7355;
  font-size: 0.95rem;
  font-weight: 300;
  transform: rotate(-0.2deg);
}

/* Letter content */
.letter-content {
  line-height: 1.8;
  font-size: 1.05rem;
  color: #2d2d2d;
  position: relative;
  z-index: 2;
}

.letter-section {
  margin-bottom: 28px;
  padding: 20px 0;
  position: relative;
}

/* Opening section */
.opening {
  text-align: center;
  border-bottom: 1px solid rgba(139, 115, 85, 0.2);
  padding-bottom: 25px;
  margin-bottom: 35px;
}

.handwritten-text {
  font-family: "Libre Baskerville", serif;
  font-size: 1.25rem;
  color: #2d2d2d;
  font-style: italic;
  transform: rotate(-0.1deg);
}

.small-text {
  font-size: 0.8rem;
  color: #8b7355;
  font-style: normal;
  display: block;
  margin-top: 6px;
  transform: rotate(0.2deg);
}

/* Message blocks with handwritten feel */
.message-block {
  margin-bottom: 25px;
  padding: 20px 0;
  position: relative;
  text-align: justify;
  transform: rotate(0.05deg);
}

.message-block::before {
  content: "";
  position: absolute;
  left: -15px;
  top: 0;
  width: 2px;
  height: 100%;
  background: rgba(139, 115, 85, 0.15);
  opacity: 0.6;
}

.message-block.vulnerable::before {
  background: rgba(139, 115, 85, 0.25);
}

.message-block.understanding::before {
  background: rgba(139, 115, 85, 0.2);
}

.message-block.critical::before {
  background: rgba(139, 115, 85, 0.3);
}

.message-block.memory::before {
  background: rgba(139, 115, 85, 0.18);
}

.message-block.hope::before {
  background: rgba(139, 115, 85, 0.22);
}

.message-block p {
  margin-left: 15px;
  text-indent: 15px;
  transform: rotate(-0.05deg);
}

.highlight {
  color: #8b7355;
  font-weight: 600;
  font-style: italic;
}

/* Section headers */
.letter-section h3 {
  font-family: "Libre Baskerville", serif;
  font-size: 1.3rem;
  color: #8b7355;
  margin-bottom: 20px;
  font-weight: 400;
  transform: rotate(-0.3deg);
}

/* Memory section */
.memory-section {
  background: rgba(139, 115, 85, 0.03);
  border-radius: 3px;
  padding: 25px;
  border: 1px solid rgba(139, 115, 85, 0.15);
  transform: rotate(0.1deg);
}

.memory-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 15px;
  margin-top: 18px;
}

.memory-card {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 4px;
  padding: 18px;
  text-align: center;
  border: 1px solid rgba(139, 115, 85, 0.2);
  transition: all 0.3s ease;
  transform: rotate(-0.2deg);
}

.memory-card:hover {
  background: rgba(139, 115, 85, 0.08);
  border-color: #8b7355;
  transform: rotate(-0.1deg) translateY(-2px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

.memory-text {
  font-size: 0.9rem;
  color: #2d2d2d;
  font-style: italic;
  line-height: 1.4;
}

/* Photo gallery */
.photo-gallery {
  margin-top: 30px;
  padding-top: 25px;
  border-top: 1px solid rgba(139, 115, 85, 0.2);
}

.photo-gallery h4 {
  font-family: "Libre Baskerville", serif;
  font-size: 1.1rem;
  color: #8b7355;
  margin-bottom: 20px;
  text-align: center;
  font-weight: 400;
  transform: rotate(-0.2deg);
}

.photos-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 15px;
}

.photo-frame {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  padding: 15px;
  border: 2px solid rgba(139, 115, 85, 0.2);
  transition: all 0.3s ease;
  transform: rotate(0.1deg);
  text-align: center;
}

.photo-frame:hover {
  transform: rotate(0deg) translateY(-3px);
  border-color: #8b7355;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.memory-photo {
  width: 100%;
  height: 200px;
  object-fit: contain;
  object-position: center;
  border-radius: 4px;
  margin-bottom: 10px;
  transition: transform 0.3s ease;
  background-color: rgba(139, 115, 85, 0.05);
}

.photo-frame:hover .memory-photo {
  transform: scale(1.02);
}

.photo-caption {
  font-size: 0.85rem;
  color: #8b7355;
  font-style: italic;
  line-height: 1.3;
  transform: rotate(-0.1deg);
}

/* Closing */
.closing {
  text-align: center;
  border-top: 1px solid rgba(139, 115, 85, 0.2);
  padding-top: 25px;
  margin-top: 35px;
  transform: rotate(-0.1deg);
}

.closing-text {
  font-family: "Libre Baskerville", serif;
  font-size: 1.15rem;
  color: #2d2d2d;
  margin-bottom: 18px;
  font-style: italic;
}

.signature {
  font-size: 1.3rem;
  font-weight: 600;
  color: #8b7355;
  font-family: "Libre Baskerville", serif;
  transform: rotate(0.8deg);
  animation: signatureFlicker 3s ease-in-out infinite;
}

@keyframes signatureFlicker {
  0% {
    opacity: 1;
  }
  20% {
    opacity: 0.1;
  }
  40% {
    opacity: 1;
  }
  60% {
    opacity: 0.1;
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}

.postscript {
  font-size: 0.9rem;
  color: #8b7355;
  font-style: italic;
  margin-top: 20px;
  transform: rotate(0.3deg);
}

/* Typography improvements */
strong {
  color: #8b7355;
  font-weight: 600;
}

em {
  color: #8b7355;
  font-style: italic;
}

/* Responsive design */
@media (max-width: 768px) {
  .container {
    margin: 15px 10px;
    padding: 35px 25px;
    transform: rotate(-0.2deg);
  }

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

  .memory-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .letter-content {
    font-size: 1rem;
  }

  .photos-container {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .memory-photo {
    height: 250px;
  }

  .photo-frame {
    padding: 12px;
  }
}

@media (max-width: 480px) {
  .main-title {
    font-size: 1.6rem;
  }

  .memory-cards {
    grid-template-columns: 1fr;
  }

  .letter-section {
    padding: 15px 0;
  }

  .message-block {
    padding: 15px 0;
  }

  .message-block p {
    margin-left: 12px;
    text-indent: 12px;
  }

  .photos-container {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .memory-photo {
    height: 280px;
  }

  .photo-frame {
    padding: 10px;
  }

  .photo-gallery {
    margin-top: 25px;
    padding-top: 20px;
  }
}

/* Print styles */
@media print {
  body {
    background: white;
  }

  .container {
    box-shadow: none;
    margin: 0;
    padding: 20px;
    transform: none;
  }

  .memory-card:hover {
    transform: none;
    box-shadow: none;
  }
}
