@font-face {
  font-family: Aptos;
  src: url(./fonts/Aptos.ttf);
}

@font-face {
  font-family: AptosSemiBold;
  src: url(./fonts/Aptos-SemiBold.ttf);
}

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

body {
  height: 100vh;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  font-family: sans-serif;
  background-color: #d6efd8;
}

.wrapper {
  height: 600px;
  width: 900px;
  background-color: #1a5319;
  position: relative;
  display: flex;
  justify-content: center;
  z-index: 0;
}

#open {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  width: 90px;
  height: 90px;
  border-radius: 100%;
  border: none;
  color: #00441b;
  cursor: pointer;
  font-size: 24px;
  animation-delay: 0.5s;
}

#open:hover {
  background-color: #ffef14;
}

#close {
  display: inline;
  padding: 10px 20px;
  margin-top: 20px;
  font-size: 24px;
  border-radius: 10px;
  border: none;
  color: white;
  background-color: #1a5319;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
}

#close:hover {
  background-color: #ffef14;
  color: #1a5319;
}

.flap {
  position: absolute;
  height: 100%;
  width: 100%;
  top: 0;
  left: 0;
  border-right: 450px solid transparent;
  border-bottom: 300px solid transparent;
  border-left: 450px solid transparent;
  transform-origin: top;
  transition: transform 0.25s linear;
}

/* flap when closed */
.flap.one {
  border-top: 300px solid #1a5319;
  transform: rotateX(0deg);
  z-index: 3;
  transition-delay: 0.75s;
}

/* flap when opened */
.flap.two {
  border-top: 300px solid #1a5319;
  transform: rotateX(90deg);
  z-index: 1;
  transition-delay: 0.5s;
}

.envelope {
  position: absolute;
  height: 100%;
  width: 100%;
  top: 0;
  left: 0;
  border-top: 300px solid transparent;
  border-right: 450px solid #80af81;
  border-bottom: 300px solid #80af81;
  border-left: 450px solid #508d4e;
  z-index: 3;
}

.letter {
  position: absolute;
  padding: 20px;
  top: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: start;
  flex-direction: column;
  background-color: white;
  color: #1a5319;
  border-radius: 15px;
  z-index: 2;
  transition: 0.5s;
}

.letter #destination {
  font-family: AptosSemiBold;
  font-style: italic;
}

.letter .content {
  display: flex;
  flex-direction: column;
}

.letter p {
  margin-top: 20px;
  font-size: 24px;
  color: #1a5319;
}

.wrapper .flap-one-open {
  transform: rotateX(90deg);
  transition-delay: 0s;
}

.wrapper .flap-two-open {
  transform: rotateX(180deg);
  transition-delay: 0.25s;
}

.wrapper .letter-open {
  animation-name: openLetter;
  animation-duration: 100s;
  animation-delay: 0.5s;
}

.wrapper .letter-close {
  animation-name: closeLetter;
  animation-duration: 100s;
  animation-delay: 0s;
}

@keyframes openLetter {
  0% {
    transform: none;
    z-index: 2;
  }

  1% {
    transform: translateY(-100%);
    z-index: 2;
  }

  3% {
    transform: translateY(0);
    z-index: 100;
  }

  100% {
    transform: translateY(0);
    z-index: 100;
  }
}

@keyframes closeLetter {
  0% {
    transform: none;
    z-index: 100;
  }

  1% {
    transform: translateY(-100%);
    z-index: 2;
  }

  3% {
    transform: translateY(0);
    z-index: 2;
  }

  100% {
    transform: translateY(0);
    z-index: 2;
  }
}
