:root {
  --paper: #faf7f2;
  --ink: #2c2218;
  --muted: #9b7a52;
  --rose: #c0785a;
  --rose-dark: #9b5a3a;
  --cream: #f7efd8;
  --shadow: 0 8px 30px rgba(74, 48, 28, .15);
}

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

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 12%, rgba(192, 120, 90, .07), transparent 25rem),
    radial-gradient(circle at 90% 80%, rgba(155, 122, 82, .06), transparent 28rem),
    var(--paper);
  color: var(--ink);
  font-family: "Lora", Georgia, serif;
}

button {
  font: inherit;
}

.intro {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 2rem;
  text-align: center;
}

.intro-heart {
  color: var(--rose);
  font-size: 30px;
  margin-bottom: 1.25rem;
  animation: heartbeat 1.8s ease-in-out infinite;
}

.intro h1 {
  max-width: 360px;
  color: var(--muted);
  font: italic 500 clamp(24px, 7vw, 30px)/1.5 "Playfair Display", serif;
  margin-bottom: 2rem;
}

.primary-button {
  border: 0;
  border-radius: 999px;
  padding: 16px 36px;
  background: linear-gradient(135deg, var(--rose), var(--rose-dark));
  box-shadow: 0 5px 22px rgba(192, 120, 90, .38);
  color: white;
  cursor: pointer;
  font: italic 500 18px "Playfair Display", serif;
  transition: transform .2s ease, box-shadow .2s ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(192, 120, 90, .46);
}

.primary-button:active {
  transform: scale(.97);
}

.primary-button:focus-visible,
.dot:focus-visible,
.carousel-arrow:focus-visible,
.envelope:focus-visible {
  outline: 3px solid rgba(192, 120, 90, .38);
  outline-offset: 4px;
}

.landing {
  display: none;
  position: relative;
  overflow: hidden;
}

.landing.visible {
  display: block;
  animation: page-in 1s ease both;
}

.flash {
  position: fixed;
  z-index: 50;
  inset: 0;
  pointer-events: none;
  background: white;
  animation: flash .55s ease forwards;
}

.page-shell {
  width: min(100%, 460px);
  margin-inline: auto;
  padding: 40px 24px 60px;
}

.date-block {
  margin-bottom: 32px;
  min-height: 73px;
  text-align: center;
}

.eyebrow {
  color: var(--rose);
  font-size: 9px;
  letter-spacing: .22em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.date-text {
  color: var(--muted);
  font: italic 500 clamp(28px, 8vw, 32px)/1.3 "Playfair Display", serif;
}

.date-text::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: .9em;
  margin-left: 3px;
  background: var(--muted);
  vertical-align: -.05em;
  animation: blink .75s steps(1) infinite;
}

.date-text.done::after {
  display: none;
}

.polaroid-reveal {
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 1.8s ease, transform 1.8s ease;
}

.polaroid-reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.polaroid {
  width: min(320px, 88vw);
  padding: 14px 14px 18px;
  position: relative;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .16), var(--shadow);
  transform: rotate(-1.5deg);
}

.polaroid::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(155, 122, 82, .07);
  pointer-events: none;
}

.carousel {
  width: 100%;
  aspect-ratio: 1 / 1.05;
  overflow: hidden;
  position: relative;
  border-radius: 2px;
  background: #e8e0d4;
  touch-action: pan-y;
}

.carousel-track {
  display: flex;
  height: 100%;
  transition: transform .5s cubic-bezier(.22, 1, .36, 1);
}

.slide {
  flex: 0 0 100%;
  height: 100%;
}

.slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carousel-arrow {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .75);
  color: var(--ink);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity .2s ease, background .2s ease;
  backdrop-filter: blur(5px);
}

.carousel:hover .carousel-arrow,
.carousel:focus-within .carousel-arrow {
  opacity: 1;
}

.carousel-arrow:hover {
  background: white;
}

.previous { left: 9px; }
.next { right: 9px; }

.dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: 9px;
}

.dot {
  width: 7px;
  height: 7px;
  border: 0;
  border-radius: 50%;
  background: rgba(155, 122, 82, .3);
  cursor: pointer;
  transition: transform .2s ease, background .2s ease;
}

.dot.active {
  background: var(--muted);
  transform: scale(1.15);
}

.names {
  margin-top: 8px;
  text-align: center;
  font: 19px "Playfair Display", serif;
}

.names span { color: var(--rose); }

.thread {
  display: block;
  width: 60px;
  margin: 8px auto;
  color: var(--rose);
  opacity: .75;
}

.envelope {
  margin: 0 4px 32px;
  position: relative;
  cursor: pointer;
  transition: transform .2s ease;
}

.envelope:hover:not(.open) { transform: scale(1.012); }

.envelope-body {
  min-height: 190px;
  max-height: 190px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1px solid rgba(160, 120, 70, .35);
  border-radius: 4px 4px 14px 14px;
  background: linear-gradient(160deg, var(--cream) 0%, #ecdcc0 60%, #e4d0b0 100%);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .14);
  transition: max-height 1.8s ease .2s;
}

.envelope-body::before {
  content: "";
  height: 0;
  position: absolute;
  bottom: 0;
  left: -10px;
  right: -10px;
  border-right: 55vw solid transparent;
  border-bottom: 95px solid rgba(200, 175, 125, .35);
  border-left: 55vw solid transparent;
  pointer-events: none;
}

.envelope-body::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, transparent 49.5%, rgba(180, 145, 90, .12) 49.5%, rgba(180, 145, 90, .12) 50.5%, transparent 50.5%),
    linear-gradient(45deg, transparent 49.5%, rgba(180, 145, 90, .12) 49.5%, rgba(180, 145, 90, .12) 50.5%, transparent 50.5%);
  pointer-events: none;
}

.envelope.open .envelope-body { max-height: 3000px; }

.seal-wrap {
  z-index: 5;
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translate(-50%, -50%);
  transition: opacity .4s ease .2s, transform .4s ease .2s;
}

.seal-wrap p {
  color: var(--muted);
  font: italic 16px "Playfair Display", serif;
  white-space: nowrap;
}

.seal {
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  border-radius: 48% 52% 46% 54% / 52% 45% 55% 48%;
  background:
    radial-gradient(circle at 32% 25%, rgba(255, 210, 190, .35), transparent 36%),
    radial-gradient(circle at 38% 35%, #b02020, #7d1111 54%, #4a0808 100%);
  box-shadow: inset 0 0 0 3px rgba(255, 210, 190, .12), 0 5px 12px rgba(74, 8, 8, .5);
  color: rgba(255, 225, 210, .95);
  transform: rotate(-2deg);
}

.envelope:not(.open) .seal {
  animation: seal-pulse 1.35s ease-in-out infinite;
}

.seal::before {
  content: "";
  width: 64px;
  height: 64px;
  position: absolute;
  border: 1px solid rgba(255, 210, 190, .2);
  border-radius: 50%;
}

.seal span {
  z-index: 1;
  font: italic 10px Georgia, serif;
  letter-spacing: .03em;
  text-decoration: underline;
}

.envelope.open .seal-wrap {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(.75);
}

.letter {
  width: 100%;
  max-height: 0;
  overflow: hidden;
  padding: 30px 24px 26px;
  z-index: 2;
  position: relative;
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px);
  transition: opacity 1s ease 1.8s, transform 1s ease 1.8s;
}

.envelope.open .letter {
  max-height: 5000px;
  overflow: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.letter-copy {
  color: #3d2e1e;
  font-size: 15px;
  font-style: italic;
  line-height: 1.85;
}

.letter-copy p + p {
  margin-top: 18px;
}

.letter-copy strong {
  color: #6b1f20;
  font-weight: 600;
}

.question {
  padding: 28px 0 8px;
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .8s ease 2.8s, transform .8s ease 2.8s;
}

.envelope.open .question {
  opacity: 1;
  transform: translateY(0);
}

.question p {
  margin-bottom: 24px;
  color: var(--rose);
  font: italic 500 22px/1.4 "Playfair Display", serif;
}

.counter-card {
  display: none;
  margin: 0 4px 32px;
  padding: 32px 24px;
  border: 1px solid rgba(155, 122, 82, .08);
  border-radius: 20px;
  background: rgba(255, 252, 248, .88);
  box-shadow: 0 2px 16px rgba(0, 0, 0, .06);
  text-align: center;
}

.counter-card.visible {
  display: block;
  animation: reveal .9s ease both;
}

.counter-title,
.counter-subtitle {
  color: var(--muted);
  font: italic 18px "Playfair Display", serif;
}

.counter-subtitle { margin-top: 15px; }

.counter-grid {
  display: flex;
  justify-content: center;
  gap: clamp(20px, 8vw, 32px);
  margin-top: 17px;
}

.counter-grid div {
  min-width: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.counter-grid strong {
  color: var(--ink);
  font: 600 35px/1 "Playfair Display", serif;
}

.counter-grid span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.final-photo {
  display: none;
  margin: 0 4px 12px;
  overflow: hidden;
  border-radius: 4px;
  box-shadow: 0 6px 32px rgba(0, 0, 0, .12);
}

.final-photo.visible {
  display: block;
  animation: rise-in 1s ease both;
}

.final-photo img {
  width: 100%;
  max-height: 520px;
  display: block;
  object-fit: cover;
}

.final-message {
  display: none;
  margin-top: 20px;
  color: var(--muted);
  text-align: center;
  font: italic 20px/1.5 "Playfair Display", serif;
}

.final-message.visible {
  display: block;
  animation: rise-in 1.2s .2s ease both;
}

footer {
  margin-top: 40px;
  color: #6a5235;
  font-size: 10px;
  letter-spacing: .3em;
  opacity: .35;
  text-align: center;
  text-transform: uppercase;
}

.effects {
  position: fixed;
  z-index: 999;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

[hidden] {
  display: none !important;
}

.music-toggle {
  width: 48px;
  height: 48px;
  position: fixed;
  z-index: 1000;
  right: 18px;
  bottom: 18px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(155, 90, 58, .22);
  border-radius: 50%;
  background: rgba(255, 252, 248, .9);
  box-shadow: 0 5px 20px rgba(74, 48, 28, .18);
  color: var(--rose-dark);
  cursor: pointer;
  font-size: 21px;
  backdrop-filter: blur(8px);
  transition: transform .2s ease, background .2s ease;
}

.music-toggle:hover {
  background: #fff;
  transform: translateY(-2px);
}

.falling-heart {
  position: absolute;
  top: -40px;
  opacity: 0;
  animation: heart-fall linear forwards;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.17); }
  28% { transform: scale(1); }
  42% { transform: scale(1.12); }
}

@keyframes seal-pulse {
  0%, 100% {
    transform: rotate(-2deg) scale(1);
    box-shadow: inset 0 0 0 3px rgba(255, 210, 190, .12), 0 5px 12px rgba(74, 8, 8, .5);
  }
  50% {
    transform: rotate(-2deg) scale(1.09);
    box-shadow: inset 0 0 0 3px rgba(255, 210, 190, .16), 0 7px 22px rgba(122, 17, 17, .62), 0 0 0 7px rgba(176, 32, 32, .08);
  }
}

@keyframes blink {
  50% { opacity: 0; }
}

@keyframes flash {
  from { opacity: .92; }
  to { opacity: 0; }
}

@keyframes page-in {
  from { opacity: 0; transform: scale(.98); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes reveal {
  from { opacity: 0; transform: scale(.93); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes heart-fall {
  0% { opacity: 0; transform: translateY(0) rotate(0deg) scale(.5); }
  10%, 80% { opacity: .95; }
  100% { opacity: 0; transform: translateY(110vh) rotate(var(--rotation)) scale(var(--scale)); }
}

@media (max-width: 520px) {
  .page-shell { padding-inline: 20px; }
  .carousel-arrow { opacity: .86; }
}

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