/* Scroll — Jack: context menu, summary card, ref picker, live-reference
   cards, data view, resolved overlay, bucket view. Uses the shared theme
   variables from index.html. Author: Claude (Opus 4.8), Room B lane, 2026-07-24. */

/* ── toolbar buttons ─────────────────────────────────────────────────── */
#jack-toolbar { display: inline-flex; gap: 6px; }
#jack-toolbar button.active { border-color: var(--accent); color: var(--accent); background: rgba(74,158,255,0.10); }

/* ── flat context menu ───────────────────────────────────────────────── */
.jack-menu {
  position: fixed; z-index: 200; min-width: 210px; padding: 4px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 12px 34px rgba(0,0,0,0.55); font-size: 13px; color: var(--text);
}
.jack-item { padding: 8px 10px; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.jack-item:hover { background: var(--surface); color: var(--text-bright); }
.jack-item.disabled { color: var(--text-dim); cursor: default; }
.jack-item.disabled:hover { background: transparent; }
.jack-sep { height: 1px; background: var(--border); margin: 4px 2px; }

/* ── summarize result card ───────────────────────────────────────────── */
.jack-card {
  position: fixed; z-index: 200; width: min(360px, 92vw);
  background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.6); padding: 12px; color: var(--text);
}
.jack-card.error { border-color: #ff6b6b; }
.jack-card-body { font-size: 13px; line-height: 1.5; max-height: 40vh; overflow-y: auto; white-space: pre-wrap; }
.jack-card.error .jack-card-body { color: #ff9a8a; }
.jack-card-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.jack-card-actions button { font-size: 11px; padding: 4px 9px; }

/* ── popover (ref picker) ────────────────────────────────────────────── */
.jack-popover {
  position: fixed; z-index: 200; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, 94vw); max-height: 86vh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.6); color: var(--text);
}
.jack-popover .jp-head {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 14px;
  border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-bright);
}
.jack-popover .jp-x { border: none; background: transparent; color: var(--text-dim); font-size: 13px; cursor: pointer; }
.jack-popover .jp-x:hover { color: var(--text-bright); }
.jack-popover .jp-row { display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 12px; flex-wrap: wrap; }
.jack-popover .jp-row label { color: var(--text-dim); width: 70px; }
.jack-popover .jp-row select, .jack-popover .jp-row input {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text-bright);
  padding: 6px 8px; border-radius: 5px; font-size: 12px;
}
.jack-popover .rp-doc { flex: 1; min-width: 0; }
.jack-popover .rp-lane { flex: 1; min-width: 120px; }
.jack-popover .rp-start, .jack-popover .rp-end { width: 76px; }
.jack-popover .jp-to { color: var(--text-dim); }
.jack-popover .jp-hint { color: var(--text-dim); font-size: 10px; }
.jack-popover .rp-preview {
  margin: 6px 14px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface2); overflow: auto; flex: 1; min-height: 120px; max-height: 46vh;
}
.jack-popover .rp-preview-hint { padding: 12px; color: var(--text-dim); font-size: 12px; }
.jack-popover .rp-lines { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.jack-popover .rp-line { display: flex; gap: 10px; padding: 1px 10px; cursor: pointer; }
.jack-popover .rp-line:hover { background: rgba(74,158,255,0.08); }
.jack-popover .rp-line.sel { background: rgba(74,158,255,0.18); }
.jack-popover .rp-num { color: var(--text-dim); min-width: 30px; text-align: right; user-select: none; }
.jack-popover .rp-tx { color: var(--text); white-space: pre-wrap; word-break: break-word; }
.jack-popover .jp-actions { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.jack-popover .rp-insert { border-color: var(--accent); color: var(--accent); }

/* ── live-reference cards (synthetic documents) ──────────────────────── */
#editor .sb-ref, #editor-b .sb-ref {
  border: 1px solid #c9d3e0; border-left: 3px solid var(--accent); border-radius: 8px;
  background: #f3f6fb; margin: 10px 0; padding: 0; overflow: hidden; cursor: default;
  font-family: -apple-system, "Segoe UI", sans-serif;
}
#editor .sb-ref .ref-head, #editor-b .sb-ref .ref-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: #e7edf6; border-bottom: 1px solid #d3dbe8; font-size: 11px; color: #45526b;
}
.sb-ref .ref-title { font-weight: 600; color: #2b3550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45%; }
.sb-ref .ref-range { color: #6b7c93; }
.sb-ref .ref-actions { margin-left: auto; display: flex; gap: 4px; }
.sb-ref .ref-actions button {
  border: 1px solid #c2ccdb; background: #fbfdff; color: #45526b; border-radius: 4px;
  font-size: 10px; padding: 2px 7px; cursor: pointer;
}
.sb-ref .ref-actions button:hover { border-color: var(--accent); color: var(--accent); }
.sb-ref .ref-body {
  padding: 8px 12px; font-family: Georgia, serif; font-size: 11pt; color: #2a2a2a;
  white-space: pre-wrap; line-height: 1.5; max-height: 320px; overflow: auto;
}

/* ── data view (prose flip) ──────────────────────────────────────────── */
#jack-dataview { flex: 1; display: none; flex-direction: column; min-height: 0; background: #05070b; }
#jack-dataview .dv-bar {
  padding: 8px 16px; font-size: 12px; color: var(--text-dim);
  border-bottom: 1px solid var(--border); background: var(--surface);
}
#jack-dataview .dv-err { color: #ff9a8a; }
#jack-dataview textarea {
  flex: 1; width: 100%; border: none; outline: none; resize: none; box-sizing: border-box;
  padding: 24px 40px; background: #05070b; color: #cfe3ff;
  font-family: 'JetBrains Mono', monospace; font-size: 13px; line-height: 1.7;
}

/* ── resolved overlay ────────────────────────────────────────────────── */
#jack-resolved { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #05070b; }
#jack-resolved .jr-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 16px; font-size: 12px; color: var(--text-dim);
  border-bottom: 1px solid var(--border); background: var(--surface);
}
#jack-resolved .jr-page {
  flex: 1; overflow: auto; padding: 40px; display: flex; flex-direction: column; align-items: center;
}
#jack-resolved .jr-src {
  width: 8.5in; max-width: 100%; font-size: 10px; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--accent); margin: 14px 0 4px; padding-left: 2px;
}
#jack-resolved .jr-region {
  width: 8.5in; max-width: 100%; background: #fdfdfb; color: #1a1a1a;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4); padding: 0.4in 0.7in; box-sizing: border-box;
  font-family: Georgia, serif; font-size: 12pt; line-height: 1.6;
}
#jack-resolved .jr-region .sb[data-list] { position: relative; padding-left: 1.6em; }
#jack-resolved .jr-region .sb[data-list="bullet"]::before { content: "\2022"; position: absolute; left: 0.4em; }

/* ── bucket view (same #editor, CSS re-render) ───────────────────────── */
#bucket-addrow {
  width: 100%; box-sizing: border-box; margin: 0 0 8px; padding: 10px 12px;
  border: 1px dashed var(--accent); border-radius: 8px; color: var(--accent);
  font-family: -apple-system, sans-serif; font-size: 13px; cursor: pointer;
  background: rgba(74,158,255,0.06); user-select: none;
}
#bucket-addrow:hover { background: rgba(74,158,255,0.14); }

#editor.bucket-view { padding-top: 0.6in; }
#editor.bucket-view .sb { min-height: 1.4em; }
/* every list block becomes an item row card */
#editor.bucket-view .sb[data-list] {
  border: 1px solid #d8dee8; border-radius: 8px; background: #ffffff;
  margin: 6px 0; padding: 10px 12px 10px 2.1em; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
/* enlarge the check gutter so a left-gutter click reliably toggles */
#editor.bucket-view .sb[data-list="check"]::before {
  width: 1.15em; height: 1.15em; left: 0.5em; top: 0.7em;
}
#editor.bucket-view .sb[data-list="check"][data-checked="1"]::after {
  left: 0.62em; top: 0.5em; font-size: 1em;
}
#editor.bucket-view .sb[data-list="check"][data-checked="1"] { opacity: 0.72; }
#editor.bucket-view .sb[data-list="bullet"]::before { left: 0.7em; top: 0.7em; }
/* description lines (indented, immediately after an item) render dim + tucked */
#editor.bucket-view .sb.bucket-desc {
  color: #6b7280; font-size: 0.92em; margin: -2px 0 4px 1.4em; padding-left: 0.6em;
  border-left: 2px solid #e2e6ee;
}
