* {
  box-sizing: border-box;
}

:root {
  --cream: #f8f9ff;
  --paper: #fcfcff;
  --ink: #2f3050;
  --muted: #7a7c9c;
  --rose: #7d8fe0;          /* main periwinkle accent */
  --rose-dark: #5a6bc4;     /* deeper periwinkle */
  --rose-light: #dde2fa;
  --line: rgba(70, 80, 140, 0.14);
  --shadow: 0 22px 60px rgba(60, 70, 140, 0.13);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 15%, rgba(214, 221, 250, .8), transparent 28rem),
    radial-gradient(circle at 90% 75%, rgba(228, 218, 250, .75), transparent 28rem),
    var(--cream);
  font-family: "DM Sans", sans-serif;
  overflow-x: hidden;
}

body.modal-open {
  overflow: hidden;
}

button {
  font: inherit;
}

.ambient {
  position: fixed;
  width: 18rem;
  height: 18rem;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .25;
  pointer-events: none;
}

.ambient-1 {
  background: #a9b6f2;
  top: -7rem;
  right: -5rem;
}

.ambient-2 {
  background: #c9b8f0;
  bottom: -8rem;
  left: -6rem;
}

.site-shell {
  width: min(1100px, calc(100% - 40px));
  margin: 0 auto;
  position: relative;
}

.hero {
  min-height: 76vh;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  padding: 80px 0 50px;
}

.tiny-heart {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255,255,255,.5);
  color: var(--rose);
  font-family: Georgia, serif;
  font-size: 27px;
  margin-bottom: 26px;
  box-shadow: 0 10px 35px rgba(60, 70, 140, .07);
}

.eyebrow,
.modal-eyebrow,
.section-heading p {
  text-transform: uppercase;
  letter-spacing: .2em;
  font-size: 11px;
  font-weight: 600;
  color: var(--rose-dark);
}

.hero h1 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(4rem, 10vw, 7.6rem);
  font-weight: 600;
  line-height: .78;
  letter-spacing: -.045em;
}

.hero h1 em {
  color: var(--rose-dark);
  font-weight: 500;
}

.intro {
  max-width: 570px;
  margin: 36px auto 0;
  color: var(--muted);
  line-height: 1.8;
  font-size: 15px;
}

.scroll-hint {
  margin-top: 48px;
  color: #9a9cb8;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .13em;
}

.scroll-hint span {
  display: block;
  margin-top: 9px;
  font-size: 17px;
  animation: bob 1.8s ease-in-out infinite;
}

@keyframes bob {
  50% { transform: translateY(5px); }
}

.letters-section {
  padding: 35px 0 100px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 38px;
}

.section-heading span {
  height: 1px;
  flex: 1;
  background: var(--line);
}

.section-heading p {
  margin: 0;
  white-space: nowrap;
  color: #9092b5;
}

.envelope-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.envelope {
  --tilt: 0deg;
  position: relative;
  min-height: 240px;
  padding: 25px;
  border: 0;
  border-radius: 22px;
  background: transparent;
  cursor: pointer;
  perspective: 900px;
  transform: rotate(var(--tilt));
  transition: transform .3s ease;
}

.envelope:hover {
  transform: translateY(-8px) rotate(0deg);
}

.envelope:focus-visible {
  outline: 3px solid rgba(125, 143, 224, .4);
  outline-offset: 5px;
}

.envelope-paper {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(70, 80, 140, .12);
  border-radius: 20px;
  background: linear-gradient(145deg, #fdfdff, #eef0fd);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.envelope-paper::before {
  content: "";
  position: absolute;
  width: 160px;
  height: 160px;
  right: -80px;
  top: -80px;
  border-radius: 50%;
  background: rgba(214, 221, 250, .55);
}

.envelope-paper::after {
  content: "";
  position: absolute;
  left: -65px;
  bottom: -65px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(228, 218, 250, .45);
}

.envelope-flap {
  position: absolute;
  inset: 0 0 auto 0;
  height: 58%;
  background: #e3e7fb;
  clip-path: polygon(0 0, 100% 0, 50% 72%);
  transform-origin: top;
  transition: transform .35s ease;
  z-index: 2;
}

.envelope:hover .envelope-flap {
  transform: rotateX(12deg);
}

.envelope-content {
  position: relative;
  z-index: 3;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  padding: 15px 10px 5px;
}

.envelope-icon {
  position: absolute;
  top: 43px;
  font-family: Georgia, serif;
  font-size: 34px;
  color: var(--rose-dark);
}

.envelope-content h3 {
  margin: 0;
  max-width: 230px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 28px;
  line-height: 1;
  font-weight: 600;
}

.envelope-content p {
  margin: 10px 0 0;
  color: #9b9dba;
  font-size: 12px;
  line-height: 1.5;
}

footer {
  padding: 0 0 55px;
  text-align: center;
  color: #a3a5c4;
  font-size: 12px;
}

footer span {
  display: block;
  color: var(--rose);
  font-family: Georgia, serif;
  font-size: 22px;
  margin-top: 8px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  visibility: hidden;
  opacity: 0;
  transition: opacity .25s ease, visibility .25s ease;
}

.modal.is-open {
  visibility: visible;
  opacity: 1;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 32, 66, .48);
  backdrop-filter: blur(9px);
}

.letter-modal {
  position: relative;
  width: min(680px, 100%);
  max-height: min(760px, 90vh);
  overflow-y: auto;
  padding: 58px clamp(28px, 7vw, 72px) 44px;
  border-radius: 25px;
  background:
    linear-gradient(rgba(255,255,255,.84), rgba(255,255,255,.84)),
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 31px,
      rgba(90, 96, 150, .05) 32px
    ),
    var(--paper);
  box-shadow: 0 35px 100px rgba(25, 27, 60, .28);
  transform: translateY(25px) scale(.97);
  transition: transform .35s cubic-bezier(.2,.8,.2,1);
}

.modal.is-open .letter-modal {
  transform: translateY(0) scale(1);
}

.close-button {
  position: absolute;
  top: 17px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(125, 143, 224, .1);
  color: var(--rose-dark);
  cursor: pointer;
  font-size: 27px;
  line-height: 1;
  transition: .2s ease;
}

.close-button:hover {
  background: rgba(125, 143, 224, .2);
  transform: rotate(5deg);
}

.modal-decoration {
  color: var(--rose);
  font-family: Georgia, serif;
  font-size: 38px;
  margin-bottom: 8px;
}

.modal-eyebrow {
  margin: 0 0 9px;
}

.letter-modal h2 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(40px, 7vw, 58px);
  line-height: .95;
  font-weight: 600;
}

.modal-message {
  margin-top: 30px;
  color: #4b4d6e;
  font-size: 15px;
  line-height: 1.95;
}

.modal-message p {
  margin: 0 0 17px;
}

.letter-signoff {
  margin-top: 35px;
  padding-top: 23px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 20px;
  color: #8a8db5;
}

.letter-signoff strong {
  font-size: 27px;
  color: var(--rose-dark);
}

.next-button {
  display: block;
  margin: 34px auto 0;
  padding: 12px 19px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.7);
  color: var(--rose-dark);
  cursor: pointer;
  font-size: 12px;
  letter-spacing: .06em;
  transition: .2s ease;
}

.next-button:hover {
  background: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(60, 70, 140, .1);
}

.next-button span {
  margin-left: 8px;
}

@media (max-width: 780px) {
  .site-shell {
    width: min(100% - 28px, 600px);
  }

  .hero {
    min-height: 70vh;
    padding-top: 55px;
  }

  .hero h1 {
    font-size: clamp(3.5rem, 17vw, 6rem);
  }

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

  .envelope {
    min-height: 215px;
    padding: 18px;
  }

  .envelope-content h3 {
    font-size: 25px;
  }
}

@media (max-width: 480px) {
  .envelope-grid {
    grid-template-columns: 1fr;
  }

  .envelope {
    min-height: 210px;
  }

  .intro {
    font-size: 14px;
  }

  .letter-modal {
    padding: 50px 25px 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition-duration: .01ms !important;
  }
}
