/* BLK Optimizer canvas editor.
 *
 * This is the ONE stylesheet added for this page, and it deliberately introduces almost no new
 * visual vocabulary: the toolbar buttons carry the shipped .secondary-button class and are only
 * made compact, the toolbar / stage / note boxes reuse the same border and surface tokens as
 * .image-previews section, and every colour here is a variable site.css already defines. A
 * tool that is part of this site must not look like a widget dropped in from somewhere else.
 *
 * It lives in its own file rather than in the view's <style> block for one concrete reason: the
 * page needs an EXPLICIT canvas height. site.css sizes .image-previews canvas with width:100%
 * and no height at all, so today the canvas' height="420" ATTRIBUTE is what gives the element its
 * layout box. The editor has to size the backing store from the CSS box instead, and if the CSS
 * box were still derived from the height attribute the two would drive each other in a loop that
 * grows the canvas on every frame. Pinning the height here breaks that cycle at its source.
 */
[data-blk-optimization] .blk-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  padding: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

/* Compact variant of .secondary-button. The shipped class sets min-height:36px and a 1px
   letter-spacing, which is sized for the export row at the bottom of the page; a toolbar that
   tall would be taller than the canvas' own header. */
[data-blk-optimization] .blk-editor-toolbar .secondary-button {
  min-height: 28px;
  padding: 4px 9px;
  font-size: 10px;
  letter-spacing: .06em;
}
/* The armed eraser is a mode, not an action, so it is shown with aria-pressed and tinted with
   the accent - the same accent the primary button uses, not a second highlight colour. */
[data-blk-optimization] .blk-editor-toolbar .secondary-button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}
/* site.css styles no :disabled state for .secondary-button, so a disabled toolbar button would
   otherwise still light up on hover - which reads as "press this" for a control that cannot do
   anything. Undo and Redo are disabled most of the time here, so this matters. */
[data-blk-optimization] .blk-editor-toolbar .secondary-button:disabled {
  opacity: .38;
  cursor: default;
}
[data-blk-optimization] .blk-editor-toolbar .secondary-button:disabled:hover {
  background: transparent;
  color: #ddd;
  border-color: var(--border-strong);
}

[data-blk-optimization] .blk-editor-zoom {
  min-width: 56px;
  color: var(--accent);
  text-align: center;
  font: 11px Consolas, monospace;
  letter-spacing: 0;
}

[data-blk-optimization] .blk-editor-radius {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 1px;
}
[data-blk-optimization] .blk-editor-radius input[type=range] {
  width: 92px;
  min-width: 0;
  accent-color: var(--accent);
}
[data-blk-optimization] .blk-editor-radius output {
  min-width: 32px;
  color: var(--text);
  font: 11px Consolas, monospace;
  letter-spacing: 0;
}

/* The stage is the positioning context for the read-out chip. It carries the same #050505 the
   canvas itself has, so the chip has one surface to sit on rather than a second box. */
[data-blk-optimization] .blk-editor-stage {
  position: relative;
  background: #050505;
}
[data-blk-optimization] .blk-editor-canvas {
  display: block;
  width: 100%;
  height: 520px;
  /* The camera owns every pointer gesture on this surface. Without this, a touch drag over the
     canvas is claimed by the browser as a scroll or a pinch and the erase stops mid-stroke. */
  touch-action: none;
  cursor: crosshair;
}
/* While the eraser is armed the canvas draws the real cursor ring itself, so the system cursor
   is hidden: two cursors on one surface is worse than one. data-blk-eraser-armed is the one
   attribute blk-optimization.js sets from script. */
[data-blk-optimization] .blk-editor-canvas[data-blk-eraser-armed="true"] {
  cursor: none;
}

/* Decorative duplicate of the toolbar read-outs, so it is hidden from assistive technology:
   announcing the same two values twice per zoom step would be noise. The toolbar carries the
   accessible copy. */
[data-blk-optimization] .blk-editor-hud {
  position: absolute;
  left: 8px;
  bottom: 8px;
  margin: 0;
  padding: 3px 7px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, .72);
  color: var(--muted);
  pointer-events: none;
  font: 10px Consolas, monospace;
  letter-spacing: 0;
}

[data-blk-optimization] .blk-editor-note {
  margin: 10px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
[data-blk-optimization] .blk-editor-note strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 10px;
  letter-spacing: 1px;
}

/* Matches the page's own 900px breakpoint in BlkOptimization.cshtml so the toolbar and the
   canvas shorten together instead of wrapping onto a second row above a full-height canvas. */
@media (max-width: 900px) {
  [data-blk-optimization] .blk-editor-canvas { height: 380px; }
  [data-blk-optimization] .blk-editor-toolbar .secondary-button { min-height: 32px; }
  [data-blk-optimization] .blk-editor-radius input[type=range] { width: 70px; }
}