/* General styles */

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

* {
  box-sizing: border-box;
  --background: #0a0a0a;
  --on-background: #e5e5e5;
  --on-background-variant: #d4d4d4;
  --primary: #fb923c;
  --outline: #404040;
  --error: #f87171;
  --done: #4ade80;
  --surface: #171717;
  --surface-variant: #262626;
  --word-height: 31;
  --current-shadow: color-mix(in srgb, currentColor 10%, transparent);
}

body {
  margin: 0;
  color-scheme: dark;
  font-family: "rubik", Georgia, "Times New Roman", Times, serif;
  color: var(--on-background);
  background-color: var(--background);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.icon {
  width: 1em;
  height: 1em;
  fill: var(--on-background-variant);
  vertical-align: middle;
  margin-top: -2.35px;
  display: inline-block;
  background-size: contain;
}

a {
  text-decoration: none;
  color: var(--primary);
}

a:hover {
  text-decoration: underline;
}

button {
  cursor: pointer;
  border-radius: 6px;
  border: 0;
  background-color: transparent;
}

button.transparent {
  font-size: 24px;
  padding: 6px 10px;
}

button.transparent:hover {
  background-color: var(--current-shadow);
}

button.surface {
  font-size: 16px;
  padding: 6px 12px;
  color: var(--on-background-variant);
  background-color: var(--surface-variant);
}

button.chip {
  font-size: 18px;
  padding: 12px 42px;
  color: var(--background);
  background-color: var(--primary);
}

button:hover {
  filter: brightness(1.1);
}

input,
select {
  font-family: inherit;
  outline: 0;
  resize: none;
  font-size: 18px;
  padding: 8px;
  border: 1px solid var(--outline);
  border-radius: 4px;
  background-color: var(--surface);
}

input {
  text-transform: lowercase;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

select {
  font-size: 16px;
}

.select {
  position: relative;
  width: 150px;
}

.select select {
  width: 100%;
  border: 1px solid var(--outline);
  border-radius: 5px;
  appearance: none;
  background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="%23d4d4d4"><path d="M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 24px 24px;
}

ul {
  padding: 0;
  list-style: none;
}

main {
  display: flex;
  flex-grow: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 80%;
  margin: 0 auto;
}

footer {
  color: var(--on-background-variant);
  margin: 1rem auto;
}

/* Game styles */

time {
  color: var(--primary);
}

p {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  font-size: 22px;
  width: 80%;
  height: calc(var(--word-height) * 3px);
  overflow: hidden;
}

@media (min-width: 1024px) {
  p {
    width: 60%;
  }
}

section {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

kbd {
  position: relative;
  border-radius: 6px;
  padding: 4px 10px;
  background-color: var(--surface-variant);
}

kbd::after {
  content: "";
  position: absolute;
  left: -4px;
  bottom: 6.38px;
  border: solid var(--surface-variant);
  border-width: 0 10px 10px 0;
  transform: rotate(135deg);
  -webkit-transform: rotate(135deg);
}

word {
  padding: 2px 4px;
  border-radius: 4px;
}

word.incorrect {
  color: var(--error);
}

word.correct {
  color: var(--done);
}

word.current {
  background-color: var(--current-shadow);
}

letter.incorrect {
  text-decoration-line: underline;
  color: var(--error);
}

/* Score styles */

dialog {
  padding: 1.5rem;
  border-radius: 6px;
  background-color: var(--surface);
  border: var(--surface-variant) 1px solid;
}

dialog:-internal-dialog-in-top-layer::backdrop {
  background-color: rgba(0, 0, 0, 0.8);
}

dialog span#resume-keystrokes {
  font-size: 12px;
}

dialog span#correct-keystrokes {
  color: var(--done);
}

dialog span#incorrect-keystrokes {
  color: var(--error);
}

dialog header {
  text-align: center;
}

dialog header:focus {
  outline: none;
}

dialog header h1 {
  font-size: 46px;
  margin: 0;
}

dialog header h2 {
  font-weight: normal;
}

dialog header h4 {
  font-weight: normal;
  font-size: 14px;
  margin: -8px 0 0 0;
  color: var(--on-background-variant);
}

dialog span#incorrect-words {
  color: var(--error);
}

dialog span#correct-words {
  color: var(--done);
}

dialog span#words-per-minute {
  color: var(--primary);
}

dialog ul {
  width: 80%;
  margin: 2rem auto;
}

dialog li {
  padding: 10px 0;
  font-size: 18px;
  border-bottom: 1px solid;
  border-color: var(--outline);
  color: var(--on-background);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

dialog li span:first-child {
  color: var(--on-background-variant);
}

dialog footer {
  display: flex;
  justify-content: center;
}

dialog#score {
  width: 380px;
}

/* Settings styles */

dialog#settings {
  width: 540px;
}

dialog#settings header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 90%;
  margin: 0 auto;
}

dialog#settings input {
  width: 150px;
}
