:root {
  color-scheme: light dark;

  --toolheight: 6rem;
  --itemheight: calc(var(--toolheight) - 0.9rem);
  --statusheight: 1.25rem;
  --rulerheight: 1.25rem;
  --purple2: light-dark(#e5c4ff, #650191);
  --purple: #b78fd8;
  --font: "Hack"; /* Hack, "Courier New", Courier, monospace */
  --fontsize: 14px;

  --top: 0.2rem;

  --background: light-dark(#d1d1d1, #454545);
  --secondary: light-dark(#6d6d6d, #ababab);
  --background-gradient: light-dark(#ababab, rgb(87, 87, 87));
}

@font-face {
  font-family: Hack;
  src: url("./fonts/Hack-Regular.ttf");
}

* {
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-size: var(--fontsize);
  font-family: var(--font);
}

/* TODO Need to change some things to allow consistent viewing across different screen sizes like phone, 
regular size monitor, wide/ultra wide */
body {
  height: 100svh;
  width: 100svw;
  background: linear-gradient(
    135deg,
    var(--background) 0%,
    var(--background-gradient) 100%
  );
}

.cursor {
  width: 10px;
  height: 10px;
  background-color: var(--secondary);
  position: absolute;
  border: 1px black solid;
}
/* .cursor {
  width: 10px;               
  height: 10px;
  position: absolute;
  border: 1px solid #000;    
}
.cursor-label {
  position: absolute;
  top: -16px;               
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #fff;
  text-shadow: 0 0 2px #000; 
  white-space: nowrap;
  pointer-events: none;     
} */

/* Nothing */
/* #ribbon {
  width: 100svw;
  height: 1.5rem;
  background-color: rgb(67, 46, 148);
  overflow: visible;
}

#quicktoolbar {
  width: 100svw;
  height: 1.5rem;
  background-color: rgb(147, 59, 59);
  overflow: visible;
} */

/* main top UI  */
#toolbar {
  /* width: 100svw; */
  height: var(--toolheight);
  overflow: visible;
  display: flex;
  justify-content: space-between;
  /* align-items: center; */
  margin-top: -0.3rem;
  /* margin-left: .1rem; */
}

#toolbar-left {
  /* width: 100svw; */
  height: var(--toolheight);
  overflow: visible;
  display: flex;
  /* margin-left: -0.4rem; */
  align-items: center;
  flex-wrap: wrap;
  margin-left: 0.05rem;
  gap: 0.1rem;
}

#toolbar-right {
  /* width: 100svw; */
  height: var(--toolheight);
  overflow: visible;
  display: flex;
  /* justify-content: space-between; */
  /* margin-left: -0.4rem; */
  margin-right: 0.3rem;
  align-items: center;
}

#toolbar button.active {
  background-color: var(--secondary);
  /* box-shadow: 0px 0px 1px 1px var(--purple); */
}

#toolbar button svg.active {
  fill: var(--background);
}

/* in the name: drawing area */
#drawingarea {
  width: 100svw;
  height: calc(
    100svh - var(--toolheight) - var(--rulerheight) - var(--statusheight)
  );
  touch-action: none; /* for screen users */
  grid-column: 2 / 3;
  grid-row: 2 / 3;
}

canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* For the color pickers === primary/secondary/userColor */
input[type="color"] {
  width: 6rem;
  height: 6rem;
  border: 1px transparent;
  margin-top: 1px;
  margin-right: -0.25rem;

  background-color: transparent;
}

/* #primaryPicker,
#secondaryPicker,
#userColor {

} */

#customInputUsernameBox {
  /* background-color: var(--background); */
  /* height: var(--itemheight); */
  height: var(--itemheight);
  background-color: transparent;

  color: var(--secondary);
  /* border: var(--secondary) 2px solid; */
  border: transparent 2px solid;
  /* border: red 1px solid; */
  /* padding-left: 0.5rem; */
  text-align: left;
}

.custom-dropdown-username-box {
  font-size: var(--fontsize);
  font-family: var(--font);
  /* padding: 2px 4px; */
  width: 11rem;
  height: var(--itemheight);
  margin-left: 0.3rem;
  /* margin-right: 2rem; */
  /* margin-right: .3rem; */
  text-align: left;
  border: 1px transparent solid;
}

.custom-dropdown-username-box input {
  width: 100%;
  /* margin-top: 0.1rem; */

  border: var(--secondary) 2px solid;
  font-size: var(--fontsize);
  font-family: var(--font);
  outline: none;
  transition: none;
  appearance: none;
  text-align: center; /* Center-align text for consistent positioning */
  background-image: none;
  background-repeat: no-repeat;
}

#customInputBrushsizeBox {
  /* background-color: var(--background); */
  /* height: var(--itemheight); */
  height: var(--itemheight);
  background-color: transparent;

  color: var(--secondary);
  /* border: var(--secondary) 2px solid; */
  border: transparent 2px solid;
  /* border: red 1px solid; */
  padding-left: 0.5rem;
  text-align: left;
}

.custom-dropdown-brushsize-box {
  position: relative;
  display: inline-block;
  /* height: var(--itemheight); */
  /* width: 175px; */
  width: 12.5rem;

  /* margin-right: 17.5px; */
  /* margin-right: 8.5px; */
  overflow: visible;
  background-color: transparent;
  color: var(--secondary);
}

/* Input field with dynamic brush size preview */
/* Input field with brush size preview on the right */
.custom-dropdown-brushsize-box input {
  width: 100%;
  margin-top: 0.1rem;

  border: var(--secondary) 2px solid;
  font-size: var(--fontsize);
  font-family: var(--font);
  outline: none;
  transition: none;
  appearance: none;
  text-align: center; /* Center-align text for consistent positioning */
  background-image: none;
  background-repeat: no-repeat;
}

.custom-dropdown-brushsize-box input::selection {
  background-color: var(--purple);
}

/* Ensure no change on focus */
.custom-dropdown-brushsize-box input:focus {
  border: 1px solid var(--secondary);
  /* box-shadow: inset 0 0 0 1px #ffffff; */ /* box-shadow: 0 0 10px 2px #ddc6f0;; Prevent focus shadow */
  outline: none; /* Prevent focus outline */
  transition: none; /* Ensure no visual transition */
  align-items: center;
}

/* Dropdown list styling */
.actual-dropdown-list-brushsize-box {
  display: none; /* Hidden by default */
  position: absolute;
  /* top: 100%;  */
  width: 100%;

  /* width: 158px; */
  /* border-top: 1px solid var(--secondary);
  border-left: 1px solid var(--secondary);
  border-right: 1px solid var(--secondary);
  border-bottom: 1px solid var(--secondary); */
  /* left: 0.7rem; */
  /* padding-right: 12px; */

  background-color: var(--background);

  margin: 0;
  list-style: none;
  z-index: 1; /* LUL */
}

.actual-dropdown-list-brushsize-box.show {
  display: block;
}

.dropdown-item {
  display: flex; /* Align text and line horizontally */
  align-items: center;
  justify-content: start; /* Space between the number and the line preview */
  /* justify-content: space-evenly; */
  padding-top: 8px;
  padding-bottom: 8px;
  padding-right: 0px;
  padding-left: 5px;
  font-family: var(--font); /* Match input font */
  font-size: 14px;
  cursor: pointer;
  height: calc(var(--toolheight) / 4); /* Ensure consistent height */
  width: 11.6rem;
}

.dropdown-item:hover {
  background-color: var(--purple2);
}
.dropdown-item:active {
  background-color: var(--purple);
}

.size-label {
  text-align: center; /* Align numbers in dropdown */
  margin-right: 10px; /* Space between label and line preview */
  width: 20px; /* Fixed width for numbers, handles up to 3 digits */
}

.size-line {
  background-color: var(--secondary); /* Line color */
  display: inline-block;
  /* margin-left: 3px; */
  width: 131px; /* Consistent width for all line previews */
}

#main-tools {
  display: grid;
  grid-template-columns: repeat(2, 1.5rem);
  grid-template-rows: repeat(3, 1.5rem);
  gap: 0.3rem;
  align-items: center;
  justify-content: center;
  /* margin: auto 1rem; */

  /* margin-left: 0.25rem;
  padding-top: var(--top); */
  /* margin-right: -.2rem; super debateable option right here no kizzy no cappy */
  z-index: 1;
  overflow: visible;
}

#fillTool,
#pencil,
#undo,
#redo,
#eraser,
#straightLine {
  /* display: flex; */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;

  width: 1.7rem;
  height: 1.7rem;
  /* padding: 1px;
  margin-top: 0.2rem;
  margin-right: 0.25em;
  margin-left: 0.25em; */

  /* border: var(--secondary) 2px solid; */
  background-color: transparent;
  border: transparent 2px solid;
}

#fillTool svg,
#pencil svg,
#undo svg,
#redo svg,
#eraser svg,
#straightLine svg {
  /* margin: auto; */
  width: 20px;
  height: 20px;
  /* color: red;
  fill: red; */
  fill: var(--secondary);
}

#fillTool:hover,
#pencil:hover,
#undo:hover,
#redo:hover,
#eraser:hover,
#straightLine:hover {
  background-color: var(--purple2);
}

#fillTool:active,
#pencil:active,
#undo:active,
#redo:active,
#eraser:active,
#straightLine:active {
  background-color: var(--secondary);
  fill: var(--purple2);
}

#fillTool svg:active,
#pencil svg:active,
#undo svg:active,
#redo svg:active,
#eraser svg:active,
#undo svg:active,
#straightLine svg:active {
  /* box-shadow: 0px 0px 1px 0.5px var(--purple); */
  /* background-color: var(--secondary); */
  fill: var(--purple);
}

#paletteToggle {
  /* display: flex; */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;

  width: 6rem;
  height: 6rem;
  /* padding: 1px;
  margin-top: 0.2rem;
  margin-right: 0.25em;
  margin-left: 0.25em; */

  /* border: var(--secondary) 2px solid; */
  background-color: transparent;
  border: transparent 2px solid;
}

#paletteToggle svg {
  /* margin: auto; */
  width: 6rem;
  height: 6rem;
  /* color: red;
  fill: red; */
  fill: var(--secondary);
}

#paletteToggle:hover {
  background-color: var(--purple2);
}

#paletteToggle:active {
  background-color: var(--secondary);
  fill: var(--purple2);
}

#paletteToggle svg:active {
  fill: var(--purple);
}

.colorpalette-full {
  display: block;
}

.colorpalette-condensed {
  display: none;
  position: relative;
}

.colorpalette-condensed .dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border: 1px solid gray;
  z-index: 10;
}

.colorpalette-condensed.active .dropdown {
  display: block;
}

#colorpalette {
  display: grid;
  grid-template-columns: repeat(10, 25px);
  grid-template-rows: repeat(3, 25px);
  /* gap:1px; */
  /* padding-top: 2.5px; */
  /* margin-top: -.1rem; */

  margin-left: -0.07rem;
  margin-left: 0.15rem;

  position: relative;
  overflow: visible;
}

.swatch {
  /* box-sizing:border-box; */
  border: 0px solid var(--background);
  outline: 1px solid var(--secondary);
  cursor: pointer;
  /* overflow: visible; */
  margin-left: 1.5px;
  margin-top: 1.5px;
  margin-bottom: 1.5px;
  margin-right: 1.5px;
}

.swatch:hover {
  overflow: visible;
  outline: 1px solid #b217fb;
}

.adjuster {
  background-color: var(--background);
  width: 5px;
  height: 5px;
  position: absolute;
  border: var(--secondary) solid 2px;
  cursor: pointer;
}

#mainbody {
  margin: 0;
  display: grid;
  height: calc(100svh - var(--toolheight) - var(--statusheight));
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr;
}

#statusbar {
  height: var(--statusheight);
  padding: 0;
  background-color: transparent;
  width: 100svw;
  display: flex;
}

.statusbarValue {
  height: 100%;
  width: 12rem;
  font-size: 1rem;
  padding-right: 0.125rem;
  padding-left: 0.125rem;
  color: var(--secondary);
  font-weight: 500;
}

#completionbarContainer {
  border: var(--secondary) 1px solid;
  padding: 0;
  padding-bottom: 0.125rem;
}

#completionbar {
  height: 100%;
  width: 0%;
  background-color: var(--secondary);
  transition: width 0.2s ease-out; /* Adjust duration and easing as needed */
}

#top-ruler {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  background-color: transparent;
  height: var(--rulerheight);
  display: flex;
  padding: 0;
  width: 100%;
  position: relative;
}

#left-ruler {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
  background-color: transparent;
  width: var(--rulerheight);
  display: flex;
  flex-direction: column;
  padding: 0;
  height: 100%;
  position: relative;
}

.topSegment {
  border-right: var(--secondary) 1px solid;
  flex-shrink: 0;
}

.topNumber {
  height: 75%;
  width: 100%;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--secondary);
}

.topTick {
  height: 25%;
  width: 100%;
  display: flex;
  padding: 0;
}

.topSubtick {
  width: 10%;
  height: 100%;
  border-right: var(--secondary) 1px solid;
  box-sizing: border-box;
}

.topSubtick:last-child {
  border-right: var(--secondary) 0px solid;
}

#topIndicator {
  position: absolute;
  height: 100%;
  border-right: var(--secondary) 1px solid;
}

#leftIndicator {
  position: absolute;
  width: 100%;
  border-bottom: var(--secondary) 1px solid;
}

.leftSegment {
  border-bottom: var(--secondary) 1px solid;
  display: flex;
  flex-shrink: 0;
}

.leftNumber {
  height: 100%;
  width: 75%;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--secondary);
  writing-mode: sideways-lr;
  text-align: right;
}

.leftTick {
  height: 100%;
  width: 25%;
  padding: 0;
}

.leftSubtick {
  width: 100%;
  height: 10%;
  border-bottom: var(--secondary) 1px solid;
  box-sizing: border-box;
}

.leftSubtick:last-child {
  border-bottom: var(--secondary) 0px solid;
}

@media (max-width: 900px) {
  #colorpalette.colorpalette-full {
    display: none; /* !important */
  }
  .colorpalette-condensed {
    display: block;
  }
}
