:root {
  --grid-rows: 10;
  --grid-cols: 10;
}

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

body {
  height: 100vh;
  font-family: "Fira Sans", sans-serif;
}

.container {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "header header"
    "main main";
  height: 100%;
}

header {
  grid-area: header;
  background-color: #000;
  color: #fff;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;

  border-bottom: 1px solid white;
  box-shadow: 0 0 10px 5px rgba(95, 86, 86, 0.796);
  z-index: 10;
}

section.sidebar {
  --min-width: 200px;
  --bg-color: rgba(0, 0, 0, 0.796);
  grid-area: main;
  background-color: var(--bg-color);
  color: #fff;
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: relative;

  width: var(--min-width);
  transition: width 0.5s ease-in-out, padding 0.5s ease-in-out;
  z-index: 2;

  padding: 1rem;
}

.sidebar-toggler {
  position: absolute;
  top: 0;
  left: 100%;
}

@media only screen and (max-width: 850px) {
  section.sidebar {
    /* grid-area: main; */
    --bg-color: rgba(0, 0, 0, 0.842);
  }
}

.sidebar-toggler ion-icon {
  font-size: 2rem;
  color: var(--bg-color);
  cursor: pointer;
  transition: transform 0.2s ease-in-out;
}
section.sidebar.closed {
  width: 0;
  padding: 1rem 0;
}

section.sidebar.closed .sidebar-toggler ion-icon {
  transform: rotate(-180deg);
}

section.sidebar .sidebar-content::-webkit-scrollbar {
  display: none;
}

.algorithms {
  display: flex;
  flex-direction: column;
  gap: 2%;
  position: relative;
  max-height: 100%;

  /* transition: max-height 0.5s; */
}
.dropdown-title ion-icon {
  font-size: 1.2rem;
  color: white;
  cursor: pointer;
  display: block;
  transition: transform 0.2s ease-in-out;
}

.dropdown-title:has(+ :not(.minimized)) ion-icon {
  transform: rotate(180deg);
}

.algorithms.minimized {
  max-height: 0;
  overflow: hidden;
}

.sidebar-content .dropdown-title {
  width: 100%;
  display: flex;
  justify-content: space-between;
}

.algorithms label {
  cursor: pointer;
  padding: 0.5rem;
  font-size: 0.85rem;
  margin-left: 2%;
}

.algorithms label:is(:hover, :has(:checked)) {
  background-color: rgba(0, 0, 0, 1);
  border-radius: 5px;
}

input[type="radio"] {
  display: none;
}

.sidebar-content {
  display: flex;
  /* justify-content: space-between; */
  /* align-items: center; */
  flex-direction: column;
  /* grid-template-rows: auto; */

  gap: 5%;
  /* width: fit-content; */

  height: 100%;
  width: 100%;

  overflow-y: auto;

  white-space: nowrap;
}

.sidebar-content hr {
  border: 1px solid white;
  width: 100%;
  border-bottom: 0;
}

.grid-container {
  grid-area: main;
  position: relative;
  /* z-index: 0; */
}

.scrollable-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  overflow-y: auto;

  padding: 1rem;

  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 1rem;

  --grid-width: 90%;
  --grid-max-size: 90vmin;
}

/* .grid-wrapper {
  position: absolute;
  top: 20%;
  left: calc(50% - calc(min(var(--grid-max-size), var(--grid-width)) / 2));
  z-index: 5;
} */

.grid {
  --aspect-ratio: calc(var(--grid-cols) / var(--grid-rows));

  /* resize: both;
  -webkit-resize: both;
  overflow: auto; */
  width: min(var(--grid-max-size), var(--grid-width));
  height: min(
    var(--grid-max-size),
    calc(var(--grid-width) / var(--aspect-ratio))
  );

  /* margin: 0 auto; */
  border: 2px solid black;

  display: grid;
  grid-template-columns: repeat(var(--grid-cols), 1fr);
  grid-template-rows: repeat(var(--grid-rows), 1fr);

  user-select: none;
  -webkit-user-select: none;
}

#summary-container {
  /* position: absolute;
  top: 5%; */
  padding: 2%;
  left: calc(50% - calc(min(var(--grid-max-size), var(--grid-width)) / 2));
  width: min(var(--grid-max-size), var(--grid-width));
  height: min(
    var(--grid-max-size),
    calc(var(--grid-width) / var(--aspect-ratio))
  );
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  padding-left: 5%;
  align-items: flex-start;
  background-color: rgba(0, 0, 0, 1);
  background: linear-gradient(210deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 1));
  color: white;
  font-size: 1rem;
  font-weight: bold;
  z-index: 1;
}

#summary-container p {
  font-weight: normal;
}

#summary-container .key {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

#summary-container .key-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.key > .key-item > .key-item-color {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.5rem;
}

.cell {
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.672);
  background-color: transparent;

  --row-pos: 0;
  --col-pos: 0;

  counter-reset: row var(--row-pos) col var(--col-pos);
}

.cell::after {
  content: "(" counter(row) " , " counter(col) ")";
  display: block;
  position: absolute;
  width: 3rem;
  height: 1.5rem;
  top: 50%;

  visibility: hidden;
  transform: scale(0);
  transition: all 0.2s ease-in-out;

  font-size: 0.8rem;
  /* opacity: 0.7; */
  background-color: #000;
  color: #fff;
  padding: 5%;

  display: flex;
  justify-content: center;
  align-items: center;

  border-radius: 0.5rem;
  z-index: 2;
}

.cell:hover::after {
  visibility: visible;
  transform: scale(1);
}

.grid .cell.start,
.key-item-color.start-color {
  background-color: green;
}

.grid .cell.target,
.key-item-color.target-color {
  background-color: red;
}

.cell.frontier,
.key-item-color.frontier-color {
  background-color: rgb(137, 146, 137);
}

.cell.visited,
.key-item-color.visited-color {
  background-color: rgb(34, 34, 163);
}

.cell.path,
.key-item-color.path-color {
  background-color: rgb(227, 91, 114);
}

.cell.wall,
.key-item-color.wall-color {
  background-color: rgb(0, 0, 0);
}

input[type="number"] {
  width: 3rem;
  text-align: center;
}

.start-end-pos {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.start-end-pos h3 {
  margin-bottom: 0.3rem;
}

.pos-wrapper {
  display: flex;
  /* flex-direction: column; */
  /* align-items: center; */
  gap: 0.5rem;
}

.pos-wrapper label p {
  font-size: 0.8rem;
  /* font-weight: bold; */
}

#generate,
#stop-generate {
  font-size: 3rem;
  cursor: pointer;
  /* position: relative; */
  /* display: flex; */
  /* flex: 0 0 auto; */
  /* z-index: 1; */
}

.start-btn {
  position: relative;
}

.start-btn::after {
  content: "Please select a start and end position";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  background-color: rgba(0, 0, 0, 0.821);
  color: #fff;
  padding: 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  /* display: block; */
  z-index: 3;
  visibility: hidden;
  opacity: 0;
  transition: all 0.2s ease-in-out;
}

.start-btn:is(.start-error)::after {
  visibility: visible;
  opacity: 1;
}

.control-buttons {
  flex-shrink: 0;
  display: flex;
  /* flex-direction: column; */
  /* justify-content: space-between; */
  align-items: start;
  gap: 1rem;

  position: relative;
  /* width: 100%; */

  /* overflow: auto; */
}

.control-buttons button {
  /* background-color: #000; */
  color: #000;
  border: 2px solid #000;
  border-radius: 0.5rem;
  font-weight: bold;
  cursor: pointer;
  width: 90px;
  padding: 0.5rem 1rem;
}

.control-buttons button:disabled {
  background-color: #ccc !important;
  color: #000 !important;
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.control-buttons #clear {
  background-color: red;
  color: white;
}

.control-buttons #toggle-walls.active {
  background-color: #000;
  color: #fff;
  border-color: dodgerblue;
}

.control-buttons #erase-walls {
  background-color: dodgerblue;
}

h1 {
  font-size: 2em;
  font-weight: bold;
  font-family: "Zilla Slab", serif;
}
h2 {
  font-size: 1.5em;
  font-weight: bold;
  font-family: "Zilla Slab", serif;
}

h3,
.sidebar-content .dropdown-title p {
  font-size: 1.17em;
  font-weight: bold;
  font-family: "Lato", "Zilla Slab", serif;
  margin-bottom: 0.5rem;
}

input[type="number"] {
  font-size: 1em;
  font-weight: bold;
  font-family: "Lato", "Zilla Slab", serif;

  border: 2px solid #000;
  border-radius: 5px;
}

.hidden {
  visibility: hidden;
}

/* slider settings */
#anim-speed {
  --thumb-pos: -64.5px;
  --speed: 0;
  counter-reset: speed var(--speed);

  position: relative;

  appearance: none;
  height: 4px;
  border-radius: 5px;
  background: linear-gradient(30deg, red, #000);

  box-shadow: inset var(--thumb-pos) 0 #fff;
}

#anim-speed::after {
  content: "x" counter(speed);
  position: absolute;
  top: -150%;
  right: -25%;

  color: white;
}

#anim-speed::-webkit-slider-thumb {
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgb(251, 0, 0);
  cursor: pointer;
}

#anim-speed::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: red;
  cursor: pointer;
}

@media only screen and (max-width: 690px) {
  /* .grid {
    top: 35%;
  }

  #results-container {
    top: 7%;
  }

  .grid-size,
  .start-end-pos {
    justify-self: start;
  } */
}

/* mobile adjustments */
@media only screen and (max-width: 450px) and (min-width: 320px) {
}
