@font-face {
  font-family: "SF Pro Display";
  src: url("/fonts/sf-pro/SFProDisplay-SemiboldItalic.woff2") format("woff2"),
    url("/fonts/sf-pro/SFProDisplay-SemiboldItalic.woff") format("woff"),
    url("/fonts/sf-pro/SFProDisplay-SemiboldItalic.ttf") format("truetype");
  font-weight: 600;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "SF Pro Display";
  src: url("/fonts/sf-pro/SFProDisplay-Medium.woff2") format("woff2"),
    url("/fonts/sf-pro/SFProDisplay-Medium.woff") format("woff"),
    url("/fonts/sf-pro/SFProDisplay-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "SF Pro Display";
  src: url("/fonts/sf-pro/SFProDisplay-Regular.woff2") format("woff2"),
    url("/fonts/sf-pro/SFProDisplay-Regular.woff") format("woff"),
    url("/fonts/sf-pro/SFProDisplay-Regular.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "SF Pro Display";
  src: url("/fonts/sf-pro/SFProDisplay-Bold.woff2") format("woff2"),
    url("/fonts/sf-pro/SFProDisplay-Bold.woff") format("woff"),
    url("/fonts/sf-pro/SFProDisplay-Bold.ttf") format("truetype");
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

/* Main CSS */

:root {
  --correct-gradient: linear-gradient(
    148.7deg,
    #47e6a3 -5.51%,
    #074b2f 115.28%
  );
  --wrong-location-gradient: linear-gradient(
    158.36deg,
    #896405 -12.56%,
    #ead51d 113.82%
  );
  --empty-tile-gradient: linear-gradient(
    162.84deg,
    rgba(53, 45, 51, 0.5) -9.92%,
    rgba(149, 69, 237, 0.5) 88.2%
  );
  --primary-color: #e0b1fd;
  --primary-hover: #daa1fe;
  --primary-pressed: #a366ca;
  --secondary-color: #44bc8a;
  --neutral-color: #b9b7b7;
  --active-border: 2px solid rgb(191, 145, 245);
  --title-gradient: linear-gradient(180deg, #454c4d 4.44%, #ffffff 82.41%);
}

*,
*::after,
*::before {
  box-sizing: border-box;
  padding: 0px;
  margin: 0px;
  overflow: hidden;
  font-family: Arial;
}

html {
  height: -webkit-fill-available;
  height: 100%;
}

body {
  position: relative;
  background-color: hsl(240, 3%, 7%);
  background-image: url(/images/black-background.jpg);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  margin: 0;
  /* padding-top: 1em; */
  touch-action: manipulation;
  /* min-height: -webkit-fill-available;
  overflow-y: hidden; */
  /* font-size: clamp(0.5rem, 2.5vmin, 1.5rem); */
}

/* CSS specific to iOS devices */

@supports (-webkit-touch-callout: none) {
  .game-container,
  body {
    height: 100%;
    min-height: -webkit-fill-available;
  }
}

.game-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0.5em;
  justify-content: space-between;
  touch-action: manipulation;
}

.title,
.modal__title {
  color: white;
  font-family: "Rowdies", cursive;
  font-style: normal;
  font-weight: normal;
  letter-spacing: 0.15em;
  user-select: none;
  text-transform: uppercase;
  text-align: center;

  background-image: var(--title-gradient);
  background-size: 100%;
  -webkit-background-clip: text;
  -moz-background-clip: text;
  -webkit-text-fill-color: transparent;
  -moz-text-fill-color: transparent;
  /* visibility: hidden; */
}

.title {
  font-size: clamp(2rem, 7vmin, 6rem);
}

.title,
.keyboard,
.tile {
  /* visibility: hidden; */
}

header {
  display: flex;
  justify-content: center;
  align-items: center;
  max-height: 100px;
  width: 100%;
  /* padding-top: 1rem; */
  display: flex;
  max-height: 100px;
}

@media screen and (max-height: 600px) {
  header {
    padding-top: 0rem;
  }
}

.keyboard {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  grid-auto-rows: 30%;
  width: 100%;
  max-width: 600px;
  min-height: 200px;
  max-height: 35vh;
  gap: 0.25em;
  justify-content: center;
  justify-self: flex-end;
  align-self: center;
  /* visibility: hidden; */
}

.key {
  font-size: inherit;
  font-weight: 600;
  grid-column: span 2;
  border: none;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #eae9e9;
  color: hsla(0, 0%, 28%, 1);
  text-transform: uppercase;
  border-radius: 0.25rem;
  cursor: pointer;
  user-select: none;
}

.key.large {
  grid-column: span 3;
  font-size: clamp(0.5rem, 2.5vmin, 1.1rem);
}

.key.enter {
  background: #6c6c6c;
  color: white;
}

.key.enter:focus,
.key.enter:hover {
  background: #505050;
}

.key.delete {
  background: #c94d4d;
  color: white;
}

.key.delete:focus,
.key.delete:hover {
  background: #832d2d;
}

.key:hover,
.key:focus {
  background: #d1cfcf;
}

.key.wrong {
  background: none;
  color: hsla(0, 3%, 79%, 1);
}

.key.wrong:hover,
.key.wrong:focus {
  background: rgba(240, 240, 240, 0.1);
}

.key.wrong-location {
  background: var(--wrong-location-gradient);
  color: white;
}

.key.wrong-location:hover,
.key.wrong-location:focus {
  background: #e2af2b;
}

.key.correct {
  background: var(--correct-gradient);
  color: white;
}

.key.correct:hover,
.key.correct:focus {
  background: #2d966a;
}

.guess-grid {
  display: grid;
  justify-content: center;
  align-content: center;
  align-self: center;
  /* flex-grow: 1; */
  grid-template-columns: repeat(5, 8vh);
  grid-template-rows: repeat(6, 8vh);
  gap: 0.6em;
  max-width: 700px;
  margin: 1em;
  font-size: clamp(0.5rem, 2.5vmin, 1.5rem);
  overflow: visible;
  height: auto;
  /* transition: 0.5s; */
}

@media (max-width: 750px) {
  .guess-grid {
    grid-template-columns: repeat(5, 7.8vh);
    grid-template-rows: repeat(6, 7.8vh);
  }
}

/* @media (max-width: 600px) {
  .guess-grid {
    grid-template-columns: repeat(5, 13vw);
    grid-template-rows: repeat(6, 13vw);
    gap: 1em;
  }
} */

.tile {
  /* aspect-ratio: 1; */
  font-size: clamp(2rem, 3vw, 3rem);
  color: white;
  background: var(--empty-tile-gradient);
  border: 2px solid rgba(174, 133, 221, 0.5);
  box-shadow: 0px 4px 22px rgba(2, 224, 238, 0.08);
  border-radius: 0.4rem;
  text-transform: uppercase;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  /* transform: rotate(0deg); */
  transition: transform 100ms linear;
}

.tile[data-state="active"] {
  border: var(--active-border);
}

.tile[data-state="wrong"] {
  color: #6c6c6c;
  background: none;
}

.tile[data-state="wrong-location"] {
  background: var(--wrong-location-gradient);
  border: 1px solid rgba(226, 214, 214, 0.1);
}

.tile[data-state="correct"] {
  background: var(--correct-gradient);
  border: 1px solid rgba(226, 214, 214, 0.1);
}

.tile.shake {
  animation: shake 250ms 1 ease-in-out;
}

.tile.dance {
  animation: dance 500ms ease-in-out;
}

.tile.flip {
  transform: rotateX(90deg);
}

@keyframes shake {
  10% {
    transform: translateX(-5%);
  }
  30% {
    transform: translateX(5%);
  }
  50% {
    transform: translateX(-7.5%);
  }
  70% {
    transform: translateX(7.5%);
  }

  90% {
    transform: translateX(-5%);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes dance {
  20% {
    transform: translateY(-50%);
  }
  40% {
    transform: translateY(5%);
  }
  60% {
    transform: translateY(-25%);
  }
  80% {
    transform: translateY(2.5%);
  }
  90% {
    transform: translateY(-5%);
  }
  100% {
    transform: translateY(0);
  }
}

/* MODAL */

.alert-container {
  position: fixed;
  top: 10vh;
  left: 50vw;
  transform: translateX(-50%);
  z-index: 102;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.alert {
  pointer-events: none;
  background-color: hsl(204, 7%, 85%);
  padding: 0.75em;
  border-radius: 0.25em;
  opacity: 1;
  transition: opacity 500ms ease-in-out;
  margin-bottom: 0.5em;
  text-align: center;
}

.alert:last-child {
  margin-bottom: 0;
}

.alert.hide {
  opacity: 0;
}

/* MODAL */

#darkened-background {
  display: none;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.6);
  height: 100vh;
  width: 100vw;
  position: absolute;
  z-index: 100;
}

.modal {
  display: none;
  position: relative;
  flex-direction: column;
  background-color: #121213;
  border-radius: 8px;
  max-width: 500px;
  /* max-height: 400px; */
  padding: 1.5em;
  width: 90%;
  max-height: 90%;
  position: absolute;
  z-index: 101;
}

.close-icon {
  display: grid;
  place-items: center;
  position: absolute;
  right: 1em;
  top: 1em;
  width: 2.5em;
  height: 2.5em;
  cursor: pointer;
  border-radius: 4px;
}

.close-icon:hover {
  background-color: rgba(255, 255, 255, 0.043);
}

.title-row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  margin-bottom: 1em;
  width: 100%;
}

.modal__title {
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  display: inline-block;
}

.game-score {
  display: inline-block;
  color: var(--secondary-color);
  font-family: SF Pro Display;
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  font-weight: 800;
  margin-left: 16px;
  user-select: none;
}

.score-grid {
  display: grid;
  width: 100%;
  grid-template-columns: 55% auto auto;
  grid-template-rows: 2.3rem 2.3rem 2.3rem;
  row-gap: clamp(0.1rem, 1vh, 1rem);
  margin-bottom: 28px;
  /* grid-template-rows: 4; */
}

.score-title {
  display: flex;
  align-items: center;
  color: var(--neutral-color);
  font-family: SF Pro Display;
  font-style: normal;
  font-weight: bold;
  font-size: clamp(1rem, 5vw, 1.3rem);
  line-height: 21px;
}

.score-value,
.score-points {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  font-family: SF Pro Display;
  font-style: normal;
  font-weight: bold;
  font-size: clamp(1rem, 5vw, 1.3rem);
  line-height: 29px;
}

.score-value {
  color: white;
}

.attempted {
  display: inline-flex;
}

@media screen and (max-width: 508px) {
  .attempted {
    display: none;
  }
}

#seconds,
#minutes {
  margin-left: 5px;
}

.score-points {
  display: flex;
  justify-content: flex-end;
  color: var(--primary-color);
}

.highscore-grid {
  display: grid;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  grid-template-columns: auto auto auto;
  grid-template-rows: 1rem 1rem 1rem 1rem 1rem;
  row-gap: 16px;
  color: var(--neutral-color);
  font-family: SF Pro Display;
  font-style: normal;
  font-weight: bold;
  font-size: clamp(18px, 20px, 24px);
  line-height: 29px;
  margin-bottom: 28px;
}

.highscore__date {
  /* justify-self: right; */
}

.highscore__word {
  /* justify-self: center; */
  text-align: center;
  letter-spacing: 0.4em;
  text-transform: uppercase;
}

.highscore__score {
  /* justify-self: center; */
}

.current-highscore {
  color: var(--secondary-color);
  font-weight: 700;
}

.current-highscore::before {
  content: "";
}

.cta-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 5px;
}

.cta-button {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  background-color: var(--primary-color);
  box-shadow: 0px 3.1159px 15.5795px rgba(224, 177, 253, 0.12);
  border: none;
  border-radius: 6.23181px;
  font-family: SF Pro Display;
  font-style: normal;
  font-weight: bold;
  font-size: 1.7em;
  line-height: 33px;
  text-transform: uppercase;
  width: 8em;
  height: 2.2em;
  cursor: pointer;
  user-select: none;

  color: #331844;
  transition: all 0.2s ease;
  transform: scale(1);
}

.cta-button:hover {
  background-color: var(--primary-hover);
  transform: scale(1.02);
}

.cta-button:active {
  background-color: var(--primary-pressed);
}

button img {
  margin-left: 4px;
  width: 1.2em;
}
