/* ---- stage & board ------------------------------------------------------ */

/* The stage is the whole window. Its padding isn't empty space: it marks what the top bar,
   toolbar and zoom slider cover, so "Fit" shows the canvas between them (Renderer.viewport).
   The board - the drawing canvas - fills all of it, and the paper is drawn inside, so it can
   be zoomed and moved anywhere (.claude/rules/canvas.md). */
.stage {
  position: fixed;
  inset: 0;
  padding: 72px 24px 108px 84px;
}

.board {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}
.board.ready { opacity: 1; }

/* ---- entering a room: placeholder while it loads and draws ---------------- */

/* Not ".room-loading": that's the body's class while a room loads, and the pill's styles
   on it squeezed the whole page into a narrow column (seen live, 2026-10-09). */
.loading-pill {
  position: absolute;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  z-index: 6;
  /* Only shows if loading takes a moment: small rooms never flash it. */
  animation: loading-in 0.2s 0.15s var(--ease) both;
}
.loading-pill[hidden] { display: none; }
@keyframes loading-in { from { opacity: 0; } }

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  animation: spin 0.8s linear infinite; /* a transform: keeps turning even while the page is busy */
}
@keyframes spin { to { transform: rotate(360deg); } }

/* No tools until the room has arrived; the chat says it's on its way. */
body.room-loading .toolbar { display: none; }
body.room-loading #chatMessages > * { display: none; }
body.room-loading #chatMessages::before {
  content: "Loading chat…";
  color: var(--muted);
  font-size: 13px;
}

canvas {
  display: block;
  touch-action: none;
  cursor: crosshair;
}
@media (hover: hover) and (pointer: fine) {
  #canvas { cursor: none; }
}
#canvas.off-board { cursor: default; }
#canvas.panning { cursor: grab; }
#canvas.dragging { cursor: grabbing; }

/* ---- zoom slider (left edge) -------------------------------------------- */

.zoom-control {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 6px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  box-shadow: var(--shadow-lg);
  z-index: 5;
}
.board:not(.ready) ~ .zoom-control { visibility: hidden; }

.zoom-btn, .zoom-fit {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s;
}
.zoom-btn { width: 34px; height: 34px; }
.zoom-btn svg { width: 18px; height: 18px; }
.zoom-btn:hover, .zoom-fit:hover { background: var(--hover); }
.zoom-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.zoom-divider { width: 22px; height: 1px; background: var(--border); }
.zoom-fit { padding: 4px 6px; font-size: 12px; font-weight: 600; }

input[type="range"].zoom-slider {
  writing-mode: vertical-lr;
  direction: rtl; /* bottom = zoomed out, top = zoomed in */
  width: 4px;
  height: 140px;
  background: linear-gradient(to top, var(--text) var(--fill, 10%), var(--border) var(--fill, 10%));
}

.zoom-percent {
  min-width: 40px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--muted);
}

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.brush-ring {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  border: 1.5px solid rgb(0 0 0 / 0.55);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.8);
  opacity: 0;
  transition: opacity 0.15s, width 0.15s var(--ease), height 0.15s var(--ease);
  will-change: transform;
}
.brush-ring.visible { opacity: 1; }

.cursor {
  position: absolute;
  left: 0;
  top: 0;
  transition: transform 90ms linear, opacity 0.2s;
  will-change: transform;
}
.cursor.hidden { opacity: 0; }
.cursor svg {
  width: 20px;
  height: 20px;
  fill: var(--c);
  stroke: #fff;
  stroke-width: 1.5;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.25));
}
.cursor span {
  position: absolute;
  left: 16px;
  top: 18px;
  padding: 3px 8px;
  border-radius: 999px 999px 999px 4px;
  background: var(--c);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.15);
}


@media (max-width: 640px) {
  .stage { padding: 64px 10px 92px 58px; }
  .zoom-control { left: 8px; padding: 6px 4px; }
  .zoom-btn { width: 30px; height: 30px; }
  input[type="range"].zoom-slider { height: 96px; }
}

/* ---- debug panel (?debug=true) ------------------------------------------ */

.debug-panel {
  position: absolute;
  top: 72px;
  left: 84px;
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  box-shadow: var(--shadow-sm);
  font: 11.5px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
  pointer-events: none; /* never in the way of drawing */
  z-index: 5;
}
.debug-panel[hidden] { display: none; }
.debug-rows { display: grid; gap: 2px; }
.debug-rows > div { display: flex; justify-content: space-between; gap: 14px; }
.debug-rows > div > span:first-child { color: var(--muted); }
.debug-panel button {
  margin-top: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  font: inherit;
  cursor: pointer;
  pointer-events: auto; /* the panel lets clicks through to the canvas; its button doesn't */
}
.debug-panel button:hover { background: var(--hover); }
.debug-panel button[hidden] { display: none; }
.debug-panel .warn { color: #b45309; }
.debug-panel .full { color: var(--danger); font-weight: 600; }

@media (max-width: 640px) {
  .debug-panel { top: 64px; left: 58px; }
}
