/* Track W — whiteboard mode of a note (mounted by js/whiteboard.js).
   The chrome (toolbar, buttons) rides the app's tokens so dark mode is free;
   the page itself is a deliberately FIXED white paper in both themes, because
   stroke and text colors are stored as literal hex in the board JSON — a
   theme-tinted paper would make saved ink unreadable in one of the modes. */

.wb-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 460px;
}

/* ---------- toolbar ---------- */
.wb-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.wb-toolbar .wb-spacer { flex: 1; }
.wb-group { display: flex; align-items: center; gap: var(--sp-1); flex-wrap: wrap; }
.wb-sep { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }

.wb-tool.active,
.wb-tool.active:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.wb-tool-icon { font-size: var(--fs-md); line-height: 1; }

.wb-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.wb-swatch.active { outline: 2px solid var(--accent); outline-offset: 2px; }

.wb-width {
  width: 30px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
}
.wb-width:hover { background: var(--surface-2); }
.wb-width.active { background: var(--accent-soft); border-color: var(--accent); }
.wb-width .wb-dot { border-radius: 50%; background: var(--text); }
.wb-width .wb-dot-0 { width: 4px; height: 4px; }
.wb-width .wb-dot-1 { width: 7px; height: 7px; }
.wb-width .wb-dot-2 { width: 11px; height: 11px; }

.wb-zoom { font-variant-numeric: tabular-nums; }

/* ---------- stage (the paper) ---------- */
.wb-stage {
  position: relative;
  flex: 1;
  min-height: 420px;
  overflow: hidden;
  background: #ffffff; /* fixed paper — see file header */
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  touch-action: none; /* pointer events own all gestures here */
}

.wb-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Tool cursors; pan states override everything below. */
.wb-stage[data-tool="pen"] .wb-canvas,
.wb-stage[data-tool="highlighter"] .wb-canvas { cursor: crosshair; }
.wb-stage[data-tool="eraser"] .wb-canvas { cursor: cell; }
.wb-stage[data-tool="text"] .wb-canvas { cursor: text; }
.wb-root.wb-space .wb-canvas { cursor: grab; }
.wb-root.wb-panning,
.wb-root.wb-panning * { cursor: grabbing !important; }

/* ---------- text box overlay ---------- */
/* A zero-size anchor at world origin; one CSS transform pans/zooms every box
   with the canvas. --wb-inv (set from JS as 1/zoom) counter-scales the small
   handles so they stay a constant screen size. */
.wb-boxes {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  overflow: visible;
  transform-origin: 0 0;
  pointer-events: none;
}

.wb-box {
  position: absolute;
  pointer-events: auto;
  padding: 6px;                       /* the grab border (sketch geometry, not a UI token) */
  border: 1.5px dashed transparent;
  border-radius: 4px;
  cursor: move;
  touch-action: none;
}
.wb-box:hover { border-color: #c3cfdd; }
.wb-box.selected { border-color: #1857b6; border-style: solid; }

.wb-box-text {
  outline: none;
  cursor: text;
  min-height: 1.2em;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  touch-action: auto;
}
.wb-box-text:empty::before {
  content: attr(data-ph);
  color: #9aa8ba;
  pointer-events: none;
}

.wb-box-resize {
  display: none;
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: #1857b6;
  border: 2px solid #ffffff;
  border-radius: 3px;
  cursor: nwse-resize;
  transform-origin: 100% 100%;
  transform: scale(var(--wb-inv, 1));
}
.wb-box.selected .wb-box-resize { display: block; }

/* Per-box controls float above the selected box. They are app chrome, not
   ink, so they follow the theme tokens like the main toolbar. They wrap on a
   narrow stage, and js/whiteboard-boxes.js placeTools() anchors them to the
   box's right edge when the left anchor would run them off the paper. */
.wb-box-tools {
  display: none;
  position: absolute;
  bottom: 100%;
  left: -2px;
  margin-bottom: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  align-items: center;
  flex-wrap: wrap;
  width: max-content;
  max-width: calc(100vw - 24px);
  gap: var(--sp-1);
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.14);
  transform-origin: left bottom;
  transform: scale(var(--wb-inv, 1));
}
.wb-box.selected .wb-box-tools { display: flex; }
.wb-box-tools.wb-box-tools-right { left: auto; right: -2px; transform-origin: right bottom; }

.wb-bt {
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
  min-width: 24px;
  min-height: 24px;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius);
  cursor: pointer;
}
.wb-bt:hover { background: var(--surface-2); }
.wb-bt-val {
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 18px;
  text-align: center;
}
.wb-bt-sep { width: 1px; height: 14px; background: var(--border); }
.wb-box-close { color: var(--danger); }
.wb-box-close:hover { background: var(--surface-2); }

/* A 24px target around a 14px dot: the surface-coloured border pads the
   inline background colour, the inset shadow draws the dot's edge. */
.wb-mini {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 5px solid var(--surface);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.wb-mini:hover { outline: 2px solid #c3cfdd; outline-offset: 1px; }

/* ---------- dark theme ---------- */
/* Chrome already follows the tokens; the paper stays white on purpose. Only
   soften the hard edge between dark surface and white paper. */
:root[data-theme="dark"] .wb-stage { border-color: #2e415a; }
