.envelope {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  perspective: 900px; /* makes the flap open in 3D */
  transform: translateY(-150px); /* sits in the middle of the page while closed */
  transition: transform 0.6s ease;
}

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

.envelope-back,
.envelope-front,
.envelope-flap {
  position: absolute;
  left: 20px;
  top: 320px;
  width: 320px;
}

.envelope-back {
  z-index: 1;
  height: 200px;
  background-color: #2a0409;
  border-radius: 4px;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.8);
}

.envelope-front {
  z-index: 3;
  height: 200px;
  background: linear-gradient(160deg, #8e0b26, #4a0510);
  border-radius: 4px;
  clip-path: polygon(0 0, 50% 50%, 100% 0, 100% 100%, 0 100%);
}

.envelope-front p {
  position: absolute;
  bottom: 24px;
  width: 100%;
  font-size: 9px;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
  opacity: 0.8;
}

#sig-env {
  color: black;
}

.envelope-flap {
  z-index: 4;
  height: 110px;
  background: linear-gradient(180deg, #a3102f, #6e0717);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  /* the z-index swaps halfway through, so the open flap goes behind the letter */
  transition: transform 0.6s ease, z-index 0s 0.3s;
}

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

.envelope-hint {
  position: absolute;
  top: 400px;
  left: 0;
  width: 100%;
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
  animation: pulse 2.4s infinite;
}

.envelope-hint.hidden {
  display: none;
}


/* the contract */

.letter-slot {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  width: 100%;
  height: 510px; /* stops just above the bottom of the envelope */
  overflow: hidden;
}

.letter {
  position: absolute;
  top: 14px;
  left: 36px;
  width: 288px;
  height: 380px;
  padding: 24px 26px;
  color: var(--ink);
  text-align: center;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.2'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 40%, #e8e5e0 0%, var(--paper) 60%, #b9b4ad 100%);
  transform: translateY(326px); /* tucked inside the envelope */
  transition: transform 0.9s ease;
}

.envelope.letter-out .letter {
  transform: translateY(0);
}

/* thin red border printed on the paper */
.letter::before {
  content: '';
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 8px;
  right: 8px;
  border: 1px solid var(--blood);
  pointer-events: none;
}

.letter-logo {
  display: block;
  width: 150px;
  margin: 0 auto 6px auto;
}

.letter .kicker {
  letter-spacing: 2px;
  color: var(--blood);
  opacity: 1;
}

.letter .divider {
  margin: 8px auto;
  background-color: var(--blood);
}

.letter .divider::after {
  background-color: var(--blood);
}

.letter-text {
  font-size: 13.5px;
  line-height: 1.3;
}

form {
  text-align: left;
}

label {
  display: block;
  margin-top: 10px;
  font-family: var(--font-heading);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--blood);
}

input {
  width: 100%;
  padding: 3px 1px;
  font-family: var(--font-body);
  font-size: 16px; 
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  user-select: text;
}

input:focus {
  outline: none;
  border-bottom: 2px solid var(--red);
}

#signup-button {
  width: 100%;
  margin-top: 18px;
  padding: 10px;
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--silver);
  background-color: var(--blood);
  border: none;
  cursor: pointer;
}
