/* The welcome letter page. */
.welcome {
  position: relative;
  z-index: 20;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 2rem 1rem;
}
.welcome__kicker {
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  color: var(--gold);
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
}
.welcome__hint { font-style: italic; animation: bob 2.2s ease-in-out infinite; }

/* The envelope: back, letter peeking out, front pocket, flap and seal. */
.envelope {
  position: relative;
  width: min(84vw, 420px);
  aspect-ratio: 3 / 2;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  perspective: 900px;
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.5));
  animation: wiggle 3s ease-in-out 1s infinite;
}
.envelope > span { position: absolute; display: block; }
.envelope__back { inset: 0; background: #8f1a26; border-radius: 8px; }
.envelope__letter {
  left: 7%;
  right: 7%;
  top: 8%;
  height: 84%;
  background: repeating-linear-gradient(transparent 0 18px, rgba(29, 51, 83, 0.12) 18px 19px), var(--cream);
  border-radius: 4px;
  transition: transform 0.9s cubic-bezier(0.3, 0.7, 0.3, 1) 0.55s;
}
.envelope__pocket {
  inset: 0;
  background: #c8202d;
  border-radius: 8px;
  clip-path: polygon(0 30%, 50% 66%, 100% 30%, 100% 100%, 0 100%);
}
.envelope__flap {
  inset: 0 0 auto;
  height: 66%;
  background: #a61e2b;
  border-radius: 8px 8px 0 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transition: transform 0.6s ease-in, z-index 0s 0.3s;
  z-index: 3;
}
.envelope__seal {
  left: 50%;
  top: 66%;
  z-index: 4;
  width: 16%;
  aspect-ratio: 1;
  translate: -50% -50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font: bold clamp(1.2rem, 5vw, 2rem) Georgia, serif;
  color: #7a5410;
  background: radial-gradient(circle at 35% 35%, #ffe08a, #e0a93a 60%, #b07c1c);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s;
}
.envelope.is-open { animation: none; cursor: default; }
.envelope.is-open .envelope__seal { opacity: 0; }
.envelope.is-open .envelope__flap { transform: rotateX(180deg); z-index: 0; }
.envelope.is-open .envelope__letter { transform: translateY(-55%); }

/* The letter itself. */
.letter {
  width: min(36rem, 100%);
  padding: clamp(1.2rem, 5vw, 2.4rem);
  color: #35210f;
  line-height: 1.6;
  background: repeating-linear-gradient(transparent 0 31px, rgba(29, 51, 83, 0.08) 31px 32px), var(--cream);
  border: 3px double var(--red);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  animation: unfold 0.7s ease-out;
}
.letter h1 { font-size: 1.6rem; color: var(--red); margin-bottom: 0.8rem; }
.letter__body p { margin-bottom: 0.9rem; }
.letter__signoff { margin: 1.2rem 0 1.4rem; font-style: italic; text-align: right; }
.letter__after {
  margin: 0 0 1.4rem;
  padding-top: 1rem;
  border-top: 2px dashed rgba(179, 32, 44, 0.35);
  font-size: 0.95rem;
}
.letter__after:empty { display: none; }
.letter__after p { margin-bottom: 0.7rem; }
.letter .button { display: table; margin: 0 auto; }

.welcome.is-reading .welcome__kicker,
.welcome.is-reading .envelope,
.welcome.is-reading .welcome__hint { display: none; }

@keyframes bob { 50% { transform: translateY(-5px); } }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-3deg); } 90% { transform: rotate(3deg); } 95% { transform: rotate(-2deg); } }
@keyframes unfold { from { opacity: 0; transform: translateY(40px) scale(0.92); } }

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