*,
/* *::after, */
*::before {
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
}

:root {
  --background-standard: hsl(240, 3%, 7%);
  --grey-standard: hsl(206, 3%, 48%);
  --yellow-standard: hsl(51, 52%, 55%);
  --green-standard: hsl(116, 28%, 53%);
  --placed: hsl(115, 28%, 53%);
  --valid: hsl(51, 52%, 55%);
  --bad: hsl(0, 0%, 25%);
}

body {
  background-color: var(--background-standard);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  padding: 1em;
  /* sauce: https://developer.mozilla.org/en-US/docs/Web/CSS/clamp */
  font-size: clamp(0.5rem, 2.5vmin, 1.5rem);
}

#titleText {
  height: 8vh;
  width: 90vw;
  margin-top: 2vh;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  font-size: 2.5em;
  font-weight: bolder;
}

span {
  color: var(--placed);
  font-family: "Courier New", Courier, monospace;
}

.blinker {
  opacity: 1;
  margin-bottom: -2px;
  height: 2px;
  margin-left: -10px;
  border-left: 0px solid var(--placed);
  animation: blinker 0.9s steps(2, start) infinite;
}

@keyframes blinker {
  to {
    visibility: hidden;
  }
}

#themeSetter {
  width: 20vw;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 1em;
  display: flex;
  flex-direction: row;
  justify-content: space-around;
}

#themeSetter div {
  cursor: pointer;
}

#mainContainer {
  height: 80vh;
  width: 90vw;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  box-sizing: border-box;
  padding: 0.5em;
}

#playerSide,
#cpuSide {
  width: 50%;
  box-sizing: border-box;
  margin: 0.8em;
}

#gridContainer {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.alertContainer {
  position: fixed;
  top: 15vh;
  left: 50vw;
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  align-items: center;
  flex-direction: column;
}

.alert {
  pointer-events: none;
  background-color: white;
  padding: 0.75em;
  border-radius: 0.25em;
  opacity: 0.7;
  transition: opacity 500ms ease-in-out;
  margin-bottom: 0.5em;
}

.alert.hide {
  opacity: 0;
}

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

.playerGrid,
.cpuGrid {
  display: grid;
  justify-content: center;
  align-content: center;
  flex-grow: 1;
  grid-template-columns: repeat(5, 3em);
  grid-template-rows: repeat(6, 1fr);
  gap: 0.25em;
}

.keyboard {
  display: grid;
  /* sauce (couldn't get the staggered keys look without this) - https://stackoverflow.com/questions/51284823/how-to-offset-a-div-in-a-css-grid */
  grid-template-columns: repeat(20, minmax(auto, 0.65em));
  grid-auto-rows: 3em;
  gap: 0.25em;
  justify-content: center;
  bottom: 0;
}

.key {
  font-size: inherit;
  grid-column: span 2;
  border: none;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: hsl(
    var(--hue, 200),
    var(--saturation, 1%),
    calc(var(--lightness-offset, 0%) + var(--lightness, 38%))
  );
  color: white;
  fill: white;
  text-transform: uppercase;
  border-radius: 0.25em;
  user-select: none;
}

.key.large {
  grid-column: span 3;
}

.key > svg {
  width: 1.75em;
  height: 1.75em;
}

.player-keyboard > .key:hover {
  --lightness-offset: 10%;
  cursor: pointer;
}

.key.bad {
  background-color: var(--bad);
}

.key.valid {
  background-color: var(--valid);
}

.key.placed {
  background-color: var(--placed);
}

.playerLabel {
  text-align: center;
  margin: 1.5em;
  color: white;
  font-family: "Courier New", Courier, monospace;
}

.tile {
  color: white;
  border: 0.05em solid hsl(240, 2%, 23%);
  font-size: 2em;
  text-transform: capitalize;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  align-content: center;
  user-select: none;
  transition: transform 150ms linear;
}

.tile[data-state="active"] {
  border-color: rgba(242, 242, 242, 0.342);
}

.tile[data-state="bad"] {
  border: none;
  background-color: var(--bad);
}

.tile[data-state="valid"] {
  border: none;
  background-color: var(--valid);
}

.tile[data-state="placed"] {
  border: none;
  background-color: var(--placed);
}

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

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

.tile.dance {
  animation: dance 500ms;
}

@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(-15%);
  }
  80% {
    transform: translateY(2.5%);
  }
  100% {
    transform: translateY(0%);
  }
}
