/* ---- CHESS ESCAPE STYLESHEET ---- */
/* ---- VARIABLES ---- */
:root {
  --background: #000;
  --modal-background: #0007;
  --interface: #333;
  --accent: #555;
  --accent-hover: #666;
  --text: #fff;
  --option-selected: #3c7d7d;
  --option-selected-border: #47b5b5;
}

/* ---- GENERAL STYLES ---- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  color: var(--text);
  font-family: "Roboto Slab", serif;
  font-weight: 300;
}
img {
  -webkit-user-drag: none;
  user-select: none;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}
b { font-weight: bold; }
body {
  background-color: var(--background);
}
#app {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  height: 100vh;
  overflow: hidden;
}
.back-button {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  top: 20px; left: 20px;
  width: 40px; height: 40px;
  border: 2px solid var(--accent);
  border-radius: 20px;
  font-size: 20px;
  background-color: var(--accent);
  cursor: pointer;
  overflow: hidden;
}
.back-button-sprite {
  width: 100%;
  height: 100%;
  clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 55% 70%, 50% 55%, 80% 55%, 80% 45%, 50% 45%, 55% 30%, 17% 50%, 55% 70%, 0% 100%);
  background-color: var(--interface);
}
.restart-button, .credits-button, .reset-data-button {
  position: absolute;
  bottom: 20px; right: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 5px 30px;
  border: 2px solid var(--accent-hover);
  background-color: var(--interface);
  color: var(--accent-hover);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  z-index: 99;
}
.credits-button {
  top: 10px; bottom: auto;
  left: 10px; right: auto;
}
.reset-data-button {
  top: 10px; bottom: auto;
}
.credits-button:hover, .reset-data-button:hover, .restart-button:hover { filter: brightness(120%); }
@keyframes fade-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes fade-out {
  0% { opacity: 1; }
  100% { opacity: 0; }
}
/* hover effects */
.back-button:hover, .restart-button:hover { filter: brightness(1.2); }

/* ---- LOADING SCREEN ---- */
#loading-div {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 99999;
}
.loading-game-title {
  position: absolute;
  top: 30%;
  font-size: 30px;
  text-align: center;
}
.loading-info {
  position: absolute;
  top: 60%;
  font-size: 20px;
  text-align: center;
  padding: 0 100px;
  opacity: .5;
}
.loading-div-part {
  flex: 1;
  width: 100%;
  background-color: var(--background);
}
#ld-part-1 { border-bottom: 1px solid var(--text); }
#ld-part-2 { border-top: 1px solid var(--text); }
#start-button {
  position: absolute;
  padding: 20px 40px;
  border: 2px solid var(--text);
  background-color: var(--background);
  cursor: pointer;
  font-size: 20px;
}
#loading-span {
  position: absolute;
  font-size: 20px;
  padding: 10px 20px;
  background-color: var(--background);
  border: 2px solid var(--text);
  border-radius: 20px;
}
#start-button:hover { filter: brightness(1.2); background-color: rgb(20, 20, 20) }
@keyframes scrollUp {
  0% { transform: translateY(0); }
  100% { transform: translateY(-100%); }
}
@keyframes scrollDown {
  0% { transform: translateY(0); }
  100% { transform: translateY(100%); }
}

/* ---- TITLE SCREEN ---- */
.title-screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 30px;
}
.title-box {
  width: 100%;
  height: 100%;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}
.title-animation {
  position: absolute;
  left: 0;
  width: 100%;
  height: 70%;
  filter: grayscale(100%);
  box-shadow: inset 0 0 100px var(--background);
  opacity: .2;
  background-image: url('sources/pattern.png');
  background-size: 25%;
}
.title-animation-activated { animation: 40s linear infinite titleAnimation; }
@keyframes titleAnimation {
  from {
    background-position-x: 0;
    background-position-y: 0;
  }
  to {  
    background-position-x: 1000px;
    background-position-y: 500px;
  }
}
.title {
  position: relative;
  font-size: 80px;
  text-align: center;
  letter-spacing: 6px;
  font-weight: bold;
  z-index: 999;
}
.title-buttons {
  flex: 1;
  display: grid;
  grid-template: 1fr 1fr / 1fr 1fr;
  gap: 30px;
  place-items: center;
}
.title-button:first-child { grid-column: 1 / 3; }
.title-button {
  width: 100%;
  height: 100%;
  border: none;
  font-size: 50px;
  font-weight: bold;
  cursor: pointer;
  background-color: var(--interface);
}
.title-button:hover { background-color: var(--accent); }
.credits {
  flex-basis: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  opacity: .4;
}

/* ---- OPTIONS ---- */
.options-box {
  width: 80%;
  height: 80%;
  background-color: var(--accent);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
}
.options-title {
  font-size: 40px;
  text-align: center;
  font-weight: bold;
  letter-spacing: 5px;
}
.options {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.option {
  width: 100%;
  flex-basis: 80px;
  display: flex;
  border-bottom: 2px solid var(--accent-hover);
}
.option:first-child { border-top: 2px solid var(--accent-hover); }
.option-title {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.option-boxes {
  flex: 2;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
}
.option-box {
  width: 50px;
  height: 50px;
  border: 2px solid var(--accent-hover);
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  cursor: pointer;
}
.option-box:hover { background-color: var(--accent-hover); }
.option-box-selected {
  background-color: var(--option-selected);
  border-color: var(--option-selected-border);
}
.option-box-selected:hover { background-color: var(--option-selected-border); }
.option-box-sprite {
  width: 100%;
  height: 100%;
}

/* ---- LEVEL SELECT ---- */
.level-select {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}
.level-select-box {
  width: 80%;
  height: 80%;
  padding: 20px;
  background-color: var(--interface);
  border-radius: 20px;
  display: grid;
  grid-template: 1fr 4fr 4fr 4fr 1fr / repeat(8, 1fr);
  place-items: center;
}
.level {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 100px; height: 100px;
  margin: 10px;
  font-size: 20px;
  border-radius: 20px;
  font-weight: bold;
  user-select: none;
  cursor: pointer;
  background-color: var(--accent);
  border-bottom: 6px solid var(--background);
}
.level:hover { background-color: var(--accent-hover); }
.level:active { border: none; }
.stars-container {
  position: absolute;
  bottom: 10px;
  width: 90%;
  height: 20%;
  display: flex;
  justify-content: space-evenly;
}
.level-select-star {
  height: 100%;
  width: 20%;
  background-image: url('sources/star-empty.svg');
  background-size: cover;
}
.blocked .level-select-star { display: none; }
.star-obtained {
  background-image: url('sources/star-full.svg');
}
.blocked {
  background-color: var(--background);
  color: transparent;
  border: none;
  cursor: default;
  background-image: url('sources/lock.svg');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 40%;
}
.blocked:hover { background-color: var(--background); }
.change-page-button {
  width: 20%;
  height: 70%;
  grid-column: 1 / 9;
  background-color: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}
.change-page-button:last-child { grid-row: 5 / 6; }
.change-page-button:hover { filter: brightness(150%); }
.page-sprite {
  height: 50%;
  width: 30px;
  background-color: var(--accent-hover);
  filter: brightness(130%);
}
.prev-page-sprite { clip-path: polygon(50% 0, 100% 100%, 80% 100%, 50% 50%, 25% 100%, 0 100%); }
.next-page-sprite { clip-path: polygon(25% 0, 50% 50%, 75% 0, 100% 0, 50% 100%, 50% 100%, 0 0); }
.page-button-blocked {
  filter: brightness(40%);
  cursor: default;
}
.page-button-blocked:hover { filter: brightness(40%); }

/* ---- LEVEL SCREEN / BOARD ---- */
.level-screen {
  display: flex;
  flex-direction: column;
  width: 100%; height: 100%;
}
.level-info {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  font-size: 40px;
  font-weight: bold;
  flex: 1;
  border-bottom: 2px solid var(--accent);
  user-select: none;
}
.board-box {
  flex: 5;
  display: flex;
  justify-content: center;
  align-items: center;
}
.board {
  position: relative;
}
#board-canvas {
  width: 100%;
  height: 100%;
}
#canvas-mask, #mouse-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.piece {
  position: absolute;
  left: 0;
  top: 0;
  cursor: pointer;
}
.object {
  position: absolute;
  left: 0;
  top: 0;
}
#objects-box, #pieces-box {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}
.star-animation { animation: 2s ease infinite star-movement; }
@keyframes pulse {
  0% { filter: sepia(200%); }
  100% { filter: sepia(0%); }
}
@keyframes pulse-blocked {
  0% { filter: brightness(0%);  }
  100% { filter: brightness(100%); }
}
@keyframes star-movement {
  0% { top: 0; filter: drop-shadow(0 0 0.2rem rgba(255, 255, 0, 50%)) brightness(100%); }
  50% { top: -7px; filter: drop-shadow(0 0 0.5rem rgba(255, 255, 0, 50%)) brightness(140%); }
  100% { top: 0; filter: drop-shadow(0 0 0.2rem rgba(255, 255, 0, 50%)) brightness(100%); }
}

/* ---- MODAL ---- */
.modal {
  position: absolute;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background-color: var(--modal-background);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999999;
}
.modal-box, .modal-box-video {
  width: 70%;
  height: 60%;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
  background-color: var(--interface);
  border-radius: 20px;
  padding: 0 80px;
  animation: 1s ease modalAppear;
}
.modal-box-video { height: 90%; }
.modal-box:has(> .credits-box) { height: 80%; }
.credits-box { font-size: 19px; text-align: center; }
.modal-text {
  font-size: 50px;
  text-align: center;
}
.modal-buttons {
  flex-basis: 50px;
  width: 100%;
  display: flex;
  gap: 80px;
}
.modal-button {
  flex: 1;
  border: none;
  background-color: var(--accent);
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  border-bottom: 4px solid black;
  border-radius: 20px;
  user-select: none;
}
.modal-button:hover { background-color: var(--accent-hover); }
.modal-button:active { border: none; }
@keyframes modalAppear {
  from { transform: scale(0%); }
  to { transform: scale(100%); }
}
.modal-video {
  width: 60%;
  height: 200px;
  border: 2px solid var(--text);
  background-color: var(--background);
}
.modal-stars {
  width: 40%;
  flex-basis: 60px;
  display: flex;
  justify-content: space-between;
  position: relative;
}
.modal-star {
  height: 100%;
  flex-basis: 30%;
  background-image: url('sources/star-empty.svg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}
.modal-star-obtained { background-image: url('sources/star-full.svg'); }
.info-button {
  position: absolute;
  width: 25px; height: 25px;
  top: -20px; right: -20px;
  background-color: var(--accent-hover);
  border: 2px solid var(--background);
  border-radius: 50%;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}
.info-tooltip {
  position: absolute;
  width: 80%;
  padding: 10px;
  left: 100%;
  background-color: var(--background);
  border: 2px solid var(--accent-hover);
  display: none;
}
.info-button:hover ~ .info-tooltip { display: block; }

/* ANDROID MEDIA QUERIES */
@media only screen and (width <= 720px) {
  .level-select-box {
    width: 95%;
    height: 90%;
    padding: 10px;
    grid-template: 2fr repeat(8, 4fr) 2fr / 1fr 1fr 1fr;
  }
  .level {
    width: 90% !important;
    justify-content: flex-start;
    height: 90% !important;
    margin: 0;
    padding: 7px;
    border-radius: 10px;
    border-bottom-width: 3px;
  }
  .level-info { font-size: 25px; }
  .stars-container {
    bottom: 7px;
    height: 30%;
  }
  .change-page-button {
    grid-column: 1 / 4;
    width: 60%;
  }
  .change-page-button:last-child { grid-row: 10 / 11; }
  .modal-text { font-size: 40px; }
  .credits-box { font-size: 14px; }
}
@media only screen and (500px <= width <= 720px) {
  .level { width: 80% !important; padding: 4px; }
  .stars-container {
    bottom: 4px;
    width: 70%;
    height: 40%;
  }
}
@media only screen and (width <= 500px) {
  .loading-game-title { font-size: 23px; }
  .loading-info { padding: 0 20px; font-size: 16px; }
  .title { font-size: 60px; }
  .title-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  .title-animation { background-size: 50%; }
  .options-box { width: 90%; }
  .modal-text { font-size: 30px; }
  .modal-box, .modal-box-video {
    width: 95%;
    padding: 0 10px;
  }
  .modal-video { width: 90%; }
  .level-info { flex-direction: column; }
  .modal-buttons { gap: 10px; }
  .info-tooltip { width: 160%; left: 50%; }
}
/* IPAD MEDIA QUERIES */
@media only screen and (720px < width < 1200px) {
  .level-select-box {
    width: 85%;
    padding: 10px;
    grid-template: 2fr repeat(4, 4fr) 2fr / repeat(6, 1fr);
  }
  .change-page-button {
    grid-column: 1 / 7;
    width: 60%;
  }
  .change-page-button:last-child { grid-row: 6 / 7;}
}
@media only screen and (500px < width < 1200px) {
  .title-animation { background-size: 35%; }
  .level { width: 80px; height: 80px; }
  .modal-box, .modal-box-video {
    width: 85%;
    padding: 0 40px;
  }
  .modal-buttons { gap: 40px; }
}
@media only screen and (500px < width < 1200px) and (height > 820px) {
  .title { font-size: 120px; }
  .options-box { width: 85%; }
  .option { flex-basis: 150px; }
  .option-title { font-size: 26px; padding: 20px; }
  .level-select-box {
    width: 85%;
    padding: 10px;
    grid-template: 1fr repeat(6, 4fr) 1fr / 1fr 1fr 1fr 1fr;
  }
  .change-page-button {
    grid-column: 1 / 5;
    width: 60%;
  }
  .change-page-button:last-child { grid-row: 8 / 9;}
  .modal-span { font-size: 30px; }
}
/* XXL MEDIA QUERIES */
@media only screen and (width > 1900px) {
  .loading-game-title { font-size: 50px; }
  #start-button {
    padding: 30px 60px;
    font-size: 30px;
  }
  .level {
    width: 150px;
    height: 150px;
    font-size: 36px;
  }
  .modal-box-video { padding: 0 100px; }
  .modal-video { width: 70%; height: 400px; }
  .modal-buttons { gap: 100px; }
  .modal-button {
    font-size: 28px;
    padding: 12px 0;
  }
  .modal-span { font-size: 22px; }
  .modal-text { font-size: 60px; }
  .modal-stars {
    width: 50%;
    flex-basis: 85px;
  }
  .option { flex-basis: 120px; }
  .option-title { font-size: 28px; }
  .option-box {
    width: 80px;
    height: 80px;
    font-size: 20px;
  }
  .credits-box { font-size: 26px; }
}