/* Whiteboard. Three stacked canvases fill the stage; the toolbar floats on top. */

/* --wb-b, the button size, also shrinks with the width so the bar always
   fits: about 16.5 buttons wide with colors inline, 10.7 when folded. */
.wb {
  --wb-b: clamp(32px, min(max(8cqmin, 44px), (100cqw - 130px) / 16.5), 54px);
  --wb-sw: calc(var(--wb-b) * .74);
  overflow: hidden; user-select: none; -webkit-user-select: none;
}
.wb .t-canvas { pointer-events: none; }
.wb .wb-live { pointer-events: auto; cursor: crosshair; }
.wb[data-tool="text"] .wb-live { cursor: text; }
.wb[data-tool="eraser"] .wb-live { cursor: none; }

.wb-ring {
  position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--stage-ink) 70%, transparent);
  background: color-mix(in srgb, var(--stage-bg) 35%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--stage-bg) 80%, transparent);
}
.wb.is-dark .wb-ring { border-color: rgba(255, 255, 255, .8); background: rgba(255, 255, 255, .08); box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); }

/* ---- toolbar ---- */
.wb-bar, .wb-fly {
  position: absolute; z-index: 6;
  display: flex; align-items: center; gap: clamp(2px, .5cqmin, 6px);
  padding: clamp(4px, .9cqmin, 8px);
  border-radius: calc(var(--wb-b) * .42);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
  color: var(--ink);
}
.wb-bar {
  left: 50%; bottom: clamp(6px, 2.2cqmin, 22px); transform: translateX(-50%);
  max-width: calc(100% - 12px); transition: opacity .2s, transform .2s;
}
.wb.bar-hidden .wb-bar { opacity: 0; transform: translate(-50%, 30%); pointer-events: none; visibility: hidden; }
.wb-group { display: flex; align-items: center; gap: clamp(2px, .5cqmin, 6px); }

.wb-btn {
  flex: none; position: relative;
  width: var(--wb-b); height: var(--wb-b); padding: 0; border: 0; border-radius: calc(var(--wb-b) * .28);
  display: grid; place-items: center; background: transparent; color: var(--ink-soft);
  transition: background .12s, color .12s, box-shadow .12s;
}
.wb-btn .icon { width: 52%; height: 52%; }
.wb-btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }
.wb-btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--cat) 16%, var(--card)); color: var(--cat);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--cat) 55%, transparent);
}
.wb-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.wb-btn:focus-visible, .wb-sw:focus-visible, .wb-size:focus-visible { outline: 3px solid var(--ring); outline-offset: 1px; }
.wb-has-fly::after {
  content: ""; position: absolute; right: 12%; bottom: 12%;
  border: 3px solid transparent; border-right-color: currentColor; border-bottom-color: currentColor; opacity: .6;
}
.wb-hide { width: calc(var(--wb-b) * .7); }
.wb-hide .icon { width: 60%; height: 60%; }

.wb-sep { flex: none; width: 1px; height: calc(var(--wb-b) * .62); background: var(--line); margin: 0 clamp(1px, .4cqmin, 5px); }

/* Color swatches: a ring around the pressed one, a softer square for the highlighter. */
.wb-sw {
  flex: none; width: var(--wb-sw); height: var(--wb-b); padding: 0; border: 0; background: transparent;
  display: grid; place-items: center; border-radius: 10px;
}
.wb-sw i {
  width: 74%; aspect-ratio: 1; border-radius: 50%; background: var(--c, #888);
  box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .28), 0 1px 2px rgba(0, 0, 0, .15);
  transition: transform .12s;
}
.wb-sw.is-hl i { border-radius: 28%; }
.wb-sw:hover i { transform: scale(1.1); }
.wb-sw[aria-pressed="true"] i { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--cat); transform: scale(1.04); }

.wb-size {
  flex: none; width: calc(var(--wb-b) * .78); height: var(--wb-b); padding: 0; border: 0; border-radius: 10px;
  display: grid; place-items: center; background: transparent; color: var(--ink-soft);
}
.wb-size:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.wb-size i { display: block; border-radius: 50%; background: currentColor; }
.wb-size-s i { width: 18%; aspect-ratio: 1; }
.wb-size-m i { width: 30%; aspect-ratio: 1; }
.wb-size-l i { width: 46%; aspect-ratio: 1; }
.wb-size[aria-pressed="true"] { color: var(--cat); background: color-mix(in srgb, var(--cat) 14%, var(--card)); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--cat) 50%, transparent); }

/* The color button shows the current color and size. */
.wb-color-btn i {
  width: 46%; aspect-ratio: 1; border-radius: 50%; background: var(--c, #888);
  box-shadow: 0 0 0 2px var(--card), 0 0 0 3.5px var(--line);
}
.wb-color-btn i[data-size="s"] { width: 32%; }
.wb-color-btn i[data-size="l"] { width: 58%; }

.wb-fly { flex-direction: column; align-items: stretch; }
.wb-fly[hidden] { display: none; }
.wb-fly-colors .wb-colors { flex-wrap: wrap; justify-content: center; max-width: calc(var(--wb-sw) * 6 + 40px); }
.wb-fly-colors .wb-sizes { justify-content: center; border-top: 1px solid var(--line-soft); padding-top: 4px; }

/* Wide boards show everything; narrower ones fold shapes and colors into pop-ups. */
.wb-shapes-inline { display: none; }
.wb-color-btn { display: none; }
@container (min-width: 1180px) {
  .wb { --wb-b: clamp(32px, min(max(8cqmin, 44px), (100cqw - 150px) / 19.5), 54px); }
  .wb-shapes-inline { display: flex; }
  .wb-shapes-btn { display: none; }
}
@container (max-width: 760px) {
  .wb { --wb-b: clamp(32px, min(max(8cqmin, 44px), (100cqw - 100px) / 10.7), 54px); }
  .wb-colors-inline { display: none; }
  .wb-color-btn { display: grid; }
}
@container (max-width: 470px) {
  .wb-extra { display: none; }
}
@container (max-width: 400px) {
  .wb { --wb-b: 33px; }
  .wb-hide { display: none; }
  .wb-bar .wb-sep { margin: 0; }
}

.wb-show {
  position: absolute; left: clamp(8px, 2cqmin, 20px); bottom: clamp(8px, 2cqmin, 20px); z-index: 6;
  background: color-mix(in srgb, var(--card) 88%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transition: opacity .2s;
}
.wb.bar-hidden .wb-show { opacity: .7; visibility: visible; }
.wb.bar-hidden .wb-show:hover { opacity: 1; }

.wb-warn {
  position: absolute; top: clamp(8px, 2cqmin, 18px); left: 50%; transform: translateX(-50%); z-index: 6;
  padding: .3em .9em; border-radius: 999px; white-space: nowrap; pointer-events: none;
  font: 600 clamp(11px, 2.4cqmin, 18px)/1.3 var(--font-display);
  background: color-mix(in srgb, var(--warn) 18%, var(--card)); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--warn) 55%, transparent); box-shadow: var(--shadow);
}

/* Typing text: an input laid exactly where the words will be drawn. */
.wb .wb-text {
  position: absolute; z-index: 5; margin: 0; padding: 0; height: auto; min-height: 0;
  font-family: var(--font-display); font-weight: 600; line-height: 1.2;
  background: color-mix(in srgb, var(--stage-bg) 55%, transparent); border: 0; border-radius: 4px;
  outline: 2px dashed color-mix(in srgb, var(--cat) 75%, transparent); outline-offset: 4px;
  caret-color: var(--cat); box-shadow: none;
}
.wb .wb-text:focus { outline: 2px dashed var(--cat); box-shadow: none; border: 0; }
.wb .wb-text::placeholder { color: color-mix(in srgb, currentColor 45%, transparent); }

/* Settings: how full the board is. */
.wb-meter { height: 10px; border-radius: 999px; background: var(--card-alt); border: 1px solid var(--line); overflow: hidden; }
.wb-meter i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--cat); transition: width .3s; }
.wb-meter.is-warn i { background: var(--warn); }
