/* 🔹 Biar halaman utama gak ada scrollbar */
html,
body {
  height: 100%;
  overflow: hidden;
  /* tidak bisa scroll atas/bawah/kiri/kanan */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Poppins', sans-serif;
  background: #f3f4f6;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 16px;
}

.wrapper {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

h1 {
  text-align: center;
  margin-bottom: 20px;
}

/* Badge Notification */
.new-message-badge {
  position: fixed;
  top: 20px;
  right: 20px;
  background: linear-gradient(135deg, #ff4444, #cc0000);
  color: white;
  padding: 12px 20px;
  border-radius: 50px;
  box-shadow: 0 4px 12px rgba(255, 68, 68, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  z-index: 1000;
  font-weight: 600;
  transition: all 0.3s ease;
  animation: badgePulse 2s infinite;
}

.new-message-badge:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(255, 68, 68, 0.6);
}

.badge-icon {
  font-size: 20px;
  animation: badgeShake 0.5s ease infinite;
}

.badge-text {
  font-size: 14px;
}

@keyframes badgePulse {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(255, 68, 68, 0.4);
  }
  50% {
    box-shadow: 0 4px 20px rgba(255, 68, 68, 0.8);
  }
}

@keyframes badgeShake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

.message-grid {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* amplop (ukuran sesuai yang kamu mau) */
.envelope-decoration {
  position: absolute;
  top: 0;
  left: 0;
  width: 110px;
  display: block;
}

.envelope-icon {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 180px;
  display: block;
}

.envelope-card {
  position: relative;
  width: 700px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Container untuk nomor + refresh button */
.card-top-controls {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

/* Nomor urut lingkaran */
.card-number {
  width: 40px;
  height: 40px;
  background: #5a4321;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
}

/* Refresh Button */
.refresh-btn {
  background: #5a4321;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 6px rgba(90, 67, 33, 0.3);
}

.refresh-btn:hover {
  background: #3d2d17;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(90, 67, 33, 0.4);
}

.refresh-btn:active {
  transform: translateY(0);
}

.refresh-icon {
  font-size: 16px;
  display: inline-block;
}

.refresh-btn:hover .refresh-icon {
  animation: spin 0.6s ease-in-out;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Envelope wrapper */
.card-content {
  position: relative;
  height: 400px;
  width: 100%;
  cursor: pointer;
  perspective: 800px;
}

.envelope {
  position: absolute;
  inset: 0;
  background: #e5e7eb;
  border-radius: 16px;
  overflow: hidden;
  transform-origin: bottom;
  transition: .6s;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 2;
  pointer-events: auto;
}

/* Letter (surat kuning) */
.letter {
  position: absolute;
  inset: 0;
  background: #f8eee0;
  border-radius: 16px;
  padding: 16px;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  transform-origin: top;
  transform: rotateX(90deg);
  opacity: 0;
  transition: .6s;
  z-index: 1;
  pointer-events: none;
}

/* Chrome, Edge, Safari */
.letter::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* Envelope terbuka */
.envelope-card.open .card-content .envelope {
  transform: rotateX(-90deg);
  opacity: 0;
}

.envelope-card.open .card-content .letter {
  transform: rotateX(0deg);
  opacity: 1;
  pointer-events: auto;
}

.hint {
  margin-top: 10px;
  text-align: center;
  font-size: 12px;
  color: #444;
}

.center-text {
  text-align: center;
  font-weight: 600;
}

/* tombol navigasi kiri kanan */
.nav-btn {
  background: #374151;
  border: none;
  color: white;
  padding: 16px 20px;
  border-radius: 8px;
  font-size: 22px;
  cursor: pointer;
  transition: .3s;
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
}

.nav-btn:hover {
  background: #111827;
}

.nav-btn.left {
  left: 12%;
}

.nav-btn.right {
  right: 12%;
}

/* Mobile: Pindahkan tombol lebih ke samping dan pastikan centered */
@media (max-width: 768px) {
  html, body {
    height: 100vh;
    overflow: hidden;
  }
  
  body {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .wrapper {
    margin: 0;
    position: relative;
  }
  
  .envelope-card {
    width: 100%;
    max-width: 380px;
    height: 380px;
  }
  
  .message-grid {
    min-height: 380px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Tombol di mobile - center ke viewport */
  .nav-btn {
    padding: 10px 14px;
    font-size: 16px;
    position: fixed !important;
    top: 50vh !important; /* Center ke viewport height */
    transform: translateY(-50%) !important;
    z-index: 200;
  }
  
  .nav-btn.left {
    left: 8px !important;
  }
  
  .nav-btn.right {
    right: 8px !important;
  }
  
  /* Badge di mobile */
  .new-message-badge {
    top: 10px;
    right: 10px;
    padding: 10px 16px;
    font-size: 13px;
  }
}

/* Nomor urut lingkaran di surat - ATAS CENTER */
.card-number {
  width: 36px;
  height: 36px;
  background: #5a4321;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

/* Tombol Open The Picture */
.open-image-btn {
  margin: 20px auto 0;
  background: #5a4321;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: .3s;
  display: block;
  text-align: center;
  width: fit-content;
}

.open-image-btn:hover {
  background: #3d2d17;
  transform: translateY(-2px);
}

/* Modal untuk gambar */
.image-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  justify-content: center;
  align-items: center;
}

.modal-content {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 8px;
}

.close-modal {
  position: absolute;
  top: 20px;
  right: 40px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  transition: .3s;
}

.close-modal:hover {
  color: #ccc;
}