/* SOGpt canvas — bottom dock, node picker, shortcut sheet

   The canvas used to carry a 46px toolbar across the top and three permanent
   HUDs in the corners. This moves the tools into one floating dock centred under
   the canvas, the way every infinite-canvas tool now does it, and gives the
   corners back to the work.

   canvas-dock.js moves the real toolbar buttons into the dock rather than
   rebuilding them, so every handler app.js attached still applies. */

/* The old toolbar keeps its markup so nothing that queries it breaks; it is just
   no longer on screen once its buttons have been relocated. */
.canvas-toolbar.docked { display: none; }

/* -- the dock --------------------------------------------------------------- */

.canvas-dock {
  position: fixed;
  bottom: 18px;
  z-index: 30;
  display: flex;
  align-items: center;
  /* Groups are read by the space between them, so the gap here is the grouping
     device and there is only one rule in the whole row. */
  gap: 9px;
  padding: 5px;
  border: 1px solid var(--canvas-line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--canvas-card) 88%, transparent);
  box-shadow: 0 16px 44px rgba(0, 0, 0, .42);
  backdrop-filter: blur(18px) saturate(140%);
  transform: translateX(-50%);
}

html[data-theme="light"] .canvas-dock {
  box-shadow: 0 14px 36px rgba(23, 64, 78, .16);
}

.canvas-dock button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--canvas-ink-2);
  cursor: pointer;
  font-size: 0;
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}

/* The icon set is drawn on one 24x24 grid; everything about its weight and
   alignment is declared here rather than inherited from a font. */
.canvas-dock button svg,
.canvas-dock summary svg,
.canvas-node-picker > button svg,
.dock-more-panel button svg,
.shortcut-sheet svg {
  width: 17px;
  height: 17px;
  display: block;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: butt;
  stroke-linejoin: miter;
}

.canvas-dock button svg .ic-fill,
.dock-more-panel button svg .ic-fill {
  fill: currentColor;
  stroke: none;
}

/* A zero-length path with a round cap is a dot; it needs the weight to read. */
.canvas-dock button svg .ic-dots {
  stroke-width: 2.4;
  /* Beats the butt cap the svg above sets, and has to: these paths have no
     length, so the round cap is the only thing that paints them. */
  stroke-linecap: round;
}

.dock-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.canvas-dock button:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--canvas-ink-1);
}

.canvas-dock button.active {
  background: var(--gold-soft);
  border-color: color-mix(in srgb, var(--gold) 45%, transparent);
  color: var(--gold);
}

.canvas-dock button:disabled { opacity: .38; cursor: not-allowed; }

.canvas-dock button:focus-visible {
  outline: 2px solid var(--gold-ring);
  outline-offset: 1px;
}

.dock-sep {
  width: 1px;
  height: 18px;
  flex: none;
  background: var(--canvas-line);
}

/* Run is the one primary action on the canvas, so it keeps its label. */
.canvas-dock #run-ready,
.canvas-dock #run-ready:not(:disabled) {
  /* The icon-only buttons centre a single glyph in a grid cell; this one has a
     label beside the glyph, so it needs a row instead of a stack. */
  width: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  white-space: nowrap;
  background: var(--gold);
  color: var(--on-gold);
  font-size: 11px;
  font-weight: 700;
}

.canvas-dock #run-ready > span { font-size: 11px; }
.canvas-dock #run-ready svg { width: 15px; height: 15px; }
.canvas-dock #run-ready:hover:not(:disabled) { background: color-mix(in srgb, var(--gold) 88%, #fff); }
.canvas-dock #run-ready:disabled { background: var(--surface-4); color: var(--text-4); }

/* The zoom stepper moves in from the corner and loses its own chrome. */
.canvas-dock .zoom-control {
  position: static;
  display: flex;
  border: 0;
  background: transparent;
}

.canvas-dock .zoom-control button { width: 28px; height: 28px; }

/* A read-out that happens to be clickable should not wear the same chrome as
   the two controls beside it. */
.canvas-dock .zoom-control #zoom-label {
  width: auto;
  min-width: 44px;
  border: 0;
  background: transparent;
  color: var(--canvas-ink-3);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.canvas-dock .zoom-control #zoom-label { font-size: 10px; }
.canvas-dock .zoom-control #zoom-label:hover { background: transparent; color: var(--canvas-ink-1); }

/* -- overflow menu ---------------------------------------------------------- */

.dock-more { position: relative; }

.dock-more-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 2;
  display: none;
  min-width: 200px;
  flex-direction: column;
  gap: 1px;
  padding: 5px;
  border: 1px solid var(--canvas-line);
  border-radius: 11px;
  background: color-mix(in srgb, var(--canvas-card) 96%, transparent);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .4);
  backdrop-filter: blur(18px);
}

.dock-more.open .dock-more-panel { display: flex; }

.dock-more-panel button {
  width: 100%;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 9px;
  justify-content: flex-start;
  padding: 0 9px;
  border-radius: 7px;
  color: var(--canvas-ink-2);
  font-size: 11px;
}

.dock-more-panel button > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dock-more-panel button > kbd {
  margin-left: auto;
  border: 1px solid var(--canvas-line);
  border-radius: 4px;
  background: var(--canvas-inset);
  color: var(--canvas-ink-3);
  padding: 1px 5px;
  font: 9px var(--font-mono, ui-monospace, monospace);
}

/* -- node picker -----------------------------------------------------------
   One list, opened three ways: the dock's plus, a double-click on empty canvas,
   or Tab. Double-click and Tab drop the node where the pointer is.

   The panel lives on <body>, not inside the dock: the dock's transform and
   backdrop-filter each make it a containing block for fixed-position children,
   which would measure the panel's coordinates from the dock instead of the
   viewport and fling it off screen. */

.canvas-dock .node-library { position: relative; }

/* Add-a-node used to carry the accent as well, which put two accented elements
   four buttons apart and left neither reading as the primary action. It is a
   tool like the others now; Run keeps the accent to itself. */
.canvas-dock .node-library > summary {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--canvas-ink-2);
  cursor: pointer;
  font-size: 0;
  list-style: none;
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}

.canvas-dock .node-library > summary:hover {
  background: var(--surface-3);
  color: var(--canvas-ink-1);
}

.canvas-dock .node-library > summary::-webkit-details-marker { display: none; }
.canvas-dock .node-library > summary > b { font-size: 16px; }
.canvas-dock .node-library[open] > summary { background: var(--gold); color: var(--on-gold); }

.canvas-node-picker {
  position: fixed;
  z-index: 40;
  display: none;
  flex-direction: column;
  gap: 1px;
  width: 268px;
  max-height: min(58vh, 420px);
  overflow: auto;
  padding: 5px;
  border: 1px solid var(--canvas-line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--canvas-card) 97%, transparent);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .46);
  backdrop-filter: blur(18px);
}

.canvas-node-picker.open { display: flex; }

/* Outside .canvas-dock these no longer inherit its button reset, so state it
   here or the browser's default light button face shows through. */
.canvas-node-picker > button {
  width: 100%;
  height: auto;
  display: grid;
  border: 1px solid transparent;
  background: transparent;
  color: var(--canvas-ink-2);
  cursor: pointer;
  font-family: inherit;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  text-align: left;
  font-size: 11px;
}

.canvas-node-picker > button > b svg {
  width: 15px;
  height: 15px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: butt;
  stroke-linejoin: miter;
}

.canvas-node-picker > button > b {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--canvas-line);
  border-radius: 7px;
  background: var(--canvas-inset);
  color: var(--canvas-ink-2);
  font-size: 12px;
}

.canvas-node-picker > button > span {
  min-width: 0;
  display: block;
  color: var(--canvas-ink-1);
  font-size: 11px;
  font-weight: 600;
}

.canvas-node-picker > button small {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  color: var(--canvas-ink-3);
  font-size: 9px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-node-picker > button:hover {
  background: var(--gold-soft);
}

.canvas-node-picker > button:hover > b,
.canvas-node-picker > button:focus-visible > b {
  border-color: color-mix(in srgb, var(--gold) 45%, transparent);
  color: var(--gold);
}

.canvas-node-picker > button:focus-visible {
  outline: none;
  border-color: var(--gold);
  background: var(--gold-soft);
}

/* -- corners ---------------------------------------------------------------
   The hint bar taught the gestures once and then sat there forever. It now
   fades on the first canvas gesture, and ? brings back the full sheet. */

.canvas-hint {
  transition: opacity .4s var(--ease);
}

.canvas-hint.faded {
  opacity: 0;
  pointer-events: none;
}

/* -- corner cluster ---------------------------------------------------------
   One stack in the bottom-left: the controls in a row, the overview map opening
   above them. Both used to be spread across the bottom edge at a weight that
   competed with the dock. */

.canvas-hud {
  position: absolute;
  left: 18px;
  /* Same distance off the bottom as .canvas-dock, so the two bars share a baseline. */
  bottom: 18px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}

.canvas-hud .canvas-hint {
  position: static;
  max-width: 300px;
}

.canvas-hud .minimap {
  position: static;
  display: none;
  width: 168px;
  height: 104px;
  border-radius: 10px;
}

.canvas-hud.map-open .minimap { display: block; }

/* Set by avoidOverlap() when the centred dock would run into this cluster. */
.canvas-hud.stacked { bottom: 68px; }

/* Every value here matches .canvas-dock: same padding, radius, ground, blur and
   shadow, so the pair reads as one control surface split across the edge. */
.canvas-hud-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--canvas-line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--canvas-card) 88%, transparent);
  box-shadow: 0 16px 44px rgba(0, 0, 0, .42);
  backdrop-filter: blur(18px) saturate(140%);
}

html[data-theme="light"] .canvas-hud-row { box-shadow: 0 14px 36px rgba(23, 64, 78, .16); }

.canvas-hud-row button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--canvas-ink-2);
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}

.canvas-hud-row button:hover { background: var(--surface-3); color: var(--canvas-ink-1); }

.canvas-hud-row button:focus-visible {
  outline: 2px solid var(--gold-ring);
  outline-offset: 1px;
}

.canvas-hud-row .hud-toggle.on {
  background: var(--gold-soft);
  border-color: color-mix(in srgb, var(--gold) 45%, transparent);
  color: var(--gold);
}

.canvas-hud-row button svg {
  width: 17px;
  height: 17px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: butt;
  stroke-linejoin: miter;
}

/* The zoom stepper moves out of the dock and loses its own chrome again. */
.canvas-hud-row .zoom-control {
  position: static;
  display: flex;
  border: 0;
  background: transparent;
}

.canvas-hud-row .zoom-control button { width: 28px; height: 32px; }

.canvas-hud-row .zoom-control #zoom-label {
  width: auto;
  min-width: 42px;
  border: 0;
  background: transparent;
  color: var(--canvas-ink-2);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.canvas-hud-row .zoom-control #zoom-label:hover { background: transparent; color: var(--canvas-ink-1); }

/* Hide the cards, keep the connections: the shape of the graph without the
   contents, for finding your way around a canvas with thirty nodes on it. */
.canvas-stage.connections-hidden #edge-layer { display: none; }

@media (max-width: 760px) {
  .canvas-hud { left: 10px; bottom: 10px; }
  .canvas-hud .minimap { width: 132px; height: 82px; }
  .canvas-hud-row { padding: 4px; }
  .canvas-hud-row button { width: 30px; height: 30px; }
}

/* -- inspector handle ------------------------------------------------------
   Collapsing the right panel was always possible, but only from a menu item.
   This puts the affordance on the seam itself, where every panel that collapses
   keeps it, and leaves it there when the panel is gone so it can be brought back. */

.inspector-handle {
  position: absolute;
  top: 50%;
  z-index: 12;
  width: 16px;
  height: 60px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--canvas-line);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: color-mix(in srgb, var(--canvas-card) 94%, transparent);
  color: var(--canvas-ink-2);
  cursor: pointer;
  transform: translateY(-50%);
  transition: color var(--motion-fast) var(--ease),
              background var(--motion-fast) var(--ease),
              width var(--motion-fast) var(--ease);
  backdrop-filter: blur(14px);
}

.inspector-handle svg {
  width: 13px;
  height: 13px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.96;
  stroke-linecap: butt;
  stroke-linejoin: miter;
}

.inspector-handle:hover {
  width: 20px;
  background: var(--canvas-card);
  color: var(--canvas-ink-1);
}

.inspector-handle:focus-visible {
  outline: 2px solid var(--gold-ring);
  outline-offset: 2px;
}

/* Collapsed, the handle is the only way back, so it sits proud of the edge. */
.canvas-layout.inspector-collapsed .inspector-handle {
  border-right: 1px solid var(--canvas-line);
  border-radius: 7px 0 0 7px;
  box-shadow: -4px 0 14px rgba(0, 0, 0, .25);
}

@media (max-width: 760px) {
  .inspector-handle { display: none; }
}

/* -- shortcut sheet --------------------------------------------------------- */

.shortcut-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, .42);
}

.shortcut-sheet.open { display: grid; }

.shortcut-sheet > div {
  width: min(700px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  overflow: auto;
  border: 1px solid var(--canvas-line);
  border-radius: 12px;
  background: var(--canvas-card);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .48);
  padding: 14px 16px 14px;
}

.shortcut-foot {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--canvas-line);
  color: var(--canvas-ink-3);
  font-size: 9.5px;
  text-align: center;
}

.shortcut-sheet header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.shortcut-sheet h2 {
  margin: 0;
  color: var(--canvas-ink-1);
  font-size: 12px;
  font-weight: 650;
}

.shortcut-sheet header button {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--canvas-ink-3);
  cursor: pointer;
}

.shortcut-sheet header button:hover { color: var(--canvas-ink-1); }
.shortcut-sheet header button svg { width: 14px; height: 14px; }

/* Four fixed columns rather than auto-fit: auto-fit dropped the last column
   onto its own row on a wide screen, and the empty half was what made the
   dialog feel oversized. */
.shortcut-columns {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px 20px;
}

@media (max-width: 660px) { .shortcut-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; } }
@media (max-width: 400px) { .shortcut-columns { grid-template-columns: minmax(0, 1fr); } }

.shortcut-columns h3 {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.shortcut-columns dl { margin: 0; }

.shortcut-columns div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 1.5px 0;
}

.shortcut-columns dt {
  min-width: 0;
  color: var(--canvas-ink-2);
  font-size: 10.5px;
  line-height: 1.3;
}

.shortcut-columns dd {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  flex: none;
}

.shortcut-columns kbd {
  min-width: 16px;
  display: inline-block;
  border: 1px solid var(--canvas-line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--canvas-inset);
  color: var(--canvas-ink-1);
  padding: 1px 4.5px;
  font: 9px var(--font-mono, ui-monospace, monospace);
  text-align: center;
}

.shortcut-columns em {
  color: var(--canvas-ink-3);
  font-size: 9px;
  font-style: normal;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .canvas-dock { bottom: 10px; gap: 0; padding: 4px; }
  .canvas-dock button { width: 30px; height: 30px; }
  .canvas-dock .zoom-control #zoom-label { min-width: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  .canvas-dock button,
  .canvas-hint { transition: none; }
}

/* -- align palette ---------------------------------------------------------- */

.align-menu {
  position: fixed;
  z-index: 45;
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--canvas-line);
  border-radius: 11px;
  background: color-mix(in srgb, var(--canvas-card) 96%, transparent);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .44);
  backdrop-filter: blur(18px);
}

html[data-theme="light"] .align-menu { box-shadow: 0 14px 34px rgba(23, 64, 78, .18); }

.align-menu.open { display: flex; }

.align-note {
  margin: 0 2px;
  color: var(--canvas-ink-3);
  font: 500 9px/1.4 var(--font-ui, system-ui, sans-serif);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.align-grid {
  display: flex;
  align-items: center;
  gap: 2px;
}

.align-rule {
  width: 1px;
  height: 18px;
  flex: none;
  margin: 0 5px;
  background: var(--canvas-line);
}

.align-grid button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--canvas-ink-2);
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}

.align-grid button:hover:not(:disabled) { background: var(--gold-soft); color: var(--gold); }
.align-grid button:disabled { opacity: .3; cursor: not-allowed; }
.align-grid button:focus-visible { outline: 2px solid var(--gold-ring); outline-offset: 1px; }

.align-grid button svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.59;
  stroke-linecap: butt;
  stroke-linejoin: miter;
}
