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

:root {
  --paper: #fffaf1;
  --paper-dark: #efe1cf;
  --rose: #b66d78;
  --rose-dark: #7b404b;
  --wine: #4d3036;
  --ink: #4a383b;
  --cream: #f5eadf;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Cormorant Garamond", Georgia, serif;
  background: #2a2023;
}

.background {
  position: fixed;
  inset: -20px;
  z-index: -3;
  background:
    linear-gradient(rgba(45, 33, 36, 0.44), rgba(35, 26, 28, 0.72)),
    url("images/pes4.jpeg") center / cover no-repeat;
  filter: brightness(0.54) saturate(0.72);
  transform: scale(1.05);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: radial-gradient(circle at 50% 15%, rgba(255, 243, 227, 0.15), transparent 45%);
}

.page {
  position: relative;
  z-index: 2;
  width: min(1080px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 20px 100px;
}

.back-button {
  display: inline-block;
  padding: 10px 20px;
  border: 1px solid rgba(255, 250, 244, 0.46);
  border-radius: 999px;
  color: #fffaf4;
  background: rgba(73, 52, 57, 0.52);
  text-decoration: none;
  backdrop-filter: blur(10px);
}

.intro {
  margin-top: 34px;
  text-align: center;
}

.intro p {
  color: #ead7d0;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.intro h1 {
  margin: 6px 0 8px;
  color: #fff6ec;
  font-family: "Great Vibes", cursive;
  font-size: clamp(68px, 10vw, 128px);
  font-weight: 400;
  line-height: 1;
}

.intro span {
  color: rgba(255, 250, 244, 0.82);
  font-size: 20px;
}

.envelope-area {
  display: flex;
  justify-content: center;
  min-height: 760px;
}

.envelope-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 230px;
}

.envelope {
  position: relative;
  width: 480px;
  height: 305px;
  perspective: 1400px;
  filter: drop-shadow(0 24px 34px rgba(30, 18, 21, 0.36));
}

.envelope-back {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 14px;
  background: linear-gradient(145deg, #d8b8a9, #b98b83);
}

.letter {
  position: absolute;
  left: 30px;
  bottom: 24px;
  z-index: 2;
  width: calc(100% - 60px);
  height: 560px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 18px 45px rgba(45, 29, 33, 0.24);
  transform: translateY(520px) scale(0.82);
  transform-origin: bottom center;
  opacity: 0;
  transition:
    transform 1.25s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.2s ease 0.65s;
}

.letter-paper {
  position: relative;
  height: 100%;
  overflow-y: auto;
  padding: 34px 30px 40px 58px;
  color: var(--ink);
  background:
    linear-gradient(
      to right,
      transparent 0,
      transparent 43px,
      rgba(171, 78, 91, 0.26) 44px,
      rgba(171, 78, 91, 0.26) 46px,
      transparent 47px
    ),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 31px,
      rgba(90, 113, 139, 0.19) 32px,
      rgba(90, 113, 139, 0.19) 33px
    ),
    linear-gradient(135deg, #fffaf1, #f1e4d3);
}

.letter-photo {
  display: block;
  width: 100%;
  height: 210px;
  margin-bottom: 26px;
  object-fit: cover;
  border: 8px solid #fffdf7;
  box-shadow: 0 10px 24px rgba(61, 37, 43, 0.18);
  transform: rotate(-0.8deg);
}

.letter-paper h2,
.letter-paper p {
  font-family: "Caveat", cursive;
}

.letter-paper h2 {
  margin-bottom: 18px;
  text-align: center;
  color: var(--rose-dark);
  font-size: 38px;
}

.letter-paper p {
  margin-bottom: 12px;
  font-size: 24px;
  line-height: 33px;
}

.signature {
  margin-top: 24px;
  text-align: right;
  color: var(--rose-dark);
  font-size: 32px !important;
  font-weight: 700;
}

.envelope-front {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  border-radius: 14px;
}

.envelope-front::before,
.envelope-front::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 72%;
  height: 100%;
}

.envelope-front::before {
  left: 0;
  background: linear-gradient(145deg, #d7b0a6, #b9837c);
  clip-path: polygon(0 0, 100% 55%, 100% 100%, 0 100%);
}

.envelope-front::after {
  right: 0;
  background: linear-gradient(215deg, #cf9f98, #ac756f);
  clip-path: polygon(100% 0, 0 55%, 0 100%, 100% 100%);
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  width: 100%;
  height: 195px;
  background: linear-gradient(180deg, #e2c4b7, #bc8c84);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.9s ease, z-index 0s linear 0.45s;
}

.heart-seal {
  position: absolute;
  top: 120px;
  left: 50%;
  z-index: 7;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 2px solid rgba(255, 238, 224, 0.7);
  border-radius: 50%;
  color: #f8e9dc;
  background: #7b404b;
  font-size: 30px;
  cursor: pointer;
  transform: translateX(-50%);
  box-shadow: 0 10px 24px rgba(77, 48, 54, 0.28);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.open-button {
  margin-top: 42px;
  padding: 15px 32px;
  border: 1px solid rgba(255, 250, 244, 0.52);
  border-radius: 999px;
  color: #fffaf4;
  background: rgba(123, 64, 75, 0.92);
  font-family: inherit;
  font-size: 21px;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(54, 32, 37, 0.24);
}

.envelope-wrapper.open .envelope-flap {
  z-index: 0;
  transform: rotateX(180deg);
}

.envelope-wrapper.open .heart-seal {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) scale(0);
}

.envelope-wrapper.open .letter {
  z-index: 8;
  opacity: 1;
  transform: translateY(-255px) scale(1);
}

/* Květinová stěna zůstává plná, ale bez neonového podbarvení. */
.flower-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  background: #efe4d7;
}

.flower-overlay.active {
  visibility: visible;
  opacity: 1;
}

.flower-overlay.fade-out {
  opacity: 0;
  transition: opacity 0.7s ease;
}

#flowerCanvas {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: 100vw;
  height: 220vh;
  transform: translate3d(0, -110vh, 0);
  will-change: transform;
}

.flower-overlay.active #flowerCanvas {
  animation: flowerWallFall 5s linear forwards;
}

@keyframes flowerWallFall {
  from { transform: translate3d(0, -110vh, 0); }
  to { transform: translate3d(0, 0, 0); }
}

@media (max-width: 600px) {
  .page {
    padding: 20px 12px 80px;
  }

  .envelope-wrapper {
    padding-top: 205px;
  }

  .envelope {
    width: 320px;
    height: 210px;
  }

  .envelope-flap {
    height: 135px;
  }

  .heart-seal {
    top: 80px;
    width: 50px;
    height: 50px;
    font-size: 23px;
  }

  .letter {
    left: 18px;
    bottom: 15px;
    width: calc(100% - 36px);
    height: 460px;
    transform: translateY(430px) scale(0.82);
  }

  .envelope-wrapper.open .letter {
    transform: translateY(-205px) scale(1);
  }

  .letter-paper {
    padding: 24px 18px 30px 46px;
  }

  .letter-photo {
    height: 155px;
  }

  .letter-paper h2 {
    font-size: 31px;
  }

  .letter-paper p {
    font-size: 20px;
    line-height: 30px;
  }
}
