@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;1,400&family=DM+Sans:wght@400;500&family=La+Belle+Aurore&display=swap");

:root {
  --burgundy: #491727;
  --ivory: #f5ead9;
  --blush: #e5b8c4;
  --muted: #cda6b0;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 75% 40%, #85445b44, transparent 55%),
    radial-gradient(ellipse at 15% 90%, #71324733, transparent 50%),
    var(--burgundy);
  color: var(--ivory);
  font-family: "DM Sans", sans-serif;
}

body.letter-visible {
  overflow: hidden;
}

button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 2px solid var(--blush);
  outline-offset: 7px;
}

/* Header */

header {
  position: relative;
  z-index: 3;
  margin: 0 7%;
  padding: 23px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid #f5ead925;
}

.monogram {
  font: italic 32px "Cormorant Garamond", Georgia, serif;
}

.header-note {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 1px;
}

/* Main composition */

main {
  position: relative;
  z-index: 2;
  max-width: 1280px;
  min-height: calc(100svh - 165px);
  margin: auto;
  padding: 90px 9% 140px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: center;
  gap: 65px;
}

.intro,
.envelope-scene {
  position: relative;
}

.eyebrow {
  margin: 0 0 28px;
  color: var(--blush);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 2.5px;
}

h1 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(56px, 6vw, 82px);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -2px;
}

h1 em {
  color: var(--blush);
  font-weight: 400;
}

.description {
  margin: 28px 0;
  color: #dec2ca;
  font-size: 12px;
  line-height: 1.9;
}

.open-button {
  padding: 17px 23px;
  border: 1px solid #fff5e833;
  border-radius: 3px;
  background: var(--ivory);
  color: var(--burgundy);
  font-size: 12px;
  box-shadow: 0 8px 25px #220b1920;
  transition: transform 0.25s, background 0.25s;
}

.open-button span {
  margin-left: 30px;
}

.open-button:hover {
  background: #fff6e9;
  transform: translateY(-3px);
}

.open-button:active {
  transform: scale(0.97);
}

.handwritten {
  margin-top: 23px;
  color: var(--blush);
  font: 21px "La Belle Aurore", cursive;
}

.intro .handwritten {
  transform: rotate(-4deg);
}

/* Ivory envelope */

.envelope-scene {
  text-align: center;
}

.envelope-glow {
  position: absolute;
  inset: -70px -20px;
  border-radius: 50%;
  background: radial-gradient(circle, #dba0b016, transparent 68%);
  pointer-events: none;
}

.envelope {
  position: relative;
  display: block;
  width: 100%;
  max-width: 410px;
  aspect-ratio: 1.48;
  margin: 30px auto 0;
  padding: 0;
  border: none;
  background: transparent;
  perspective: 1200px;
  transform: rotate(-7deg);
  filter: drop-shadow(0 25px 25px #21091470);
  transition: transform 0.45s, filter 0.45s;
}

.envelope:focus-visible {
  outline-offset: 15px;
}

.envelope-back {
  position: absolute;
  inset: 0;
  border-radius: 5px;
  background: #dac9af;
}

.letter-preview {
  position: absolute;
  inset: 8% 8% 5%;
  z-index: 2;
  padding: 25px 20px;
  background: #fff8ed;
  color: #754151;
  text-align: left;
  font: italic 26px "Cormorant Garamond", Georgia, serif;
  transition: transform 0.7s;
}

.letter-preview span {
  display: block;
  margin-top: 15px;
  font-size: 15px;
  line-height: 1.5;
}

.envelope-front {
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: 4px;
  background: linear-gradient(135deg, #f4e7d1, #e4d1b5);
  clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%);
}

.envelope-front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, #efe0c7, #f8edda);
  clip-path: polygon(0 100%, 50% 45%, 100% 100%);
}

.envelope-flap {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: linear-gradient(160deg, #fbefdb, #dfceb3);
  clip-path: polygon(0 0, 100% 0, 50% 58%);
  transform-origin: top;
  transition: transform 0.7s, z-index 0s 0.35s;
}

.envelope-address {
  position: absolute;
  bottom: 22px;
  left: 27px;
  z-index: 4;
  color: #754151;
  text-align: left;
  font: italic 27px "Cormorant Garamond", Georgia, serif;
}

.envelope-address span {
  display: block;
  margin-top: 4px;
  font: 8px "DM Sans", sans-serif;
  letter-spacing: 1.5px;
}

.wax-seal {
  position: absolute;
  top: 45%;
  left: 50%;
  z-index: 5;
  width: 59px;
  height: 59px;
  display: grid;
  place-items: center;
  transform: translateX(-50%);
  border: 4px double #b97583;
  border-radius: 46% 53% 48% 51%;
  background: radial-gradient(circle at 30% 25%, #a75468, #70283e);
  box-shadow: 0 4px 8px #51203255;
  color: #edbec8;
  font: italic 31px "Cormorant Garamond", Georgia, serif;
  transition: opacity 0.25s, box-shadow 0.3s;
}

@media (hover: hover) and (pointer: fine) {
  .envelope:hover {
    transform: rotate(-3deg) translateY(-10px);
    filter: drop-shadow(0 35px 30px #21091488);
  }

  .envelope:hover .wax-seal {
    box-shadow: 0 5px 14px #51203288;
  }
}

.envelope:active {
  transform: rotate(-4deg) translateY(2px) scale(0.97);
}

.envelope.open,
.envelope.open:hover {
  transform: rotate(0deg) translateY(-8px);
}

.envelope.open .envelope-flap {
  transform: rotateX(180deg);
  z-index: 1;
}

.envelope.open .letter-preview {
  transform: translateY(-80px);
  transition-delay: 0.3s;
}

.envelope.open .wax-seal {
  opacity: 0;
}

.envelope-caption {
  margin: 50px 0 0;
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 2px;
}

.tap-hint {
  margin-top: 12px;
  color: var(--blush);
  font: 18px "La Belle Aurore", cursive;
}

/* Your watercolor lilies */

.flowers {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;

  /* Softens the dark background visible in the images. */
  mix-blend-mode: screen;
}

.flower-wrap {
  position: absolute;
  bottom: -55px;
  width: clamp(180px, 24vw, 340px);
}

.flower-wrap.left {
  left: -70px;
  transform: rotate(-12deg);
}

.flower-wrap.right {
  right: -70px;
  transform: scaleX(-1) rotate(-10deg);
}

.flower-image {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0.86;
  transform-origin: 50% 95%;
  animation: flower-sway 8s ease-in-out infinite alternate;

  /* Feather the image edges into the page. */
  -webkit-mask-image:
    radial-gradient(ellipse at center, #000 45%, transparent 73%);
  mask-image:
    radial-gradient(ellipse at center, #000 45%, transparent 73%);
}

.right .flower-image {
  animation-duration: 9s;
  animation-delay: -4s;
}

@keyframes flower-sway {
  from {
    transform: rotate(-2deg);
  }

  to {
    transform: rotate(3deg);
  }
}

/* Falling petals */

.petal-field {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.falling-petal {
  position: absolute;
  top: -40px;
  left: var(--left);
  width: var(--size);
  height: calc(var(--size) * 1.5);
  opacity: 0;
  animation: petal-fall var(--duration) linear infinite;
  animation-delay: var(--delay);
}

.falling-petal span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 85% 15% 75% 25%;
  background: linear-gradient(135deg, #f7d5dc, #d991a7 55%, #b66c87);
  animation: petal-turn var(--turn) ease-in-out infinite;
  animation-delay: var(--delay);
}

@keyframes petal-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, -30px, 0);
  }

  12% {
    opacity: 0.45;
  }

  85% {
    opacity: 0.3;
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--drift), 110vh, 0);
  }
}

@keyframes petal-turn {
  0% {
    transform: rotate(0deg) rotateY(0deg);
  }

  50% {
    transform: rotate(100deg) rotateY(65deg);
  }

  100% {
    transform: rotate(210deg) rotateY(180deg);
  }
}

/* Your personal letter */

#letter-dialog {
  width: min(640px, calc(100% - 28px));
  max-height: 85vh;
  max-height: 85dvh;
  padding: 48px clamp(24px, 6vw, 58px) 35px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: none;
  border-radius: 4px;
  background:
    radial-gradient(ellipse at top, #fffaf0, transparent 75%),
    #f7efe2;
  color: var(--burgundy);
  box-shadow: 0 30px 100px #19091066;
  scrollbar-width: thin;
  scrollbar-color: #c49aa8 #f7efe2;
}

#letter-dialog::backdrop {
  background: #240c1bcc;
  backdrop-filter: blur(7px);
}

#letter-dialog[open] {
  animation: letter-arrives 0.45s ease-out;
}

#close-letter {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--burgundy);
  font-size: 27px;
}

#close-letter:hover {
  background: #501b2c0d;
}

#letter-dialog .eyebrow {
  color: #946575;
  font-size: 8px;
}

#letter-dialog h2 {
  margin: 0 0 25px;
  font: 400 43px "Cormorant Garamond", Georgia, serif;
}

#letter-dialog h2 em {
  font-weight: 400;
}

.letter-message {
  color: #76515e;
  font-size: 15px;
  line-height: 1.95;
  overflow-wrap: break-word;
}

.letter-message > p {
  margin: 0 0 23px;
}

.courtship-question {
  margin: 35px 0;
  padding: 25px 0;
  border-top: 1px solid #d9bac3;
  border-bottom: 1px solid #d9bac3;
  color: var(--burgundy);
  font: italic 400 clamp(32px, 7vw, 42px)/1.15
    "Cormorant Garamond", Georgia, serif;
  text-align: center;
}

.personal-signature {
  margin-top: 35px;
}

.personal-signature p {
  margin: 0 0 8px;
}

.personal-signature .signed-name {
  margin-top: 15px;
  color: #965c72;
  font: 30px "La Belle Aurore", cursive;
}

.letter-heart {
  display: block;
  margin-top: 25px;
  color: #ad7788;
  font-size: 28px;
  text-align: center;
}

@keyframes letter-arrives {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Footer */

footer {
  position: relative;
  z-index: 3;
  margin: 0 7%;
  padding: 23px 0;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid #f5ead925;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.5px;
}

/* Phone layout */

@media (max-width: 700px) {
  header {
    padding: 18px 0;
  }

  .header-note {
    font-size: 9px;
    letter-spacing: 0;
  }

  main {
    grid-template-columns: minmax(0, 1fr);
    gap: 45px;
    padding: 50px 8% 100px;
  }

  .intro {
    text-align: center;
  }

  h1 {
    font-size: clamp(48px, 13vw, 62px);
  }

  .eyebrow {
    font-size: 8px;
    letter-spacing: 2px;
  }

  .description {
    font-size: 11px;
  }

  .envelope {
    width: 90%;
    max-width: 340px;
  }

  .wax-seal {
    width: 49px;
    height: 49px;
    font-size: 26px;
  }

  .envelope-address {
    bottom: 17px;
    left: 20px;
    font-size: 23px;
  }

  .letter-preview {
    padding: 18px;
    font-size: 23px;
  }

  .letter-preview span {
    font-size: 13px;
  }

  .envelope-caption {
    margin-top: 40px;
    font-size: 7px;
  }

  .flower-wrap {
    width: 190px;
    bottom: -40px;
  }

  .flower-wrap.left {
    left: -85px;
  }

  .flower-wrap.right {
    right: -85px;
  }

  .flower-image {
    opacity: 0.7;
  }

  .falling-petal:nth-child(n + 9) {
    display: none;
  }

  #letter-dialog h2 {
    font-size: 38px;
  }

  .letter-message {
    line-height: 1.85;
  }

  footer {
    font-size: 8px;
    line-height: 1.6;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .petal-field {
    display: none;
  }
}
/* Subtle movement instead of a repeating side-to-side sway */

.flower-image {
  transform-origin: 50% 100%;
  animation: lily-breeze 19s ease-in-out infinite;
  will-change: transform;
}

.right .flower-image {
  animation-name: lily-breeze-right;
  animation-duration: 23s;
  animation-delay: -9s;
}

@keyframes lily-breeze {
  0%, 100% {
    transform: rotate(-0.3deg) translateX(0);
  }

  23% {
    transform: rotate(0.45deg) translateX(1px);
  }

  42% {
    transform: rotate(0.1deg) translateX(0.3px);
  }

  71% {
    transform: rotate(-0.5deg) translateX(-0.8px);
  }

  86% {
    transform: rotate(-0.15deg) translateX(-0.2px);
  }
}

@keyframes lily-breeze-right {
  0%, 100% {
    transform: rotate(0.2deg) translateX(0);
  }

  31% {
    transform: rotate(-0.4deg) translateX(-0.7px);
  }

  56% {
    transform: rotate(0.15deg) translateX(0.2px);
  }

  78% {
    transform: rotate(0.5deg) translateX(0.8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .flower-image {
    animation: none !important;
  }
}
@media (max-width: 700px) {
  .falling-petal:nth-child(-n + 18) {
    display: block;
  }

  .falling-petal:nth-child(n + 19) {
    display: none;
  }
}