/* style.css: layout skeleton only (matches the whiteboard sketch).
   No theme yet; colors, fonts and visuals get layered on later.

   +--------------------------------------------------+
   | [gear]        GHOULLE banner / 5:00     [round]  |  header
   +------+---------------------------------+---------+
   | undo |                                 | brush/  |
   | clear|            canvas               | eraser/ |
   |      |                                 | dropper |
   | save |                                 | wheel   |
   |      |                                 | sliders |
   |      |                                 | sizes   |
   |      |                                 | swatches|
   +------+---------------------------------+---------+
*/

* {
  box-sizing: border-box;
}

@font-face {
  font-family: "Cairopixel";
  src: url("../assets/cairopixel/Cairopixel.ttf") format("truetype");
  font-display: swap;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: "Cairopixel", Arial, sans-serif;
}

button,
input,
select,
textarea,
output,
summary {
  font-family: inherit;
}

h1, h2, h3, b, strong, th, summary, label, button, output, figcaption {
  font-weight: normal;
}

body {
  background: #1b1026 url("../assets/ui/ui-backdrop.GIF") center / cover
    no-repeat fixed;
  image-rendering: pixelated;
}

/* Logo is 127x41 pixel art. Same size on every screen; scales with the
   window's width (height follows from the aspect ratio). */
.logo {
  display: block;
  width: clamp(190px, 30vw, 560px);
  height: auto;
  image-rendering: pixelated;
  max-width: 100%;
  margin: 0 auto;
}

@media (max-height: 800px) {
  #workspace { padding: 6px 12px; }
}

#toolbar,
#color-picker-panel {
  background: transparent;
  color: #fff;
  text-shadow: 0 1px 3px #000;
}
#round-timer {
  color: #fff;
  text-shadow: 0 1px 3px #000;
}

#app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  overflow: hidden;
}

#page-footer {
  padding: 4px 12px 8px;
  color: #fff;
  font-size: 14px;
  text-align: center;
  text-shadow: 0 1px 3px #000;
}

#streak {
  color: #fff;
  font-size: 16px;
  text-shadow: 0 1px 3px #000;
  white-space: nowrap;
}

#canvas-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  min-height: 0;
}

/* spacers that center the canvas frame, each 10% of the column height */
#canvas-col::before,
#canvas-col::after {
  content: "";
  flex: 1 1 0;
}
#canvas-col::after { order: 3; }
#draw-footer { order: 2; } /* right under the canvas, above the bottom spacer */

#draw-footer {
  justify-content: center;
  padding-top: 16px;
}

/* ---- header ---- */
#top-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
}

#settings-btn {
  justify-self: start;
}

.title-block {
  text-align: center;
}

.banner {
  margin: 0;
  font-size: 28px;
}

#round-timer {
  font-size: 32px;
  font-variant-numeric: tabular-nums;
}

#round-timer.urgent {
  color: red;
}

#round-slot {
  justify-self: end;
}

/* ---- 3-column workspace ---- */
#workspace {
  display: grid;
  grid-template-columns: 240px 1fr 240px; /* equal side columns keep the canvas on the screen's center line */
  gap: 12px;
  padding: 12px;
  min-height: 0; /* lets the canvas shrink instead of overflowing */
}

/* left action strip: undo / clear / save */
#toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-self: start;
  width: 72px;
  gap: 8px;
  padding: 8px 0;
}

.tool {
  min-width: 56px;
  height: 36px;
  padding: 0 8px;
  font-size: 16px;
  cursor: pointer;
}

.tool.active {
  outline: 2px solid #fff;
}

/* text buttons: base art picked by button size (1x1 = 32px square, 1x3 = 96x32, 1x4 = 128x32) */
:root {
  --btn-1x1: url("../assets/ui/ui-button-1x1.png");
  --btn-1x3: url("../assets/ui/ui-button-1x3.png");
  --btn-1x4: url("../assets/ui/ui-button-1x4.png");
  --icon-button-bg: url("../assets/ui/ui-button-1x1.png");
}

.htp-close,
#layer-toggle button,
#round-bar button,
.settings-actions button,
.results-actions button,
.mode-btn {
  border: var(--bw, 3px) solid #8a4650;
  border-radius: 0;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  background: #a14d55;
  border-image: var(--btn-art) 3 fill / var(--bw, 3px) stretch;
  image-rendering: pixelated;
}

.mode-btn { --bw: 6px; }

.htp-close { --btn-art: var(--btn-1x1); }
#layer-toggle button,
#round-bar button,
#results-save,
#results-share,
.settings-actions [data-close] { --btn-art: var(--btn-1x3); }
#settings-quit,
#results-again,
.mode-btn { --btn-art: var(--btn-1x4); }

/* icon buttons: one shared background image + a separate icon image per button */

.icon-button {
  position: relative;
  width: 48px;
  min-width: 0; /* stay square even when it's also a .tool */
  height: 48px;
  padding: 0;
  border: 0;
  cursor: pointer;
  background: #444 var(--icon-button-bg) center / 100% 100% no-repeat;
  image-rendering: pixelated;
}

.icon-button .icon {
  position: absolute;
  inset: 0;
  background: var(--icon) center / 95% no-repeat;
  image-rendering: pixelated;
  pointer-events: none;
}

.icon-back     { --icon: url("../assets/ui/ui-icon-undo.png"); }
.icon-clear    { --icon: url("../assets/ui/ui-icon-trash.png"); }
.icon-erase    { --icon: url("../assets/ui/ui-icon-eraser.png"); }
.icon-settings { --icon: url("../assets/ui/ui-icon-cog.png"); }
.icon-pencil   { --icon: url("../assets/ui/ui-icon-pen.png"); }
.icon-bucket   { --icon: url("../assets/ui/ui-icon-paintbucket.png"); }
.icon-dropper  { --icon: url("../assets/ui/ui-icon-eyedropper.png"); }

#save-status {
  font-size: 16px;
  text-align: center;
}

/* center canvas: script.js sizes the <canvas> to fill #canvasDiv */
#canvas-frame {
  position: relative;
  flex: 8 1 0; /* 80% of the column height; the ::before/::after spacers share the rest */
  order: 1;
  width: 80%;
  min-width: 0;
  min-height: 0;
  margin: 0 auto;
  transform: scale(0.8);
  transform-origin: center;
  border: 1px solid #333;
}

/* notebook pad: larger than the drawing field, sits behind it */
#canvas-frame::before {
  content: "";
  position: absolute;
  inset: -17% -10%;
  background: url("../assets/ui/ui-canvas.png") center / 100% 100% no-repeat;
  image-rendering: pixelated;
  pointer-events: none;
}

#canvasDiv {
  position: absolute;
  inset: 0;
}

#canvas {
  display: block;
  touch-action: none; /* stop touch-scrolling while drawing */
}

/* right drawing-tools panel */
#draw-tools {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* live brush preview under the size slider (holds up to the 60px eraser) */
#brush-preview-box {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
}

#brush-preview {
  display: block;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

#brush-preview.eraser {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  outline: 1px dashed rgba(0, 0, 0, 0.5);
  outline-offset: 2px;
}

#brush-size {
  writing-mode: vertical-lr;
  direction: rtl; /* larger size at the top */
  height: clamp(60px, 16vh, 140px);
  width: 24px;
  cursor: pointer;
}

#color-picker-panel {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px;
  overflow-y: auto;
  min-height: 0;
}

#color-wheel {
  width: 100%;
  max-width: min(200px, 24vh);
  aspect-ratio: 1;
  align-self: center;
  border-radius: 50%;
  cursor: crosshair;
}

#color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#color-row .tool {
  flex: none;
}

#selected-color {
  display: block;
  flex: 1;
  text-align: center;
  padding: 4px;
  font-family: inherit;
  border: 1px solid #333;
}

/* slider tracks (from the original color picker styles; saturation's
   gradient is set live by Slider.js) */
#brightness {
  background: linear-gradient(to right, #000, #fff);
}

#hue {
  background: linear-gradient(
    to right,
    #f00,
    #ff0,
    #0f0,
    #0ff,
    #00f,
    #f0f,
    #f00
  );
}

#dropper-status {
  display: block;
  min-height: 1em;
  font-size: 16px;
  text-align: center;
}

.color-controls {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 16px;
}

.panel-label {
  font-size: 16px;
}

#brush-sizes {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

#brush-sizes button {
  flex: 1;
  height: 36px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

#brush-sizes button i {
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  background: #000;
}

#brush-sizes button.active {
  outline: 2px solid #333;
}

#swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

#layer-toggle,
#saved-slots {
  display: flex;
  gap: 6px;
}

#layer-toggle button {
  flex: 1;
  height: 32px;
  padding: 0 2px;
  font-size: 16px;
  cursor: pointer;
}

#layer-toggle button.active {
  outline: 2px solid #fff;
}

.slot {
  flex: 1;
  height: 32px;
  border: 1px solid #999;
  cursor: pointer;
}

.slot.active {
  outline: 3px solid #fff;
  outline-offset: 1px;
}

.swatch {
  aspect-ratio: 1;
  border: 1px solid #999;
  cursor: pointer;
}

/* ---- settings dialog + how-to-play steps (start screen) ---- */
#settings-dialog {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 24px;
  border: 0;
  background: #571843 url("../assets/ui/ui-box-1x1.5.png") center / 100% 100%
    no-repeat;
  color: #fff;
  text-shadow: 0 1px 3px #000;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

#settings-dialog::backdrop {
  background: rgba(10, 5, 20, 0.6);
}

.htp-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
}

.htp-steps {
  list-style: none;
  counter-reset: step;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 14px;
  padding: 0;
}

.htp-steps li {
  counter-increment: step;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 12px 12px 14px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 16px;
}

.htp-steps li::before {
  content: counter(step);
  position: absolute;
  top: 10px;
  right: 12px;
  opacity: 0.35;
}

.htp-tips {
  margin-bottom: 16px;
  font-size: 16px;
}

.settings-actions button {
  height: 32px;
  min-width: 96px;
  padding: 0 14px;
  cursor: pointer;
}

#settings-dialog .setting {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0 18px;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

#sound-volume {
  flex: 1;
  min-width: 0;
}

#sound-volume-value {
  min-width: 3.5em;
  text-align: right;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.htp-tips summary {
  cursor: pointer;
}
.htp-tips ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

@media (max-width: 480px) {
  .htp-steps {
    grid-template-columns: 1fr;
  }
}

/* ---- narrow screens: stack tools / canvas / colors ---- */
@media (max-width: 800px) {
  #app {
    height: auto;
    min-height: 100vh;
  }

  #top-bar {
    grid-template-columns: auto 1fr;
  }
  #round-slot {
    grid-column: 1 / -1;
    justify-self: center;
  }

  #workspace {
    grid-template-columns: 1fr;
  }

  #toolbar {
    flex-direction: row;
    justify-content: center;
    justify-self: stretch;
    width: auto;
  }

  #canvas-frame {
    flex: none;
    height: 48vh;
  }
}
