:root {
  --deepblue: #16232b;
  --brightblue: #05ecff;
  --orange: #ff5b04;
  --lightblue: #e4eef0;
  --lightgrey: #fafafa;
  --white: #fff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  text-box: trim-both cap alphabetic;
}

button {
  all: unset;
  text-box: trim-both cap alphabetic;
}

@font-face {
  font-family: "ABC Areal";
  src:
    url("./fonts/ABCAreal-Bold.woff2") format("woff2"),
    url("./fonts/ABCAreal-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

a {
  color: var(--orange);
}

label {
  display: inline-block;
}

/* Utility */

.mt-l {
  margin-top: 3rem;
}

.mt-m {
  margin-top: 1.5rem;
}

.mt-s {
  margin-top: 1.25rem;
}

.mb-xs {
  margin-bottom: 0.625rem;
}

.mb-m {
  margin-bottom: 1.5rem;
}

.mb-l {
  margin-bottom: 3rem;
}

.ml-s {
  margin-left: 1.25rem;
}

.mr-xs {
  margin-right: 0.625rem;
}

.mr-s {
  margin-right: 1.25rem;
}

.p-indent {
  padding-left: 1.25rem;
}

.hidden {
  display: none;
}

.d-flex {
  display: flex;
  gap: 0.5rem;
}

.link {
  cursor: pointer;
  text-decoration: underline;
}

.link:hover {
  text-decoration: none;
}

.link.ghost {
  color: var(--deepblue);
  text-decoration: none;
}

.link.ghost:hover {
  text-decoration: underline;
}

.link.inactive {
  opacity: 20%;
}

.col-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.orange {
  color: var(--orange);
}

/* General */

body {
  font-family: "ABC Areal", Arial, Helvetica, sans-serif;
  font-size: 0.875rem;
  line-height: 140%;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--deepblue);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  background-color: var(--lightgrey);
  padding-bottom: 3rem;
}

main {
  padding: 1.25rem 1.25rem 0;
  min-height: calc(100dvh - 3rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Nav */

.nav ul {
  display: flex;
}

.nav li {
  list-style: none;
}

.nav ul > li:not(:last-child)::after {
  content: ",\00a0";
}

/* Content */

article[data-page="how-to-play"],
article[data-page="about"],
article[data-page="show-movements"],
main:has(#how-to-play:checked, #about:checked) > header,
#video-example:not(:checked) ~ #how-to-play-video {
  display: none;
}

#how-to-play:checked ~ article[data-page="how-to-play"],
#about:checked ~ article[data-page="about"],
#show-movements:checked ~ article[data-page="show-movements"],
main:has(#how-to-play:checked, #about:checked) + footer #close-panels,
#video-example:checked ~ #how-to-play-video {
  display: block;
}

body:has(#how-to-play:checked, #about:checked) :is(#logo, #copyright),
body:has(#how-to-play:checked, #about:checked)
  .nav
  ul
  > li:not(:last-child)::after,
body:has(#how-to-play:checked) :is(label[for="about"]),
body:has(#about:checked) :is(label[for="how-to-play"]) {
  opacity: 20%;
}

#close-panels {
  color: var(--orange);
}

.page-container label[for="video-example"]::after,
.page-container label[for="show-movements"]::after {
  content: "\00a0↘";
}

.page-container:has(#video-example:checked) label[for="video-example"]::after,
.page-container:has(#show-movements:checked)
  label[for="show-movements"]::after {
  content: "\00a0↗";
}

.page-container:has(#video-example:not(:checked)) label[for="video-example"],
.page-container:has(#show-movements:not(:checked)) label[for="show-movements"] {
  opacity: 0.2;
}

#how-to-play-video {
  width: 100%;
  display: block;
}

/* Footer */

footer {
  position: fixed;
  bottom: 0;
  width: 100%;

  padding: 1.25rem 1.25rem 1.125rem;
  background-color: var(--lightgrey);
}

footer div:last-child {
  text-align: right;
}

/* Header */

header {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Boards containers */

.game-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-top: 3px;
}

#next-level {
  color: var(--orange);
}

/* Board */

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  aspect-ratio: 1 / 1;
}

.board li {
  list-style: none;
  background-color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
}

.board li:nth-child(odd) {
  background-color: var(--lightblue);
}

#board li:has(> *),
#board li.legal-move {
  cursor: pointer;
}

#board li.selected {
  outline: 6px solid var(--brightblue);
  outline-offset: -6px;
}

.board li.legal-move::after {
  content: "";
  width: 25%;
  aspect-ratio: 1 / 1;
  background-color: var(--brightblue);
}

#board li.correct-position svg {
  color: var(--orange);
}

.square svg {
  width: 40%;
  height: auto;
  color: var(--deepblue);
}

#final-board > .square svg {
  color: orangered;
}

@media screen and (width > 720px) {
  .col-2 {
    gap: 2.5rem;
  }

  main {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2.5rem;

    padding: 2.5rem 2.5rem 0;
  }

  footer {
    padding: 2.5rem 2.5rem 2.125rem;
  }

  main:has(#how-to-play:checked, #about:checked) > header {
    display: flex;
    opacity: 20%;
    pointer-events: none;
  }
}

@media screen and (width > 1280px) {
  header {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2.5rem;
    height: fit-content;
  }

  #final-board-container.col-2 {
    display: flex;
    flex-direction: column;
    row-gap: 1.5rem;
  }

  #final-board-container > .game-info {
    flex: 1 1 auto;
  }

  #board-container {
    grid-column: span 2;
    height: fit-content;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2.5rem;
  }

  .page-container {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 2.5rem;
  }

  .page-container p,
  .page-container label,
  #how-to-play-video,
  .tabs-container {
    grid-column: span 2;
  }

  article[data-page="show-movements"] {
    grid-column: span 3;
  }

  article[data-page="show-movements"] > div {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 2.5rem;
    row-gap: 1rem;
  }

  article[data-page="show-movements"] > div > :nth-child(3) {
    grid-column: 1;
  }

  main:has(#how-to-play:checked, #about:checked) > header {
    display: grid;
  }
}
