/* Font Faces */
@font-face {
  font-family: "Moderat Mono Black";
  src: url("../fonts/Moderat-Mono-Black.ttf") format("truetype"),
    url("../fonts/Moderat-Mono-Black.woff") format("woff"),
    url("../fonts/Moderat-Mono-Black.woff2") format("woff2");
}

@font-face {
  font-family: "Moderat Mono Bold";
  src: url("../fonts/Moderat-Mono-Bold.ttf") format("truetype"),
    url("../fonts/Moderat-Mono-Bold.woff") format("woff"),
    url("../fonts/Moderat-Mono-Bold.woff2") format("woff2");
}

@font-face {
  font-family: "Moderat Regular";
  src: url("../fonts/Moderat-Regular.ttf") format("truetype"),
    url("../fonts/Moderat-Regular.woff") format("woff"),
    url("../fonts/Moderat-Regular.woff2") format("woff2");
}

/* Body */
html,
body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: hsl(18, 37.7%, 47.8%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

/* Box Wrapper */

#box-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2vmin;
  position: relative;
}

/* Grid */
#grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  position: relative;
}

/* Gamefield + Cardbox */

#gamefield,
#card-box {
  position: relative;
  width: 60vmin;
  height: 60vmin;
  background-color: hsl(18, 37.7%, 47.8%);
  border: 0.1875rem solid white;
  overflow: hidden;
  box-sizing: border-box;
}

#gamefield {
  z-index: 1;
}

#card-box {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  margin: -0.5rem;
  width: 60vmin;
  height: 60vmin;
  box-sizing: border-box;
}

#gamefield video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#gamefield .audiocard,
#gamefield .videocard {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  box-sizing: border-box;
  aspect-ratio: 1 / 1;
  border: 0.1875rem solid white;
  background-color: hsl(134, 13.8%, 75.9%);
}

/* Cards*/

.audiocard,
.videocard {
  flex: 0 1 calc(50% - 1rem);
  aspect-ratio: 1 / 1;
  margin: 0.5rem;
  box-sizing: border-box;
  border: 0.1875rem solid white;
  background-color: hsl(134, 13.8%, 75.9%);
  display: flex;
  justify-content: center;
  align-items: center;
}

.audiocard img,
.videocard img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.5s;
}

.audiocard:hover,
.videocard:hover {
  filter: brightness(120%);
}

.audiocard.flipped,
.videocard.flipped {
  transform: rotateY(180deg);
}

.audiocard.flipped img,
.videocard.flipped img {
  transform: rotateY(-180deg);
}

.audiocard.unflip,
.videocard.unflip {
  transform: rotateY(0deg);
}

.audiocard.unflip img,
.videocard.unflip img {
  transform: rotateY(0deg);
}

.flipped {
  background-color: black;
}

.unflip {
  transform: rotateY(18deg);
  transition: transform 0.5s;
}

.audiocard-clone,
.videocard-clone {
  margin: 0;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.5;
  box-sizing: border-box;
}

/* Logos */
#logo,
#logo-rev {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
}

#logo {
  top: 2vmin;
}

#logo-rev {
  position: absolute;
  bottom: 2vmin;
  left: 50%;
  transform: translateX(-48%) rotate(180deg);
  z-index: 1000;
}

/* Buttons */
button {
  font-family: "Moderat Mono Black";
  font-weight: bold;
  font-size: 1.5625rem;
  color: white;
  background-color: transparent;
  height: 6.25rem;
  width: 12.5rem;
  padding: 4rem 0.9375rem 0 0.9375rem;
}

button:hover ~ #gamefield {
  background-color: hsl(134, 13.8%, 75.9%);
}

#level:hover,
#next:hover,
#replay:hover,
#description:hover {
  background-color: hsl(134, 13.8%, 75.9%);
  box-shadow: inset 0 0 0 0.17rem white;
  color: black;
}

.button {
  background-color: hsl(134, 13.8%, 75.9%);
  color: white;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 0.3125rem;
  cursor: pointer;
  display: none;
}

.button-disappear {
  opacity: 0;
  transition: opacity 0.5s ease;
}

#level,
#next,
#replay,
#description {
  position: absolute;
  z-index: 10;
  width: 15rem;
  height: 7rem;
  font-size: 1.5rem;
  background: transparent;
  color: white;
  border: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-right: 0.5rem;
  transform: rotate(270deg);
  box-sizing: border-box;
}

#level {
  top: 4rem;
  left: 2.5rem;
  transform: translate(-100%, 0) rotate(270deg);
  border-right: 0.1875rem solid white;
}

#replay {
  bottom: 4rem;
  left: 2.5rem;
  transform: translate(-100%, 0) rotate(270deg);
  border-left: 0.1875rem solid white;
}

#next {
  top: 4rem;
  right: 2rem;
  transform: translate(100%, 0) rotate(270deg);
  border-right: 0.1875rem solid white;
}

#description {
  bottom: 4rem;
  right: 2rem;
  transform: translate(100%, 0) rotate(270deg);
  border-left: 0.1875rem solid white;
}
#match-button {
  position: absolute;
  top: 25%;
  width: 100%;
  height: 51%;
  font-size: 3rem;
  background-color: hsl(134, 13.8%, 75.9%);
  color: black;
  border-radius: 0;
}

#no-button {
  position: absolute;
  top: 75%;
  width: 100%;
  height: 51%;
  font-size: 3rem;
  background-color: hsl(134, 13.8%, 75.9%);
  color: black;
  border-radius: 0;
}

#match-button:hover,
#no-button:hover {
  color: hsl(134, 13.8%, 75.9%);
  background-color: black;
  box-shadow: none;
}

/* Animations */

@keyframes shake {
  0% {
    transform: translate(0.0625rem, 0.0625rem) rotate(180deg);
  }
  10% {
    transform: translate(-0.0625rem, -0.125rem) rotate(179deg);
  }
  20% {
    transform: translate(-0.1875rem, 0rem) rotate(181deg);
  }
  30% {
    transform: translate(0.1875rem, 0.125rem) rotate(180deg);
  }
  40% {
    transform: translate(0.0625rem, -0.0625rem) rotate(181deg);
  }
  50% {
    transform: translate(-0.0625rem, 0.125rem) rotate(179deg);
  }
  60% {
    transform: translate(-0.1875rem, 0.0625rem) rotate(180deg);
  }
  70% {
    transform: translate(0.1875rem, 0.0625rem) rotate(179deg);
  }
  80% {
    transform: translate(-0.0625rem, -0.0625rem) rotate(181deg);
  }
  90% {
    transform: translate(0.0625rem, 0.125rem) rotate(180deg);
  }
  100% {
    transform: translate(0.0625rem, -0.125rem) rotate(179deg);
  }
}

.shake {
  animation: shake 0.82s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  perspective: 62.5em;
}

.audiocard.mismatch,
.videocard.mismatch {
  animation: shake 0.5s;
  animation-iteration-count: 2;
}

@keyframes flashing-text {
  0% {
    color: black;
    -webkit-text-stroke-color: hsl(134, 13.8%, 75.9%);
  }
  50% {
    color: hsl(134, 13.8%, 75.9%);
    -webkit-text-stroke-color: black;
  }
  100% {
    color: black;
    -webkit-text-stroke-color: hsl(134, 13.8%, 75.9%);
  }
}

/* Level Completed / Correct Message */
#correct-message,
#incorrect-message,
#level-completed-message {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Moderat Mono Black";
  font-weight: bold;
  font-size: 3rem;
  color: black;
  text-align: center;
  -webkit-text-stroke: 2px hsl(134, 13.8%, 75.9%);
  animation: flashing-text 1.5s infinite;
  transition: color 0.5s;
}

#incorrect-message {
  top: 50%;
}

#level-text {
  font-family: "Moderat Mono Black";
  font-size: 1rem;
  color: black;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: hsl(134, 13.8%, 75.9%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 1rem;
  box-sizing: border-box;
  z-index: 2;
}
#description-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: hsl(134, 13.8%, 75.9%);
  font-family: "Moderat Mono Black";
  font-size: 1rem;
  color: black;
  text-align: center;
  display: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  pointer-events: none;
  box-sizing: border-box;
  z-index: 0;
  display: flex;
}

#mismatch-count {
  font-family: "Moderat Mono Black";
  font-weight: normal;
  font-size: 2rem;
  color: white;
  text-align: center;
}

#portrait-warning {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: black;
  color: hsl(134, 13.8%, 75.9%);
  font-family: "Moderat Mono Bold";
  font-size: 2rem;
  padding: 2rem;
  box-sizing: border-box;
  z-index: 9999;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* Media Queries */

/*Portrait warning*/

#portrait-warning {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: black;
  color: hsl(134, 13.8%, 75.9%);
  font-family: "Moderat Mono Bold";
  font-size: 2rem;
  z-index: 9999;
  text-align: center;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  box-sizing: border-box;
  pointer-events: none;
}

/* mobile - landscape */
@media screen and (orientation: landscape) and (max-width: 80em) {
  #gamefield,
  #card-box {
    width: 60vmin;
    height: 60vmin;
    margin: 0.1vmin;
  }

  #logo img,
  #logo-rev img {
    width: 15rem;
  }

  #level,
  #replay,
  #next,
  #description {
    width: 7rem;
    height: 3rem;
    font-size: 0.7rem;
    transform: rotate(270deg);
  }

  #level {
    top: 1.5rem;
    left: 1rem;
    transform: translate(-100%, 0) rotate(270deg);
    border-right: 0.1875rem solid white;
    text-indent: 1rem;
  }

  #replay {
    bottom: 1.5rem;
    left: 1rem;
    transform: translate(-100%, 0) rotate(270deg);
    border-left: 0.1875rem solid white;
    text-indent: -1rem;
  }

  #next {
    top: 1.5rem;
    right: 1rem;
    transform: translate(100%, 0) rotate(270deg);
    border-right: 0.1875rem solid white;
    text-indent: 1rem;
  }

  #description {
    bottom: 1.5rem;
    right: 1rem;
    transform: translate(100%, 0) rotate(270deg);
    border-left: 0.1875rem solid white;
    text-indent: -1rem;
  }

  #description-text {
    font-size: 0.6rem;
  }

  #mismatch-count {
    font-size: 1.8rem;
  }

  #match-button,
  #no-button {
    font-size: 1.8rem;
  }

  #correct-message,
  #incorrect-message,
  #level-completed-message {
    font-size: 2rem;
  }
}

/*tablets*/

@media screen and (min-width: 64em) and (max-width: 80em) and (orientation: landscape) {
  #gamefield,
  #card-box {
    width: 50vmin;
    height: 50vmin;
  }

  #logo img,
  #logo-rev img {
    width: 25rem;
  }

  #level,
  #replay,
  #next,
  #description {
    width: 10rem;
    height: 6rem;
    font-size: 1.2rem;
    transform: rotate(270deg);
  }

  #level {
    top: 2rem;
    left: 0rem;
    transform: translateX(-90%) rotate(270deg);
    text-indent: 0rem;
  }

  #replay {
    bottom: 2rem;
    left: 0rem;
    transform: translateX(-90%) rotate(270deg);
    text-indent: 0rem;
  }

  #next {
    top: 2rem;
    right: 0rem;
    transform: translateX(90%) rotate(270deg);
    text-indent: 0rem;
  }

  #description {
    bottom: 2rem;
    right: 0rem;
    transform: translateX(90%) rotate(270deg);
    text-indent: 0rem;
  }
  #description-text {
    font-size: 1rem;
  }
}

/*ipad pro 12*/

@media screen and (min-width: 1366px) and (orientation: landscape) and (-webkit-min-device-pixel-ratio: 2) {
  #gamefield,
  #card-box {
    width: 45vmin;
    height: 45vmin;
  }
  #level,
  #replay,
  #next,
  #description {
    width: 10rem;
    height: 6rem;
    font-size: 1.2rem;
    transform: rotate(270deg);
  }
  #level {
    top: 2rem;
    left: 0rem;
    transform: translateX(-90%) rotate(270deg);
  }

  #replay {
    bottom: 2rem;
    left: 0rem;
    transform: translateX(-90%) rotate(270deg);
  }

  #next {
    top: 2rem;
    right: 0rem;
    transform: translateX(90%) rotate(270deg);
  }

  #description {
    bottom: 2rem;
    right: 0rem;
    transform: translateX(90%) rotate(270deg);
  }
}
