/* style.css */

body,
table,
tbody,
tr,
td {
  margin: 0;
  padding: 0;
  border: 0;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

body {
  width: 100%;
  margin: 0 auto;
  background-color: #eaf2ef;
  font-family: 'Contrail One', sans-serif;
  color: #292f36;
}

/* HEADER */

header {
  width: 100%;
  vertical-align: middle;
}

#title {
  text-align: center;
  margin: 10px auto;
}

/* START & END SCREEN */

.start-screen,
.end-screen {
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  top: 0;
  left: 0;
  margin: 1px;
  border: solid 1px #444;
  border-radius: 5px;
  position: absolute;
  background-color: #f7fff7;
  display: flex;
  flex-wrap: wrap;
  transition: all 1s cubic-bezier(0.680, -0.550, 0.265, 1.550);
}

.start-screen {
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  transform: translatey(0);
}

#start-screen-title,
#start-screen-credentials {
  width: 100%;
  text-align: center;
}

.start-screen-content {
  width: 200px;
  height: 200px;
  margin: auto;
}

.start-screen-hide {
  transform: translateY(-110vh);
}

.btn-start {
  margin: auto;
  display: block;
  outline: none;
  border: solid 0;
  background-color: #88e172;
  width: 150px;
  height: 50px;
  border-radius: 3px;
  font-family: 'Contrail One', sans-serif;
  font-size: 20px;
}

.end-screen {
  z-index: 3;
  transform: translatey(-110vh);
  display: flex;
  flex-wrap: wrap;
}

.end-screen-content {
  width: 200px;
  height: 450px;
  margin: auto;
}

.end-animation-container {
  width: 120px;
  height: 120px;
  margin: auto;
}

#congrats {
  text-align: center;
}

.end-game-stats {
  width: 80%;
  margin-left: 20%;
}

.btn-play-again {
  margin: auto;
  display: block;
  outline: none;
  border: solid 0;
  background-color: #88e172;
  width: 150px;
  height: 50px;
  border-radius: 3px;
  font-family: 'Contrail One', sans-serif;
  font-size: 20px;
}

.end-screen-show {
  transform: translatey(0);
}

/* STATS & RESET BUTTON */

.stats {
  display: flex;
  flex-wrap: wrap;
}

.stats-moves-box,
.stats-timer-box,
.stats-reset-box {
  width: calc(100% / 3);
}

.stats-stars {
  display: inline-block;
  margin-bottom: 5px;
  font-size: 12px;
  width: 100%;
}

.moves-count {
  display: inline;
  margin-left: 3px;
  font-size: 16px;
}

.stats-moves-box {
  display: flex;
  flex-wrap: wrap;
}

.stats-moves {
  display: inline;
  font-size: 16px;
}

.stats-timer-box {
  display: flex;
}

.stats-timer {
  width: 100%;
  margin: auto;
  text-align: center;
  font-size: 20px;
}

.btn-reset {
  font-size: 30px;
  bottom: 0;
  outline: none;
  border: none;
  background: none;
  float: right;
}

.reset-click {
  animation: shrink-with-Zrotate 0.4s linear 0s 1 normal;
}

/* GAMEBOARD */

.board {
  width: calc(100vw - 4px);
  height: calc(100vw - 4px);
  margin-left: 1px;
  border: solid 1px #444;
  background-color: #f7fff7;
  border-radius: 5px;
}

.table-board {
  width: calc(100vw - 12px);
  height: calc(100vw - 12px);
  margin: 5px;
}

.card-container {
  width: calc((100vw - 12px) / 4);
  height: calc((100vw - 12px) / 4);
}

.card {
  width: calc((100vw - 12px) / 4 - 6px);
  height: calc((100vw - 12px) / 4 - 6px);
  margin: auto;
  display: flex;
  border-radius: 5px;
  border: solid #000 0;
  transform-style: preserve-3d;
  transform: rotatey(0) translatex(0) translatey(0);
  transition: all 0.6s cubic-bezier(0.680, -0.550, 0.265, 1.550);
  cursor: pointer;
}

.flipped {
  transform: rotatey(-180deg) translatex(0) translatey(0);
}

.success {
  transform: rotatey(-180deg) translatex(0) translatey(0);
  animation: shrink-with-Yrotate 0.5s ease-in-out 0s 1 normal;
}

.card-front,
.card-back {
  width: calc(100% - 1px);
  height: calc(100% - 1px);
  backface-visibility: hidden;
  border-radius: 5px;
  border: solid #000 0.5px;
  transition: 0.5s ease-in;
}

.card-front {
  background-color: #ff6b6b;
  transform: rotateY(0) translateZ(2px);
}

.card-back {
  top: 0;
  left: 0;
  position: absolute;
  transform: rotateY(180deg);
  background-color: #ffe66d;
  align-items: center;
}

.back-success {
  background-color: #88e172;
}

.icon {
  height: 100%;
  font-size: 3.5em;
  display: block;
  margin: 0 auto;
  pointer-events: none;
  transition: none !important;
  color: #292f36;
}

.wrong {    
  animation: shake 0.5s linear 0s 1 normal;
}

.event-catcher {
  position: absolute;
  width: 100vw;
  height: 100vh;
  top: 0;
  left: 0;
}

/* ANIMATIONS */

@keyframes shake {
  10%, 90% {
    transform: translateX(-1px) rotatey(-180deg);
  }

  20%, 80% {
    transform: translateX(2px) rotatey(-180deg);
  }

  30%, 50%, 70% {
    transform: translateX(-4px) rotatey(-180deg);
  }

  40%, 60% {
    transform: translateX(4px) rotatey(-180deg);
  }
}

@keyframes shrink-with-Yrotate {
  50% {
    transform: scale(1.1) rotatey(-180deg);
  }
}

@keyframes shrink-with-Zrotate {
  0% {
    transform: scale(1) rotateZ(0deg);
  }
  
  50% {
    transform: scale(1.5) rotateZ(180deg);
  }

  100% {
    transform: scale(1) rotateZ(360deg);
  }
}

@keyframes scaleAnimation {
  0% {
    opacity: 0;
    transform: scale(1.5);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes drawCircle {
  0% {
    stroke-dashoffset: 151px;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes drawCheck {
  0% {
    stroke-dashoffset: 36px;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes fadeOut {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

#successAnimationCircle {
  stroke-dasharray: 151px 151px;
  stroke: #88e172;
}

#successAnimationCheck {
  stroke-dasharray: 36px 36px;
  stroke: #88e172;
}

#successAnimationResult {
  fill: #88e172;
  opacity: 0;
}

#successAnimation.animated {
  animation: 1s ease-out 0s 1 both scaleAnimation;
}

#successAnimationCircle {
  animation: 1s cubic-bezier(0.77, 0, 0.175, 1) 0s 1 both drawCircle,
             0.3s linear 0.9s 1 both fadeOut;
}

#successAnimationCheck {
  animation: 1s cubic-bezier(0.77, 0, 0.175, 1) 0s 1 both drawCheck,
             0.3s linear 0.9s 1 both fadeOut;
}

#successAnimationResult {
  animation: 0.3s linear 0.9s both fadeIn;
}

/* MEDIA QUERIES */

@media screen and (min-width: 401px) {
  .icon {
    font-size: 4.5em;
  }
}

@media screen and (min-width: 501px) {
  #title {
    margin: 16px auto;
  }

  .stats-stars {
    font-size: 20px;
    width: 50%;
  }
  
  .moves-count {
    font-size: 20px;
  }
  
  .stats-moves {
    font-size: 20px;
  }
  
  .stats-timer-box {
    display: flex;
  }
  
  .stats-timer {
    margin: 0;
  }

  .icon {
    font-size: 5.5em;
  }
}

@media screen and (min-width: 601px) {
  body {
    width: 600px;
    margin: auto;
  }

  .start-screen,
  .end-screen {
    width: 600px;
    height: calc(100% - 4px);
    top: 0;
    margin: auto calc((100% - 600px) / 2);
  }
  
  #title {
    font-size: 44px;
  }

  .stats-stars {
    width: 40%;
    display: flex;
    flex-direction: row;
  }

  .fa-star {
    margin: 0 2px;
  }

  .board {
    width: calc(600px - 4px);
    height: calc(600px - 4px);
  }

  .table-board {
    width: calc(600px - 52px);
    height: calc(600px - 52px);
    margin: 25px;
  }

  .card-container {
    width: calc((600px - 52px) / 4);
    height: calc((600px - 52px) / 4);
  }

  .card {
    width: 96%;
    height: 96%;
  }

  .icon {
    font-size: 6.5em;
  }

  @keyframes shrink-with-Yrotate {
    50% {
      transform: scale(1.2) rotatey(-180deg);
    }
  }
}