/* Classic MS Paint UI — adapted from JS Paint classic theme (MIT) */

.mspaint-window {
  display: flex;
  flex-direction: column;
  background: #c0c0c0;
  z-index: 200;
  font-family: Tahoma, "MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
  color: #000;
}

.mspaint-window .xp-title-text::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 4px;
  vertical-align: -3px;
  background: url("../assets/paint/tools.png") no-repeat -96px 0;
  image-rendering: pixelated;
}

.mspaint-window.xp-window {
  display: flex;
  flex-direction: column;
}

.mspaint-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: #c0c0c0;
}

/* main area */
.msp-main {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* toolbox */
.msp-toolbox {
  width: 54px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 2px 2px 4px;
  background: #c0c0c0;
  border-right: 1px solid #808080;
  box-shadow: 1px 0 0 #fff;
}
.msp-tools {
  display: flex;
  flex-wrap: wrap;
  width: 50px;
}
.msp-tool {
  position: relative;
  box-sizing: border-box;
  width: 25px;
  height: 25px;
  margin: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
  background: transparent;
  cursor: default;
  outline: 0;
}
.msp-tool::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 1px solid #fff;
  border-left: 1px solid #fff;
  border-right: 1px solid #808080;
  border-bottom: 1px solid #808080;
  pointer-events: none;
}
.msp-tool-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  background: url("../assets/paint/tools.png") no-repeat;
  background-position: calc(-16px * var(--icon)) 0;
  image-rendering: pixelated;
  pointer-events: none;
}
.msp-tool.selected,
.msp-tool:active {
  padding-bottom: 1px;
  border-top: 1px solid #000;
  border-left: 1px solid #000;
  border-right: 1px solid #fff;
  border-bottom: 1px solid #fff;
}
.msp-tool.selected::before,
.msp-tool:active::before {
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-right: 1px solid #c0c0c0;
  border-bottom: 1px solid #c0c0c0;
}
.msp-tool.selected .msp-tool-icon,
.msp-tool:active .msp-tool-icon {
  margin-top: -7px;
}

.msp-tool-options {
  margin-top: 3px;
  width: 41px;
  height: 66px;
  box-sizing: border-box;
  border: 1px solid #fff;
  border-top-color: #808080;
  border-left-color: #808080;
  display: flex;
  flex-direction: column;
  padding: 2px;
  gap: 2px;
}
.msp-opt-line {
  flex: 1;
  border: 0;
  background: #c0c0c0;
  padding: 0;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
}
.msp-opt-line span {
  display: block;
  background: #000;
  width: 80%;
}
.msp-opt-line.active {
  outline: 1px dotted #000;
  outline-offset: -2px;
}
.msp-opt-line[data-w="1"] span { height: 1px; }
.msp-opt-line[data-w="2"] span { height: 2px; }
.msp-opt-line[data-w="3"] span { height: 3px; }
.msp-opt-line[data-w="4"] span { height: 4px; }
.msp-opt-line[data-w="5"] span { height: 5px; }

/* workspace */
.msp-workspace {
  flex: 1;
  min-width: 0;
  overflow: auto;
  background: #808080;
  position: relative;
}
.msp-sheet {
  position: relative;
  display: inline-block;
  margin: 0;
  line-height: 0;
}
.msp-sheet canvas#paintCanvas {
  display: block;
  background: #fff;
  image-rendering: pixelated;
  cursor: crosshair;
  touch-action: none;
}
.msp-handle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #000080;
  border: 1px solid #fff;
  box-sizing: border-box;
  z-index: 2;
}
.msp-handle-br { right: -3px; bottom: -3px; cursor: nwse-resize; }
.msp-handle-r  { right: -3px; top: 50%; margin-top: -3px; cursor: ew-resize; }
.msp-handle-b  { bottom: -3px; left: 50%; margin-left: -3px; cursor: ns-resize; }

/* bottom: colors + status */
.msp-bottom {
  flex: 0 0 auto;
  background: #c0c0c0;
}
.msp-colors {
  height: 47px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.msp-color-box {
  display: flex;
  align-items: center;
  height: 32px;
}
.msp-current-colors {
  position: relative;
  width: 30px;
  height: 31px;
  flex: 0 0 auto;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-right: 1px solid #fff;
  border-bottom: 1px solid #fff;
  box-sizing: border-box;
}
.msp-current-colors::after {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  right: -2px;
  bottom: -2px;
  border-right: 1px solid #fff;
  border-bottom: 1px solid #fff;
  pointer-events: none;
}
.msp-fg-color,
.msp-bg-color {
  position: absolute;
  width: 15px;
  height: 15px;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-right: 1px solid #fff;
  border-bottom: 1px solid #fff;
  box-sizing: border-box;
}
.msp-fg-color { left: 2px; top: 4px; z-index: 2; }
.msp-bg-color { right: 3px; bottom: 3px; z-index: 1; }

.msp-palette {
  display: flex;
  flex-wrap: wrap;
  width: 224px;
  height: 32px;
  margin-left: 1px;
}
.msp-swatch {
  position: relative;
  width: 15px;
  height: 15px;
  margin: 0 0 1px 1px;
  padding: 0;
  border: 0;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-right: 1px solid #fff;
  border-bottom: 1px solid #fff;
  box-sizing: border-box;
  cursor: default;
}
.msp-swatch::after {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  right: -2px;
  bottom: -2px;
  border-right: 1px solid #fff;
  border-bottom: 1px solid #fff;
  pointer-events: none;
}

.msp-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 21px;
  padding: 2px 2px 0;
  gap: 2px;
  font-family: Tahoma, "Segoe UI", sans-serif;
  font-size: 11px;
  overflow: hidden;
  white-space: nowrap;
  user-select: none;
}
.msp-status-field {
  flex: 0 0 114px;
  height: 21px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  padding-left: 3px;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-right: 1px solid #fff;
  border-bottom: 1px solid #fff;
  min-width: 0;
  overflow: hidden;
}

.mspaint-window canvas,
.mspaint-window .msp-tool-icon {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}
