:root {
  --lightgray: #e8e8e8;
  --midgray: #ababab;
  --darkgray: #686868;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 62.5%;
}

main {
  font-size: 1.6rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5rem;
  padding: 0 5rem;
}

h1 {
  font-family: 'Joti One', serif;
  font-weight: 400;
  font-style: normal;
  width: 100%;
  text-align: center;
  font-size: 5rem;
  margin-bottom: 5rem;
  padding: 2rem 5rem;
}

/* Board */
.board-wrapper {
  flex: auto;
  display: flex;
  justify-content: end;
  align-items: start;
}

.board {
  background-color: var(--lightgray);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: fit-content;
  align-items: center;
  padding: 1rem;
  gap: 5rem;
  border-radius: 2rem;
}

.board-control {
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Grid Control */
#toggle-grid {
  border-radius: 50%;
  padding: 0.5rem;
}

#toggle-grid.checked {
  background-color: var(--lightgray);
}

.grid-size .bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
}

#grid-size-number {
  width: 7rem;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  border: none;
  outline: 0.1rem solid var(--lightgray);
  text-align: center;
}

#grid-size-number:focus {
  outline: 0.1rem solid var(--darkgray);
}

#grid-size-range {
  appearance: none;
  width: 18rem;
  height: 1rem;
  border-radius: 2rem;
  background: linear-gradient(90deg, var(--darkgray) 30%, var(--lightgray) 30%);
  cursor: pointer;
}

/* Thumb: for Chrome, Safari, Edge */
#grid-size-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 2.5rem;
  height: 2.5rem;
  border: 0.2rem solid var(--darkgray);
  border-radius: 2rem;
  background: #ffffff;
  box-shadow: none;
}

/* Thumb: for Firefox */
#grid-size-range::-moz-range-thumb {
  width: 2.5rem;
  height: 2.5rem;
  border: 0.2rem solid var(--darkgray);
  border-radius: 2rem;
  background: #ffffff;
  box-shadow: none;
}

/* Board Controls */
#rainbow-checkbox {
  content: url(https://img.icons8.com/?size=100&id=TKkMHrWl9Fe9&format=png&color=000000);
}

#brush-radio {
  content: url(https://img.icons8.com/?size=100&id=oqO6o4EHk9ME&format=png&color=000000);
}

#eraser-radio {
  content: url(https://img.icons8.com/?size=100&id=84INfFRwy0iG&format=png&color=000000);
}

#bucket-radio {
  content: url(https://img.icons8.com/?size=100&id=CFNKyVyM8D55&format=png&color=000000);
}

#grid-size-icon,
#frame-icon,
#color-palette,
#rainbow-checkbox,
#brush-radio,
#eraser-radio,
#bucket-radio,
#broom-icon,
#snapshot-icon {
  appearance: none;
  width: 4.8rem;
  height: 4.8rem;
  border: none;
  padding: 0.5rem;
}

#frame-icon.checked,
#color-palette.checked,
#rainbow-checkbox:checked,
#brush-radio:checked,
#eraser-radio:checked,
#bucket-radio:checked {
  background-color: white;
  outline: 0.1rem solid var(--darkgray);
  border-radius: 50%;
}

/* Popup */
.popup {
  background-color: white;
  position: absolute;
  top: 100%;
  left: 0;
  padding: 2rem;
  border-radius: 2rem;
  border: 0.1rem solid var(--lightgray);
  display: none;
  z-index: 1;
}

.on {
  display: block;
}

/* Tooltip */
.tooltip {
  position: relative;
  pointer-events: auto;
}

.tooltip .tooltip-text {
  font-family: monospace;
  font-size: 1.6rem;
  text-wrap: nowrap;
  text-align: center;
  color: white;
  visibility: hidden;
  min-width: 12rem;
  background-color: black;
  padding: 0.5rem 1rem;

  position: absolute;
  left: 50%;
  top: -25%;
  z-index: 1;
}

.tooltip:hover .tooltip-text {
  visibility: visible;
}

/* Canvas */
.canvas-wrapper {
  flex: 3;
  display: flex;
  justify-content: center;
}

.frame {
  background-color: black;
  width: min-content;
  height: min-content;
}

.frame-inner {
  background-color: white;
}

.canvas {
  width: 65rem;
  height: 65rem;
  background-color: white;
  display: flex;
  flex-wrap: wrap;
  outline: 0.1rem solid black;
}

.grid {
  flex: auto;
  background-color: white;
  border: 0.05rem solid black;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
}

.no-outline {
  border: none;
  outline: none;
}

@media screen and (max-width: 980px) {
  .board,
  .board-control {
    flex-direction: row;
  }
  .board-wrapper,
  .canvas-wrapper {
    justify-content: center;
  }
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 0.1rem;
  height: 0.1rem;
  padding: 0;
  margin: -0.1rem;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
