:root {
  --cream: #fdf6ee;
  --paper: #fffaf3;
  --rose-100: #fbe3e4;
  --rose-300: #f0a8b0;
  --rose-500: #d9637a;
  --rose-700: #a83b55;
  --wine: #6e2238;
  --ink: #3d2a30;
  --ink-soft: #7a6168;
  --shadow: 0 18px 40px -18px rgb(110 34 56 / 0.45);

  --font-script: "Dancing Script", cursive;
  --font-serif: "Lora", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-serif);
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, var(--rose-100), transparent 45%),
    radial-gradient(circle at 85% 90%, var(--rose-100), transparent 40%),
    var(--cream);
  overflow-x: hidden;
}

/* ---------- Background capybaras ---------- */

.floating-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.floating-bg img {
  position: absolute;
  bottom: -60px;
  height: auto;
  opacity: 0.55;
  animation: float-up linear infinite;
}

@keyframes float-up {
  to {
    transform: translateY(-120vh) rotate(15deg);
  }
}

/* ---------- Layout ---------- */

.hero,
main {
  position: relative;
  z-index: 1;
}

.hero {
  text-align: center;
  padding: 64px 16px 24px;
}

.hero__eyebrow {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--rose-700);
}

.hero__title {
  margin: 8px 0;
  font-family: var(--font-script);
  font-size: clamp(3rem, 12vw, 5rem);
  font-weight: 700;
  color: var(--wine);
  line-height: 1;
}

.hero__days {
  margin: 0;
  font-style: italic;
  color: var(--ink-soft);
}

main {
  display: grid;
  gap: 72px;
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 16px 96px;
}

.section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.section__title {
  margin: 0;
  font-family: var(--font-script);
  font-size: 2.2rem;
  color: var(--wine);
}

.section__hint {
  margin: 4px 0 32px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* ---------- Button ---------- */

.button {
  margin-top: 24px;
  padding: 14px 32px;
  border: none;
  border-radius: 999px;
  font: 600 1rem var(--font-serif);
  color: #fff;
  background: linear-gradient(135deg, var(--rose-500), var(--rose-700));
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button:active {
  transform: translateY(1px) scale(0.98);
}

.button:focus-visible,
.envelope:focus-visible {
  outline: 3px solid var(--rose-500);
  outline-offset: 4px;
}

.button--ghost {
  color: var(--wine);
  background: var(--paper);
}

/* ---------- Envelope ---------- */

.envelope {
  position: relative;
  width: min(320px, 85vw);
  aspect-ratio: 3 / 2;
  margin-top: 40px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  perspective: 900px;
  animation: wobble 4s ease-in-out infinite;
}

.envelope.is-open {
  animation: none;
  cursor: default;
}

@keyframes wobble {
  0%, 85%, 100% { transform: rotate(0); }
  89% { transform: rotate(-2deg); }
  93% { transform: rotate(2deg); }
  97% { transform: rotate(-1deg); }
}

.envelope span {
  position: absolute;
  inset: 0;
}

.envelope__back {
  z-index: 0;
  border-radius: 6px;
  background: var(--rose-700);
  box-shadow: var(--shadow);
}

.envelope__paper {
  z-index: 2;
  inset: 8% 6% 6% !important;
  border-radius: 4px;
  background:
    repeating-linear-gradient(transparent 0 14px, var(--rose-100) 14px 15px),
    var(--paper);
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.3, 1) 0.45s;
}

.envelope__pocket {
  z-index: 3;
  border-radius: 6px;
  background: var(--rose-500);
  clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%);
}

.envelope__flap {
  z-index: 4;
  background: var(--rose-300);
  clip-path: polygon(0 0, 100% 0, 50% 58%);
  transform-origin: top center;
  transition: transform 0.5s ease, z-index 0s 0.25s;
}

.envelope__seal {
  z-index: 5;
  inset: auto !important;
  left: 50% !important;
  top: 58% !important;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.3rem;
  color: var(--rose-100);
  background: var(--wine);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.3);
  transform: translate(-50%, -50%);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.envelope.is-open .envelope__seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4);
}

.envelope.is-open .envelope__flap {
  z-index: 1;
  transform: rotateX(180deg);
}

.envelope.is-open .envelope__paper {
  transform: translateY(-55%);
}

/* ---------- Letter dialog ---------- */

.letter {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: none;
  background: transparent;
  overflow: visible;
}

.letter[open] {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: letter-in 0.5s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.letter::backdrop {
  background: rgb(61 42 48 / 0.55);
  backdrop-filter: blur(4px);
}

@keyframes letter-in {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.92);
  }
}

.letter__paper {
  width: 100%;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding: 40px 32px;
  border-radius: 6px;
  border-top: 6px solid var(--rose-300);
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: left;
  line-height: 1.75;
}

.letter__greeting,
.letter__signature {
  font-family: var(--font-script);
  font-size: 1.9rem;
  color: var(--wine);
}

.letter__greeting {
  margin: 0 0 8px;
}

.letter__body p {
  margin: 0 0 1.2em;
}

.letter__closing {
  margin: 0;
  font-style: italic;
}

.letter__signature {
  margin: 0;
  text-align: right;
}

/* ---------- Playlist ---------- */

.playlist {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.playlist iframe {
  display: block;
  width: 100%;
  height: 352px;
  border: 0;
}

/* ---------- Reasons ---------- */

.reason-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  min-height: 180px;
  margin-top: 24px;
  padding: 32px 24px;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.reason-card.is-changing {
  animation: reason-in 0.45s ease;
}

@keyframes reason-in {
  from {
    opacity: 0;
    transform: translateY(12px) rotateX(20deg);
  }
}

.reason-card__text {
  margin: 0;
  font-size: 1.3rem;
  font-style: italic;
  color: var(--ink);
}

.reason-card__count {
  margin: 16px 0 0;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rose-700);
}

.reason-card__count:empty {
  display: none;
}

/* ---------- Burst hearts ---------- */

.burst-heart {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  color: var(--rose-500);
  font-size: 1.2rem;
  animation: burst 0.9s ease-out forwards;
}

@keyframes burst {
  to {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.6);
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
  }
}
