* {
  box-sizing: border-box;
  font-family: "Segoe UI", system-ui, sans-serif;
}

body {
  margin: 0;
  background-color: #fff5f8;
  color: #333;
  overflow-x: hidden; /* Prevent accidental side scroll */
}

/* ================= HEADER ================= */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: #ffccd5;
  padding: 1rem;
  text-align: center;
}

header h1 {
  margin: 0 0 0.5rem;
  color: #a4002c;
}

nav button {
  background: none;
  border: none;
  margin: 0 10px;
  font-size: 1rem;
  color: #a4002c;
  cursor: pointer;
}

nav button:hover {
  text-decoration: underline;
}

/* ================= LAYOUT ================= */

main {
  max-width: 900px;
  margin: auto;
  padding: 2rem;
}

.section {
  display: none;
  animation: fadeIn 0.4s ease-in-out;
  padding-top: 2rem;
  padding-bottom: 3rem;
}

.section.active {
  display: block;
}

.section h2 {
  margin-top: 0;
  color: #a4002c;
}

.section img {
  width: 100%;
  border-radius: 12px;
  margin-bottom: 1rem;
}

/* ================= COLLAGE ================= */

.collage {
  margin: 4rem auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  max-width: 700px;
  position: relative;
}

.collage-photo {
  width: 180px;
  padding: 8px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  margin: -20px; /* Creates overlap */
}

/* Controlled playful rotation */
.collage-photo:nth-child(odd) {
  transform: rotate(-5deg);
}

.collage-photo:nth-child(even) {
  transform: rotate(5deg);
}

.collage-photo:nth-child(3n) {
  transform: rotate(-8deg);
}

.collage-photo:hover {
  transform: rotate(0deg) scale(1.1);
  z-index: 10;
  box-shadow: 0 15px 35px rgba(0,0,0,0.35);
}

/* Mobile adjustment */
@media (max-width: 767px) {

  .collage {
    max-width: 100%;
  }

  .collage-photo {
    width: 42vw;
    margin: -12px;
  }
}

.collage-photo:hover {
  transform: rotate(0deg) scale(1.08);
  z-index: 10;
  box-shadow: 0 15px 35px rgba(0,0,0,0.35);
}

.envelope-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 4rem;
  perspective: 1000px;
}

.envelope {
  position: relative;
  width: 420px;
  max-width: 95%;
  height: 160px;
  background: #f8d7da;
  border-radius: 8px;
  cursor: pointer;
  transition: height 0.8s ease;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.envelope.open {
  height: 650px;
}

.flap {
  position: absolute;
  top: 0;
  width: 100%;
  height: 120px;
  background: #ffccd5;
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  transform-origin: top;
  transition: transform 0.6s ease;
  z-index: 2;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.envelope.open .flap {
  transform: rotateX(180deg);
}

.letter-content {
  position: absolute;
  top: 120px;
  left: 0;
  width: 100%;
  padding: 1.5rem;
  background: white;
  border-radius: 6px;
  font-size: 1rem;
  line-height: 1.6;
  opacity: 0;
  transition: opacity 0.6s ease 0.3s;
}

.envelope.open .letter-content {
  opacity: 1;
}

.signature {
  margin-top: 2rem;
  text-align: right;
  font-style: italic;
}

.popup-photo {
  width: 100%;
  margin-top: 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.popup-photo:hover {
  transform: scale(1.05);
}

/* ================= LIGHTBOX ================= */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 9999;
}

.lightbox img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 12px;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.lightbox.active {
  opacity: 1;
  pointer-events: auto;
}

.lightbox.active img {
  transform: scale(1);
}

/* ================= ANIMATIONS ================= */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
