/* Infinite-canvas island chrome (docs/design-islands.md §2).
   Retro aesthetic: 2px #333 borders, 4px 4px 0 hard shadow, white cards,
   Helvetica. Server-rendered stylesheet — not part of the JS bundle. */

.canvas-root {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: #f4f1ea;
  background-image: radial-gradient(#dcd7cc 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: Helvetica, Arial, sans-serif;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

/* Pan is a held modifier (⌘ / Space / middle-mouse), not a tool — the cursor
   flips to a grab hand while one is down. data-mode="pan" is the read-only
   public canvas, which pans by default. */
.canvas-root.pan-ready { cursor: grab; }
.canvas-root.panning { cursor: grabbing; }
.canvas-root[data-mode="pan"] { cursor: grab; }
.canvas-root[data-mode="draw-zone"] { cursor: crosshair; }
.canvas-root.connecting { cursor: crosshair; }

/* The ONE composited transform target. */
.viewport {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

/* ---- layers ---- */
.edges,
.overlay-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.zones,
.cards {
  position: absolute;
  top: 0;
  left: 0;
}

/* ---- edges ---- */
.edge-line {
  fill: none;
  stroke: #333;
  stroke-width: 2px;
}
.edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 14px;
  pointer-events: stroke;
  cursor: pointer;
}
.edge.selected .edge-line { stroke: #2b6cb0; stroke-width: 3px; }
.edge-label {
  font: 600 11px Helvetica, Arial, sans-serif;
  fill: #333;
  stroke: #f4f1ea;
  stroke-width: 3px;
  paint-order: stroke;
  pointer-events: none;
}

/* ---- zones (behind cards) ---- */
.zone {
  position: absolute;
  box-sizing: border-box;
  background: color-mix(in srgb, var(--zone-color, #b7a98b) 22%, transparent);
  border: 1px dashed #8a8172;
  border-radius: 2px;
}
.zone-label {
  position: absolute;
  top: 4px;
  left: 8px;
  font: 700 11px Helvetica, Arial, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b6250;
  pointer-events: none;
}
.zone.selected { border-color: #2b6cb0; border-style: solid; }
.zone-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 2px solid #2b6cb0;
  box-sizing: border-box;
  display: none;
}
.zone.selected .zone-handle { display: block; }
.handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.handle-n  { top: -6px; left: calc(50% - 5px); cursor: ns-resize; }
.handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.handle-e  { top: calc(50% - 5px); right: -6px; cursor: ew-resize; }
.handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.handle-s  { bottom: -6px; left: calc(50% - 5px); cursor: ns-resize; }
.handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle-w  { top: calc(50% - 5px); left: -6px; cursor: ew-resize; }

/* ---- cards ---- */
.card {
  position: absolute;
  box-sizing: border-box;
  background: #fff;
  border: 2px solid #333;
  border-left-width: 6px;
  box-shadow: 4px 4px 0 #333;
  padding: 8px 10px;
  /* visible (not hidden) so the connector handle can stick out past the right
     edge as a comfortable hit target; the title/snippet clip themselves. */
  overflow: visible;
  cursor: pointer;
  font-family: Helvetica, Arial, sans-serif;
}
.card[data-status="published"] { border-left-color: #3a7d44; }
.card[data-status="draft"],
.card[data-status="drafting"] { border-left-color: #d99a2b; }
.card[data-status="idea"] { border-left-color: #9a958b; }

/* ---- card identity: the map wears the public site's post types ---------- */
/* Short posts are the site's light-green cards (.mini-post, site.css). */
.card[data-post-type="mini"] { background: #f0f8f0; }
/* Book reviews get a warm paper stock; the eyebrow carries the star rating. */
.card[data-post-type="book"] { background: #fbf6ec; }
/* Non-post docs read as materials, not articles: no status stripe, softer ink. */
.card[data-kind="note"] { background: #fffdf5; border-left-color: #6a86a8; }
.card[data-kind="clip"] { background: #f6f4fb; border-left-color: #8a6aa8; border-left-style: dashed; }
.card[data-kind="draft"] { background: #fffdf5; border-left-color: #d99a2b; }

.card-kind {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7a7364;
  line-height: 1.2;
  margin-bottom: 3px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.card-kind:empty { display: none; }
.card[data-post-type="book"] .card-kind { color: #8a5a00; }
.card[data-post-type="mini"] .card-kind { color: #2f7d43; }

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: #222;
  line-height: 1.2;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card-snippet {
  font-size: 12px;
  color: #666;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.card.selected {
  box-shadow: 4px 4px 0 #333, 0 0 0 2px #2b6cb0;
}

/* Connector handle for drawing edges (editor only). ALWAYS on screen — there is
   no "edge mode" to switch into, so the handle is the affordance (map feedback
   2026-07-27). It sits back at 45% until you approach the card, and stays lit
   through the whole drag via .connecting: pointer capture on the root drops
   :hover from the card the instant you press, which used to make the handle
   vanish out from under the pointer and read as "nothing happened". */
.card-port {
  position: absolute;
  right: -11px;
  top: calc(50% - 10px);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #333;
  box-shadow: 2px 2px 0 #333;
  box-sizing: border-box;
  display: block;
  opacity: 0.45;
  transition: opacity 0.12s ease-out;
  cursor: crosshair;
  z-index: 2;
}
/* A retro "+" glyph so the handle reads as "connect from here". */
.card-port::before,
.card-port::after {
  content: "";
  position: absolute;
  background: #333;
}
.card-port::before { left: 3px; right: 3px; top: calc(50% - 1px); height: 2px; }
.card-port::after { top: 3px; bottom: 3px; left: calc(50% - 1px); width: 2px; }
.card-port:hover { background: #2b6cb0; }
.card-port:hover::before,
.card-port:hover::after { background: #fff; }
.card:hover .card-port,
.card.selected .card-port,
.card.connecting .card-port { opacity: 1; }
/* The armed source of a sticky (click-then-click) connection. */
.card.connecting .card-port { background: #2b6cb0; }
.card.connecting .card-port::before,
.card.connecting .card-port::after { background: #fff; }

/* ---- level-of-detail (< 0.4 scale): collapse to title dot/label ---- */
.viewport[data-lod="far"] .card-snippet { display: none; }
.viewport[data-lod="far"] .card { padding: 6px 8px; box-shadow: 3px 3px 0 #333; }
.viewport[data-lod="far"] .card-title { -webkit-line-clamp: 3; font-size: 13px; }
.viewport[data-lod="far"] .card-port { display: none; }

/* ---- overlays ---- */
.marquee {
  fill: rgba(43, 108, 176, 0.12);
  stroke: #2b6cb0;
  stroke-width: 1px;
  stroke-dasharray: 4 3;
  vector-effect: non-scaling-stroke;
}
.ghost-edge {
  fill: none;
  stroke: #2b6cb0;
  stroke-width: 2px;
  stroke-dasharray: 5 4;
}

/* ---- inline label editor ---- */
.inline-edit {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 30;
  font: 600 12px Helvetica, Arial, sans-serif;
  padding: 2px 6px;
  border: 2px solid #333;
  background: #fff;
  box-shadow: 2px 2px 0 #333;
}

/* ---- toolbar + sync status (shared visual pattern) ---- */
.canvas-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 8px;
  background: #fff;
  border: 2px solid #333;
  box-shadow: 4px 4px 0 #333;
}
.toolbar-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tool-btn {
  font: 600 12px Helvetica, Arial, sans-serif;
  padding: 4px 10px;
  background: #fff;
  border: 2px solid #333;
  box-shadow: 2px 2px 0 #333;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.tool-btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 #333; }
.tool-btn.active { background: #333; color: #fff; }
.tool-key {
  font: 700 10px ui-monospace, Menlo, monospace;
  border: 1px solid currentColor;
  border-radius: 2px;
  padding: 0 3px;
  opacity: 0.7;
}
.toolbar-spacer { flex: 1; min-width: 8px; }
.toolbar-hint {
  font: 600 11px Helvetica, Arial, sans-serif;
  color: #555;
  padding: 2px 2px 0;
  max-width: 340px;
}

/* ---- zoom controls (retro; shared editor + public read-only) ---- */
.zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  display: flex;
  align-items: stretch;
  background: #fff;
  border: 2px solid #333;
  box-shadow: 4px 4px 0 #333;
}
.zoom-btn {
  font: 700 13px Helvetica, Arial, sans-serif;
  min-width: 34px;
  padding: 6px 8px;
  background: #fff;
  border: none;
  border-left: 2px solid #333;
  color: #333;
  cursor: pointer;
  line-height: 1;
}
.zoom-btn:first-child { border-left: none; }
.zoom-btn:hover { background: #f0ede4; }
.zoom-btn:active { background: #333; color: #fff; }
.zoom-btn.zoom-pct { min-width: 52px; font-variant-numeric: tabular-nums; }
.zoom-btn.zoom-fit { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }

.sync-status {
  font: 600 11px Helvetica, Arial, sans-serif;
  padding: 3px 10px;
  border: 2px solid #333;
  border-radius: 999px;
  background: #e6efe6;
  color: #256029;
}
.sync-status[data-status="syncing"] { background: #fbf0d6; color: #8a5a00; }
.sync-status[data-status="offline"] { background: #eceae4; color: #555; }
.sync-status[data-status="conflict"] { background: #f7dede; color: #a12020; }
