/* ══ PRISMA FLOW DIAGRAM STAGE ═══════════════════════════════════════
 *
 * Self-contained companion to Javascript/prisma.js — mirrors the inline-
 * injection pattern project-home.css uses: the stage hides .left-panel /
 * .right-panel and injects its own full-width panel (#projPrismaDash)
 * into .proj-body, so it never touches the Sources/Summarisation markup
 * or CSS. .proj-body--prisma's own layout numbers are copied verbatim
 * from .proj-body--home so both full-width stages scroll identically.
 *
 * Sections in this file:
 *   1. Layout shell      — .proj-body--prisma / .proj-prisma-dash
 *   2. Flow diagram       — .prisma-flow / .prisma-row / .prisma-box
 *   3. Reason breakdowns  — .prisma-reason-list (inside excluded boxes)
 *   4. Topbar filter      — .prisma-filter-dropdown (search-tag menu)
 *
 * Colour language matches project-home.css: teal for the main "forward"
 * flow, red for excluded/removed side boxes, amber for "awaiting a
 * decision" captions, purple for "conflict to resolve" captions.
 * ══════════════════════════════════════════════════════════════════ */

/* ══ 1. LAYOUT SHELL ═══════════════════════════════════════════════════ */
.proj-body.proj-body--prisma {
  display: flex !important;
  flex-direction: column;
  gap: 18px;
  height: calc(100vh - 80px);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 8px 6px 14px;
}

.proj-prisma-dash {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.prisma-empty-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal-dim);
  font-size: 0.76rem;
  font-weight: 600;
}
.prisma-empty-banner .bx { font-size: 0.95rem; flex-shrink: 0; }

/* ══ 2. FLOW DIAGRAM ═══════════════════════════════════════════════════ */
.prisma-flow-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 4px 28px;
}
.prisma-flow-wrap::-webkit-scrollbar { width: 5px; }
.prisma-flow-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.prisma-flow {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
}

/* Every row (main+elbow+side, and the vertical connector rows between
   them) shares this exact column template so the vertical connector
   always lands centred under the main-box column, and the elbow always
   meets the side box at the same horizontal position, regardless of which
   row it is. */
.prisma-row {
  display: grid;
  grid-template-columns: 340px 40px 1fr;
  align-items: center;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.prisma-row-main { grid-column: 1; min-width: 0; }

/* Terminal box ("Studies Included in Review") — no elbow/side columns,
   just the main box centred in the row's full width (see
   _prismaFinalRowHtml, prisma.js). */
.prisma-row--final {
  display: flex;
  justify-content: center;
  grid-template-columns: none;
}
.prisma-row--final .prisma-row-main { width: 340px; max-width: 100%; }
.prisma-row-elbow {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}
.prisma-elbow-line { flex: 1; height: 2px; background: var(--border-hover); }
.prisma-row-elbow .bx-chevron-right { color: var(--ink-muted); font-size: 0.95rem; margin-left: -3px; flex-shrink: 0; }
.prisma-row-side { grid-column: 3; min-width: 0; }

/* Vertical connector between stacked main boxes — lands in the same
   column-1 track as .prisma-row-main above/below it. */
.prisma-connector-row { padding: 2px 0; }
.prisma-connector {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.prisma-connector-line { width: 2px; height: 14px; background: var(--border-hover); }
.prisma-connector .bx-chevron-down { color: var(--ink-muted); font-size: 1rem; line-height: 1; }
.prisma-connector-note {
  font-size: 0.62rem; font-weight: 700; color: var(--ink-soft);
  background: var(--bg-page); border: 1px solid var(--border);
  padding: 2px 9px; border-radius: 20px; margin-top: 2px; white-space: nowrap;
}
.prisma-connector-note--amber { background: var(--amber-soft); color: var(--amber); border-color: rgba(217,119,6,0.25); }
.prisma-connector-note--purple { background: var(--purple-soft); color: var(--purple); border-color: rgba(124,58,237,0.25); }

/* ── Main boxes (the vertical spine) ─────────────────────────────────── */
.prisma-box--main {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hover, rgba(43,24,23,0.16));
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}
.prisma-box-icon {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--teal-soft); color: var(--teal);
  font-size: 0.95rem;
}
.prisma-box-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.prisma-box-count {
  font-size: 1.3rem; font-weight: 800; color: var(--ink);
  line-height: 1.15; font-variant-numeric: tabular-nums;
}
.prisma-box-title { font-size: 0.76rem; font-weight: 700; color: var(--ink); }
.prisma-box-sub { font-size: 0.66rem; color: var(--ink-muted); }

.prisma-box-notes {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  width: 340px; max-width: 100%; margin: 6px auto 0;
}
.prisma-box-note {
  font-size: 0.63rem; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  background: var(--bg-elevated); color: var(--ink-soft); border: 1px solid var(--border);
  white-space: nowrap;
}
.prisma-box-note--amber { background: var(--amber-soft); color: var(--amber); border-color: rgba(217,119,6,0.25); }
.prisma-box-note--purple { background: var(--purple-soft); color: var(--purple); border-color: rgba(124,58,237,0.25); }

/* ── Side boxes (removed / excluded branches) ────────────────────────── */
.prisma-box--side {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 11px 13px;
}
.prisma-box--clickable {
  cursor: pointer;
  transition: border-color 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease;
}
.prisma-box--clickable:hover {
  border-color: rgba(220,38,38,0.35);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(43,24,23,0.10);
}
.prisma-box-side-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 7px;
}
.prisma-box-side-title { font-size: 0.71rem; font-weight: 700; color: var(--ink-soft); }
.prisma-box-side-count {
  font-size: 1rem; font-weight: 800; color: var(--red);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.prisma-side-note { font-size: 0.7rem; color: var(--ink-muted); }

/* ══ 3. REASON BREAKDOWNS ══════════════════════════════════════════════ */
.prisma-reason-list { display: flex; flex-direction: column; gap: 4px; }
.prisma-reason-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 0.68rem; color: var(--ink-soft);
}
.prisma-reason-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.prisma-reason-count { font-weight: 800; color: var(--ink); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.prisma-reason-other .prisma-reason-label { font-style: italic; color: var(--ink-muted); }
.prisma-reason-empty { font-size: 0.7rem; color: var(--ink-muted); font-style: italic; }

/* ══ 4. TOPBAR — search-tag filter dropdown ═══════════════════════════
 * Same trigger+dropdown shape as Abstract Screen / Full Text Screen's own
 * topbar filters (see .asv-filter-dropdown, abstract-screen.css) — the
 * ID+class width-override trick beats design-alignment.css's later,
 * otherwise-winning .icon-btn-sm 30px-square rule. */
.prisma-filter-dropdown { position: relative; }

#prismaFilterBtn.prisma-filter-btn {
  width: auto;
  gap: 6px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-soft);
}
#prismaFilterBtn.prisma-filter-btn .bx-purchase-tag { font-size: 0.85rem; }
#prismaFilterBtn.prisma-filter-btn.active {
  background: var(--teal-soft); border-color: var(--teal); color: var(--teal);
}
.prisma-filter-caret { font-size: 0.85rem; transition: transform 0.16s ease; }
#prismaFilterBtn.open .prisma-filter-caret { transform: rotate(180deg); }

.prisma-filter-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  max-height: 280px;
  overflow-y: auto;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(43,24,23,0.14);
  padding: 6px;
  z-index: 40;
}
.prisma-filter-menu.open { display: flex; }
.prisma-filter-menu::-webkit-scrollbar { width: 4px; }
.prisma-filter-menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.prisma-filter-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 9px; border-radius: 6px; border: none;
  background: none; color: var(--ink-soft); font-family: inherit;
  font-size: 0.75rem; font-weight: 600; cursor: pointer; text-align: left;
  transition: all 0.14s;
}
.prisma-filter-item .bx-purchase-tag { font-size: 0.85rem; color: var(--teal); flex-shrink: 0; }
.prisma-filter-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prisma-filter-item:hover { background: var(--teal-soft); color: var(--teal); }
.prisma-filter-item.active { background: var(--teal-soft); color: var(--teal); font-weight: 700; }
.prisma-filter-check { flex: 0 0 auto !important; color: var(--teal); font-size: 0.9rem; }
.prisma-filter-divider { height: 1px; background: var(--border); margin: 4px 2px; }

/* ══ Responsive — collapse the branch layout below ~760px ═══════════════
 * The elbow connector only makes sense once there's room for a visible
 * side-by-side branch; below that, side boxes drop underneath their main
 * box in normal document order (still readable top-to-bottom) and the
 * elbow simply hides rather than trying to reflow into a vertical joint. */
@media (max-width: 760px) {
  .prisma-row, .prisma-connector-row {
    grid-template-columns: 1fr;
    row-gap: 8px;
  }
  .prisma-row-elbow { display: none; }
  .prisma-row-side { grid-column: 1; }
  .prisma-connector { grid-column: 1; }
}