/*
Author: Yesiha Vang
File Name: paint.css
*/

/* Toolbar container */
#toolbar {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 12px 20px;
  background: #e3ddcf;
  border-bottom: 2px solid #e3ddcf;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Inputs and buttons */
#toolbar input,
#toolbar button {
  padding: 10px 14px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #f7f7f7;
  transition: 0.2s ease;
  font-family:  'Strichpunkt Sans', sans-serif;
}

/* Hover effect */
#toolbar button:hover,
#toolbar input:hover,
#brushType:hover {
  background: #f8ecd8;
  cursor: pointer;
}

/* Color picker */
#colorPicker {
  width: 60px;
  height: 60px;
  padding: 0;
  border-radius: 20%;
  border: none;
  cursor: pointer;
}

/* Brush size slider */
#brushSize {
  width: 120px;
}

/* Buttons */
#toolbar button {
  background: #f0f0f0;
  border: 1px solid #bbb;
}

#toolbar button:active {
  transform: scale(0.96);
}

/* Left-side vertical toolbar */
#toolbar {
  position: fixed;
  left: 0;
  top: 0;
  width: 138px;
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #94A16F;
  border-right: 2px solid #94A16F;
  box-shadow: 2px 0 8px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 15px 10px;
  z-index: 10;
}
#toolbar {
  scrollbar-width: thin;
  scrollbar-color: rgba(247, 159, 43, 0.463) transparent;
}
#toolbar::-webkit-scrollbar {
  width: 6px;
}
#toolbar::-webkit-scrollbar-track {
  background: transparent;
}
#toolbar::-webkit-scrollbar-thumb {
  background: rgba(31, 38, 20, 0.3);
  border-radius: 6px;
}
#toolbar::-webkit-scrollbar-thumb:hover {
  background: rgba(31, 38, 20, 0.55);
}
#toolbarToggle {
  display: block;
}

/* Style inputs and buttons */
#toolbar input,
#toolbar button {
  box-sizing: border-box;
  flex-shrink: 0;
}
#toolbar input {
  width: 90%;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid #f8e4c1;
  background: #f8e4c1;
  font-size: 14px;
}
#toolbar label {
  width: 90%;
  color: #341c11;
  font-family: 'Strichpunkt Sans', sans-serif;
  font-size: 14px;
}
#toolbar button {
  width: 90%;
  padding: 7px;
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid #f8e4c1;
  box-shadow: 2px 0 8px rgba(0,0,0,0.08);
  background: #f8e4c1;
  font-size: 14px;
  color: #341c11;
}
#board {
  border: none;
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  margin: none;
  background: #e3ddcf;
  cursor: crosshair;
}
#brushType {
    width: 90%;
    box-sizing: border-box;
    padding: 6px;
    border-radius: 8px;
    border: 1px solid #f8e4c1;
    background: #f8e4c1;
    color: #341c11;
    font-family: 'Strichpunkt Sans', sans-serif;
}
.size-control {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
    width: 90%;
}
.size-control label {
    width: 100%;
}
.size-control input[type="range"],
.size-control select {
    width: 100%;
}
.sticky {
  position: absolute;
  width: 150px;
  height: 150px;
  background: #fff8a6;
  border: 1px solid #e0d97c;
  padding: 10px;
  resize: both;
}


/* Brush slider */
#brushSize {
  accent-color: #C05223;
}
/* Eraser slider */
#eraserSize {
  accent-color: #C05223;
}


/* Notes */
#canvasContainer {
    position: fixed;
    left: 138px;
    top: 0;
    width: calc(100vw - 138px);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}
#board {
    display: block;
}
.sticky-note {
    position: absolute;
    width: 180px;
    min-height: 180px;
    cursor: grab;
    background: #F79F2B;
    border: 1px solid #e49227;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,.2);
    z-index: 50;
}
.note-header {
    background: #e49227;
    padding: 3px;
    cursor: move;
    border-radius: 8px 8px 0 0;
    font-family: 'Madimi One', serif;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.note-body {
    width: 100%;
    min-height: 140px;
    cursor: text;
    border: none;
    resize: none;
    padding: 3px;
    background: transparent;
    outline: none;
    box-sizing: border-box;
    font-family:  'Strichpunkt Sans', sans-serif;
}
.delete-note {
    background: #e49227;
    color: black;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    cursor: pointer;
    font-size: 10px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.1s;
}


/* Text */
.canvas-text {
    position: absolute;
    min-width: 150px;
    min-height: 40px;
    padding: 8px;
    font-size: 24px;
    background: transparent;
    outline: none;
    cursor: move;
    user-select: none;
    touch-action: none;
  font-family:  'Strichpunkt Sans', sans-serif;
}
.delete-text {
    background: #ff4d4d;
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 1%;
    font-size: 10px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.1s;
}
.delete-text:hover {
    background: #cc0000;
}


/* Touch on different devices */
.note-header {
    touch-action: none;
    cursor: move;
}
.sticky-note {
    touch-action: none;
}


/* Mobile */
@media (max-width: 550px) {
  #toolbar {
    position: fixed;
    inset: 0 0 auto;
    width: 100%;
    height: 224px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: 56px 56px 38px 38px;
    grid-template-areas:
      "color brush-size brush-size draw"
      "erase eraser-size eraser-size brush-type"
      "undo redo clear fill"
      "note text download toggle";
    align-items: stretch;
    justify-items: stretch;
    gap: 5px;
    padding: 8px;
    overflow: hidden;
    border: 0;
    border-bottom: 1px solid rgba(52, 28, 17, 0.15);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
    transition: transform 180ms ease;
  }
  #toolbarToggle {
    position: fixed;
    left: 50%;
    top: 224px;
    transform: translateX(-50%);
    width: 80px;
    height: 30px;
    z-index: 100;
    border: 1px solid #85925f;
    border-radius: 8px;
    background: #94A16F;
    color: #341c11;
    font: 11px 'Strichpunkt Sans', sans-serif;
    transition: top 180ms ease;
  }
  body.toolbar-collapsed #toolbar {
    transform: translateY(calc(-100% + 40px));
  }
  body.toolbar-collapsed #toolbarToggle {
    top: 24px;
    z-index: 9;
  }
  #colorPicker {
    grid-area: color;
    width: 100%;
    height: 42px;
    align-self: center;
  }
  #brushSizeControl {
    grid-area: brush-size;
  }
  #eraserSizeControl {
    grid-area: eraser-size;
  }
  #brushTypeControl {
    grid-area: brush-type;
    width: 100%;
  }
  #toolbar .size-control {
    justify-content: center;
    min-width: 0;
  }
  #toolbar label {
    width: 100%;
    font-size: 12px;
    line-height: 1;
  }
  #toolbar input[type="range"],
  #toolbar select {
    width: 100%;
    min-width: 0;
    height: 24px;
    padding: 0 4px;
  }
  #brushType {
    height: 28px;
    padding: 2px 4px;
    font-size: 12px;
  }
  #toolbar button {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    height: 100%;
    padding: 4px 2px;
    font-size: 12px;
    line-height: 1.1;
  }
  #drawButton {
    grid-area: draw;
  }
  #eraserButton {
    grid-area: erase;
  }
  #undoButton {
    grid-area: undo;
  }
  #redoButton {
    grid-area: redo;
  }
  #clearButton {
    grid-area: clear;
  }
  #fillButton {
    grid-area: fill;
  }
  #addNote {
    grid-area: note;
  }
  #addText {
    grid-area: text;
  }
  #downloadButton {
    grid-area: download;
  }
  #toolbarToggle {
    grid-area: toggle;
  }
  #canvasContainer {
    left: 0;
    top: 224px;
    width: 100vw;
    height: calc(100vh - 224px);
    height: calc(100dvh - 224px);
    transition: top 180ms ease, height 180ms ease;
  }
  body.toolbar-collapsed #canvasContainer {
    top: 40px;
    height: calc(100vh - 40px);
    height: calc(100dvh - 40px);
  }
  .sticky-note {
    width: min(180px, calc(100vw - 24px));
  }
  .canvas-text {
    max-width: calc(100vw - 32px);
    font-size: 20px;
  }
}


/* Tablet */
  @media (min-width: 701px) and (max-width: 1024px) {
  #toolbar {
    position: fixed;
    inset: 0 0 auto;
    width: 100%;
    height: 224px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: 56px 56px 38px 38px;
    grid-template-areas:
      "color brush-size brush-size draw"
      "erase eraser-size eraser-size brush-type"
      "undo redo clear fill"
      "note text download toggle";
    align-items: stretch;
    justify-items: stretch;
    gap: 5px;
    padding: 8px;
    overflow: hidden;
    border: 0;
    border-bottom: 1px solid rgba(52, 28, 17, 0.15);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
    transition: transform 180ms ease;
  }
  #toolbarToggle {
    position: fixed;
    left: 50%;
    top: 224px;
    transform: translateX(-50%);
    width: 80px;
    height: 30px;
    z-index: 100;
    border: 1px solid #85925f;
    border-radius: 8px;
    background: #94A16F;
    color: #341c11;
    font: 11px 'Strichpunkt Sans', sans-serif;
    transition: top 180ms ease;
  }
  body.toolbar-collapsed #toolbar {
    transform: translateY(calc(-100% + 40px));
  }
  body.toolbar-collapsed #toolbarToggle {
    top: 24px;
    z-index: 9;
  }
  #colorPicker {
    grid-area: color;
    width: 100%;
    height: 42px;
    align-self: center;
  }
  #brushSizeControl {
    grid-area: brush-size;
  }
  #eraserSizeControl {
    grid-area: eraser-size;
  }
  #brushTypeControl {
    grid-area: brush-type;
    width: 100%;
  }
  #toolbar .size-control {
    justify-content: center;
    min-width: 0;
  }
  #toolbar label {
    width: 100%;
    font-size: 12px;
    line-height: 1;
  }
  #toolbar input[type="range"],
  #toolbar select {
    width: 100%;
    min-width: 0;
    height: 24px;
    padding: 0 4px;
  }
  #brushType {
    height: 28px;
    padding: 2px 4px;
    font-size: 12px;
  }
  #toolbar button {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    height: 100%;
    padding: 4px 2px;
    font-size: 12px;
    line-height: 1.1;
  }
  #drawButton {
    grid-area: draw;
  }
  #eraserButton {
    grid-area: erase;
  }
  #undoButton {
    grid-area: undo;
  }
  #redoButton {
    grid-area: redo;
  }
  #clearButton {
    grid-area: clear;
  }
  #fillButton {
    grid-area: fill;
  }
  #addNote {
    grid-area: note;
  }
  #addText {
    grid-area: text;
  }
  #downloadButton {
    grid-area: download;
  }
  #toolbarToggle {
    grid-area: toggle;
  }
  #canvasContainer {
    left: 0;
    top: 224px;
    width: 100vw;
    height: calc(100vh - 224px);
    height: calc(100dvh - 224px);
    transition: top 180ms ease, height 180ms ease;
  }
  body.toolbar-collapsed #canvasContainer {
    top: 40px;
    height: calc(100vh - 40px);
    height: calc(100dvh - 40px);
  }
  .sticky-note {
    width: min(180px, calc(100vw - 24px));
  }
  .canvas-text {
    max-width: calc(100vw - 32px);
    font-size: 20px;
  }
}


/* Desktop */
@media (max-width: 1000px) and (max-height: 520px) and (orientation: landscape) {
  #toolbar {
    left: 0;
    top: 0;
    width: 100%;
    height: 124px;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: 36px 36px 32px;
    grid-template-areas:
      "color brush-size brush-size draw erase eraser-size eraser-size"
      "brush-type brush-type undo redo clear fill note"
      "text download toggle";
    gap: 4px;
    padding: 5px;
  }
  #toolbarToggle {
    display: block;
    grid-area: toggle;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 2px;
    font-size: 11px;
  }
  #toolbar button {
    min-height: 34px;
    font-size: 11px;
  }
  #colorPicker {
    height: 34px;
  }
  #brushTypeControl {
    width: 100%;
  }
  #brushType {
    height: 22px;
  }
  #canvasContainer {
    left: 0;
    width: 100vw;
    top: 124px;
    height: calc(100vh - 124px);
    height: calc(100dvh - 124px);
  }
  #toolbarToggle {
    top: 124px;
  }
  body.toolbar-collapsed #toolbar {
    transform: translateY(calc(-100% + 36px));
  }
  body.toolbar-collapsed #toolbarToggle {
    top: 20px;
    z-index: 9;
  }
  body.toolbar-collapsed #canvasContainer {
    top: 36px;
    height: calc(100vh - 36px);
    height: calc(100dvh - 36px);
  }
}

@media (min-width: 1025px) {
  #toolbar {
    transition: transform 180ms ease;
  }
  #toolbarToggle {
    position: fixed;
    left: 138px;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 88px;
    padding: 6px 4px;
    z-index: 11;
    border: 1px solid #85925f;
    border-radius: 8px;
    background: #94A16F;
    color: #341c11;
    font: 11px 'Strichpunkt Sans', sans-serif;
    writing-mode: vertical-rl;
    transition: left 180ms ease;
  }
  body.toolbar-collapsed #toolbar {
    transform: translateX(calc(-100% + 40px));
  }
  body.toolbar-collapsed #toolbarToggle {
    left: 40px;
  }
  body.toolbar-collapsed #canvasContainer {
    left: 40px;
    width: calc(100vw - 40px);
  }
}