* {
  box-sizing: border-box;
}

:root {
  --input-background-colour: white;
  --input-set-colour: whitesmoke;
  --input-text-colour: black;

  --unused-colour-dot: #bfbfbf;
  --unused-colour-dash: #bfbfbf;

  --used-colour-dot: #4285f4;
  --used-colour-dash: #ff6d01;

  --over-colour-dot: red;
  --over-colour-dash: red;

  --centre-colour: black;

  --border-colour: black;
  --inner-border-width: 1px;
  --outer-border-width: 0.25rem;
  --selected-border-width: 2px;
  --outer-border-radius: 0.25rem;

  --clickable-text-color: #008;

  /* padding between dots/dashes and grid outline */
  --dotdash-padding: 0.75rem;
}

@font-face {
  font-family: "Morse";
  src: url("https://blog.alifeee.co.uk/font-workshop/fonts/vmorse/VMORSE.woff");
}
@font-face {
  font-family: "Arvo";
  src: url("/Arvo-Regular.ttf") format("truetype");
}

body {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: "Arvo", serif;
}
header {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1rem 0 0;
}
h1 {
  font-size: 3em;
  text-align: center;
  position: relative;
  margin: 0;
}
.help {
  position: absolute;
  right: -2.5rem;
  top: 0;
  bottom: 0;
  margin: auto 0;
  border-radius: 50%;
  border: 3px solid black;
  font-weight: 900;
  height: 2rem;
  width: 2rem;
  background: none;
  cursor: pointer;
  text-decoration: none;
  color: black;
  font-size: 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
}
.help span {
  display: block;
}
main {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "puzzle"
    "nextprev"
    "morse"
    "tutorial"
    "faq";
}

.puzzle {
  grid-area: puzzle;
}
.nextprev {
  grid-area: nextprev;
}
.morse {
  grid-area: morse;
}
@media screen and (min-width: 1200px) {
  main {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "puzzle morse"
      "nextprev morse"
      "tutorial tutorial"
      "faq faq";
  }
}

.puzzle .centre {
  background-color: var(--centre-colour);
}

.puzzle input {
  border-radius: 0;
  width: 3rem;
  height: 3rem;

  border-color: var(--border-colour);
  border-width: var(--inner-border-width);
  border-style: solid;

  background-color: var(--input-background-colour);
  color: var(--input-text-colour);

  font-size: 1.75rem;
  text-align: center;
  font-weight: bold;
  text-transform: uppercase;
  font-family: "Arvo", serif;
}
.puzzle input:focus {
  outline: none;
  border-width: var(--selected-border-width);
}
.puzzle input:disabled {
  background-color: var(--input-set-colour);
}

.hidden {
  display: none;
}
.dot.used {
  background-color: var(--used-colour-dot);
}
.dash.used {
  background-color: var(--used-colour-dash);
}
.dot.over {
  background-color: var(--over-colour-dot);
}
.dash.over {
  background-color: var(--over-colour-dash);
}
.over {
  animation: shakeLeftRight 0.82s cubic-bezier(0.36, 0.07, 0.19, 0.97) infinite;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  perspective: 1000px;
}
.left .over,
.right .over {
  animation-name: shakeUpDown;
}
@keyframes shakeLeftRight {
  10%,
  90% {
    transform: translate3d(-1px, 0, 0);
  }

  20%,
  80% {
    transform: translate3d(2px, 0, 0);
  }

  30%,
  50%,
  70% {
    transform: translate3d(-4px, 0, 0);
  }

  40%,
  60% {
    transform: translate3d(4px, 0, 0);
  }
}

@keyframes shakeUpDown {
  10%,
  90% {
    transform: translate3d(0, -1px, 0);
  }

  20%,
  80% {
    transform: translate3d(0, 2px, 0);
  }

  30%,
  50%,
  70% {
    transform: translate3d(0, -4px, 0);
  }

  40%,
  60% {
    transform: translate3d(0, 4px, 0);
  }
}

.dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background-color: var(--unused-colour-dot);
  flex-shrink: 0;
}
.dots {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}
.top.dots {
  flex-direction: column-reverse;
  margin-bottom: var(--dotdash-padding);
  justify-content: flex-start;
}
.left.dots {
  flex-direction: row-reverse;
  margin-right: var(--dotdash-padding);
  justify-content: flex-start;
}
.dash {
  width: 1.5rem;
  height: 0.5rem;
  border-radius: 0%;
  background-color: var(--unused-colour-dash);
}
.dashes {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.bottom.dashes {
  flex-direction: column;
  margin-top: var(--dotdash-padding);
  justify-content: flex-start;
}
.right.dashes {
  flex-direction: row;
  margin-left: var(--dotdash-padding);
  justify-content: flex-start;
}
.right.dashes .dash {
  height: 1.5rem;
  width: 0.5rem;
}

.nextprev {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin: 1rem;
}
.nextprev a,
.nextprev span {
  display: block;
  padding: 0.5rem 1rem;
  margin: 0.5rem;
  background-color: black;
  color: white;
  text-decoration: none;
  border-radius: 0.5rem;
}
.nextprev a:hover {
  background-color: gray;
  color: black;
}
.nextprev span {
  background-color: gray;
  cursor: not-allowed;
}

section.morse {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
}
section.morse form {
  margin: 1rem;
}
section.morse form input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
}
section.morse .showfilter {
  border: 0;
  padding: 0;
  background: none;
  color: var(--clickable-text-color);
}
section.morse .showfilter:hover {
  cursor: pointer;
}
section.morse .filterdots {
  min-width: 10rem;
}

.cheatsheet {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
}
.cheatsheet .translation {
  text-align: center;
  margin: 0.5rem;
  font-size: 2rem;
}
.cheatsheet .translation .morse {
  display: flex;
  justify-content: center;
  align-items: center;
}
.cheatsheet .translation.unavailable {
  opacity: 0.25;
}
.cheatsheet .vmorse {
  font-family: "Morse";
}
.translation .dot {
  margin: 0.25rem;
}
.translation .dash {
  margin: 0.25rem;
}

/* big screens */
@media screen and (min-width: 1200px) {
  .puzzle,
  .nextprev {
    justify-self: end;
    padding-right: 1rem;
  }
  section.morse {
    max-width: 45rem;
    padding-right: 5rem;
  }
}

/* small screens */
@media screen and (max-width: 600px) {
  .puzzle input {
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
  }
  .dot {
    width: 0.5rem;
    height: 0.5rem;
  }
  .dash {
    width: 1rem;
    height: 0.25rem;
  }
  .right.dashes .dash {
    height: 1rem;
    width: 0.25rem;
  }
  .cheatsheet .translation {
    font-size: 1.5rem;
  }
}

.tutorial,
.faq {
  display: flex;
  flex-direction: column;
  grid-area: tutorial;
  margin: 1rem;
  align-items: center;
  text-align: center;
}
.tutorial > * {
  max-width: 40rem;
}
.inline-block {
  display: inline-block;
}

.faq {
  grid-area: faq;
}
.faq h3 {
  margin: 0;
}

footer {
  margin: auto 1rem 1rem;
  display: flex;
  justify-content: center;
  align-items: end;
  text-align: center;
}
