/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: #333;
  font-family: "Playfair Display", serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

.container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
}

/* Page Styles */
.page {
  background-color: #fdfaf7;
  border: 1px solid #e0d8d0;
  overflow: hidden;
  box-shadow: inset -3px 0 10px rgba(0, 0, 0, 0.1);
}

.page.cover-front,
.page.cover-back {
  background-color: #8e44ad;
  color: white;
  border: 2px solid #6c3483;
}

.content-wrapper {
  padding: 15px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start; /* Items stack from top */
  align-items: center;
  text-align: center;
}

/* Typography */
h1 {
  font-size: 2.2rem;
  margin-bottom: 5px;
}
h2 {
  font-size: 1.8rem;
  font-weight: 400;
  font-style: italic;
}
h3 {
  font-size: 1.4rem;
  margin-bottom: 15px;
}
h4 {
  font-family: "Caveat", cursive;
  font-size: 1.6rem;
  color: #555;
  margin-bottom: 5px;
  flex-shrink: 0;
}

p {
  font-family: "Caveat", cursive;
  font-size: 1.2rem;
  line-height: 1.3;
  color: #333;
}

.subtitle {
  font-family: "Playfair Display", serif;
  font-size: 0.8rem;
  margin-top: 20px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
}

.decoration {
  font-size: 2rem;
  color: #e74c3c;
  margin-top: 20px;
}

/* Scrollable Message Area */
.message-scroll {
  width: 100%;
  margin-bottom: 10px;
  max-height: 30%; /* Limits text so photos fit */
  overflow-y: auto;
  flex-shrink: 0; /* Prevents text from being crushed to 0 height */
  padding-right: 5px;
}

/* Button Styling */
.add-btn {
  font-family: "Caveat", cursive;
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: #e74c3c;
  color: white;
  font-size: 18px;
  text-decoration: none;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  padding: 10px 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
}

.add-btn:hover {
  transform: scale(1.05);
  background-color: #c0392b;
}

/* --- CLUSTERED SCRAPBOOK SYSTEM --- */
.photo-grid {
  position: relative;
  width: 100%;
  /* CHANGED: Flexible height instead of fixed 320px */
  flex-grow: 1;
  min-height: 200px; /* Ensure at least some space for photos */
  margin-top: 10px;
  overflow: visible;
}

.photo-grid img {
  position: absolute;
  width: 45%;
  height: auto;
  max-width: 180px;
  background-color: white;
  padding: 5px;
  padding-bottom: 12px;
  box-shadow: 2px 4px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.photo-grid img:hover {
  z-index: 100 !important;
  transform: translate(-50%, -50%) scale(1.2) rotate(0deg) !important;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  z-index: 9999;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  justify-content: center;
  align-items: center;
}
.lightbox img {
  max-width: 95%;
  max-height: 80%;
  border: 2px solid white;
}
.lightbox-close {
  position: absolute;
  top: 15px;
  right: 20px;
  color: white;
  font-size: 35px;
  cursor: pointer;
}
/* --- NAVIGATION ARROWS (Mobile Optimization) --- */
.nav-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(255, 255, 255, 0.8);
  color: #8e44ad; /* Matches your cover color */
  border: 2px solid #8e44ad;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 15px;
  cursor: pointer;
  z-index: 900; /* Below lightbox (9999) but above book */
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;

  /* Hide by default on desktop, show on mobile via media query below */
  opacity: 0;
  pointer-events: none;
}

.nav-arrow:active {
  background-color: #8e44ad;
  color: white;
  transform: translateY(-50%) scale(0.95);
}

.left-arrow {
  left: 15px;
}

.right-arrow {
  right: 15px;
}

/* Animation to suggest interactivity */
@keyframes pulse-arrow {
  0% {
    transform: translateY(-50%) scale(1);
  }
  50% {
    transform: translateY(-50%) scale(1.1);
  }
  100% {
    transform: translateY(-50%) scale(1);
  }
}

/* Only show and animate arrows on screens smaller than 800px */
@media (max-width: 800px) {
  .nav-arrow {
    opacity: 1;
    pointer-events: auto;
    animation: pulse-arrow 2s infinite;
  }
}
/* --- MOBILE OPTIMIZATION (Below 600px) --- */
@media (max-width: 600px) {
  /* Shrink text */
  h1 {
    font-size: 1.6rem;
  }
  h2 {
    font-size: 1.3rem;
  }
  h3 {
    font-size: 1.2rem;
  }
  h4 {
    font-size: 1.3rem;
  }
  p {
    font-size: 1rem;
  }

  .content-wrapper {
    padding: 10px;
  }

  /* Shrink photos */
  .photo-grid img {
    max-width: 120px;
    padding: 3px 3px 8px 3px;
  }

  /* Adjust message scroll to give more room to photos */
  .message-scroll {
    max-height: 25%;
  }

  /* Make button smaller */
  .add-btn {
    font-size: 14px;
    padding: 8px 15px;
  }
}

/* Ultra Small Screen Tweak (iPhone SE, Foldable cover screens) */
@media (max-width: 360px) {
  h1 {
    font-size: 1.4rem;
  }
  .photo-grid img {
    max-width: 90px;
  }
}
